Handling global variables (Newbie)
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sat Mar 15 02:03:45 EDT 2008
On Fri, 14 Mar 2008 12:19:18 -0700, MRAB wrote:
> On Mar 13, 4:25 am, "David S" <dav... at evertech.com.au> wrote:
>> Hi,
>>
>> I have an error occurring at
>> self.build_root = os.path.abspath(os.path.split(__file__)[0])
>>
>> The error states 'NameError: global name '__file__' is not defined'
>>
>> In Python 2.5 I ran my script as a module in IDLE gui. How does _file_ get
>> defined?
>>
> Do you perhaps mean '__name__'?
I guess not. It makes more sense to apply path functions to `__file__`
than to `__name__`.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list