[Python-Dev] webbrowser no longer support 'internet-config' on Mac

2012-04-18 Thread Leo
The doc says supported as in
http://docs.python.org/library/webbrowser.html

but the code has been deleted in
http://hg.python.org/cpython/rev/66b3eda6283f

Leo

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] [BUG] Trailing spaces in pretty-printed JSON

2012-10-13 Thread Leo
Use this script on a json file and observe all the trailing spaces
generated. (screenshot attached.)

#!/usr/bin/env python

"""
Pretty print json file.
"""

if __name__ == '__main__':
import sys
import json

if '-h' in sys.argv or '--help' in sys.argv:
print "Usage: ppjson "
exit(0)

assert sys.argv[1], "No file provided"
with open(sys.argv[1]) as f:
print json.dumps(json.load(f), indent=4)


<>___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [BUG] Trailing spaces in pretty-printed JSON

2012-11-15 Thread Leo
On 2012-10-14 02:06 +0800, Xavier Morel wrote:
> 1. Why didn't you report that on the tracker?

Reported: http://bugs.python.org/issue16476

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] operator.attrgetter(attr[, args...]) etc.

2012-11-20 Thread Leo
Sorry the python issue tracker seems broken (I cannot log in). So I am
posting it here.

In the doc:

  operator.attrgetter(attr[, args...])
  operator.itemgetter(item[, args...])
  operator.methodcaller(name[, args...])

The signatures of these functions seem confusing. ARGS is not documented
and does not match the python implementation in the doc.

Leo

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] doc error in 2.6.2

2009-05-15 Thread Leo Jay
There is a syntax error in the client side code of
"SocketServer.UDPServer Example" in
http://docs.python.org/library/socketserver.html:
import socket
import sys

HOST, PORT = "localhost"
data = " ".join(sys.argv[1:])

Obviously, it should be:
HOST, PORT = "localhost", 

--
Leo Jay
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [ANN] Python 2.5.6 Release Candidate 1

2011-04-17 Thread Leo Jay
Hi,

I think the release date of 2.5.6c1 should be 17-Apr-2011, instead of
17-Apr-2010
http://www.python.org/download/releases/2.5.6/NEWS.txt

On Mon, Apr 18, 2011 at 5:57 AM, "Martin v. Löwis"  wrote:
>
> On behalf of the Python development team and the Python community, I'm
> happy to announce the release candidate 1 of Python 2.5.6.
>
> This is a source-only release that only includes security fixes. The
> last full bug-fix release of Python 2.5 was Python 2.5.4. Users are
> encouraged to upgrade to the latest release of Python 2.7 (which is
> 2.7.1 at this point).
>
> This releases fixes issues with the urllib, urllib2, SimpleHTTPServer,
> and audiop modules. See the release notes at the website (also
> available as Misc/NEWS in the source distribution) for details of bugs
> fixed.
>
> For more information on Python 2.5.6, including download links for
> various platforms, release notes, and known issues, please see:
>
>    http://www.python.org/2.5.6
>
> Highlights of the previous major Python releases are available from
> the Python 2.5 page, at
>
>    http://www.python.org/2.5/highlights.html
>
> Enjoy this release,
> Martin
>
> Martin v. Loewis
> mar...@v.loewis.de
> Python Release Manager
> (on behalf of the entire python-dev team)


--
Best Regards,
Leo Jay
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Cannot use multiprocessing and zip together on windows

2011-12-21 Thread Leo Jay
Hi All,

I posted this several days ago in python mailing list but got no response
and I think it might be a bug, so I post it here. Apologize if it's
not appropriate.

I have a file p.zip, there is a __main__.py in it, and the content of
__main__.py is:

from multiprocessing import Process
import os

def f():
  print 'in f, pid:', os.getpid()

if __name__ == '__main__':
  print 'pid:', os.getpid()
  p = Process(target=f)
  p.start()
  p.join()


On linux, I can get expected result for running "python p.zip"
But on windows xp, I got:

Traceback (most recent call last):
 File "", line 1, in 
 File "C:\python27\lib\multiprocessing\forking.py", line 346, in main
  prepare(preparation_data)
 File "C:\python27\lib\multiprocessing\forking.py", line 454, in prepare
  assert main_name not in sys.modules, main_name
AssertionError: __main__

It seems that the situation described here is similar:
http://bugs.python.org/issue10128

But the patch doesn't work for me.

Anybody knows how to fix this?
Thanks.

--
Best Regards,
Leo Jay
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] On __cmp__ specifications and implementation (to mimic it on Jython)

2008-08-05 Thread Leo Soto M.
Hi Python developers!

First, a quick introduction: My name is Leonardo Soto, I'm a  GSoC
2008 student working under PSF and the Jython project, and a Jython
commiter since one month ago.

As part of what I did on this GSoC, I've improved Jython's __cmp__ a
bit. That made me go to look at CPython sources (v2.5.2) to read the
implementation of cmp(a,b).

Aside from what I've already fixed on Jython, I've found four
differences between Jython and CPython cmp(a, b):

(1). CPython's cmp() uses a.__cmp__(b) before rich-cmp methods if the
types of the two arguments are the same.

(2). When using rich-cmp methods, CPython first check if the second
type is a subtype of the first, and starts trying with the second
method instead of the first. [i.e, the process starts by b.__gt__(a)
instead of a.__lt__(b) if type(b) != type(a) and issubclass(b, a)]

