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
"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
|
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
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
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
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
>>
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
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
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
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) -->
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:
> 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 (
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.
> 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 -->
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
15 matches
Mail list logo