dynamic names

Mel Wilson mwilson at the-wire.com
Mon Mar 8 14:15:58 EST 2004


In article <c2gck2$1mu$03$2 at news.t-online.com>,
"Diez B. Roggisch" <deets_noospaam at web.de> wrote:
>Val Bykoski wrote:
>>     tot=tot + ("L%s" % L)
>
>Here you seem to miss an exec - the line should probably read like this:
>
>tot = tot + exec("L%s" % L)


Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> tot=0
>>> L=1
>>> L1=3
>>> tot = tot + exec("L%s" % L)
  File "<stdin>", line 1
    tot = tot + exec("L%s" % L)
                   ^
SyntaxError: invalid syntax

You mean

tot = tot + eval ("L%s" % L)


exec is a statement.


        Regards.        Mel.















































>
>--
>Regards,
>
>Diez B. Roggisch




More information about the Python-list mailing list