Re: Anyway to clarify this code? (dictionaries)

2005-11-23 Thread Steven D'Aprano
javuchi wrote: > I want to avoid converting the dictionary to a list and then to a > dictionay. Are there speed penalties for such a conversion? You mean, is it faster to write, test, debug and execute slow Python code rather than letting Python's built-in routines written in fast C do the job?

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Steve Holden
Christoph Zwerschke wrote: > This is probably a FAQ, but I dare to ask it nevertheless since I > haven't found a satisfying answer yet: Why isn't there an "ordered > dictionary" class at least in the standard list? Time and again I am > missing that feature. Maybe there is something wrong with m

Re: What a curious assignment.

2005-11-23 Thread Steven D'Aprano
[EMAIL PROTECTED] wrote: > Is there somthing wrong Kids today, don't they learn about inheritence? :-) Python's object model is that instances inherit both methods and attributes from the class (and superclasses). Methods are just a special case of attributes: the method is a callable att

SelfExtract with zipfile

2005-11-23 Thread Catalin Lungu
Hi, I need to compress files in self-extract archive. I use the zipfile module. Is there an option or parameter to do that? Thanks in advance, Catalin -- http://mail.python.org/mailman/listinfo/python-list

Re: What a curious assignment.

2005-11-23 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > [EMAIL PROTECTED] wrote: > > > Is there somthing wrong > > Kids today, don't they learn about inheritence? :-) > > Python's object model is that instances inherit both > methods and attributes from the class (and > superclasses). Methods are just a special case of > at

Re: python gui using boa

2005-11-23 Thread Steve Holden
Ashok wrote: > hi, > i am trying to develop a small gui app using boa constructor. say this > app has one frame which has one static text control. i want the frame > to resize itself to the width of the text contrl when i change the > label of the text control via SetLabel(). how can i do this in b

Re: Cmd Module

2005-11-23 Thread Fredrik Lundh
Godwin Burby wrote: > I was just curious about using the cmd module for building my > own command line interface. i saw a problem. The script is as follows: it helps if you include the code you were running, instead of some approximation of it. File "test", line 10 if passwd = 'god

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Fuzzyman
Christoph Zwerschke wrote: > >>I still believe that the concept of an "ordered dictionary" ("behave > >>like dict, only keep the order of the keys") is intuitive and doesn't > >>give you so much scope for ambiguity. But probably I need to work on an > >>implementation to become more clear about po

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Fuzzyman
Bengt Richter wrote: > On 22 Nov 2005 02:16:22 -0800, "Fuzzyman" <[EMAIL PROTECTED]> wrote: > > > > >Kay Schluehr wrote: > >> Christoph Zwerschke wrote: > >> > >> > That would be also biased (in favour of Python) by the fact that > >> > probably very little people would look for and use the packag

Re: mxODBC sql MSAccess

2005-11-23 Thread Steve Holden
BartlebyScrivener wrote: > Hello, I'm new to python and trying to get records from an MSAccess > database using mxODBC. It works, but the output is not formatted the > way I want it. > > Here's the script: > > import mx.ODBC.Windows as odbc > > driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=

Re: Cmd Module

