Re: [Python-Dev] mkdir -p in python

2010-07-19 Thread Ray Allen
Agree. Through searching for existing issues, I found there isn't any such
request. And I will submit one.

The '-p' option of shell's mkdir has tow functions:
1, create parents directories if not exists,
2, suppress "File exists" error if the target has already exists.
What we need is the second function. So I think both os.mkdir() and
os.makedirs() should add a keyword argument to suppress the "OSError: [Errno
17] File exists". So we can remove many "try...except..." codes surround
os.mkdir() and os.makedirs() as Greg said, "The operation of 'make sure this
directory and all its parents exist' is very commonly required"

-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] mkdir -p in python

2010-07-19 Thread Ray Allen
See http://bugs.python.org/issue9299

On Mon, Jul 19, 2010 at 1:16 PM, Ray Allen  wrote:

>
> Agree. Through searching for existing issues, I found there isn't any such
> request. And I will submit one.
>
> The '-p' option of shell's mkdir has tow functions:
> 1, create parents directories if not exists,
> 2, suppress "File exists" error if the target has already exists.
> What we need is the second function. So I think both os.mkdir() and
> os.makedirs() should add a keyword argument to suppress the "OSError: [Errno
> 17] File exists". So we can remove many "try...except..." codes surround
> os.mkdir() and os.makedirs() as Greg said, "The operation of 'make sure
> this directory and all its parents exist' is very commonly required"
>
> --
> Ray Allen
> Best wishes!
>



-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] mkdir -p in python

2010-07-20 Thread Ray Allen
>
> I don't see what would be so bad about adding a new

function for this. Think of it as correcting the mistake

of not making makedirs() behave this way from the

beginning.


If you want to add a new function,  then what its name should be? I guess it
should be too similar as existing ones. It's confusing for using because
they have similar names and do the same major things except exception. For
users it's easier to remember one function than tow. If we want to correct a
mistake, it's better not to import another mistake.


I don't like writing code that depends on particular

errno values, because I don't trust it to work cross-

platform.

I think in this case, the errno is generate by c standard library, which can
be seen as cross-platform.





>
>
> --
> Greg
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/ysj.ray%2Bpython-dev%40gmail.com
>



-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] mkdir -p in python

2010-07-28 Thread Ray Allen
I believe, in design purpose, the os.mkdir() is to match the system call
"mkdir()" exactly, the os.makedirs() is a "Super-mkdir", it provides
extra convenience for using when we want to create directories. This is the
case makedirs() should deal with. A new function maybe confused with
makedirs().

I think os.makedirs() should go to shutil, but we have missed the right
time.


On Wed, Jul 28, 2010 at 3:29 PM, Hrvoje Niksic wrote:

> On 07/27/2010 06:18 PM, Alexander Belopolsky wrote:
>
>> On Tue, Jul 20, 2010 at 10:20 AM, R. David Murray
>>  wrote:
>>
>>>  I'd go with putting it in shutil.
>>>
>>
>> +1
>>
>> I would also call it shutil.mktree which will go well with
>> shutil.rmtree next to it.
>>
>
> Note that mktree is not analogous to rmtree - while rmtree removes a
> directory tree beneath a specified directory, mktree would only create a
> single "branch", not an entire tree.  I'd imagine a mktree function to
> accept a data structure describing the tree to be created.
>
> If you're going for a short name distinctive from mkdir, I propose
> mksubdirs.
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/ysj.ray%2Bpython-dev%40gmail.com
>



-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Tracker status

2010-08-02 Thread Ray Allen
Down for me as well. Initially I though it was shield by "Great Firewall" since
I'm from China.

On Tue, Aug 3, 2010 at 9:29 AM, David Stanek  wrote:

> On Mon, Aug 2, 2010 at 6:17 PM, Nick Coghlan  wrote:
> > Are the bug tracker and meta-tracker down for anyone else, or is it just
> me?
> >
>
> It is down for me as well. It appears to be accepting the connection
> and then just doesn't return any content.
>
> --
> David
> blog: http://www.traceback.org
> twitter: http://twitter.com/dstanek
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/ysj.ray%2Bpython-dev%40gmail.com
>



-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Tracker status

2010-08-03 Thread Ray Allen
Is the tracker OK now?

-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Proposed tweaks to functools.wraps

2010-08-11 Thread Ray Allen
I think this is a good idea, because sometimes getting the innermost wrapped
function from a wrapper function is very useful. For example, when I use
inspect.getsource(), in most case, I want to get the source code of the
wrapped function, not the wrapper, because the wrapped function usually
contains the most important code. Even further, we can add optional keyword
argument to let the functions in inspect module to get the wrapped function
instead of the wrapper function by following the __wrapped__ chain
automatically.


-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 395: Module Aliasing

2011-03-18 Thread Ray Allen
Just now I was trapped by the "Importing the main module twice" problem
for a while, and then I searched on web and go into here. It seems pretty
good to fix this problem, since it is really difficult to find out this
problem. Anyway, a module should not be initialized twice which results in
that each of the objects defined in this module has TWO instances
in separate modules. Accidentally people will mix up them together.

-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Issue 9523: Ask for a review on C code

2011-03-23 Thread Ray Allen
Hi all,
Currently I worked out a patch for http://bugs.python.org/issue9523,
which adds full support of Collections.MutableMapping interface to ndbm and
gdbm objects, as well as . And thanks for eric doing reviews mainly on
python code and doc! Could someone do a review on the C code? Thanks very
much for help! :)

-- 
Ray Allen
Best wishes!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com