Simple questions on use of objects (probably faq)
Max M
maxm at mxm.dk
Wed Mar 8 07:08:45 EST 2006
Brian Elmegaard wrote:
> Hi,
>
> I am struggling to understand how to really appreciate object
> orientation. I guess these are FAQ's but I have not been able to find
> the answers. Maybe my problem is that my style and understanding are
> influenced by matlab and fortran.
> What I hoped I could do:
> class Foo:
> def __init__(self,self.x):
> continue
> y=[]
> y.append(Foo(10.0))
> y.append(Foo(110.0))
> y.append(Foo(60.0))
>
> ys=([y[].x])
> y_max=max(y[].x)
> y_min=min(y[].x)
>
> yz=[y[:-1].x-y[1:].x]
It is hard to tell what you are trying to do here. But here is a shot at
parts of the code.
class Foo:
def __init__(self, x):
self.x = x
y = [Foo(10.0), Foo(110.0), Foo(60.0)]
x_values = [o.x for o in y]
y_max = max(x_values)
y_min = min(x_values)
Otherwise you could try and describe with words what you are getting at.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Python-list
mailing list