You need to do either:
from mylibrary.utils import signon
signon.signon("test")
Or:
from mylibrary.utils.signon import signon
signon("test")
Give that a try and see if that helps. The reason yours didn't work is
because the signon function exists within the signon module's namespace. So
you need to refer to it through the module name, as in example one above, or
import the function itself, as in example two. It's all about namespaces.
Make use of dir() to help get a feel for it.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Larry Bates
Sent: Monday, June 25, 2001 3:02 PM
To: [EMAIL PROTECTED]
Subject: RE: Newbie & package setup (more)
Thanks for feedback.
This function works perfectly if I put it in c:\python21\lib
but I'm going to write a bunch of different ones and need a way
to keep them organized (other than stuffing them all in ..\lib).
Here is the signon function. All it does it print the string
that is passed to it with Day, date, and time appended to it
preceded by a line of dashes. I use it at the top of most
programs to show program name, date and time as first output
from the program.
-----------------signon module----------------------------
import time
def signon (pstring):
print ""
printstring=pstring+" "+time.ctime(time.time())
print len(printstring)*"-","\n",printstring,"\n"
return
-----------------------------------------------------------
I interactively typed in the following lines:
from mylibrary.utils import signon # (no error)
help(signon) # shows me what I expect
# Python knows about the
module
signon("test")
and I get the error message.
It is not just this function, it is any working module that I put
in the package subdirectory.
Regards,
Larry Bates
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython