Hi VPython people!
Below I enclose an exchange of postings on comp.lang.py
with Alex Martelli on an observation when working with
VPython, which reveals something we consider to be a
bug or at least an anomaly ...
Does somebody have an explanation?
Hope this goes to the right adress ... (otherwise could you
redirect it ?)
Gregor Lingl
----------------------------------------------------------
1:: Gregor Lingl:
I thought to understand the dir() function, but...
... when playing around with VPython I encountered the
following:
>>> from visual import *
Visual-2002-06-14
>>> s=3Dsphere() # beautiful white sphere displayed immediately
>>> s
<Primitive object at 0x01563D34>
>>> dir(s)
['__class__', 'axis', 'blue', 'color', 'constr',
'display', 'frame', 'green', 'name', 'pos', 'radius',
'red', 'rotate', 'up', 'visible', 'x', 'y', 'z']
>>> s.__methods__
['rotate']
>>> s.__dict__
{'__class__': <built-in method sphere of tuple object at 0x00A65590>}
>>> s.__members__
['axis', 'blue', 'color', 'display', 'frame', 'green',
'pos', 'radius', 'red', 'up', 'visible', 'x', 'y', 'z']
>>> s.name
Traceback (most recent call last):
File "<pyshell#7>", line 1, in ?
s.name
AttributeError: name
>>>
So, what are 'name' and 'constr', which both do not appear
neither in s.__members__ nor in s.__dict__ nor in s.__methods__,
but in the list returned by dir(s)?
(Or: what is generally returned by dir() ?)
Perhaps there is somebody who can explain this.
Thanks, Gregor
In other words: what happens in the following example, should not
happen in my understanding:
>>> from visual import *
Visual-2002-06-14
>>> s =3D sphere()
>>> for att in dir(s):
print att, ':',
print type(eval('s.'+att))
__class__ : <type 'instance'>
axis : <type 'vector'>
blue : <type 'float'>
color : <type 'tuple'>
constr :
Traceback (most recent call last):
File "<pyshell#46>", line 3, in ?
print type(eval('y.'+att))
File "<string>", line 0, in ?
AttributeError: constr
>>>
-----------------------------------------------------------------
2:: Alex Martelli:
Gregor Lingl wrote:
> I thought to understand the dir() function, but...
dir() is somewhat in transition between Python 2.1 and 2.2.
Not sure what Python level should be installed with Visual-06-14.
It does matter which exact level you did install, and on which
platform, though.
I just downloaded and installed Visual-2002-07-07 on top of
my Python 2.2.1 but the s.__members__ access, and thus also
dir(s), just kills the Python interactive session stone dead
with 'Aborted' as the only message. Maybe the 06-14 version
had its own problems -- not quite as serious as 07-07's (at
least with Python 2.2.1 on Mandrake Linux 8.2:-) but enough
to give the anomalies you observe.
(It's also possible that I made some mistake in installation,
of course, but I closely followed the specific instructions
for Mandrake on the "additional info" page of Visual).
Alex
-----------------------------------------------------------------
3:: Gregor Lingl:
What a surprise to come into contact with martellibot just
after having read your interview on the Euro Python website.
I'm working with Python 2.2.1 on a Windows2000 machine.
Curious if something similar would happen on my machine
I just deinstalled Visual-2002-06-14 and replaced it by
Visual-2002-07-07 and I obtain exactly the same results
as before - the session remaining alive...
Let's see, if somebody else will give us more information
on this ...
Gregor
------------------------------------------------------------------
4:: Alex Martelli:
Gregor Lingl wrote:
> What a surprise to come into contact with martellibot just
> after having read your interview on the Euro Python website.
Pleased to meet you! I shouldn't be here (don't tell my
O'Reilly editor I'm writing on c.l.py when I should be
busy finishing the Nutshell book...), but...
> I'm working with Python 2.2.1 on a Windows2000 machine.
I have not tried VPython anywhere except on Linux, where
I just tried reproducing your problem -- as I said, it's
slightly different there.
> Curious if something similar would happen on my machine
> I just deinstalled Visual-2002-06-14 and replaced it by
> Visual-2002-07-07 and I obtain exactly the same results
> as before - the session remaining alive...
>
> Let's see, if somebody else will give us more information
> on this ...
I think you should forward a copy of these exchanges (or
a pointer to them via google advanced group search) to
the VPython guys -- I'm sure they'll be able to debug and
fix the problem very simply, while it would take longer
for somebody utterly unfamiliar with VPython's internals,
such as yours truly...
Alex
|