[newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Mahmoud Abdel-Fattah
Hello, I'm coming from PHP background ant totally new to Python, I just started using scrapy, but has some generic question in python. 1. How can I write the following code in easier way in Python ? if len(item['description']) > 0: item['description'] = item['description'][0]

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Mahmoud Abdel-Fattah
Thanks ChrisA a lot. I just tried what you said, but I got an error, here's what I tried : item['name'] = hxs.select('//div[@id="center-main"]/h1/text()').extract()[0] author_brand = re.match(r'^[.*] - (.*)$', item['name'], re.I|re.S|re.M) item['author_brand'] = author_brand.group(2) if type(autho