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

2014-01-04 Thread spir
On 01/04/2014 06:36 AM, Steven D'Aprano wrote: Now, it's true that when *debugging code*, being able to see the name of the variable and the contents of the variable is useful. But in ordinary code, why would you care to print the name of the variable and its contents. Who cares what the variable

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

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 01:55:29AM -0500, Keith Winston wrote: [...] > I want to iterate through a bunch of lists, subsequently printing both list > members (via indexing, for example) and the name of the list I'm on. Why? What does this gain you? Now, it's true that when *debugging code*, being

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

2014-01-03 Thread Asokan Pichai
On Fri, Jan 03, 2014 at 02:45:04AM -0500, Keith Winston wrote: > And to beat that poor horse in the same example, my current way of doing > that would be: > > for alist in "lista", "listb": > print(alist, eval(alist)) Since you know both pieces, namely the name of the entity "alist" and its

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

2014-01-02 Thread Keith Winston
And to beat that poor horse in the same example, my current way of doing that would be: for alist in "lista", "listb": print(alist, eval(alist)) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pytho

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

2014-01-02 Thread Keith Winston
I spoke about iterating through a bunch of lists in my last post, but in fact I'm iterating through a bunch of dicts in the example I gave. Sorry. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.o

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

2014-01-02 Thread Mark Lawrence
On 03/01/2014 06:55, Keith Winston wrote: Mark wrote: You enjoy making life difficult for yourself :) You've assigned strings to the name func, just assign the functions themselves? Like. for func in max, min: print(func.__name__, func(range(5))) Output. max 4 min

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

2014-01-02 Thread Keith Winston
Mark wrote: You enjoy making life difficult for yourself :) You've assigned strings to the name func, just assign the functions themselves? Like. > > for func in max, min: > print(func.__name__, func(range(5))) > > Output. > > max 4 > min 0 > > I wouldn't say I enjoy making life difficult fo

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

2014-01-02 Thread Mark Lawrence
On 03/01/2014 06:18, Keith Winston wrote: Shoot: I sent this response directly to Mark, without even trimming. Here it is to the list... Hi Mark: sorry for unclarity. I am probably going to make a hash of explaining this, but here goes: I want to iterate a variable across a list of objects, and

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

2014-01-02 Thread Keith Winston
Shoot: I sent this response directly to Mark, without even trimming. Here it is to the list... Hi Mark: sorry for unclarity. I am probably going to make a hash of explaining this, but here goes: I want to iterate a variable across a list of objects, and print both the outputs (wrong word) of sai