ValueError: zero length field name in format - Running under Python 2.7.3?

Chris Angelico rosuav at gmail.com
Tue Nov 5 00:02:50 CET 2013


On Tue, Nov 5, 2013 at 9:33 AM, Victor Hooi <victorhooi at gmail.com> wrote:
> However, when I run this line, I get the following error:
>
>     Traceback (most recent call last):
>       File "my_script.py", line 25, in <module>
>         LOG_FILENAME = 'my_something_{}.log'.format(datetime.now().strftime('%Y-%d-%m_%H.%M.%S'))
>     ValueError: zero length field name in format
>
>
> The weird thing, when I start a Python REPL and run that line interactively, it works fine

Google tells me that that was an issue in Python 2.6, so my first
check would be to see what `/usr/bin/env python` actually gives you -
are you running inside an environment that changes your path? Drop a
"import sys; print(sys.version)" at the top of your script and see
what it's really running as.

ChrisA



More information about the Python-list mailing list