On Sat, Feb 13, 2010 at 8:08 PM, the kids <the7hans...@msn.com> wrote:
> Hi, my name is John Paul.
>
> I was trying to define a class but I can't make it asign particular objects
> particular variables at their creation.  Please help.

It would help to see some details of what you are trying to do. It
sounds like you want an __init__() method in your class:

In [1]: class Data(object):
   ...:     def __init__(self, a, b):
   ...:         self.a = a
   ...:         self.b = b


In [2]: d = Data(1, 2)

In [3]: d.a
Out[3]: 1

In [4]: d.b
Out[4]: 2

In [5]: dd = Data(42, 57)

In [6]: dd.a, dd.b
Out[6]: (42, 57)

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to