On 14/04/2012 23:45, Chris Angelico wrote:
On Sun, Apr 15, 2012 at 8:41 AM, Mahmoud Abdel-Fattah
<accou...@abdel-fattah.net>  wrote:
 item['author_brand'] = author_brand.group(2) if type(author_brand) != None
 else ''

Almost there! :)

None is a singleton, not a type; you don't need to check
type(author_brand) but rather its identity. Use "author_brand is not
None" for your condition and it should work like you're expecting. In
this case, you can actually just use "author_brand" as your condition
(no quotes, of course), as None evaluates as false.

re.match(...) returns either a match object or None. In a condition, a
match object always evaluates as True and None always evaluates as
False.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to