Hi experts,

I want got a py-file named as try.py

The content is

--------------------------------

import sys


def cal(init_code):

    try:

        exec(init_code)

    except: 

        print('OMG')

    try:

        if 'A0=' not in init_code:

            print('OMG')

            A0=A

            print('A0=',A0)

    except NameError as e:

        print(e)


init_code = ''

for statement in sys.argv[1:]:

    init_code += statement + '\n'


cal(init_code)

--------------------------------


When I run it via command line in Spyder, IPython console, (I am using 
python 3.4)

I got error:

--------------------------------------------------------

In[1]: !python try.py A=10 p=5 n=730

OMG

name 'A' is not defined
--------------------------------------------------------

My idea is that the first try does not work porperly. Because in the second 
try, the code "print('OMG')" works. But the code "A0=A" does not work.

Could you please help me with this?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to