2005-11-23 Thread Godwin Burby
Sorry! I just retyped my script instead of copy pasting it. well thank u once again for clearing my confusion. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread [EMAIL PROTECTED]
Steve Holden wrote: > Perhaps now the answer top your question is more obvious: there is by no > means universal agreement on what an "ordered dictionary" should do. > Given the ease with which Python allows you to implement your chosen > functionality it would be presumptuous of the core develope

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Fuzzyman
Christoph Zwerschke wrote: > One implementation detail that I think needs further consideration is in > which way to expose the keys and to mix in list methods for ordered > dictionaries. > > In http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 > the keys are exposed via the keys() me

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Fuzzyman
There is already an update method of course. :-) Slicing an ordered dictionary is interesting - but how many people are actually going to use it ? (What's your use case) You can already slice the sequence atribute and iterate over that. All the best, Fuzzyman http://www.voidspace.org.uk/python

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Fuzzyman
While we're on the subject, it would be useful to be able to paste in a changelog as well as a description. Currently when updating versions you have to include the changelog in the description - or not at all... All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://m

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Fredrik Lundh
Bengt Richter wrote: > >Though it looks nice, it's an implementation dependant solution. What if > >someone changes zip to fetch the second item first? > > That would be a counter-intuitive thing to do. Most things go left->right > in order as the default assumption. it's not only the order that

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Personally, I would like to see it as [('a',1,'b',2), ('c',3, > None,None)],  as a list of tuple of equal length is easier to be dealt > with. > > i = iter(aList) > zip(i,chain(i,repeat(None)), > chain(i,repeat(None)),chain(i,repeat(None))) Here's some more: >>> it =

Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > led to more serious flaws like the missing if-then-else expression, > something I use in virtually every piece of code I write, and which > increases readability. you obviously need to learn more Python idioms. Python works better if you use it to write Python code; n

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Duncan Booth
Bengt Richter wrote: > On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" > <[EMAIL PROTECTED]> wrote: >>Duncan Booth wrote: >> >>> >>> it = iter(aList) >>> >>> zip(it, it) >>> [('a', 1), ('b', 2), ('c', 3)] >> >>is "relying on undefined behaviour" perhaps the new black ? > Is it really undefin

Re: sort the list

2005-11-23 Thread Duncan Booth
Neil Hodgson wrote: >> Since no-one mentioned it and its a favourite of mine, you can use the >> decorate-sort-undecorate method, or "Schwartzian Transform" > > That is what the aforementioned key argument to sort is: a built-in > decorate-sort-undecorate. And crucially it is a built-in DSU

Re: Hot to split string literals that will across two or more lines ?

2005-11-23 Thread Mohammad Jeffry
I tried to use this method in my code like this:- - #!/usr/bin/python  def print_sql():  

Re: What a curious assignment.

2005-11-23 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > [test 1] > class A: > > ...i = 1 > ... > a = A() A.i > > 1 > a.i > > 1 > A.i = 2 A.i > > 2 > a.i > > 2 > > > [test2] > class A: > > ...i = 1 > ... > a = A() A.i > > 1 > a.i > > 1 > a.i = 2 A.i

Re: a new design pattern for Python Library?

2005-11-23 Thread Ben Sizer
The Eternal Squire wrote: > I tend to use this design pattern a lot in order to aid in > compartmentalizing interchangeable features in a central class that > depend on the central class's data. I'm afraid I've read this paragraph and the code 3 times and I still have no idea what you're trying to

PyQt QGridLayout question

2005-11-23 Thread Volker Lenhardt
Once again a maybe silly question, but I find no solution, neither in the documentation nor in examples. I have got some different layouts to change place by the help of a QGridLayout in its parent widget. To make it nice I use row/col spacing and stretch respectively as well as multicell widge

Re: Hot to split string literals that will across two or more lines ?

2005-11-23 Thread Steve Holden
Mohammad Jeffry wrote: > I tried to use this method in my code like this:- > - > #!/usr/bin/python > > > def print_sql(): > sql = '''aaa > bbb'''.replace("\n","") >

Re: Hot to split string literals that will across two or more lines ?

2005-11-23 Thread Fredrik Lundh
Mohammad Jeffry wrote: > I can always do this :- > - > #!/usr/bin/python > > > def print_sql(): > sql = '''aaa > bbb'''.replace("\n","") > print sql > > print_sql() > > -

Re: How can I package a python script and modules into a single script?

2005-11-23 Thread Fuzzyman
You could use my includer script. http://www.voidspace.org.uk/python/recipebook.shtml#includer It effectively adds an include direct to python scripts. ##include module.py from module import * You then run ``includer.py infilename outfilename`` This replaces the ``##include ..`` with the sourc

Re: sort the list

2005-11-23 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Duncan Booth wrote: >> e.g. it is stable when you reverse the order: >> >> >>> lst = [[4,1],[4,2],[9,3],[5,4],[2,5]] >> >>> list(reversed([ x[-1] for x in sorted([ (x[0],x) for x in lst ]) ])) >> [[9, 3], [5, 4], [4, 2], [4, 1], [2, 5]] >> >>> l1 = list(lst) >> >>> l1.so

Re: sort the list

2005-11-23 Thread [EMAIL PROTECTED]
Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > > Duncan Booth wrote: > >> e.g. it is stable when you reverse the order: > >> > >> >>> lst = [[4,1],[4,2],[9,3],[5,4],[2,5]] > >> >>> list(reversed([ x[-1] for x in sorted([ (x[0],x) for x in lst ]) ])) > >> [[9, 3], [5, 4], [4, 2], [4, 1], [2, 5]]

Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-23 Thread Antoon Pardon
Op 2005-11-23, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > [EMAIL PROTECTED] wrote: > >> led to more serious flaws like the missing if-then-else expression, >> something I use in virtually every piece of code I write, and which >> increases readability. > > you obviously need to learn more Python

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > Steve Holden wrote: > > Perhaps now the answer top your question is more obvious: there is by no > > means universal agreement on what an "ordered dictionary" should do. > > Given the ease with which Python allows you to implement your chosen > > functionality it would b

strange behaviour when writing a large amount of data on stdout

2005-11-23 Thread Manlio Perillo
Regards. On my system: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32, Windows XP I have this problem: >>> n = 61409 + 1 >>> data = 'x' * n >>> print data Traceback (most recent call last): File "xxx", line xxx, in ? print data IOError: [Errno 12] Not enou

Re: user-defined operators: a very modest proposal

2005-11-23 Thread Fredrik Lundh
Joseph Garvin wrote: > >Jeff Epler's proposal to use unicode operators would synergise most > >excellently with this, allowing python to finally reach, and even surpass, > >the level of expressiveness found in languages such as perl, APL and > >INTERCAL. > > > What do you mean by unicode operators

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Duncan Booth
Christoph Zwerschke wrote: > Ok, I just did a little research an compared support for ordered dicts > in some other languages: > Just to add to your list: In Javascript Object properties (often used as an associative array) are defined as unordered although as IE seems to always store them in

Re: bsddb185 question

2005-11-23 Thread Martin v. Löwis
thakadu wrote: > However the line: > del db[key] > results in an error: (1, 'Operation not permitted') > (only tested on Python 2.3.5) Did you open the dbm file for read-write? This should work, and is implemented. > Could this be because the .del() method of the dictionary > has not been impleme

Re: sort in the list

2005-11-23 Thread Bengt Richter
On Tue, 22 Nov 2005 14:03:32 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >"Shi Mu" wrote: > >>I use Python 2.3 to run the following code: > a=[[1,2],[4,8],[0,3]] > a.sort() > a >> [[0, 3], [1, 2], [4, 8]] > >> I wonder whether the sort function automatically consider the firs

Re: sort the list

2005-11-23 Thread [EMAIL PROTECTED]
Duncan Booth wrote: > e.g. it is stable when you reverse the order: > > >>> lst = [[4,1],[4,2],[9,3],[5,4],[2,5]] > >>> list(reversed([ x[-1] for x in sorted([ (x[0],x) for x in lst ]) ])) > [[9, 3], [5, 4], [4, 2], [4, 1], [2, 5]] > >>> l1 = list(lst) > >>> l1.sort(key=operator.itemgetter(0), rev

Re: Anyway to clarify this code? (dictionaries)

2005-11-23 Thread Bengt Richter
On 22 Nov 2005 19:52:40 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: >> >>> def my_search(another, keys, x): return dict((k,another[k]) for k in >> keys if another[k]>x) >> ... >> >>> my_search(another, 'cb', .3) >> {'b': 0.35806602909756235} >> >>> my_search

Missing /usr/lib/python2.3/config

2005-11-23 Thread Tin Gherdanarra
Hallo, when trying to run the script ez_setup.py, I fail with unable to open /usr/lib/python2.3/config/Makefile This is true. There is no /usr/lib/python2.3/config directory. A check on groups.google revealed that this is a bug in my debian distro or something. Is this true? Is there a wor

Re: Missing /usr/lib/python2.3/config

2005-11-23 Thread Zoli
Hi. > when trying to run the script ez_setup.py, I fail > with > > unable to open /usr/lib/python2.3/config/Makefile > > This is true. There is no /usr/lib/python2.3/config > directory. A check on groups.google revealed that > this is a bug in my debian distro or something. Is > this true?

Re: Missing /usr/lib/python2.3/config

2005-11-23 Thread Fredrik Lundh
Tin Gherdanarra wrote: > when trying to run the script ez_setup.py, I fail > with > > unable to open /usr/lib/python2.3/config/Makefile > > This is true. There is no /usr/lib/python2.3/config > directory. A check on groups.google revealed that > this is a bug in my debian distro or something.

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Bengt Richter
On 23 Nov 2005 01:24:46 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: > >[EMAIL PROTECTED] wrote: >> Steve Holden wrote: >> > Perhaps now the answer top your question is more obvious: there is by no >> > means universal agreement on what an "ordered dictionary" should do. >> > Given the ease wi

Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-23 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > > (Well, ok that is not the end of the world either but it's lack is > > irritating > > as hell, and yes, I know that it is now back in favor.) > > the thing that's in favour is "then-if-else", not "if-then-else". > there it comes :-) -- http://mail.python.org/mailman/li

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Bengt Richter
On Wed, 23 Nov 2005 09:54:46 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: > >> >Though it looks nice, it's an implementation dependant solution. What if >> >someone changes zip to fetch the second item first? >> >> That would be a counter-intuitive thing to do. Most thin

Re: user-defined operators: a very modest proposal

2005-11-23 Thread Simon Brunning
On 23/11/05, Joseph Garvin <[EMAIL PROTECTED]> wrote: > What do you mean by unicode operators? Link? http://fishbowl.pastiche.org/2003/03/19/jsr666_extended_operator_set -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/py

Re: Hot to split string literals that will across two or more lines ?

2005-11-23 Thread Fredrik Lundh
Magnus Lycka wrote: > Fredrik Lundh wrote: >> cursor.execute( >> 'select * from foo' >> ' where bar=%s' >> ' limit 100', >> bar >> ) > > The disavantage with this is that it's easy to make > a mistake, like this... > > cursor.execute( > 'select

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Fredrik Lundh
Bengt Richter wrote: > Are you thinking of something like lines from a file, where there might be > chunky buffering? ISTM that wouldn't matter if the same next method was > called. > Here we have multiple references to the same iterator. Isn't e.g. buiding > a plain tuple defined with evaluation

Re: Hot to split string literals that will across two or more lines ?

2005-11-23 Thread Magnus Lycka
Fredrik Lundh wrote: > cursor.execute( > 'select * from foo' > ' where bar=%s' > ' limit 100', > bar > ) The disavantage with this is that it's easy to make a mistake, like this... cursor.execute( 'select * from foo ' 'where bar=%s

Re: user-defined operators: a very modest proposal

2005-11-23 Thread Fredrik Lundh
Simon Brunning wrote: >> What do you mean by unicode operators? Link? > > http://fishbowl.pastiche.org/2003/03/19/jsr666_extended_operator_set see also: http://www.brunningonline.net/simon/blog/archives/000666.html http://www.python.org/peps/pep-0666.html -- http://mail.python.org/

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Simon Brunning
On 22/11/05, Bengt Richter <[EMAIL PROTECTED]> wrote: > That would be a counter-intuitive thing to do. Most things go left->right > in order as the default assumption. +1 -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/p

Re: Missing /usr/lib/python2.3/config

2005-11-23 Thread Tin Gherdanarra
Zoli wrote: > Hi. > > >>when trying to run the script ez_setup.py, I fail >>with >> >> unable to open /usr/lib/python2.3/config/Makefile >> >>This is true. There is no /usr/lib/python2.3/config >>directory. A check on groups.google revealed that >>this is a bug in my debian distro or somethi

Re: Converting a flat list to a list of tuples

2005-11-23 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > >it's not only the order that matters, but also the number of items > >read from the source iterators on each iteration. > > > Not sure I understand. > > Are you thinking of something like lines from a file, where there might be > chunky buffering? ISTM that wouldn't matter

Re: SelfExtract with zipfile

2005-11-23 Thread Simon Brunning
On 23/11/05, Catalin Lungu <[EMAIL PROTECTED]> wrote: > Hi, > I need to compress files in self-extract archive. I use the zipfile module. > Is there an option or parameter to do that? No, AFAIK. If you have a command line tool, perhaps you could try driving that. -- Cheers, Simon B, [EMAIL PROTEC

Re: Converting a flat list to a list of tuples

2005-11-23 Thread Peter Otten
Fredrik Lundh wrote: > Bengt Richter wrote: > >> Are you thinking of something like lines from a file, where there might >> be chunky buffering? ISTM that wouldn't matter if the same next method >> was called. Here we have multiple references to the same iterator. Isn't >> e.g. buiding a plain tu

Re: about sort and dictionary

2005-11-23 Thread Sion Arrowsmith
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >OKB (not okblacke) wrote: >> Fredrik Lundh wrote: >> > [EMAIL PROTECTED] wrote: [ ... ] >> >> > so what would an entry-level Python programmer expect from this >> >> > piece of code? >> >> > >> >> > for item in a.reverse(): >> >> > print ite

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Rick Wotnaz
"Fuzzyman" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > > Christoph Zwerschke wrote: >> - the internal keys list should be hidden > > I disagree. It is exposed so that you can manually change the > order (e.g. to create a "sorted" dict, rather than one ordered > by key insertion). >

Re: user-defined operators: a very modest proposal

2005-11-23 Thread Simon Brunning
On 23/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > see also: > > http://www.brunningonline.net/simon/blog/archives/000666.html > http://www.python.org/peps/pep-0666.html PEP 666 should have been left open. There are a number of ideas that come up here that should be added to it - and

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Magnus Lycka
Ganesan Rajagopal wrote: >> [EMAIL PROTECTED] com <[EMAIL PROTECTED]> writes: > what would be > > the definition of "sorted" and "ordered", before we can > go on ? Sorted > would be ordered by key comparison. Iterating over such a container will > give you the keys in sorted order. Java ca

Re: about sort and dictionary

2005-11-23 Thread [EMAIL PROTECTED]
Sion Arrowsmith wrote: > 1. sort() in place makes sense in terms of space, and is not >completely unintuitive. > 2. reverse() should do what sort() does. > 3. The inexperienced user is most likely to expect the above >code to print 3 2 1 3 2 1, and is more likely to have >difficulty tr

Re: strange behaviour when writing a large amount of data on stdout

2005-11-23 Thread bruno at modulix
Manlio Perillo wrote: > Regards. > > On my system: > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > on win32, Windows XP > > I have this problem: > > n = 61409 + 1 data = 'x' * n > > print data > > > Traceback (most recent call last): > File "xxx", lin

Re: syntax errors while building pypgsql

2005-11-23 Thread [EMAIL PROTECTED]
Tin Gherdanarra wrote: > [EMAIL PROTECTED] wrote: > > Have you tried apt-get build-dep pypgsql ? > > > > It could be that you lacks the necessary packages to build it. > > funny you'd mention it, I did. pypgsql does not seem to > be an apt-get package, however. It did not work because > "E: Couldn

Re: bsddb185 question

2005-11-23 Thread thakadu
Martin you are great! If I had just opened the file with f=bsddb185.hashopen('filename',''w') it would have worked the first time. So now I will create wrapper classes around the file classes of bsddb185 and create the methods that I need to keep it consistent with bsddb. Another small difference

Tutorials for Python + PostgreSQL

2005-11-23 Thread Steve
I want to learn more about enterprise-level programming using Python and PostgreSQL. From what I've searched, it seems that psycho is interesting to improve runtime too. Do you have tutorials, articles and tips to learn this combination? I've been working with PostgreSQL for 2 years, and with Pytho

Re: syntax errors while building pypgsql

2005-11-23 Thread Tin Gherdanarra
[EMAIL PROTECTED] wrote: > Have you tried apt-get build-dep pypgsql ? > > It could be that you lacks the necessary packages to build it. funny you'd mention it, I did. pypgsql does not seem to be an apt-get package, however. It did not work because "E: Couldn't find package pypgsql" The fact tha

syntax errors while building pypgsql

2005-11-23 Thread Tin Gherdanarra
Hallo, I'm trying to install pypgsql. However, I get syntax errors while compiling the C sources. The following excerpt from pgconnection.h looks a little funny to me: typedef struct { PyObject_HEAD /* Here is the syntax error, and rightly so */ PGconn *conn; PyObject *host; P

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Carsten Haese
On Tue, 2005-11-22 at 20:44, Tom Anderson wrote: > On Tue, 22 Nov 2005, Carsten Haese wrote: > > > On Tue, 2005-11-22 at 14:37, Christoph Zwerschke wrote: > > > >> In Foord/Larosa's odict, the keys are exposed as a public member which > >> also seems to be a bad idea ("If you alter the sequence l

Re: Mac OSX oddities (compiling Python plus tkinter)

2005-11-23 Thread Kevin Walzer
MichaelW wrote: > I've been Python (2.3.4) plus Tkinter happily under MacOX 10.3, having > compiled them from scatch. (Tkinter is based on tcl/tk 8.4.1, which > were compiled from source via Fink). > > I then moved my laptop over the 10.4, and things are now breaking. > Using the Python shipped wi

Re: strange behaviour when writing a large amount of data on stdout

2005-11-23 Thread jepler
That code works here. Python2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 It's Windows XP, Pentium 4, unknown amount of RAM. I'm running python.exe in a console window. It also worked in IDLE. Jeff pgptwrbVpG8CR.pgp Description: PGP signature -- http://mail.python.or

Re: syntax errors while building pypgsql

2005-11-23 Thread Gerhard Häring
Tin Gherdanarra wrote: > Hallo, > > I'm trying to install pypgsql. However, I get syntax errors > while compiling the C sources. The following excerpt > from pgconnection.h looks a little funny to me: > > typedef struct { > PyObject_HEAD /* Here is the syntax error, and rightly so */ > [...]

Re: syntax errors while building pypgsql

2005-11-23 Thread Carsten Haese
On Wed, 2005-11-23 at 08:01, Tin Gherdanarra wrote: > Hallo, > > I'm trying to install pypgsql. However, I get syntax errors > while compiling the C sources. The following excerpt > from pgconnection.h looks a little funny to me: > > typedef struct { > PyObject_HEAD /* Here is the syntax err

Re: strange behaviour when writing a large amount of data on stdout

2005-11-23 Thread Fredrik Lundh
Manlio Perillo wrote: > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > on win32, Windows XP > > I have this problem: > n = 61409 + 1 data = 'x' * n > print data > > Traceback (most recent call last): > File "xxx", line xxx, in ? >print data > IOError: [

Re: Accessing a database from a multithreaded application

2005-11-23 Thread Frithiof Andreas Jensen
"Alan Kemp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > Can someone suggest a better (ie, valid) strategy for this? Pass the connection to the thread as a parameter and use it to create a cursor local to the thread. You may have to create a connection per thread also - in

Re: syntax errors while building pypgsql

2005-11-23 Thread [EMAIL PROTECTED]
Have you tried apt-get build-dep pypgsql ? It could be that you lacks the necessary packages to build it. Tin Gherdanarra wrote: > Hallo, > > I'm trying to install pypgsql. However, I get syntax errors > while compiling the C sources. The following excerpt > from pgconnection.h looks a little fun

Re: user-defined operators: a very modest proposal

2005-11-23 Thread bruno at modulix
Joseph Garvin wrote: > Tom Anderson wrote: > >> Jeff Epler's proposal to use unicode operators would synergise most >> excellently with this, allowing python to finally reach, and even >> surpass, the level of expressiveness found in languages such as perl, >> APL and INTERCAL. s/expressiveness/u

Re: syntax errors while building pypgsql

2005-11-23 Thread David Wahler
Tin Gherdanarra wrote: > typedef struct { > PyObject_HEAD /* Here is the syntax error, and rightly so */ [snip] > } PgConnection; > > > I don't know what PyObject_HEAD or PGconn is, > but if they are types, a syntax error is justified here: > > PyObject_HEAD /* Here is the syntax error *

Re: Problems with threaded Hotkey application

2005-11-23 Thread Tim G
And just to confirm, it does in fact work. If you move the RegisterHotKey line to within the thread's run method, the thread's message loop picks up the hotkey press. -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython Licence vs GPL

2005-11-23 Thread Andrew Koenig
"John Perks and Sarah Mount" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > we have some Python code we're planning to GPL. However, bits of it were > (This assumes the wxPython Licence is compatible with the GPL -- if not, > do we just cosmetically change any remaining lines, so n

Re: Problems with threaded Hotkey application

2005-11-23 Thread Tim G
One obvious point is that, according to: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefWM_HOTKEY.asp the WM_HOTKEY message is posted to the queue *of the thread which registered the hotkey*. I haven't yet tried it myself to see, but in your example the main th

Re: a new design pattern for Python Library?

2005-11-23 Thread bruno at modulix
Ben Sizer wrote: > The Eternal Squire wrote: > >>I tend to use this design pattern a lot in order to aid in >>compartmentalizing interchangeable features in a central class that >>depend on the central class's data. > > > I'm afraid I've read this paragraph and the code 3 times and I still > hav

Re: about sort and dictionary

2005-11-23 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > a reminder" that the change is inplace. How arrogant! While > I'm sure the designers had kindly intentions. my memory, though > bad, is not that bad, and I object to being forced to write code > that is more clunky than need be, because the designers thought > they need

Re: about sort and dictionary

2005-11-23 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > Alex Martelli wrote: > >>[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> ... >> >>>intuitive seems to be a very subjective matter, depends on once >>>background etc :-) >> >>That's a strong point of Ruby, actually -- allowing an exclamation mark >>at the end of a metho

Re: wxPython Licence vs GPL

2005-11-23 Thread Paul Boddie
Andrea Gavana wrote: > IIRC, wxPython license has nothing to do with GPL. Its license is far more > "free" than GPL is. That would be "free as in freeloading", right? (And no, I'm not intending to start a licensing flame war with that remark, but I think it's inappropriate to ignore central licens

Re: Tutorials for Python + PostgreSQL

2005-11-23 Thread Michele Simionato
Steve: > I want to learn more about enterprise-level programming using Python > and PostgreSQL. From what I've searched, it seems that psycho is > interesting to improve runtime too. Do you have tutorials, articles and > tips to learn this combination? I've been working with PostgreSQL for 2 > year

Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-23 Thread Dave Hansen
On Tue, 22 Nov 2005 23:17:31 -0700 in comp.lang.python, Steven Bethard <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: [...] >> IIRC, this was discussednd rejected in an SF bug report. It should not >> be a defined behavior for severals reasons: >[snip arguments about how confusing zip(it, i

Re: syntax errors while building pypgsql

2005-11-23 Thread Tin Gherdanarra
[EMAIL PROTECTED] wrote: > Tin Gherdanarra wrote: > >>[EMAIL PROTECTED] wrote: >> >>>Have you tried apt-get build-dep pypgsql ? >>> >>>It could be that you lacks the necessary packages to build it. >> >>funny you'd mention it, I did. pypgsql does not seem to >>be an apt-get package, however. It di

Re: the PHP ternary operator equivalent on Python

2005-11-23 Thread Daniel Crespo
> WHY WHY WHY the obsession with one-liners? What is wrong with the good old > fashioned way? > if cond: >x = true_value > else: >x = false_value Let me tell you something: I'm not a one-liner coder, but sometimes It is necesary. For example: I need to translate data from a DataField to

Re: Tutorials for Python + PostgreSQL

2005-11-23 Thread projecktzero
Michele Simionato wrote: > Steve: > > I want to learn more about enterprise-level programming using Python > > and PostgreSQL. From what I've searched, it seems that psycho is > > interesting to improve runtime too. Do you have tutorials, articles and > > tips to learn this combination? I've been w

Re: the PHP ternary operator equivalent on Python

2005-11-23 Thread Luis M. Gonzalez
This could be done easier this way: L = [('odd','even')[n%2] for i in range(8)] -- http://mail.python.org/mailman/listinfo/python-list

Re: the PHP ternary operator equivalent on Python

2005-11-23 Thread Luis M. Gonzalez
This could be done easier this way: L = [('even','odd')[n%2] for n in range(8)] -- http://mail.python.org/mailman/listinfo/python-list

Re: best cumulative sum

2005-11-23 Thread [EMAIL PROTECTED]
David Isaac wrote: > > Michael Spencer wrote: > > > This can be written more concisely as a generator: > > > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > If iterable has no elements, I believe the behaviour should be [init], > > there is also the case of init=None that needs t

Re: wxPython Licence vs GPL

2005-11-23 Thread Ed Jensen
Paul Boddie <[EMAIL PROTECTED]> wrote: > That would be "free as in freeloading", right? (And no, I'm not > intending to start a licensing flame war with that remark, but I think > it's inappropriate to ignore central licensing concepts such as > end-user freedoms, and then to make sweeping statemen

Re: Timeout for regular expression

2005-11-23 Thread Terry Hancock
On Tue, 22 Nov 2005 18:49:15 +0100 "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > not directly. the only reliable way is to run it in a > separate process, and use the resource module to set > necessary limits. Wow. Thank you Mr. Lundh, I never noticed that module. I think I have an application for

Re: drawline

2005-11-23 Thread Magnus Lycka
Ben Bush wrote: > I had the following code and when I clicked the left mouse button one > time. I got green line and the second click got a purple line and the > green disappeared. > I was confused by two questions: It's good that these postings are archived, so that teachers can check them before

Re: syntax errors while building pypgsql

2005-11-23 Thread Tin Gherdanarra
Gerhard Häring wrote: > Tin Gherdanarra wrote: > >> Hallo, >> >> I'm trying to install pypgsql. However, I get syntax errors >> while compiling the C sources. The following excerpt >> from pgconnection.h looks a little funny to me: >> >> typedef struct { >> PyObject_HEAD /* Here is the syntax

ANNOUNCE: Mod_python 3.2.5 Beta

2005-11-23 Thread Gregory (Grisha) Trubetskoy
The Apache Software Foundation and The Apache HTTP Server Project are pleased to announce the 3.2.5 Beta release mod_python. Version 3.2.5b of mod_python features several new functions and attributes providing better access to apache internals, file-based sessions and other session improvement

Re: the PHP ternary operator equivalent on Python

2005-11-23 Thread [EMAIL PROTECTED]
Luis M. Gonzalez wrote: > This could be done easier this way: > > L = [('even','odd')[n%2] for n in range(8)] That is even/odd, his(created to demonstrate the uglies of ternary) has 4 states, zero, -/+ then even/odd. -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax errors while building pypgsql

2005-11-23 Thread Tin Gherdanarra
Carsten Haese wrote: > On Wed, 2005-11-23 at 08:01, Tin Gherdanarra wrote: > >>Hallo, >> >>I'm trying to install pypgsql. However, I get syntax errors >>while compiling the C sources. The following excerpt >>from pgconnection.h looks a little funny to me: >> >>typedef struct { >> PyObject_HEAD

Re: about sort and dictionary

2005-11-23 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: ... > >>indicate that the method is a mutator. So, you can have a.reverse [NOT > >>mutating a since no !] _and_ a.reverse! [mutating a]. Probably too much > >>of a change even for Python 3000, alas... but, it DOES make it obvious > >>when an object's get

Re: a new design pattern for Python Library?

2005-11-23 Thread Ben Sizer
bruno at modulix wrote: > Ben Sizer wrote: > > I'm afraid I've read this paragraph and the code 3 times and I still > > have no idea what you're trying to convey. > > Got anything more constructive to add? -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list

Re: best cumulative sum

2005-11-23 Thread David Isaac
> Michael Spencer wrote: > > This can be written more concisely as a generator: <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If iterable has no elements, I believe the behaviour should be [init], > there is also the case of init=None that needs to be handled. Right. So it is "

  1   2   3   4   >