[Python-3000] Please don't kill the % operator...

Christian Heimes lists at cheimes.de
Thu Aug 16 22:15:05 CEST 2007


Brett Cannon wrote:
> [Tonight, the role of old, cranky python-dev'er will be played by
> Brett Cannon.  Don't take this personally, Christian, your email just
> happened to be last.  =)]

hehe :)
I don't feel offended.

> But how is::
> 
>   "{0} is happy to see {1}".format('Brett', 'Christian')
> 
> that less easier to read than::
> 
>   "%s is happy to see %s" % ('Brett', 'Christian')
> 
> ?  Yes, PEP 3101 style is more to type but it isn't grievous; we have
> just been spoiled by the overloading of the % operator.  And I don't
> know how newbies think these days, but I know I find the numeric
> markers much easier to follow then the '%s', especially if the string
> ends up becoming long.
> 
> And if it is the use of a method instead of an operator that the
> newbies might have issues with, well methods and functions come up
> quick so they probably won't go long without knowing what is going on.

My concerns are partly based on my laziness and my antipathy against '{'
and '}'. On my German keyboard I have to move my whole hand to another
position to enter a { or }. It's right ALT (Alt Gr) + 7 and 0. The %
character is much easier to type for me. :]

> This is where the cranky python-dev'er comes in: PEP 3101 was
> published in April 2006 which is over a year ago!  This is not a new
> PEP or a new plan.  I personally stayed out of the discussions on this
> subject as I knew reasonable people were keeping an eye on it and I
> didn't feel I had anything to contribute.  That means I just go with
> what they decide whether I like it or not.

I've read the PEP about an year ago. I was always under the impression
that the PEP was going to *add* an alternative and more powerful format
to Python. I didn't noticed that the PEP was about a *replacement* for
the % format operator. My fault ;)

> I understand the feeling of catching up on a thread and going, "oh no,
> I don't like that!", but that is the nature of the beast.  In my view,
> if you just don't have the time or energy (which I completely
> understand not having, don't get me wrong) for a thread, you basically
> have to defer to the people who do and trust that the proper things
> were discussed and that the group as a whole (or Guido in those cases
> where his gut tells him to ignore everyone) is going to make a sound
> decision.
> 
> At this point the discussion has gone long enough with Guido
> participating and agreeing with key decisions, that the only way to
> get this course of action changed is to come up with really good
> examples of how the % format is hugely better than PEP 3101 and
> convince the people involved.  But just saying you like %s over {0} is
> like saying you don't like the decorator syntax: that's nice and all,
> but that is not a compelling reason to change the decision being made.

You are right. I'm guilty as charged to be a participant  of a red bike
shed discussion. :) I'm seeing myself as a small Python user and
developer who is trying to get in touch with the gods in the temple of
python core development (exaggerated *G*). I've been using Python for
about 5 years and I'm trying to give something back to the community. In
the past months I've submitted patches for small bugs (low hanging
fruits) and I've raised my voice to show my personal - sometimes
inadequate - opinion.

By the way it's great that the core developers are taking their time to
discuss this matter with a newbie. Although it is sometimes
disappointing to see that my ideas don't make it into the core I don't
feel denied. It gives me the feeling that my work is appreciated but not
(yet) good enough to meet the quality standards.

I'll stick around and see how I can be of service in the future.

Christian



More information about the Python-3000 mailing list