OOP help needed incorporating existing modules in class
Peter Hansen
peter at engcorp.com
Thu Jun 30 23:56:04 EDT 2005
Koncept wrote:
> I want to incorporate the datetime and other modules into my class. I
> am new to Python and would really appreciate some help doing this.
>
> class FooBar:
> def getDate(self):
> return <datetime.datetime.ctime()>
>
> ^^^ how do I do something like this?
Um.... have you read the tutorial yet? It sounds like you might not
even be aware of the purpose of the "import" statement. Either that or
I'm misunderstanding the question, because the above code works fine in
principal if you've imported the datetime module first. (The above code
is probably incorrect in the specifics of the call to ctime(), but
reading the documentation for "datetime" after you've learnt the basics
of Python should solve that.)
-Peter
More information about the Python-list
mailing list