dhruvbird <dhruvb...@gmail.com> writes:

> No, I meant x.append(4)
> Except that I want to accomplish it using slices.
>
> (I can do it as x[lex(x):] = [item_to_append] but is there any other
> way?)

It seems that you've found a way to do so, so why do you need another
way?  Are you after elegance?  Efficiency?  Brevity?

Here are some other ways to express the same, and all use slices in some
way:

x[slice(len(x), None)] = [item_to_append]
x.__setitem__(slice(len(x), None), [item_to_append])
x.__setslice__(len(x), len(x), [item_to_append])

...but I have no idea why any of them would make any more sense than
x[len(x):] = [item_to_append].
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to