SV: Regarding coding style
Grant Edwards
grante at visi.com
Sun Mar 9 00:31:22 EST 2008
On 2008-03-09, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> On Sat, 08 Mar 2008 21:21:48 +0100, K Viltersten wrote:
>
>> Coming from C++/Java camp i can't help noticing that in most cases, when
>> i'm using a class written by somebody else, i don't want to see his/her
>> code. I only want to know WHAT the function does (is intended to be
>> doing, at least).
>>
>> I don't want to look at the source code (in some cases i can't even see
>> the code because it's compiled). I only care that when i execute
>>
>> SomeType obj = SomeType();
>> obj.aggregate();
>>
>> the object gets aggregated. How it's done will be up to the author. I'm
>> just a user of the product.
>>
>> Now, i'm getting the signal that it's done in a different way in Python.
>> Please elaborate. I'm very new to snakeology.
>
>
> I think even Grant would agree that when you call "help(make_widget)",
> you should see something like:
>
> make_widget(styleID, material) -> widget or
> raise ValueError on failure
>
> styleID: numeric ID or string name of the widget style
> material: WidgetMaterial instance or None to use default
I think docstrings are a great idea. What's needed is a way to
document the signature that can't get out-of-sync with what the
fucntion really expects.
--
Grant Edwards grante Yow! I'm wearing PAMPERS!!
at
visi.com
More information about the Python-list
mailing list