python - Use underscore builtin in script -
In an interactive console (in Python) I can do this;
k = 5 df generator (I): I + = Generator for J. Generator (J): J Print _ Where _ variables take the latest value. This can be very useful for me, when I want to loop through a generator and print an incorrect statement and raise an exception. However, when you run a script, _ does not appear - E. G. $ python my_script.py . (I tried to use __biltine __._ but it fails.) Whether to reach _ while running a script Any way If not, what are the options that I can take advantage of?
_ is a special variable that is present in interactive sessions. However, due to the scrolling rules of Python, the j variable remains in existence when the for loop ends. Therefore, you can simply: Generator (j) in J for : near print j
Comments
Post a Comment