object.enable() anti-pattern

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu May 9 09:51:16 EDT 2013


On 9 May 2013 14:07, Roy Smith <roy at panix.com> wrote:
> In article <518b32ef$0$11120$c3e8da3 at news.astraweb.com>,
>  Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>
>> There is no sensible use-case for creating a file without opening it.
>
> Sure there is.  Sometimes just creating the name in the file system is
> all you want to do.  That's why, for example, the unix "touch" command
> exists.

Wouldn't the code that implements the touch command just look
something like this:

f = open(filename)
f.close()

Or is there some other way of creating the file that doesn't open it
(I mean in general not just in Python)?


Oscar



More information about the Python-list mailing list