A simple (newbie) question.

Wolfgang Grafen wolfgang.grafen at marconi.com
Wed Feb 21 17:35:38 CET 2001


Hi David,

following should work:

>>> a='"python"'
>>> b='print'
>>> c=b+' '+a
>>> exec(c)
python

regards

Wolfgang

"David A." wrote:
> 
> Hello to everyone,
> 
>     maybe I have already sent this question to the group, but I am not sure
> (the first one never reached the group I think). Anyway, I am a newbie, so
> probably my question is a realy simple for the most experienced python
> users.
> 
> Well what I want to is this:
> >>> a='python'
> >>> b='print'
> >>> c=b+a
> >>> eval(c)
> Traceback (innermost last):
>   File "<pyshell#19>", line 1, in ?
>     eval(c)
>   File "<string>", line 1
>     print"python"
>         ^
> SyntaxError: invalid syntax
> >>>
> 
>     Of course, what I wanted was that the eval(c) prints "python"!
> what am I doing wrong? Any help is apreciated.
> 
> Thx in advance David Asfaha.
> --
> "Quidquid latine dictum sit, altum viditur."
> Whatever is said in Latin sounds profound.



More information about the Python-list mailing list