T
tinauser
hallo, i'm sorry if the question is very stupid, but i cannot
understand what i'm doing wrong here.
i have this myModule.py
<code>
class Starter:
def init(self,num):
print "hithere!"
print "the answer is ",num
import sys,os
print "path:",sys.path
print "bye"
try:
## f = open("/Users/lguerrasio/_myfold/initfile.py",'r')
f = open("initfile.py",'r')
f.close()
print "huurray!"
except IOError:
print "The file does not exist, exiting gracefully"
print "This line will always print"
</code>
the module is in the same folder of initfile
from terminal, i import sys and add to the path /Users/lguerrasio/
_myfold/;
then i import the module and call
myModule.Starter().init(9)
now,the file will be opened only if i give the full path, not if i
give only the name of the file, although the folder is in the path.
what am I missing?
understand what i'm doing wrong here.
i have this myModule.py
<code>
class Starter:
def init(self,num):
print "hithere!"
print "the answer is ",num
import sys,os
print "path:",sys.path
print "bye"
try:
## f = open("/Users/lguerrasio/_myfold/initfile.py",'r')
f = open("initfile.py",'r')
f.close()
print "huurray!"
except IOError:
print "The file does not exist, exiting gracefully"
print "This line will always print"
</code>
the module is in the same folder of initfile
from terminal, i import sys and add to the path /Users/lguerrasio/
_myfold/;
then i import the module and call
myModule.Starter().init(9)
now,the file will be opened only if i give the full path, not if i
give only the name of the file, although the folder is in the path.
what am I missing?