Re: How can a module know the module that imported it?

2009-11-12 Thread AK Eric
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

Re: How can a module know the module that imported it?

2009-11-12 Thread AK Eric
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

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread AK Eric
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?

Re: Python 2.6 Global Variables

2009-10-30 Thread AK Eric
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

Re: How can module determine its own path?

2009-10-30 Thread AK Eric
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

Re: Python 2.6 Global Variables

2009-10-29 Thread AK Eric
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

Re: Python 2.6 Global Variables

2009-10-29 Thread AK Eric
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

Re: Simple audio

2009-10-21 Thread AK Eric
Yep, you can run it without any kind of GUI to my knowledge. -- http://mail.python.org/mailman/listinfo/python-list

Re: Skeletal animation

2009-10-04 Thread AK Eric
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

Query screen resolution?

2009-08-28 Thread AK Eric
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)