Monday 15 September 2014

python 2.7 - spyderlib funny behaviour with any() and all() -


If I am on Python 2.7 and I have just started using Spider IDE.

On a terminal Python version if I

  for any (i == 1 [i to 1,2,3,4])  <  

true

Although I do this in the spider, I get a response

  & lt; Generator object & lt; Genexpr & gt; 0x3fc8af0 at & gt;   

Why is that so? Do not I have any settings or is it a different version of Python (this is called 2.7)

Quote from another about a spider's Python console behavior:

One of Spider's primary design goals is to create an interactive scientific computing as a painless one. For this feature, Spider Starts the Custom-Managed Interactive Python Session by default. It achieves this customization by setting up an environment variable called PYTHONSTARTUP, which specifies the path of the script executed on the interpreter startup. You can control this setting under Preferences ... Console ... Advanced Settings By default, Spider has indicated the scientific-startup group, which directly imports scientific modules and functions in the entire main location-space so that Otherwise, interactive exploration is easy.

As a result, the behavior you are experiencing is because you are actually numpy version any and all in the main namespace, which are directly placed in the main namespace,

  np.any (i == 1 [1,2,3,4] ] In   

or

  np.all (i == 1 in [1,2,3,4])   

And if you get back the same generator items, these last two calls do magic work May include the startup script NP as NP is imported. For more information about what's being imported, type scientist at the Spider Python console prompt.

No comments:

Post a Comment