How can I use my modules here?
Diez B. Roggisch
deets at nospam.web.de
Fri Sep 11 11:44:02 EDT 2009
More information about the Python-list mailing list
Fri Sep 11 11:44:02 EDT 2009
- Previous message (by thread): How can I use my modules here?
- Next message (by thread): Python 3.1 csv with gzip
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chris Rebert wrote: > On Fri, Sep 11, 2009 at 2:24 AM, Kermit Mei <kermit.mei at gmail.com> wrote: >> Hello community! >> >> I write a modules for testing, and my code is like this(under Linux): >> >> >> $ tree >> . >> |-- MyTestModules >> | |-- Test1.py >> | |-- Test2.py >> | `-- __init__.py >> `-- main.py >> >> 1 directory, 4 files >> >> $ find . -name '*.py' -print0|xargs -0 cat >> >> ############ main.py Begin ############## >> #!/usr/bin/env python >> >> from MyTestModules import Test1,Test2 >> >> t1 = Test1() >> t2 = Test2() >> >> print t1.first() >> print t2.first() >> ############ main.py End ############### >> >> #############Test1.py Begin ########## >> #!/usr/bin/env python >> >> class Test1: >> def first(self): >> return self.arg1 >> >> #############Test1.py End ############ >> >> #############Test1.py Begin ########## >> #!/usr/bin/env python >> >> class Test2: >> def first(self): >> return self.arg1 >> >> #############Test1.py End ############ >> >> ###### __init__.py Begin ############ >> #!/usr/bin/env python >> >> ###### __init__.py End ############ >> >> >> When I run the main.py, the following error takes: >> >> $ ./main.py >> from: can't read /var/mail/MyTestModules >> ./main.py: line 7: syntax error near unexpected token `(' >> ./main.py: line 7: `t1 = Test1()' > > For some reason, your Python program is being executed by bash as if > it were a shell script, which it's not. > No idea what the cause is though. The first comment line must go - it must be the shebang instead. http://en.wikipedia.org/wiki/Shebang_(Unix) Diez
- Previous message (by thread): How can I use my modules here?
- Next message (by thread): Python 3.1 csv with gzip
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list