Giter Site home page Giter Site logo

Comments (3)

drscotthawley avatar drscotthawley commented on June 1, 2024

Seems the behavior is not unique to inspect. It seems that Fire will unexpectedly print even if you just access locals(). This is a side effect I'd love to disable.

Minimal example:

import fire

def my_routine(arg1, arg2):
    return locals()

if __name__ == '__main__':
    vals = fire.Fire(my_routine) # this produces unwanted print statements
    print("vals = ",vals)

Output includes not just the "vals = " line but two additional variable outputs that occur when locals() gets called while using Fire():

arg1: dummy_arg1
arg2: dummy_arg2
vals =  {'arg1': 'dummy_arg1', 'arg2': 'dummy_arg2'}

It's no so much the printing that's the problem per se, it's the fact that it blocks execution and waits for the user to press enter (if it prints more than a page of variables) that's the main problem.

from python-fire.

dbieber avatar dbieber commented on June 1, 2024

Fire displays the returned object on completion by default. To disable this, you can use:

noprint = lambda _: None
fire.Fire(my_routine, serialize=noprint)

from python-fire.

drscotthawley avatar drscotthawley commented on June 1, 2024

Awesome! Thank you very much!
Closing.

from python-fire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.