Data types

W

waqar

What are the user defined types in Python? Can we call lists, tuples &
dictionaries user-defined data types?
 
L

Lonnie Princehouse

Lists, tuples, and dictionaries are built-in types.
Classes are the mechanism for user-defined types in Python.
 
V

vahmad70

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

Tim Jarman

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..... 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!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top