Python
  Home arrow Python arrow Page 2 - Object Oriented Programming With Pytho...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Object Oriented Programming With Python (part 1)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2001-11-01

    Table of Contents:
  • Object Oriented Programming With Python (part 1)
  • A Very Big Snake
  • What's In A Name?
  • Digging Deep
  • Self-Involved
  • Under Construction

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Object Oriented Programming With Python (part 1) - A Very Big Snake


    (Page 2 of 6 )

    A class definition typically looks like this:

    class veryBigSnake: # some useful methods def eat(self): # code goes here def sleep(self): # code goes here def squeeze_to_death(self): # code goes here
    Once the class has been defined, you can instantiate a new object by assigning it to a Python variable,

    Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> python = veryBigSnake() >>>
    which can then be used to access all object methods and properties.

    >>> python.eat() >>> >>> python.sleep() >>>
    As stated above, each instance of a class is independent of the others - which means that, if I was a snake fancier, I could create more than one instance of veryBigSnake(), and call the methods of each instance independently.

    >>> alpha = veryBigSnake() >>> beta = veryBigSnake() >>> # make the alpha snake eat >>> alpha.eat() >>> >>> # make the beta snake eat and sleep >>> beta.eat() >>> >>> beta.sleep() >>>

    More Python Articles
    More By icarus, (c) Melonfire


     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway