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

Tomeu Vizoso tomeu
Fri Apr 25 14:17:51 EDT 2008


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

Yes, a 'title' variable is better in this case.

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

Tomeu



More information about the Sugar-devel mailing list