[Tutor] OK real basic problem ...

Dave S pythontut at pusspaws.net
Thu Mar 11 10:12:04 EST 2004


Dave S wrote:

> I've created a file called pycode ...
>
> #!/usr/bin/env python
> print "hi my module is loaded !!!\n"
>
> def addit(a,b):
> print a+b
>
> good so far, chmod a+x pycode
>
> In python I have ...
>
>>>> import pycode
>>>> reload(pycode)
>>>
> hi my module is loaded !!!
>
> <module 'pycode' from '/home/dave/pycode/pycode.py'>
>
>>>> addit(1,2)
>>>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> NameError: name 'addit' is not defined
>
>>>>
>
> From my message "hi my module has loaded ... I thought addit() would
> work ..
>
> OK I know this is simple ... but ... err .. any ideas
>
> Dave
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
Thanks everyone ... I got the idea now

pycode.addit(1,2)

Does the job + I now understand a bit more about modules  :-) 

Cheers once again

Dave





More information about the Tutor mailing list