getting started

Miki Tebeka miki.tebeka at gmail.com
Fri May 25 09:30:44 EDT 2012


> s.name = ["a","b"]
> s.value = [3,5]
> 
> I get error that s is not defined.  How do I define s and proceed to
> give its attributes?
Either you create a class and use __init__:
class S:
    def __init__(self, name, value):
        self.name = name
        self.value = value

or create a generic object and stick attributes to it:
class Object(object):
    pass

s = Object()
s.name = ["a","b"]
s.value = [3,5]

I highly recommend going over the tutorial - http://docs.python.org/tutorial/



More information about the Python-list mailing list