1, in
>
> NameError: name '__file__' is not defined
>
>
>
>
>
>
>
> *From: *Dietrich Pescoller
> *Sent: *10 October 2016 14:36
> *To: *Pyzo
> *Cc: *dit...@gmail.com ; proj...@gmail.com
> *Subject: *Re: [Pyzo] IEP and __file__
>
>
>
>
jet...@gmail.com
Subject: Re: [Pyzo] IEP and __file__
In your suggestion the only drawback is that 'foo.py' needs to be set manually,
This would work and is acceptable but of course not optimal.
I can understand you point to not add another way to run a file.
My question/thought since in the cur
anged now, would it work for you to put this at the top of
> your file:
>
>
>
> __file__ = os.path.join(os.cwd(), ‘foo.py’)
>
>
>
> *From: *Dietrich Pescoller
> *Sent: *10 October 2016 09:20
> *To: *Pyzo
> *Cc: *dit...@gmail.com ; proj...@gmail.com
> *S
...@gmail.com
Subject: Re: [Pyzo] IEP and __file__
Yes, but also in this case if I run the file as a script than the console is
retarted and we loose all previous work.
Effectively we are in a very same situation as we had with the current
directory setting.
Perhaps could it be the definitive solution
gt; *Sent: *07 October 2016 16:41
> *To: *Pyzo
> *Cc: *proj...@gmail.com
> *Subject: *Re: [Pyzo] IEP and __file__
>
>
>
> I had the same issue recently.
> What would be the best way in a script to get its own filename than?
>
> Thanks,
> Dietrich
>
>
Run the file as a script.
Running code normally (not as a script) is equivalent to firing up having a
Python interpreter and running code in it. There is no script file, and thus no
__file__. Technically, Pyzo could set __file__ each time a file is run, but it
would be wrong to reset that
I had the same issue recently.
What would be the best way in a script to get its own filename than?
Thanks,
Dietrich
Il giorno martedì 13 ottobre 2015 22:32:24 UTC+2, Almar Klein ha scritto:
>
> __file__ is only present when running a file as script. Similar to how
> there is no __file__ in