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

    Guest

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

    Bill Mill Guest

    On 24 Mar 2005 10:29:40 -0800, <> wrote:
    > I am new to python and learning it. Can you please give me a simple
    > example of user defined type through class mechanism.


    GIYF:
    http://www.python.org/2.2/descrintro.html#subclassing

    Peace
    Bill Mill
    bill.mill at gmail.com
     
    Bill Mill, Mar 24, 2005
    #4
  5. waqar

    Tim Jarman Guest

    wrote:

    > I am new to python and learning it. Can you please give me a simple
    > example of user defined type through class mechanism.


    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.
    >>> class Gumby(object):

    .... def __init__(self, body_part):
    .... self.body_part = body_part
    .... def speak(self):
    .... print "My %s hurts!" % self.body_part
    ....
    >>> g = Gumby("brain")
    >>> g

    <__main__.Gumby object at 0x402c570c>
    >>> g.speak()

    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!

    --
    Website: www DOT jarmania FULLSTOP com
     
    Tim Jarman, Mar 24, 2005
    #5
    1. Advertisements

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. Sathyaish
    Replies:
    2
    Views:
    723
    Sathyaish
    May 22, 2005
  2. Brian Henry

    Data type question for OLEdb data types

    Brian Henry, Oct 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    721
  3. Soren Kuula
    Replies:
    2
    Views:
    812
    Henry S. Thompson
    Dec 1, 2005
  4. Jeremy Cowles

    STD types vs C++ intrinsic types

    Jeremy Cowles, Aug 18, 2003, in forum: C++
    Replies:
    5
    Views:
    2,126
    Bob Jacobs
    Aug 19, 2003
  5. Steve Knight
    Replies:
    2
    Views:
    1,063
    Steve Knight
    Oct 10, 2003
  6. Manlio Perillo

    missing types in module types?

    Manlio Perillo, May 29, 2004, in forum: Python
    Replies:
    0
    Views:
    477
    Manlio Perillo
    May 29, 2004
  7. ramu
    Replies:
    2
    Views:
    565
    rlblaster
    Feb 20, 2006
  8. Gary Roach
    Replies:
    0
    Views:
    250
    Gary Roach
    Sep 1, 2013
Loading...