[Python-Dev] Re: tarfile module (update)
Gustavo Niemeyer
niemeyer@conectiva.com
Wed, 27 Nov 2002 10:17:12 -0200
> using factory functions to create objects representing external
> entities is an extremely common pattern.
>
> in the Pythobn library, this pattern is used in aifc, anydbm, audiodev,
> dbhash, dumbdbm (and all other dbm modules), fileinput, gettext,
> gopherlib, gzip, imghdr, optparse, popen2, shelve, sndhdr, socket,
> sunau, sunaudio, tempfile, tokenize, just to name a few.
Perhaps I haven't explained it right. I was trying to tell that using a
default constructor would be more obvious than having a methodclass
"constructor" TarFile.open() which will be used 99.9% of the time.
I don't see this pattern in any of the modules you mention above.
> to figure out *why* it's a good idea to use a factory function, think
> as a user. or as a library maintainer.
That helped a lot. Thank you.
--
Gustavo Niemeyer
[ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]