Page 1 of 1

bug? Python broken in 7.7.1?

PostPosted: Tue Apr 07, 2015 9:34 pm
by Stefan Ihringer
Hi,

Python on the console does some unexpected things in 7.7.1...

Code: Select all
Py2> t=5
Py2> ==t
Traceback (most recent call last):
  File "<nofile>", line 1, in <module>
NameError: name 't' is not defined

can anybody confirm this?

Re: bug? Python broken in 7.7.1?

PostPosted: Tue Apr 07, 2015 10:00 pm
by Blazej Floch
No, I can not confirm this.
== is something that only works in eyeonscript and passes on to dump. This is not even Lua.
I am pretty sure this was documented on vfxpedia, and I am almost certain this is documented in the Generation scripting docs ;)

For python you always need to print or better print() = Python3.x ready.
However if you want all the pretty dump formatting use prettyprint:
Code: Select all
import pprint
pprint.pprint(comp.GetAttrs())


However THIS IS A BUG:
Code: Select all
from pprint import pprint
print(type(pprint))
<type 'module'> # No, it should import the function. Compare to a python console.

from pprint import pprint as pp
pp # Undefined

Re: bug? Python broken in 7.7.1?

PostPosted: Tue Apr 07, 2015 10:11 pm
by Blazej Floch
Found another one, which is not really a show stopper but misbehaving anyways:
Code: Select all
from __future__ import print_function
print "Hello" # This is supposed to raise an Syntax Error
Hello

Please note that the import statement above is not a simple import but needs to set a flag on the interpreter. There are a few others, I guess the python scripting client does not respect these.

Re: bug? Python broken in 7.7.1?

PostPosted: Wed Apr 08, 2015 10:48 am
by Stefan Ihringer
Hi Blazej,

"==" was added to the Python console in Fusion 7. It works for stuff like "==comp.ActiveTool" but not in my example.

Re: bug? Python broken in 7.7.1?

PostPosted: Wed Apr 08, 2015 10:22 pm
by Blazej Floch
Thanks I did not know that.