OOP help needed incorporating existing modules in class

K

Koncept

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?
 
P

Peter Hansen

Koncept said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top