Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Data types

Reply
Thread Tools

Data types

 
 
waqar
Guest
Posts: n/a
 
      03-24-2005
What are the user defined types in Python? Can we call lists, tuples &
dictionaries user-defined data types?
 
Reply With Quote
 
 
 
 
Lonnie Princehouse
Guest
Posts: n/a
 
      03-24-2005
Lists, tuples, and dictionaries are built-in types.
Classes are the mechanism for user-defined types in Python.

 
Reply With Quote
 
 
 
 
vahmad70@yahoo.com
Guest
Posts: n/a
 
      03-24-2005
I am new to python and learning it. Can you please give me a simple
example of user defined type through class mechanism.

 
Reply With Quote
 
Bill Mill
Guest
Posts: n/a
 
      03-24-2005
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
 
Reply With Quote
 
Tim Jarman
Guest
Posts: n/a
 
      03-24-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
equivalent c data types for vc++ data types ramu C Programming 2 02-20-2006 09:33 AM
Can XSD simple types be derived from complex types? Soren Kuula XML 2 12-01-2005 07:51 PM
Where are ref types that are members of value types stored? Sathyaish ASP .Net 2 05-22-2005 07:32 PM
Boost + Python C/API: Mixing python return types with boost return types Steve Knight Python 2 10-10-2003 10:11 AM
STD types vs C++ intrinsic types Jeremy Cowles C++ 5 08-19-2003 05:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57