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 current namespace |

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: > > (1) del x: Remove x from the curr

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 elegant than >> >> necessary to me is the del statement. For one thing, it is overlo

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 > >> to mean three different things: > >> (1) del x: R

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 x: Remove x from the current namespace >>

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__(i) > (3) del

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. Thanks for the enlight

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
Marco Aschwanden wrote: > > 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:

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