Never mind, looks like I needed an internal paren, I guess to produce a 'tuple'
errors=[]
errors.append(("name","message"))
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dan Winslow
Sent: Monday, June 08, 2009 12:10 PM
To: [email protected]
Subject: [Trac] Re: Python question
Although...this
errors=[]
errors.append("name","message")
gives
TypeError: append() takes exactly one argument (2 given
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Emmanuel Blot
Sent: Monday, June 08, 2009 12:04 PM
To: [email protected]
Subject: [Trac] Re: Python question
> Can someone explain this construct to me?
You'd want to look for "list comprehension" documentation in Python
The code snipped can be rewritten as:
errors = []
for field_name in required_fields:
if self._is_empty(ticket[field_name]):
errors.append((field_name, '%s is required' % field_name))
> errors = [(field_name, '%s is required' % field_name)
> for field_name in required_fields
> if self._is_empty(ticket[field_name])]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---