Data types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • waqar

    #1

    Data types

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

    #2
    Re: Data types

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

    Comment

    • vahmad70@yahoo.com

      #3
      Re: Data types

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

      Comment

      • Bill Mill

        #4
        Re: Data types

        On 24 Mar 2005 10:29:40 -0800, vahmad70@yahoo. com <vahmad70@yahoo .com> wrote:[color=blue]
        > I am new to python and learning it. Can you please give me a simple
        > example of user defined type through class mechanism.[/color]

        GIYF:


        Peace
        Bill Mill
        bill.mill at gmail.com

        Comment

        • Tim Jarman

          #5
          Re: Data types

          vahmad70@yahoo. com wrote:
          [color=blue]
          > I am new to python and learning it. Can you please give me a simple
          > example of user defined type through class mechanism.[/color]

          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.[color=blue][color=green][color=darkred]
          >>> class Gumby(object):[/color][/color][/color]
          .... def __init__(self, body_part):
          .... self.body_part = body_part
          .... def speak(self):
          .... print "My %s hurts!" % self.body_part
          ....[color=blue][color=green][color=darkred]
          >>> g = Gumby("brain")
          >>> g[/color][/color][/color]
          <__main__.Gum by object at 0x402c570c>[color=blue][color=green][color=darkred]
          >>> g.speak()[/color][/color][/color]
          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:
          The official home of the Python Programming Language


          Enjoy!

          --
          Website: www DOT jarmania FULLSTOP com

          Comment

          Working...