[Python-ideas] str.rreplace

Serhiy Storchaka storchaka at gmail.com
Tue Jan 28 14:07:15 CET 2014


28.01.14 14:33, Steven D'Aprano написав(ла):
> As a general rule, when you have a function that takes a parameter which
> selects between two different sets of behaviour, and you normally
> specify that parameter as a literal or constant known at edit time, then
> the function should be split into two.
>
> E.g.:
>
> # Good API
> string.upper(), string.lower()
>
> # Bad API
> string.convert_case(to_upper=True|False)

# Good API
binascii.hexlify(data), zlib.compress(data)

# Bad API
codecs.encode(data, encoding='hex_codec'|'zlib_codec')




More information about the Python-ideas mailing list