Chris Angelico wrote:
> Just FYI, Rick Johnson (aka Ranting Rick) is a known troll. Don't let
> him goad you :)
>
> Follow other people's advice, and take Rick's posts with a grain of
> salt. Sometimes he has a good point to make (more often when he's
> talking about tkinter, which is his area of
On Thu, Jun 13, 2013 at 10:06 PM, Rui Maciel wrote:
> Rick Johnson wrote:
>> Firstly. Why would you define a Point object that holds it's x,y,z values
>> in a list attribute? Why not store them as self.x, self.y and self.z?
>
>
> The position in space is represented as a vector, which is then use
Rick Johnson wrote:
> On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote:
>> [...]
>>
>>
>> class Point:
>> position = []
>> def __init__(self, x, y, z = 0):
>> self.position = [x, y, z]
>
> Firstly. Why would you define a Point object that holds it's x,y
On Monday, June 10, 2013 2:56:15 PM UTC-5, Ian wrote:
> [...]
> There are a couple of ways you might get this to work the way you
> want. One is by adding as an extra layer a proxy object, which could
> be as simple as:
> class Proxy(object):
> def __init__(self, ref):
> self.ref = ref
On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote:
> [...]
>
>
> class Point:
> position = []
> def __init__(self, x, y, z = 0):
> self.position = [x, y, z]
Firstly. Why would you define a Point object that holds it's x,y,z values in a
list attribute? W
On Mon, Jun 10, 2013 at 7:26 PM, Dave Angel wrote:
> On 06/10/2013 06:54 PM, Chris Angelico wrote:
>
>> On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards
>> wrote:
>>
>>> On 2013-06-10, Terry Jan Reedy wrote:
>>>
>>> Another principle similar to 'Don't add extraneous code' is 'Don't
rebind b
On 06/10/2013 06:54 PM, Chris Angelico wrote:
On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards wrote:
On 2013-06-10, Terry Jan Reedy wrote:
Another principle similar to 'Don't add extraneous code' is 'Don't
rebind builtins'.
OK, we've all done it by accident (especially when starting out), b
On 2013-06-11 08:54, Chris Angelico wrote:
> >> Another principle similar to 'Don't add extraneous code' is
> >> 'Don't rebind builtins'.
> >
> > OK, we've all done it by accident (especially when starting out),
> > but are there people that rebind builtins intentionally?
>
> There are times when
On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards wrote:
> On 2013-06-10, Terry Jan Reedy wrote:
>
>> Another principle similar to 'Don't add extraneous code' is 'Don't
>> rebind builtins'.
>
> OK, we've all done it by accident (especially when starting out), but
> are there people that rebind built
On 2013-06-10, Terry Jan Reedy wrote:
> Another principle similar to 'Don't add extraneous code' is 'Don't
> rebind builtins'.
OK, we've all done it by accident (especially when starting out), but
are there people that rebind builtins intentionally?
--
Grant Edwards grant.b.edwa
On 6/10/2013 4:13 PM, Rui Maciel wrote:
Terry Jan Reedy wrote:
Three answers:
Look how much trouble it has already caused ;-)
Since you are a self-declared newbie, believe us!
Since, be definition, useless code can do no good, it can only cause
trouble. Think about it.
I don't doubt that ther
Dave Angel wrote:
> So why do you also have an instance attribute of the same name?
Thanks to this thread, and after a bit of reading, I've finally managed to
discover that in Python there are class attributes and instance attributes,
the former working similarly to C++'s static member variable
Terry Jan Reedy wrote:
> Three answers:
> Look how much trouble it has already caused ;-)
> Since you are a self-declared newbie, believe us!
> Since, be definition, useless code can do no good, it can only cause
> trouble. Think about it.
I don't doubt that there might good reasons for that, but
Terry Jan Reedy wrote:
> On 6/10/2013 9:18 AM, Rui Maciel wrote:
>
>> class Model:
>> points = []
>> lines = []
>
> Unless you actually need keep the points and lines ordered by entry
> order, or expect to keep sorting them by whatever, sets may be better
> than lists. Testing
On Mon, Jun 10, 2013 at 7:57 AM, Rui Maciel wrote:
> # Case A: this works
> model.points[0].position = [2,3,4]
> line.points
>
> # Case B: this doesn't work
> test.model.points[0] = test.Point(5,4,7)
> line.points
>
>
>
> Is there a Python way of getting the same effect with Case B?
It's inform
On 6/10/2013 9:18 AM, Rui Maciel wrote:
class Model:
points = []
lines = []
Unless you actually need keep the points and lines ordered by entry
order, or expect to keep sorting them by whatever, sets may be better
than lists. Testing that a point or line is in the model wil
On 6/10/2013 12:09 PM, Rui Maciel wrote:
We've established that you don't like attribute declarations, at least those
you describe as not fulfill a technical purpose. What I don't understand is
why you claim that that would "cause nothing but trouble".
Three answers:
Look how much trouble it
On 06/10/2013 01:42 PM, Rui Maciel wrote:
Peter Otten wrote:
Have you read the code in the interpreter session I posted?
If you do not agree that the demonstrated behaviour is puzzling I'll have
to drop my claim...
I don't see how it should be puzzling. You've deleted the attribute, so it
c
Peter Otten wrote:
> Have you read the code in the interpreter session I posted?
>
> If you do not agree that the demonstrated behaviour is puzzling I'll have
> to drop my claim...
I don't see how it should be puzzling. You've deleted the attribute, so it
ceassed to exist.
> Likewise if you
Rui Maciel wrote:
> Peter Otten wrote:
>
>> I don't understand the question. My original point was that you should
>> omit class attributes that don't fulfill a technical purpose.
>>
>
> You've said the following:
>
>
>> class Point:
>
> Don't add
>
>> position = []
>
> to your cod
Peter Otten wrote:
> I don't understand the question. My original point was that you should
> omit class attributes that don't fulfill a technical purpose.
>
You've said the following:
> class Point:
Don't add
> position = []
to your code. That's not a declaration, but a class attr
Rui Maciel wrote:
> Peter Otten wrote:
>
>> Rui Maciel wrote:
>>
>>> How do you guarantee that any object of a class has a specific set of
>>> attributes?
>>
>> You don't.
>
>
> What's your point regarding attribute assignments in class declarations,
> then?
I don't understand the question.
Peter Otten wrote:
> Rui Maciel wrote:
>
>> How do you guarantee that any object of a class has a specific set of
>> attributes?
>
> You don't.
What's your point regarding attribute assignments in class declarations,
then?
Rui Maciel
--
http://mail.python.org/mailman/listinfo/python-list
Rui Maciel wrote:
> How do you guarantee that any object of a class has a specific set of
> attributes?
You don't.
Such a guarantee is like the third wheel on a bike -- it doesn't improve the
overall experience.
PS: I'd rather not mention the memory-saving technique that is sometimes
abused,
Peter Otten wrote:
> Rui Maciel wrote:
>
>> Peter Otten wrote:
>>
>>> Don't add
>>>
position = []
>>>
>>> to your code. That's not a declaration, but a class attribute and in the
>>> long run it will cause nothing but trouble.
>>
>> Why's that?
>
> Especially with mutable attributes it's
Rui Maciel wrote:
> Peter Otten wrote:
>
>> Don't add
>>
>>>position = []
>>
>> to your code. That's not a declaration, but a class attribute and in the
>> long run it will cause nothing but trouble.
>
> Why's that?
Especially with mutable attributes it's hard to keep track whether you are
o
Rui Maciel wrote:
> # Case B: this doesn't work
> test.model.points[0] = test.Point(5,4,7)
Disregard the "test." bit. I was testing the code by importing the
definitions as a module.
Rui Maciel
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
> Don't add
>
>>position = []
>
> to your code. That's not a declaration, but a class attribute and in the
> long run it will cause nothing but trouble.
Why's that?
Rui Maciel
--
http://mail.python.org/mailman/listinfo/python-list
Roy Smith wrote:
> Have you tried running the code you wrote? It does that already! When
> you do something like:
>
> my_list = [obj1, obj2]
>
> in Python, the objects are stored by reference (not just lists, all
> assignments are by reference).
I've tested the following:
model = Model()
mo
Rui Maciel wrote:
> Let:
> - class Point be a data type which is used to define points in space
> - class Line be a data type which possesses an aggregate relationship with
> objects of type Point
> - class Model be a container class which stores collections of Point and
> Line objects
>
>
> Ess
In article ,
Rui Maciel wrote:
> Essentially, a Model object stores lists of Point objects and Line objects,
> and Line objects include references to Point objects which represent the
> starting and ending point of a line.
>
> class Point:
> position = []
>
> def __init__(sel
Let:
- class Point be a data type which is used to define points in space
- class Line be a data type which possesses an aggregate relationship with
objects of type Point
- class Model be a container class which stores collections of Point and
Line objects
Essentially, a Model object stores lis
32 matches
Mail list logo