[Python-Dev] mkdir -p in python
Ron Adam
rrr at ronadam.com
Tue Jul 20 18:58:52 CEST 2010
On 07/20/2010 11:47 AM, Ron Adam wrote:
>
>
> On 07/20/2010 10:43 AM, Fred Drake wrote:
>> On Tue, Jul 20, 2010 at 9:09 AM, Steven D'Aprano<steve at pearwood.info>
>> wrote:
>>> It refers to the guideline that you shouldn't have a single function
>>> with two (or more) different behaviour and an argument that does
>>> nothing but select between them.
>>
>> In particular, when that argument is almost never given a variable
>> value, but is specified using a constant at the call site.
>
> I was thinking it should have been two functions, but I realized there
> is more subtleties involved than simply just reusing a directory that
> already exists.
>
>
> One possibility might be...
>
> mkdir(path [, allow=None, mode=0777])
>
> Where None can be replaced with one or more of the following.
>
> 'exists' dir can already exist (with same permissions as mode)
> 'case' dir case can be different. (Windows)
> 'files' dir can have files in it.
Add
'path', Complete path as -p option does.
> ... or a string containing the initials.
>
>
> It doesn't fall under the single constant rule if done this way.
>
>
> Ron
More information about the Python-Dev
mailing list