[Tutor] Fwd: Fwd: What's in a name?

Keith Winston keithwins at gmail.com
Fri Jan 3 08:34:10 CET 2014


OMG, another one to Mark and not the list. I'll see if there's something I
can adjust in email...

On Fri, Jan 3, 2014 at 2:23 AM, Mark Lawrence <breamoreboy at yahoo.co.uk>wrote:

>
> lista = list(range(5))
> listb = list(reversed(range(5)))
> for alist in lista, listb:
>     print(alist.__class__.__name__, alist)
>
> list [0, 1, 2, 3, 4]
> list [4, 3, 2, 1, 0]
>
>
> Thank you Mark for your unreasonable patience. But the output I'd like to
see from you example would be:

lista [0, 1, 2, 3, 4]
listb [4, 3, 2, 1, 0]

Which I think is not possible since the list names are lost by the time the
print statement is executing. Unless, of course, I'm wrong. I need the
instance name, I guess, not the object name, of an object that includes no
__name__ method (I'm stretching on this description)




-- 
Keith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140103/e003f8c1/attachment.html>


More information about the Tutor mailing list