An error when i switched from python v2.6.6 => v3.2.3

Chris Angelico rosuav at gmail.com
Thu Mar 7 16:13:24 CET 2013


On Fri, Mar 8, 2013 at 2:01 AM, Νίκος Γκρ33κ <nikos.gr33k at gmail.com> wrote:
> os.system( 'python metrites.py > %s' ) % htmltemp

Manually step through what this line should do. Follow the exact same
rules Python will follow in evaluating this expression.

http://docs.python.org/2/reference/expressions.html#operator-precedence
http://docs.python.org/3/reference/expressions.html#operator-precedence

As you'll see from footnote 8 or 5 (depending on which version of the
docs), your percent operator is the same one listed in the table as a
division operator.

Now. Go through that expression, step by step. Walk through everything
the Python interpreter does. Figure out exactly what happens first,
second, third. Figure out when your percent operator gets handled.
Then you'll know what's wrong with that line of code.

You'll also gain a very useful understanding of Python, and more
generally of the way most high level languages parse expressions.

ChrisA



More information about the Python-list mailing list