r+

On Sat, Apr 26, 2008 at 4:53 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
> After much ado, here is the resulting patch.
>
>  - Eben
>
>
>
>
>  On Fri, Apr 25, 2008 at 2:17 PM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
>  >
>  > On Wed, Apr 23, 2008 at 10:05 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
>  >  >
>  >  > On Wed, Apr 23, 2008 at 3:52 PM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
>  >  >  > On Wed, Apr 23, 2008 at 9:45 PM, Eben Eliason <[EMAIL PROTECTED]> 
> 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
>  >
>
_______________________________________________
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar

Reply via email to