Matthew Warren wrote:
> 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 agree that the second alternative isn't too readable. It is also not 
too maintainable. My version of the above is most often

    print "There are %(number)s ways to skin a %(furryanimal)s." % vars()

Readable and maintainable.

/MiO
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to