By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

OOP help needed incorporating existing modules in class

P: n/a

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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.