Re: Optional parameter object re-used when instantiating multiple objects

2008-11-19 Thread Rick Giuly
Thanks to all for your replies All things considered, I vote for evaluating the arguments at runtime (each time the function is called). Good reasons for this have already been mentioned so I won't repeat them. A programming language is a user interface of sorts. (Pretty much all languages are log

Optional parameter object re-used when instantiating multiple objects

2008-11-15 Thread Rick Giuly
Hello All, Why is python designed so that b and c (according to code below) actually share the same list object? It seems more natural to me that each object would be created with a new list object in the points variable. class Blob: def __init__(self, points=[]): self._points = point

Why does numpy.array(a[0],b[0]) have this meaning?

2008-11-02 Thread Rick Giuly
Hello All, Case 1 This generates an error, which makes sense because the argument should be a list of numbers: numpy.array(10,10) Case 2 This does not generate an error and the result is an array with a single element: a = numpy.array([10]) b = numpy.array([10]) numpy.array(a[0],b[0]) The only d