Hmm, you mean:

if jobject.metadata.get('title', ''):
    title_text = jobject.metadata.get('title', '')
else
    title_text = _('Untitled')

title.props.text = title_text
...

Do I not need to declare title_text outside the scope of the condition
first?  For that matter, is the null string always treated as False in
conditions, even though it's distinct from None type?  (Sorry...didn't
play in Python much before.)

I supposed there's also:

title_text = _('Untitled')
if jobject.metadata.get('title', ''):
    title_text = jobject.metadata.get('title', '')

title.props.text = title_text

- Eben


On Wed, Apr 23, 2008 at 3:32 PM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 23, 2008 at 9:26 PM, Bert Freudenberg <[EMAIL PROTECTED]> wrote:
>  >
>  >  On 23.04.2008, at 21:23, Eben Eliason wrote:
>  >
>  >  > if jobject.metadata.has_key['title'] and
>  >  > jobject.metadata.has_key['title']:
>  >
>  >
>  >  Seems a bit redundant.
>
>  ;)
>
>  I would go for
>
>  if jobject.metadata.get('title', ''):
>   _title = title
>  else:
>   _title = _('Untitled')
>
>  (more or less)
>
>  Tomeu
>
>
> _______________________________________________
>  Sugar mailing list
>  [email protected]
>  http://lists.laptop.org/listinfo/sugar
>
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to