Do whichever makes you happy I'd say
The only real difference is coding style and the formatting options of
the %s way that I can see.
%s is negligibly slower in my tests, but we're talking the tiniest
fraction of a second over thousands of iterations, not worth considering...
-h
Hari Sekhon
Matthew Warren wrote:
> Ok, not really python focused, but it feels like the people here could
> explain it for me :)
>> Now, I started programming when I was 8 with BBC Basic.
>> I never took any formal classes however, and I have never become an
> expert programmer. I'm an average/hobbyist programmer with quite a few
> languages under my belt but I cant do any really fancy tricks with any
> of them. (although Python might be nudging me into more advanced things,
> now I'm starting to get what all the __method__ thingies and operators
> are all about)
>> I learned over the years to do things like the following, and I like
> doing it like this because of readability, something Python seems to
> focus on :-
>> Print "There are "+number+" ways to skin a "+furryanimal
>> But nowadays, I see things like this all over the place;
>> print("There are %s ways to skin a %s" % (number, furryanimal))
>> Now I understand there can be additional formatting benefits when
> dealing with numbers, decimal places etc.. But to me, for strings, the
> second case is much harder to read than the first.
>> I hope I'm not being dense.
>> The result is that I have pathalogically avoided print "%s" % (thing)
> because it seems to just over complicate things.
>>> Ta, :)
>> Matt.
>>>>>> This email is confidential and may be privileged. If you are not the intended recipient please notify the sender immediately and delete the email from your computer.
>> You should not copy the email, use it for any purpose or disclose its contents to any other person.
> Please note that any views or opinions presented in this email may be personal to the author and do not necessarily represent the views or opinions of Digica.
> It is the responsibility of the recipient to check this email for the presence of viruses. Digica accepts no liability for any damage caused by any virus transmitted by this email.
>> UK: Phoenix House, Colliers Way, Nottingham, NG8 6AT UK
> Reception Tel: + 44 (0) 115 977 1177
> Support Centre: 0845 607 7070
> Fax: + 44 (0) 115 977 7000
>http://www.digica.com>> SOUTH AFRICA: Building 3, Parc du Cap, Mispel Road, Bellville, 7535, South Africa
> Tel: + 27 (0) 21 957 4900
> Fax: + 27 (0) 21 948 3135
>http://www.digica.com>