Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 3 December 2011 23:51, Peter Otten __pete...@web.de wrote: Arnaud Delobelle wrote: I need to generate some java .properties files in Python (2.6 / 2.7). It's a simple format to store key/value pairs e.g. blue=bleu green=vert red=rouge The key/value are unicode strings.  The annoying

Re: How to generate java .properties files in python

2011-12-04 Thread Peter Otten
Arnaud Delobelle wrote: On 3 December 2011 23:51, Peter Otten __pete...@web.de wrote: Arnaud Delobelle wrote: I need to generate some java .properties files in Python (2.6 / 2.7). It's a simple format to store key/value pairs e.g. blue=bleu green=vert red=rouge The key/value are

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/02/2011 03:29 PM, 8 Dihedral wrote: I clear my point a hash is a collection of (key, value) pairs that have well defined methods and behavior to be used in programming. The basic operations of a hash normally includes the following: 1. insertion of a (key, value) pair into the hash

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/02/2011 04:48 PM, 8 Dihedral wrote: On Friday, December 2, 2011 1:00:10 PM UTC+8, Chris Angelico wrote: On Fri, Dec 2, 2011 at 3:29 PM, 8 Dihedral dihedr...@googlemail.com wrote: I clear my point a hash is a collection of (key, value) pairs that have well defined methods and

Re: order independent hash?

2011-12-04 Thread Roel Schroeven
Op 2011-12-02 6:48, 8 Dihedral schreef: A hash stores (k,v) pairs specified in the run time with auto memory management build in is not a simple hash function to produce data signatures only clearly in my post. What I said a hash which is lifted as a basic type in python is called a

Re: order independent hash?

2011-12-04 Thread Hrvoje Niksic
Terry Reedy tjre...@udel.edu writes: [Hashing is] pretty much mandated because of the __hash__ protocol. Lib Ref 4.8. Mapping Types — dict A mapping object maps hashable values to arbitrary objects. This does not say that the mapping has to *use* the hash value ;-). Even if it does, it

Re: order independent hash?

2011-12-04 Thread Chris Angelico
2011/12/5 Hrvoje Niksic hnik...@xemacs.org: If a Python implementation tried to implement dict as a tree, instances of classes that define only __eq__ and __hash__ would not be correctly inserted in such a dict. Couldn't you just make a tree of hash values? Okay, that's probably not the most

struct calcsize discrepency?

2011-12-04 Thread Glen Rice
In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me. Can anyone explain? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 4 December 2011 10:22, Peter Otten __pete...@web.de wrote: I found another one: uäöü ΦΧΨ.encode(latin1, backslashreplace) '\xe4\xf6\xfc \\u03a6\\u03a7\\u03a8' That's it! I was hoping for a built-in solution and this is it. FTR, the 'backslashreplace' argument tells the encoder to replace

Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:25 AM, Glen Rice glen.rice.n...@gmail.com wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me.  Can anyone explain? Same thing happens in CPython, and it looks to be the result of

Re: struct calcsize discrepency?

2011-12-04 Thread Duncan Booth
Glen Rice glen.rice.n...@gmail.com wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me. Can anyone explain? When you mix different types in a struct there can be padding inserted between the items. In

Re: struct calcsize discrepency?

2011-12-04 Thread Dave Angel
On 12/04/2011 09:35 AM, Chris Angelico wrote: On Mon, Dec 5, 2011 at 1:25 AM, Glen Riceglen.rice.n...@gmail.com wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me. Can anyone explain? Same thing

Re: struct calcsize discrepency?

2011-12-04 Thread Peter Otten
Glen Rice wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me. Can anyone explain? A C compiler can insert padding bytes into a struct: By default, the result of packing a given C struct includes pad

Re: struct calcsize discrepency?

2011-12-04 Thread Glen Rice
On Dec 4, 9:38 am, Duncan Booth duncan.bo...@invalid.invalid wrote: Glen Rice glen.rice.n...@gmail.com wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me.  Can anyone explain? When you mix

Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:51 AM, Dave Angel d...@davea.name wrote: On 12/04/2011 09:35 AM, Chris Angelico wrote: struct.calcsize(4sQ) 16 struct.calcsize(Q4s) 12 The eight-byte integer is aligned on an eight-byte boundary, so when it follows a four-byte string, you get four padding bytes

Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Sunday, December 4, 2011 9:41:19 PM UTC+8, Roel Schroeven wrote: Op 2011-12-02 6:48, 8 Dihedral schreef: A hash stores (k,v) pairs specified in the run time with auto memory management build in is not a simple hash function to produce data signatures only clearly in my post.

