newb: Scope Question
James Stroud
jstroud at mbi.ucla.edu
Fri Jun 22 19:06:02 EDT 2007
johnny wrote:
> Scope of ids:
> When I print "ids", it's always empty string '', as I have intialized
> before. That's not what I want. I want the ids to have
> str(r['id']).join(',')
>
> if res:
> ids = ''
> for r in res['key']:
> ids = str(r['id']).join(',')
>
> print("ids: %s" %(ids))
>
1. You do not need to "initialize" ids.
2. It looks as if res['key'] is empty.
3. Are you sure you don't mean "res[key]"?
4. "ids" and "(ids)" are equivalent.
5. Are you sure you don't want to indent the print statement?
James
More information about the Python-list
mailing list