python idioms : some are confusing

alex23 wuwei23 at gmail.com
Fri Sep 21 01:52:45 EDT 2012


On Sep 21, 3:34 pm, Vineet <vineet.deod... at gmail.com> wrote:
> Amongst the python idioms, how the below-mentioned make sense?
> ## There should be one-- and preferably only one --obvious way to do it.
> --- In programming, there can be a number of ways, equally efficient, to do certain  thing.

This isn't talking about your Python code as much as about Python
itself. For example, in Python 2.x you can use either `open` or `file`
to open a file, with `file` being a factory function for creating file
objects, and `open` using it internally. In Python 3.x, `file` is no
longer a built-in, as it produced a point of confusion as to which was
the one obvious way to open a file.

> ## Although never is often better than *right* now.
> --- How come "never" is better that "right now" ?

It's better to not add a language feature than it is to add it poorly,
especially when you endeavour to provide backwards compatibility as
much as possible within major versions.



More information about the Python-list mailing list