SQLObject 1.2.1

2011-12-04 Thread Oleg Broytman
Hello! I'm pleased to announce version 1.2.1, the first stable release of branch 1.2 of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 8:39 AM, 8 Dihedral dihedral88...@googlemail.com wrote: Thanks for your comments. Are we gonna talk about the way to implement a hash table or the use of a hash table in programming? Implementing a hash table is not very relevant on a list about Python, which already

Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
A hash that can hash objects is not a trivial hash function On Monday, December 5, 2011 1:41:14 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 8:39 AM, 8 Dihedral dihedr...@googlemail.com wrote: Thanks for your comments. Are we gonna talk about the way to implement a hash table or the

LinuxJournal Readers' Choice Awards 2011 Best {Programming, Scripting} Language

2011-12-04 Thread wesley chun
in recent news... Python wins LinuxJournal's Readers' Choice Awards 2011 as Best Programming Language: http://www.linuxjournal.com/slideshow/readers-choice-2011?page=27 yee-haw!! it's even more amazing that Python has won this title 3 straight years. let's celebrate and get back to building

Re: order independent hash?

2011-12-04 Thread Tim Chase
On 12/04/11 08:08, Chris Angelico wrote: 2011/12/5 Hrvoje Niksichnik...@xemacs.org: If a Python implementation tried to implement dict as a tree, instances of classes that define only __eq__ and __hash__ would not be correctly inserted in such a dict. Couldn't you just make a tree of hash

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral dihedral88...@googlemail.com wrote: If you want to talk about ways to use dicts, please start a different thread for it.  As has been pointed out several times now, it is off-topic for this thread, which is about hash *functions*. A hash that

Re: Python 2 or 3

2011-12-04 Thread Zaphod
On Sat, 03 Dec 2011 05:54:19 +0200, Antti J Ylikoski wrote: I'm in the process of learning Python. I already can code objet-oriented programs with the language. I have in my hands the O'Reilly book by Mark Lutz, Programming Python, in two versions: the 2nd Edition, which covers Python 2,

Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Monday, December 5, 2011 4:13:01 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral dihedr...@googlemail.com wrote: If you want to talk about ways to use dicts, please start a different thread for it.  As has been pointed out several times now, it is off-topic for this

Re: order independent hash?

2011-12-04 Thread Matt Joiner
Duh. What's the point you're trying to make? On Mon, Dec 5, 2011 at 10:17 AM, 8 Dihedral dihedral88...@googlemail.com wrote: On Monday, December 5, 2011 4:13:01 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral dihedr...@googlemail.com wrote: If you want to talk about

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral dihedral88...@googlemail.com wrote: Please explain what you think a hash function is, then.  Per Wikipedia, A hash function is any algorithm or subroutine that maps large data sets to smaller data sets, called keys. Are you miss-leading the

SSL connection issue with Windows CPython

2011-12-04 Thread Blairo
Hi all, I've written a Python API for the Windows Azure Service Management web- service. Requests against the web-service are HTTPS with a client certificate used for authentication. This works fine with CPython (tested with 2.6 and 2.7) on Linux, but something is amiss with the SSL connection

Re: order independent hash?

2011-12-04 Thread Terry Reedy
On 12/4/2011 6:17 PM, 8 Dihedral wrote: In python the (k,v) pair in a dictionary k and v can be both an objects. v can be a tuple or a list. In Python, everything is an object. *tuple* and *list* are subclasses of *object*. The value v for a dict can be any object, and must be an

Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral dihedr...@googlemail.com wrote: Please explain what you think a hash function is, then.  Per Wikipedia, A hash function is any algorithm or subroutine that maps large data sets to

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/05/2011 11:52 AM, 8 Dihedral wrote: On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral dihedr...@googlemail.com wrote: Please explain what you think a hash function is, then. Per Wikipedia, A hash function is any algorithm or

Re: order independent hash?

2011-12-04 Thread Steven D'Aprano
Dihedral, you're back to double posting. Please stop. Send to the mailing list, or to the newsgroup, it doesn't matter. But don't send to both. Further comments below. On Sun, 04 Dec 2011 16:52:14 -0800, 8 Dihedral wrote: If v is a tuple or a list then a dictionary in python can replace

