On Nov 12, 11:31 am, Terry Reedy wrote:
> Alf P. Steinbach wrote:
> > One reaction to >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?
>
> I just star
On Nov 12, 10:10 am, Ethan Furman wrote:
> AK Eric wrote:
> > so:
>
> > # moduleA.py
> > import moduleB
>
> > # moduleB.py
> > import sys
> > stuff = sys._getframe(1).f_locals
> > print stuff
>
> > Prints:
>
> > {'__
so:
# moduleA.py
import moduleB
# moduleB.py
import sys
stuff = sys._getframe(1).f_locals
print stuff
Prints:
{'__builtins__': ,
'__file__': 'C:\\Documents and SettingsMy Documents\
\python\\moduleA.py',
'__name__': '__main__',
'__doc__': None}
Looks like you could query stuff['__file__']
> > 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
> > 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 spec
> 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 power
> 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
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 an
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