so:
# moduleA.py
import moduleB
# moduleB.py
import sys
stuff = sys._getframe(1).f_locals
print stuff
Prints:
{'__builtins__': module '__builtin__' (built-in),
'__file__': 'C:\\Documents and Settings\\userName\\My Documents\
\python\\moduleA.py',
'__name__': '__main__',
'__doc__': None}
Looks
On Nov 12, 10:10 am, Ethan Furman et...@stoneleaf.us wrote:
AK Eric wrote:
so:
# moduleA.py
import moduleB
# moduleB.py
import sys
stuff = sys._getframe(1).f_locals
print stuff
Prints:
{'__builtins__': module '__builtin__' (built-in),
'__file__': 'C:\\Documents
On Nov 12, 11:31 am, Terry Reedy tjre...@udel.edu wrote:
Alf P. Steinbach wrote:
One reaction to url: url:
http://preview.tinyurl.com/ProgrammingBookP3 has been that turtle
graphics may be off-putting to some readers because it is associated
with children's learning.
What do you think?
It isn't a neat trick anymore once you realize the name '__main__'
isn't special.
Replace __main__ with foo, or config, or whatever, and you get the
same results. Ok, there is a catch: a file with that name must exist,
at least an empty one...
True. I do feel a bit less special now
How can a module determine the path of the file that defines it?
(Note that this is, in the general case, different from sys.argv[0].)
__file__
Also:
import inspect
print inspect.getsourcefile(lambda:None)
--
http://mail.python.org/mailman/listinfo/python-list
2/ in Python, global really means module-level - there's nothing
like a true global namespace.
Isn't that __main__?
import __main__
__main__.foo = asdfasdf
print foo
# asdfasdf
Not advocating, but it does serve the purpose.
--
http://mail.python.org/mailman/listinfo/python-list
Good that you're not advocating it, because IMHO it's bad practice to
have circular import dependencies. By using the __main__ alias, you
avoid the worst problems, but that just means the others are more subtle.
I figured I'd get that kind of response, not that it's incorrect ;)
Great
Yep, you can run it without any kind of GUI to my knowledge.
--
http://mail.python.org/mailman/listinfo/python-list
Building on what others have said and giving a +1 to Carl:
I work daily in Maya doing character setup and rigging. As far as
doing it straight in Python, again, like others, take a look at PyGame
or Blender. I think the main question is: Do you want skeletal
animation, or do you want skeletal
Thought this would be easy, maybe I'm missing something :) Trying to
query the x,y resolution of my screen. I've seen this available
through http://python.net/crew/mhammond/win32/ :
from win32api import GetSystemMetrics
print width =, GetSystemMetrics (0)
print height =,GetSystemMetrics (1)
10 matches
Mail list logo