[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [GSoC] Adding information to UDD and inject the rendering to tasks,py



[Akshita Jha]
> This error occurs wherever "if sprosp['license'] == ' ' " is
> checked. I solved these errors by using try-except block:
>
> try:
>     if sprosp['license'] == '':
>         sprosp['license'] = 'free'
> except KeyError:
>     sprosp['license'] = 'free'

Instead of a try/except block for this, I would suggest to use the 'in'
check like this:

  if 'license' not in sprosp or sprosp['license'] == '':
      sprosp['license'] = 'free'

I find it easier to understand and it avoid the exception overhead.

-- 
Happy hacking
Petter Reinholdtsen


Reply to: