[Python-Dev] __file__

Guido van Rossum guido at python.org
Sat Feb 27 05:32:18 CET 2010


On Fri, Feb 26, 2010 at 5:13 PM, Brett Cannon <brett at python.org> wrote:
> On Fri, Feb 26, 2010 at 15:35, Glenn Linderman <v+python at g.nevcal.com>
>> When a .pyc is renamed to .py, Python (3.1 at least) recognizes and uses
>> it... I assume by design, rather than accident, but I don't know the
>> history.
>
> This does not work for me (nor should it):
>> touch temp.py
>>
>> python3 -c "import temp"
>>
>> rm temp.py
>>
>> mv temp.pyc temp.py
>>
>> python3 -c "import temp"
>>
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "temp.py", line 2
> SyntaxError: Non-UTF-8 code starting with '\x95' in file temp.py on line 2,
> but no encoding declared; see http://python.org/dev/peps/pep-0263/ for
> details

Try "python temp.py" though.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list