On Wed, 2008-01-30 at 23:01 +0000, Tim Sawyer wrote:
> Thanks everyone, I've been reading my Python In a Nutshell ("covers python
> 2.2!") and it's reminded me of what I've forgotten!
>
> Any suggestions for good books? Was going to get the django book and the
> O'Reilly Python Cookbook.
>
> On Tuesday 29 Jan 2008, Ivan Illarionov wrote:
> > or, better:
> > def name(self):
> > return '%s %s' % (self.forenames, self.surname)
>
> why is this "better"? Performance or just clearer code?
"Better" because, for one thing, it's more robust.
py>>> a = 'Hello'
py>>> b = 'World'
py>>> a + ' ' + b
'Hello World'
py>>> '%s %s' % (a, b)
'Hello World'
py>>> b = 4
py>>> a + ' ' + b
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
a + ' ' + b
TypeError: cannot concatenate 'str' and 'int' objects
py>>> '%s %s' % (a, b)
'Hello 4'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---