(3). Similar to above, if the second argument to cmp(a, b) is a
old-style instance, and the first isn't, b.__cmp__(a) is used instead
of a.__cmp__(b).

(4). CPython tries coercion as part of the three way comparison. But
doesn't do it exactly as advertised on
<http://docs.python.org/ref/coercion-rules.html>: it does coercion
*after* trying a.__cmp__(b), while the docs says *before*. And it only
uses the coerced values if both values have the same tp_compare
function. I fail to see why, and this is not mentioned on the docs
either.

[The examples that show this behaviors are at the end of this mail.]

Now, my questions:

- Are (1), (2) and (3) intentional features?  Frankly, Jython being
different on (1) and (3) isn't a big deal, but I'd like to match
CPython as much as possible (and reasonable). Point (2) is a more
interesting, because it seems to follow what
<http://docs.python.org/ref/coercion-rules.html> says for binary ops:

"Exception to the previous item: if the left operand is an instance of
a built-in type or a new-style class, and the right operand is an
instance of a proper subclass of that type or class and overrides the
base's __rop__() method, the right operand's __rop__() method is tried
before the left operand's __op__() method."

But I haven't found any documentation telling that it applies to
rich-cmp methods too. Interestingly, it *doesn't* apply to __cmp__ on
CPython 2.5.2.

BTW, PyPy also fails to follow CPython on points (2) and (3), so it is
not just me failing to found the appropriate docs ;-)

- What's the idea behind the current implemention of __cmp__ and
coercion, as described on (4)? I've to implement this feauture on
Jython, but checking that two Java instances have the same __cmp__
method is not that easy as in C. And more important: it could be
wrong, depending on what is the idea behind the current CPython
implementation.

Finally, here are the examples of the behaviors outlined at the start
of this mail.

(1):

>>> class A(object):
...   def __eq__(self, other): return True
...   def __cmp__(self, other): return 1
...
>>> cmp(A(), A())
1

(2):

>>> class A(object):
...  def __lt__(self, other): return True
...  def __gt__(self, other): return False
...  def __eq__(self, other): return False
...
>>> class B(A): pass
...
>>> cmp(A(), B())
1

(3):

>>> class A(object):
...def __cmp__(self, other): return 1
...
>>> class B:
...def __cmp__(self, other): return 1
...
>>> cmp(A(), B())
-1

(4):

>>> class A(object):
... def __coerce__(self, other): return 0, 0
... def __cmp__(self, other): return -1
...
>>> cmp(A(), A())
-1

Regards,
-- 
Leo Soto M.
http://blog.leosoto.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] On __cmp__ specifications and implementation (to mimic it on Jython)

2008-08-05 Thread Leo Soto M.
On Tue, Aug 5, 2008 at 4:45 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> Given that in Python 3.0 __cmp__ is going away, I'm not sure how much
> it all matters -- but if you care, as long as it's supported at all,
> you might as well strive for the most compatibility with 2.5...

Sure, it won't be a problem on Jython 3.0. But I'm doing this for the
upcoming Jython 2.5, where we still have to live with __cmp__

-- 
Leo Soto M.
http://blog.leosoto.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] On __cmp__ specifications and implementation (to mimic it on Jython)

2008-08-05 Thread Leo Soto M.
On Tue, Aug 5, 2008 at 4:59 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On Tue, Aug 5, 2008 at 1:56 PM, Leo Soto M. <[EMAIL PROTECTED]> wrote:
>> On Tue, Aug 5, 2008 at 4:45 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>>> Given that in Python 3.0 __cmp__ is going away, I'm not sure how much
>>> it all matters -- but if you care, as long as it's supported at all,
>>> you might as well strive for the most compatibility with 2.5...
>>
>> Sure, it won't be a problem on Jython 3.0. But I'm doing this for the
>> upcoming Jython 2.5, where we still have to live with __cmp__
>
> Which is why I recommend the closest possible compatibility. :-)

Oh, right :)

But that's going to be easier if I understand the "why" and not only
the "how". I can live with a "no idea why" answer, though.

-- 
Leo Soto M.
http://blog.leosoto.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] On __cmp__ specifications and implementation (to mimic it on Jython)

2008-08-06 Thread Leo Soto M.
On Tue, Aug 5, 2008 at 10:46 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On Tue, Aug 5, 2008 at 5:56 PM, Leo Soto M. <[EMAIL PROTECTED]> wrote:
> > But that's going to be easier if I understand the "why" and not only
> > the "how". I can live with a "no idea why" answer, though.
>
> Close -- I would have to do a lot of thinking, swapping in parts of my
> memory that have been gone for years. I say, follow CPython blindly
> and you can't go too wrong: even if the rules are arbitrary, they are
> what everyone expects.

Fair enough. It is going to be tricky with coercion (AFAIK, there is
no easy way to ask two java objects if they share the same method
implementation without resorting to reflection), but I'll do my best.

Thanks!
-- 
Leo Soto M.
http://blog.leosoto.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Python Virtual Machine Architecture

2008-08-08 Thread Leo Soto M.
On Fri, Aug 8, 2008 at 4:17 PM, Jon Stritar <[EMAIL PROTECTED]> wrote:
> I'm trying to understand the architecture of the core Python interpreter and
> virtual machine, but I've been having trouble finding the documentation. It
> looks like most of the docs are for either writing Python programs or
> extending / writing modules. Is there any documentation (or papers) geared
> towards understanding the core?

Maybe <http://wiki.python.org/moin/CPythonVmInternals>?
-- 
Leo Soto M.
http://blog.leosoto.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com