Re: order independent hash?

2011-12-04 Thread Ethan Furman
Lie Ryan wrote: On 12/05/2011 11:52 AM, 8 Dihedral wrote: On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral dihedr...@googlemail.com wrote: Please explain what you think a hash function is, then. Per Wikipedia, A hash function is any

Re: order independent hash?

2011-12-04 Thread Matt Joiner
Yes. I sent a mail earlier asking such and it was bounced. I'm one email from also blocking this fellow. On Mon, Dec 5, 2011 at 12:59 PM, Lie Ryan lie.1...@gmail.com wrote: On 12/05/2011 11:52 AM, 8 Dihedral wrote: On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote: On Sun, Dec 4,

Re: order independent hash?

2011-12-04 Thread Ben Finney
Ethan Furman et...@stoneleaf.us writes: Lie Ryan wrote: trying not to be rude, but the more you talk, the more Im convince that you're trolling. Welcome to my killfile. I think he's a bot, and he's been in my killfile for a while now. Having a ludicrous name doesn't help, and is part of

Re: order independent hash?

2011-12-04 Thread Dan Stromberg
Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed 2) If you need your hash more often, you could keep your elements in a treap or red-black tree; these will maintain sortedness

class print method...

2011-12-04 Thread Suresh Sharma
Hello All, I am new to python and i have stuck up on a particular issue with classes, i understand this might be a very dumb question but please help me out. I have created two classes and whenever i try to print the objects i get this message but not the data, __main__.cards instance at

Re: class print method...

2011-12-04 Thread Dave Angel
On 12/05/2011 02:11 AM, Suresh Sharma wrote: Hello All, I am new to python and i have stuck up on a particular issue with classes, i understand this might be a very dumb question but please help me out. I have created two classes and whenever i try to print the objects i get this message but

[issue13526] Deprecate the old Unicode API

2011-12-04 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: I agree with Benjamin. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13526 ___

[issue12555] PEP 3151 implementation

2011-12-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Is the following change in behavior caused by the fix for this issue? $ python3.2 -c $'class A(IOError):\n def __init__(self, arg): pass\nA(arg=1)' $ python3.3 -c $'class A(IOError):\n def __init__(self, arg): pass\nA(arg=1)' Traceback

[issue13464] HTTPResponse is missing an implementation of readinto

2011-12-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Hello Jon, and thanks for the patch. I have a couple of comments: - readinto() shouldn't return None but 0 when there is nothing to read (this corresponds to read() returning b) - I see _read_chunked() is only ever called with amt=None, so

[issue12555] PEP 3151 implementation

2011-12-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Is the following change in behavior caused by the fix for this issue? $ python3.2 -c $'class A(IOError):\n def __init__(self, arg): pass\nA(arg=1)' $ python3.3 -c $'class A(IOError):\n def __init__(self, arg): pass\nA(arg=1)'

[issue13526] Deprecate the old Unicode API

2011-12-04 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Closing this as rejected, for the reasons given. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13526

[issue12555] PEP 3151 implementation

2011-12-04 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: There's a fairly sophisticated tapdance in object.__new__ that deals with this problem at that level. See: http://hg.python.org/cpython/file/default/Objects/typeobject.c#l2869 The new IOError may require something similarly sophisticated to

[issue9420] gdbm with /usr/include/ndbm.h

2011-12-04 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- versions: +Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9420 ___ ___

[issue13524] critical error with import tempfile

2011-12-04 Thread Tim Golden
Tim Golden m...@timgolden.me.uk added the comment: OK, the long and short is that spwaning a process without passing in SystemRoot is asking for trouble. There's a blog post here which gives an example:

[issue13211] urllib2.HTTPError does not have 'reason' attribute.

2011-12-04 Thread Jason R. Coombs
Jason R. Coombs jar...@jaraco.com added the comment: After yet another commit, the build bots are green again: http://hg.python.org/cpython/rev/8fa1dc66de5d -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13211

[issue13464] HTTPResponse is missing an implementation of readinto

2011-12-04 Thread Jon Kuhn
Jon Kuhn jonk...@gmail.com added the comment: Thanks for the comments. Attached is an updated patch. In the RawIOBase docs it says If the object is in non-blocking mode and no bytes are available, None is returned. So I wasn't sure if that meant any time no bytes were available or just when

[issue13528] Rework performance FAQ

