Suggested coding style

Devin Jeanpierre jeanpierreda at gmail.com
Mon Sep 26 02:23:47 CEST 2011


>  Why does it suck?

The gist of what I was saying is that it's possible to define
functions that do this "generically" so that one implementation of
zfill can work with multiple implementations of strings. Having to
reimplement every time when one implementation would do is bothersome
and generally isn't done unless it has to be (thus why mmap lacks a
zfill method). Having to do more work than necessary "sucks", as does
having partial str implementations that don't do everything str does.

Ideally, I would claim that if some interface will have multiple
implementations, it should have as few methods as possible to make
implementation as easy as possible, and move as much as possible
_away_ from methods and into functions that work with arbitrary
implementations of the interface. This minimizes the amount of work
that must be done for implementors and thus makes life better.

It's also true that it's "bad practice" to have objects with large
APIs, not for convenience reasons but because it increases object
coupling, something that "good" object oriented design seeks to
eliminate. The idea there is that the less ways you can have your
object interacted with / interact with other objects, the easier it is
to think of the way state flows. I agree with this in principle, but
it doesn't really matter for strings.

The situation I see with something like zfill as-a-method is that it
has nearly negligible benefit (less imports vs function?) and some
detriment. So I would conclude it should not exist. Other people look
at this differently.

> Also, because technical people are opinionated windbags.

Pardon?

Devin

On Sun, Sep 25, 2011 at 5:48 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Sep 26, 2011 at 4:54 AM, Petite Abeille
> <petite.abeille at gmail.com> wrote:
>>
>> On Sep 25, 2011, at 8:46 PM, Tim Johnson wrote:
>>
>>>  Why does it suck? And why do people say 'suck' so much, especially in technical venues? :)
>>
>> It's a technical term:
>>
>> http://www.osnews.com/images/comics/wtfm.jpg
>
> Also, because technical people are opinionated windbags. Goes with the
> territory. :) Actually, it's partly because it's so easy to create
> standards. You don't like X? Create your own language in which it
> doesn't exist! You absolutely detest Y? Ignore it and use something
> else! But since we can't ignore _everything_ we dislike, there ends up
> a happy medium in which we all use the things that we dislike least,
> all the while ranting about those aspects of them that "absolutely,
> totally suck", and vowing that we could have done way better if we'd
> been in the position of Some Famous Guy back when he had that perfect
> opportunity to create a new and perfect standard, but he *blew it* by
> having a small and narrow view, etc, etc, etc...
>
> Of course, some of us manage to still be courteous and objective when
> discussing the things that suck, while others just go off on lengthy
> rants. And if you're willing to learn, it's not uncommon to start off
> complaining and end up appreciating. :)
>
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list