On Apr 18, 2:54 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Apr 18, 7:39 pm, wswilson <[EMAIL PROTECTED]> wrote:
>
>
>
> > Here is my code:
>
> > listing = {'id': ['a', 'b', 'c'], 'name': ['Joe&
Here is my code:
listing = {'id': ['a', 'b', 'c'], 'name': ['Joe', 'Jane', 'Bob']}
I need to output:
id name
a Joe
b Jane
c Bob
I could do:
print 'id', 'name'
for id, name in zip(listing['id'], listing['name']): print id, name
but that only works if there are two entries in the dictionary, id
On Apr 11, 10:40 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> wswilson <[EMAIL PROTECTED]> wrote:
> > Here is my code:
>
> > class A():
> > val = 0
>
> > def b(item, a):
> > a.val = a.val + 1
> > return item + a.val
>
> &
On Apr 11, 10:36 am, "antred" <[EMAIL PROTECTED]> wrote:
> > def b(item, a):
> > a.val = a.val + 1
> > return item + a.val
>
> This is where the problem lies, specifically the line a.val = a.val +
> 1
> What happens here is that the 1st a.val refers to a member of the
> class instan
Here is my code:
class A():
val = 0
def b(item, a):
a.val = a.val + 1
return item + a.val
def c():
d = [1, 2, 3]
print [b(item, A()) for item in d]
c()
I expected this to output [2, 4, 6]. However, it outputs [2, 3, 4]
which is not what I wanted. I thoug
On Apr 2, 11:01 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 1 Apr 2007 18:36:04 -0700, "asdf1234234" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > My code is:
> > -a.py-
> > import b
>
> > class A:
> > def __init__(self):
> > pass
>
> Dele
On Apr 2, 1:04 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> asdf1234234 <[EMAIL PROTECTED]> wrote:
> > My code is:
> > -a.py-
> > import b
>
> > class A:
> > def __init__(self):
> > pass
>
> Incidentally, these last two lines are totally, utterly useless. Do NOT
> define special m
On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote:
> asdf1234234 wrote:
> > -a.py-
> > import b
>
> > class A:
> > def __init__(self):
> > pass
> > def my_method(self):
> > var = 1
> > self.var = 2
> > b.set_var(self)
> > print