2011-12-04 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: This is a slimmed down rewrite of the performance question in the FAQ (also moved around to a dedicated subheader). -- assignee: docs@python components: Documentation files: perffaq.patch keywords: patch messages: 148853 nosy:

[issue13503] improved efficiency of bytearray pickling by using bytes type instead of str

2011-12-04 Thread Irmen de Jong
Irmen de Jong ir...@razorvine.net added the comment: Added new patch that only does the new reduction when protocol is 3 or higher. -- Added file: http://bugs.python.org/file23852/bytearray3x_reduceex.patch ___ Python tracker rep...@bugs.python.org

[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor
New submission from Alex Gaynor alex.gay...@gmail.com: I don't have a particularly minimal test case for this, however I am able to reproduce it consistently (so far reproduced on multiple machines, 32-bit and 64-bit on 2.6 and 2.7), using these steps: First get a checkout of the PyPy

[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor
Alex Gaynor alex.gay...@gmail.com added the comment: Antoine asked for a gdb bt, here's the last couple of useful frames: #0 _PyWeakref_ClearRef (self=0x4000) at Objects/weakrefobject.c:97 #1 0x004d4c66 in handle_weakrefs (old=0x78a2b0, unreachable=0x7fff87b0) at

[issue1660009] continuing problem with httplib multiple set-cookie headers

2011-12-04 Thread Piotr Dobrogost
Changes by Piotr Dobrogost p...@python.dobrogost.net: -- nosy: +piotr.dobrogost ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1660009 ___ ___

[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor
Alex Gaynor alex.gay...@gmail.com added the comment: Turns out this was a subtle bug in some raw memory manipulation code, which amaury spotted. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org

[issue3276] httplib.HTTPConnection._send_request should not blindly assume dicts for headers

2011-12-04 Thread Piotr Dobrogost
Changes by Piotr Dobrogost p...@python.dobrogost.net: -- nosy: +piotr.dobrogost status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3276 ___

[issue13527] Remove obsolete mentions in the GUIs page

2011-12-04 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 2111bf7e5bca by Antoine Pitrou in branch '3.2': Issue #13527: remove mention of Python megawidgets and Tkinter3000 WCK http://hg.python.org/cpython/rev/2111bf7e5bca New changeset f0008683585c by Antoine Pitrou in

[issue13527] Remove obsolete mentions in the GUIs page

2011-12-04 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13527 ___

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- hgrepos: -93 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11816 ___ ___ Python-bugs-list mailing

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- hgrepos: +94 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11816 ___ ___ Python-bugs-list mailing

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: Added file: http://bugs.python.org/file23853/5ce60675e572.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11816 ___

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: MvL pointed out I hadn't updated the Hg repo reference when I moved my sandbox over to BitBucket - the diff it was generating was from the last time I updated my pydotorg sandbox in order to try something on the buildbots. --

[issue5364] documentation in epub format

2011-12-04 Thread James Polley
James Polley jamezpol...@gmail.com added the comment: So http://bitbucket.org/birkenfeld/sphinx/issue/140/ has now been closed; sphinx happily builds epub. However, the python docs are still not available for download in epub format from http://docs.python.org/download.html, which was the

[issue13530] Docs for os.lseek neglect to mention what it returns

2011-12-04 Thread Ned Batchelder
New submission from Ned Batchelder n...@nedbatchelder.com: The docs for os.lseek don't make any mention of its return value. I believe it's the new offset in the file, but I'm not sure if there are other subtleties to be mentioned. -- assignee: docs@python components: Documentation

[issue13506] IDLE sys.path does not contain Current Working Directory

2011-12-04 Thread Marco Scataglini
Marco Scataglini atlant...@gmx.com added the comment: At first I did no see the difference on preserving the existing correct behavior and fixing the issue between the two patches... and I thought less is more, so mine was better... But, I checked again and by: ... running a python script

[issue13530] Docs for os.lseek neglect to mention what it returns

2011-12-04 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: The only subtlety is that the result is the offset from the beginning, independent of the how value. It may also raise exceptions. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org

[issue13495] IDLE: Regression - Two ColorDelegator instances loaded

2011-12-04 Thread Roger Serwy
Roger Serwy roger.se...@gmail.com added the comment: I attached a better patch that preserves the goals of the original code while not creating two color delegators. I traced down when the regression occurred (2007-09-06): (a4bd8a4805a8) 1. Fail gracefully if the file fails to decode when