[sugar] [PATCH] Fix appearance of activity bundles (in Journal)

Tomeu Vizoso tomeu
Wed Apr 23 15:52:43 EDT 2008


On Wed, Apr 23, 2008 at 9:45 PM, Eben Eliason <eben.eliason at gmail.com> wrote:
> 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.)

Sorry, didn't meant that as a literal solution.

>  I supposed there's also:
>
>  title_text = _('Untitled')
>
> if jobject.metadata.get('title', ''):
>     title_text = jobject.metadata.get('title', '')
>
>  title.props.text = title_text

This I don't like much, the person that reads needs to make more
effort to see that you are overriding the var.

This is what I would do:

if jobject.metadata.get('title', ''):
   title.props.text = jobject.metadata['title']
else
   title.props.text = _('Untitled')

Tomeu



More information about the Sugar-devel mailing list