Re: The del statement

2008-05-09 Thread Michael Torrie
George Sakkis wrote: > I think you're trying to imply that it is consistent with setting a > value (same with getting). I guess what bugs me about "del" is that > it's a keyword and not some universally well-known punctuation. Do you > you feel that Python misses a "pop" keyword and respective > ex

Re: The del statement

2008-05-08 Thread Terry Reedy
"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | One of the few Python constructs that feels less elegant than | necessary to me is the del statement. For one thing, it is overloaded | to mean three different things: | (1) del x: Remove x from the c

Re: The del statement

2008-05-08 Thread George Sakkis
On May 8, 2:58 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > One of the few Python constructs that feels less elegant than > > necessary to me is the del statement. For one thing, it is overloaded > > to mean three different things: >

Re: The del statement

2008-05-08 Thread Duncan Booth
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > Duncan Booth wrote: >> Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> >> > >> > >> > George Sakkis wrote: >> >> One of the few Python constructs that feels less elega

Re: The del statement

2008-05-08 Thread Arnaud Delobelle
Duncan Booth wrote: > Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > > > > > George Sakkis wrote: > >> One of the few Python constructs that feels less elegant than > >> necessary to me is the del statement. For one thing, it is overloaded >

Re: The del statement

2008-05-08 Thread Duncan Booth
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > George Sakkis wrote: >> One of the few Python constructs that feels less elegant than >> necessary to me is the del statement. For one thing, it is overloaded >> to mean three different things: >> (1) del

Re: The del statement

2008-05-08 Thread Arnaud Delobelle
George Sakkis wrote: > One of the few Python constructs that feels less elegant than > necessary to me is the del statement. For one thing, it is overloaded > to mean three different things: > (1) del x: Remove x from the current namespace > (2) del x[i]: Equivalent to x.__delitem

The del statement

2008-05-07 Thread George Sakkis
One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__

Re: The del statement

2006-12-07 Thread Fredrik Lundh
Marco Aschwanden wrote: > I am not convinced though that del should also remove elements > from a container/sequence. in today's Python, you can use "del" on all targets that you can assign to. I'm not sure how breaking this consistency would somehow improve things... -- http://mail.pyth

Re: The del statement

2006-12-06 Thread Marco Aschwanden
Thanks for the answers. I see that the del statement does remove an object from the namespace. And yes, it makes perfect sense to handle it from "outside" with the del command. I am not convinced though that del should also remove elements from a container/sequence. Than

Re: The del statement

2006-12-05 Thread Sion Arrowsmith
Marco Aschwanden <[EMAIL PROTECTED]> wrote: [ ... ] >> so what about >> >> del x > >Ups. I never used it for an object. So far I only used it for deletion of >elements of a container. In that case del has two purposes: > >1. Deletes an item from a container (and of course destructs it) -->

Re: The del statement

2006-12-05 Thread Dustan
.__getitem__ >>> l.__delitem__ It seems that list.__delitem__ is a different type than the rest, called method-wrapper. I can only guess from this point; someone else is bound to know about this. > Marco I can see some builtin functions leaving, but the del keyword isn't exactl

Re: The del statement

2006-12-05 Thread Marco Aschwanden
> do you find the x[i] syntax for calling the getitem/setitem methods a > bit awkward too? what about HTTP's use of "GET" and "POST" for most > about everything ? ;-) No. I like the x[i] syntax. I use it in every second row of my code and getting an item like: x.getitem(i) would be a viable (

Re: The del statement

2006-12-05 Thread Fredrik Lundh
Marco Aschwanden wrote: > 2. Calls the destructor of an object --> list.destruct() "del name" only removes the name from the current namespace, it doesn't destroy the object: http://effbot.org/pyref/del the actual destruction is handled by the garbage collector, when the time is right.

Re: The del statement

2006-12-05 Thread Marco Aschwanden
> so what about > > del x Ups. I never used it for an object. So far I only used it for deletion of elements of a container. In that case del has two purposes: 1. Deletes an item from a container (and of course destructs it) --> list.remove(elem) 2. Calls the destructor of an object -->

Re: The del statement

2006-12-05 Thread Fredrik Lundh
Marco Aschwanden wrote: > Where > > list.del(elem) > map.del(elem) > > would achieve the same result (and I think, this is what happens in the > backend). so what about del x ? > The same discussion was done for the "external" len-function (list.len() > vs. len(list)). for the curi

The del statement

2006-12-05 Thread Marco Aschwanden
Hi I was wondering whether the del statment was going to stay in Python3000? It is a bit awkward to use the del statement where a method call would do the same without the need for a new keyword. del list[elem] del map[elem] Where list.del(elem) map.del(elem) would achieve the same result