[Tutor] A few Questions

Isr Gish isrgish at fastem.com
Sun Sep 5 20:30:25 CEST 2004


Adam Cripps Wrote:

    > Dear Tutors and Friends, 
   > Here are a few questions to test your knowledge :) 
   > 1.What command makes the python programme print out the file it is in? 
   > I mean for example if it is saved in c:\windows\system what command
   >gives me this
   >
   >This would be stored in the variable sys.argv[0]
 
There are another few options:
print '__file__:  ', __file__

import inspect
print 'inspect.getsourcefile(...):  ', inspect.getsourcefile(lambda:None)
print 'inspect.getfile(...):  ', inspect.getfile(lambda:None)

All the best,
Isr

   >HTH 
   >Adam
   >--
   >proj: http://jiletters.sf.net
   >site: http://www.monkeez.org
   >wiki: http://wiki.monkeez.org
   >_______________________________________________
   >Tutor maillist  -  Tutor at python.org
   >http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list