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 c
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:
>
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
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
>
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
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
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__
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.
Than
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) -->
.__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
> 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
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
17 matches
Mail list logo