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 strin

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 >>

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 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 progr

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 > calle

Re: order independent hash?

2011-12-04 Thread Hrvoje Niksic
Terry Reedy 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 could use

Re: order independent hash?

2011-12-04 Thread Chris Angelico
2011/12/5 Hrvoje Niksic : > 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 useful way to d

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 enco

Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:25 AM, 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? Same thing happens in CPython, and it looks to be the result of alignment. >

Re: struct calcsize discrepency?

2011-12-04 Thread Duncan Booth
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? > When you mix different types in a struct there can be padding inserted between the items. In this case t

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 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? Same thing happens in CPython, and it loo

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

Re: struct calcsize discrepency?

2011-12-04 Thread Glen Rice
On Dec 4, 9:38 am, Duncan Booth wrote: > 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? > > When you mix different types in a struct there

Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:51 AM, Dave Angel 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 ge

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 eas

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 8:39 AM, 8 Dihedral 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 has them built into the lan

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 > wrote: > > Thanks for your comments. Are we gonna talk about the way to implement a > > hash > > table or the use of a hash ta

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 great

Re: order independent hash?

2011-12-04 Thread Tim Chase
On 12/04/11 08:08, Chris Angelico wrote: 2011/12/5 Hrvoje Niksic: 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 p

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral 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 can hash objects is not

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 > 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

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 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 >> wrote: >> >> If you want to talk about ways to use dicts, please start a different

Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral 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 power of true OOP ?

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 wit

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 object.

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 > 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,

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 wrote: Please explain what you think a hash function is, then. Per Wikipedia, "A hash function is any algorithm or subroutine that maps large

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 wrote: Please explain what you think a hash function is, then. Per Wikipedia, "A hash function is any algorithm or subroutine

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 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

Re: order independent hash?

2011-12-04 Thread Ben Finney
Ethan Furman writes: > Lie Ryan wrote: > > trying not to be rude, but the more you talk, the more I"m 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 what droppe

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 through

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 (mem

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 not