foobar2(), foobar3(), ... (was Re: [Python-Dev] gethostbyname2)
Peter Funk
pf@artcom-gmbh.de
Sun, 24 Jun 2001 11:20:10 +0200 (MEST)
Martin v. Loewis:
> The IPv6 patch proposes to introduce a new socket function,
> socket.gethostbyname2(name, af). This becomes necessary as a name
> might have both an IPv4 and an IPv6 address.
>
> One alternative for providing such API is to get socket.gethostbyname
> an optional second argument (the address family). itojun's rationale
> for calling it gethostbyname2 is that the C API, as defined in RFC
> 2133.
>
> Which of these alternatives would you prefer?
IMO: The possibility to add new keyword arguments with default values
is one of the major strengths Python has compared to other programming
languages.
Especially in the scenario, where an existing mature API has to be
enhanced later with added features:
In such a situation I always prefer APIs with fewer functions
(may be with large lists of optional arguments) compared to APIs
containing a bunch of functions or methods called 'popen2()',
'gethostbyname2()' and so on.
Regards, Peter
--
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen, Germany)