Re: dynamicly updating an objects fields

2005-08-30 Thread Uwe Lauth
kyle.tk wrote:
> I want to make a function that will work like this:
> 
> def updateField(object, fieldName, newValue):
>   object.fieldName = newValue

This function already exists in python.
It is called settattr.

Regards
Uwe
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: extra a column from a 2-D array?

2005-05-10 Thread Uwe Lauth
Joe Wong wrote:
(original posting not on my nntp server)
>>Hello,
>> 
>> Suppose I have a python array as follow:
>> 
>>s=[ [1,3,5],
>>[2,4,6],
>>[9,8,7]]
>> 
>>what is the quickest way to extract the second colum from all rows? That 
>>is: [3,4,8] in this example.

[a[1] for a in s]

Uwe
-- 
http://mail.python.org/mailman/listinfo/python-list