Data types

Discussion in 'Python' started by waqar, Mar 24, 2005.

  1. waqar

    waqar Guest

    What are the user defined types in Python? Can we call lists, tuples &
    dictionaries user-defined data types?
     
    waqar, Mar 24, 2005
    #1
    1. Advertisements

  2. Lists, tuples, and dictionaries are built-in types.
    Classes are the mechanism for user-defined types in Python.
     
    Lonnie Princehouse, Mar 24, 2005
    #2
    1. Advertisements

  3. waqar

    vahmad70 Guest

    I am new to python and learning it. Can you please give me a simple
    example of user defined type through class mechanism.
     
    vahmad70, Mar 24, 2005
    #3
  4. waqar

    Bill Mill Guest

    Bill Mill, Mar 24, 2005
    #4
  5. waqar

    Tim Jarman Guest

    Python 2.4 (#1, Dec 31 2004, 17:21:43)
    [GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2
    Type "help", "copyright", "credits" or "license" for more information..... def __init__(self, body_part):
    .... self.body_part = body_part
    .... def speak(self):
    .... print "My %s hurts!" % self.body_part
    ....My brain hurts!


    Despite what Mr Gumby just said, defining your own classes is pretty
    painless in Python. Check out the Tutorial, especially section 9:
    http://www.python.org/doc/2.4/tut/node11.html

    Enjoy!
     
    Tim Jarman, Mar 24, 2005
    #5
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.