OOP help needed incorporating existing modules in class

Discussion in 'Python' started by Koncept, Jul 1, 2005.

  1. Koncept

    Koncept Guest

    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
    Koncept, Jul 1, 2005
    #1
    1. Advertising

  2. Koncept

    Peter Hansen Guest

    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
    Peter Hansen, Jul 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    309
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=
    Sep 9, 2005
  2. Replies:
    0
    Views:
    359
  3. KiwiBrian
    Replies:
    3
    Views:
    1,105
    Martin
    Mar 8, 2005
  4. poener
    Replies:
    6
    Views:
    328
    poener
    Aug 29, 2006
  5. Replies:
    4
    Views:
    627
    Harlan Messinger
    Sep 19, 2006
Loading...

Share This Page