Connecting Tech Pros Worldwide Forums | Help | Site Map

OOP help needed incorporating existing modules in class

Koncept
Guest
 
Posts: n/a
#1: Jul 19 '05

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?

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche

Peter Hansen
Guest
 
Posts: n/a
#2: Jul 19 '05

re: OOP help needed incorporating existing modules in class


Koncept wrote:[color=blue]
> 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?[/color]

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
Closed Thread