Mailing List Archive

1 2  View All
Re: Status regarding Old vs. Advanced String Formating [ In reply to ]
On Sat, Feb 25, 2012 at 12:20, "Martin v. Löwis" <martin@v.loewis.de> wrote:

> > I find that strange, especially for an expert Python dev. I, a newbie,
> > find it far friendlier (and easier for a new programmer to grasp).
> > Maybe it's because I use it all the time, and you don't?
>
> That is most likely the case. You learn by practice. For that very
> reason, the claim "and easier for a new programmer to grasp" is
> difficult to prove. It was easier for *you*, since you started using
> it, and then kept using it. I don't recall any particular obstacles
> learning % formatting (even though I did for C, not for C++).
> Generalizing that it is *easier* is invalid: you just didn't try
> learning that instead first, and now you can't go back in a state
> where either are new to you.
>
> C++ is very similar here: they also introduced a new way of output
> (iostreams, and << overloading). I used that for a couple of years,
> primarily because people said that printf is "bad" and "not object-
> oriented". I then recognized that there is nothing wrong with printf
> per so, and would avoid std::cout in C++ these days, in favor of
> std::printf (yes, I know that it does have an issue with type safety).
>

Not to mention that the performance of iostreams is pretty bad, to the
extent that some projects actively discourage using them in favor of either
C-style IO (fgets, printf, etc.) or custom IO implementations. This is
marginally off-topic, although it does show that an initial thought of
deprecating an existing functionality for new one doesn't always work out
in the long run, even for super-popular languages like C++.

Eli
Re: Status regarding Old vs. Advanced String Formating [ In reply to ]
> Indeed, that note was written before we decided that getting rid of
> "%" formatting altogether would be a bad idea.
>
> It would be better to update it to say something like:
>
> "The formatting operations described here are modelled on C's printf()
> syntax. They only support formatting of certain builtin types, and the
> use of a binary operator means that care may be needed in order to
> format tuples and dictionaries correctly. As the new string formatting
> syntax is more powerful, flexible, extensible and handles tuples and
> dictionaries naturally, it is recommended for new code. However, there
> are no current plans to deprecate printf-style formatting."
>

+1 on rephrasing that doc section, but I wouldn't mention deprecation at
all. It's alright to keep calling % formatting "old style" and encouraging
.format instead, of course.

Eli
Re: Status regarding Old vs. Advanced String Formating [ In reply to ]
Big +1
On Feb 26, 2012 4:41 PM, "Eli Bendersky" <eliben@gmail.com> wrote:

>
> On Sat, Feb 25, 2012 at 12:20, "Martin v. Löwis" <martin@v.loewis.de>wrote:
>
>> > I find that strange, especially for an expert Python dev. I, a newbie,
>> > find it far friendlier (and easier for a new programmer to grasp).
>> > Maybe it's because I use it all the time, and you don't?
>>
>> That is most likely the case. You learn by practice. For that very
>> reason, the claim "and easier for a new programmer to grasp" is
>> difficult to prove. It was easier for *you*, since you started using
>> it, and then kept using it. I don't recall any particular obstacles
>> learning % formatting (even though I did for C, not for C++).
>> Generalizing that it is *easier* is invalid: you just didn't try
>> learning that instead first, and now you can't go back in a state
>> where either are new to you.
>>
>> C++ is very similar here: they also introduced a new way of output
>> (iostreams, and << overloading). I used that for a couple of years,
>> primarily because people said that printf is "bad" and "not object-
>> oriented". I then recognized that there is nothing wrong with printf
>> per so, and would avoid std::cout in C++ these days, in favor of
>> std::printf (yes, I know that it does have an issue with type safety).
>>
>
> Not to mention that the performance of iostreams is pretty bad, to the
> extent that some projects actively discourage using them in favor of either
> C-style IO (fgets, printf, etc.) or custom IO implementations. This is
> marginally off-topic, although it does show that an initial thought of
> deprecating an existing functionality for new one doesn't always work out
> in the long run, even for super-popular languages like C++.
>
> Eli
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/anacrolix%40gmail.com
>
>
Re: Status regarding Old vs. Advanced String Formating [ In reply to ]
On 24 February 2012 22:20, <martin@v.loewis.de> wrote:

> I find the .format syntax too complicated and difficult to learn. It has
> so many bells and whistles, making it more than just a *mini* language.
> So for my own code, I always prefer % formatting for simplicity.
>
> +1



> Regards,
> Martin
>

1 2  View All