getting started

Dave Angel d at davea.name
Fri May 25 09:37:44 EDT 2012


On 05/25/2012 09:12 AM, Harvey Greenberg wrote:
> elementary ques...I set
> 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?

You just have to initialize s as an object that's willing to take those
attributes.  The most trivial way I can think of to do that would be to
create an empty class for the purpose.

class MyClass:
    pass

s = MyClass()

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


Of course if you told why you want to do it, we might be able to suggest
a better type for s.

-- 

DaveA




More information about the Python-list mailing list