3
Contributors
3
Replies
5
Views
11 Years
Discussion Span
Last Post by bumsfeld
0

I'm not very certain on classes and stuff like that myself but i'm guessing and from what i've read i think if you do

class namehere(calender_name):
    stuff here

can't guarantee it will work (not on my computer so i can't get at python to try it)
but it's just an idea

0

You can only inherit another class. The module calendar contains a function calendar, but you can't inherit a function. This small code might explain a few basic things ...

import calendar
import Cookie
import inspect

if inspect.isclass(calendar):
    print "calendar is a class"
else:
    print "calendar is not a class"

# this would give you an error since calendar is not a class, but a module
# there is a function (not a class) calendar within module calendar
# you can use functions like calendar.calendar(), but not inherit them
"""
class MyCalendar(calendar):
    pass
"""

if inspect.isclass(Cookie.Morsel):
    print "Cookie.Morsel is a class"
else:
    print "Cookie.Morsel is not a class"

# this will work, since Morsel is a class in module Cookie
class MyCookie(Cookie.Morsel):
    "now do something more than pass"
    pass


print type(calendar)          # <type 'module'>
print type(calendar.calendar) # <type 'function'>

print type(Cookie)            # <type 'module'>
print type(Cookie.Morsel)     # <type 'type'>   hint of class

Note: A class name by convention starts with a capital letter, this can be a hint!

Edited by vegaseat: n/a

0

I am astonished how little classes basic Python modules uses. I thought it was more of a OO language.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.