Inherit Calendar

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Inherit Calendar

 
0
  #1
Sep 21st, 2005
I am just starting to look at writing class in Python. Can a class that I write inherit Python calendar?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 138
Reputation: a1eio is an unknown quantity at this point 
Solved Threads: 21
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Re: Inherit Calendar

 
0
  #2
Sep 22nd, 2005
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
  1. class namehere(calender_name):
  2. 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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,113
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 944
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Inherit Calendar

 
0
  #3
Sep 23rd, 2005
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 ...
  1. import calendar
  2. import Cookie
  3. import inspect
  4.  
  5. if inspect.isclass(calendar):
  6. print "calendar is a class"
  7. else:
  8. print "calendar is not a class"
  9.  
  10. # this would give you an error since calendar is not a class, but a module
  11. # there is a function (not a class) calendar within module calendar
  12. # you can use functions like calendar.calendar(), but not inherit them
  13. """
  14. class MyCalendar(calendar):
  15. pass
  16. """
  17.  
  18. if inspect.isclass(Cookie.Morsel):
  19. print "Cookie.Morsel is a class"
  20. else:
  21. print "Cookie.Morsel is not a class"
  22.  
  23. # this will work, since Morsel is a class in module Cookie
  24. class MyCookie(Cookie.Morsel):
  25. "now do something more than pass"
  26. pass
  27.  
  28.  
  29. print type(calendar) # <type 'module'>
  30. print type(calendar.calendar) # <type 'function'>
  31.  
  32. print type(Cookie) # <type 'module'>
  33. 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!
Last edited by vegaseat; Oct 1st, 2009 at 4:59 pm.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: Inherit Calendar

 
0
  #4
Sep 25th, 2005
I am astonished how little classes basic Python modules uses. I thought it was more of a OO language.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC