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

Eben Eliason eben.eliason at gmail.com
Wed Apr 23 16:05:25 EDT 2008


On Wed, Apr 23, 2008 at 3:52 PM, Tomeu Vizoso <tomeu at tomeuvizoso.net> wrote:
> 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')

I'm not sure I like that much either, since I have to set two things
to the values.

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

Hence, the reason to use a variable instead. Do you prefer this?

- Eben


More information about the Sugar mailing list