Re: hash and __eq__

2009-05-30 Thread Arnaud Delobelle
Piet van Oostrum writes: >> Arnaud Delobelle (AD) wrote: > >>AD> Piet van Oostrum writes: > Aaron Brady (AB) wrote: >>AB> I am writing a mapping object, and I want to ask about the details of >>AB> __hash__ and __eq__. IIUC if I understand correctly, the Python >>AB> dict's

Re: decoding keyboard input when using curses

2009-05-30 Thread Chris Jones
On Sat, May 30, 2009 at 04:55:19PM EDT, Arnaud Delobelle wrote: > Hi all, Disclaimer: I am not familiar with the curses python implementation and I'm neither an ncurses nor a "unicode" expert by a long shot. :-) > I am looking for advice on how to use unicode with curses. First I will > explai

Have a variable column length in printf

2009-05-30 Thread Cameron Pulsford
Hello all, I'm trying to pretty print a list, so I am doing something like print '%3d' % integer only I would like that 3 to be a variable, instead of hardcoded. Is this possible, or are there any other ways to accomplish this? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Challenge supporting custom deepcopy with inheritance

2009-05-30 Thread Michael H . Goldwasser
I've been playing around recently with customizing the deepcopy semantics within an inheritance hierarchy, and run across the following hurdle. Assume that class B inherits from class A, and that class A has legitimately customized its deepcopy semantics (but in a way that is not known to class B

(windows) How to get information as string from a GreenHills project?

2009-05-30 Thread Jebel
I use python to start a GreenHills project in command line. And the GreenHills project create a string which is include the information that needed to be analyzed. How Can I return this string from GreenHills project to python? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list

Re: DB-API execute params, am I missing something?

2009-05-30 Thread Lawrence D'Oliveiro
In message <55520c08-5b02-4231- b0f3-74eadecd6...@g1g2000yqh.googlegroups.com>, John Machin wrote: > ... suggest a better way. -- http://mail.python.org/mailman/listinfo/python-list

Re: What text editor is everyone using for Python

2009-05-30 Thread Lawrence D'Oliveiro
In message , Lie Ryan wrote: > norseman wrote: > >> Suggestion: >> Take a look at the top two most used OS you use and learn the default >> (most often available) text editors that come with them. > > Which means Notepad on Windows? Or you could take a Linux preinstallation on a Live CD/DVD or U

Release PyInstaller exe installer using distutils for windows.

2009-05-30 Thread 鎌土記良
I created pyInstaller exe installer using distutils only for windows and upload onto the following URL. It makes you to build windows executable file with setup.py's setup function. Setup function is unmounted function on original pyInstaller package, and this installer enables UPX exe archive func

Re: Metaclass mystery

2009-05-30 Thread LittleGrasshopper
On May 30, 6:15 pm, Carl Banks wrote: > On May 30, 5:32 pm, LittleGrasshopper wrote: > > > > > On May 30, 4:01 pm, LittleGrasshopper wrote: > > > > I am experimenting with metaclasses, trying to figure out how things > > > are put together. At the moment I am baffled by the output of the > > > f

Re: Metaclass mystery

2009-05-30 Thread Carl Banks
On May 30, 5:32 pm, LittleGrasshopper wrote: > On May 30, 4:01 pm, LittleGrasshopper wrote: > > > > > I am experimenting with metaclasses, trying to figure out how things > > are put together. At the moment I am baffled by the output of the > > following code: > > > **

Re: Q: finding distance between 2 time's

2009-05-30 Thread John Machin
On May 31, 7:37 am, jkv wrote: > mar...@hvidberg.net wrote: > > Thanks both > > > The first answer is quite instuctive, the other one might be the one > > I'll use in t > > I didn't receive the other answer, could you please forward it to me?> So 2x > thanks. > > You are welcome. > > I took anoth

Re: Metaclass mystery

2009-05-30 Thread LittleGrasshopper
On May 30, 4:01 pm, LittleGrasshopper wrote: > I am experimenting with metaclasses, trying to figure out how things > are put together. At the moment I am baffled by the output of the > following code: > > > """ > Output is: > > instance of metaclass MyMeta bei

Re: PyQt4 + WebKit

2009-05-30 Thread David Boddie
On Saturday 30 May 2009 17:39, dudekks...@gmail.com wrote: > I need to grab clicked links in QWebView. Everything is fine when I > use linkClicked() signal. LinkDelegationPolicy is set to > DelegateAllLinks and there is a problem. If some site has Javascript > my procedure receives QUrl from linkC

Re: how to find the last decorator of a chain

2009-05-30 Thread Benjamin Peterson
Gabriel opensuse.org> writes: > In my understanding this equivalent to: > > render('a', > render('b', > view(***))) > > Is there any way to know, in this case, that 'a' is the 'default' format? You could set an attribute on the function indicating the default. -- http://mail.python.or

Re: Q: finding distance between 2 time's

2009-05-30 Thread John Machin
On May 30, 7:33 pm, mar...@hvidberg.net wrote: > I made this little script (below) to look througt a dir to see if > there are any files newer than .e.g. 1 hour. > I have the loop through the dir working and can retreive file time as > well as present time. > both time variables are in the format r

how to find the last decorator of a chain

2009-05-30 Thread Gabriel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi, I have something like this: @render(format="a") @render(format="b") @ def view(format, data): return data Each render will do something with 'data' if format match, and nothing if not. But if there is no more renders to eval, the last o

Metaclass mystery

2009-05-30 Thread LittleGrasshopper
I am experimenting with metaclasses, trying to figure out how things are put together. At the moment I am baffled by the output of the following code: """ Output is: instance of metaclass MyMeta being created (, ) instance of metaclass MyNewMeta being created

Re: hash and __eq__

2009-05-30 Thread Piet van Oostrum
> Arnaud Delobelle (AD) wrote: >AD> Piet van Oostrum writes: Aaron Brady (AB) wrote: >>> >AB> I am writing a mapping object, and I want to ask about the details of >AB> __hash__ and __eq__. IIUC if I understand correctly, the Python >AB> dict's keys' hash codes are looked up firs

Re: Python 2.6 for Windows 64-bit AMD

2009-05-30 Thread Martin v. Löwis
> Can anyone shed any light on what's up with this build of Python > 2.6.2? You probably tried to install the 32-bit version of PyParsing; this cannot work with the 64-bit version of Python. You either need to obtain a 64-bit version of pyparsing, or install the 32-bit version of Python. HTH, Mar

Re: Python 2.6 for Windows 64-bit AMD

2009-05-30 Thread Terry Reedy
dineshv wrote: I upgraded from Python 2.5.4 to Python 2.6.2 under the Windows 64-bit AMD version, but no external libraries (eg. pyparsing and Numpy 1.3) work. I noticed a few odd things: i. pyparsing could not find an entry for Python 2.6.2 in the Wondows Registry I suspect that you did not

Re: hash and __eq__

2009-05-30 Thread Robert Kern
On 2009-05-30 17:29, Terry Reedy wrote: Aaron Brady wrote: I am writing a mapping object, and I want to ask about the details of __hash__ and __eq__. IIUC if I understand correctly, the Python dict's keys' hash codes are looked up first in O( 1 ), then all the matching hash entries are compared

Re: IndexError: tuple index out of range

2009-05-30 Thread Terry Reedy
MRAB wrote: Invert wrote: My simple python script gives me an error when I try to execute it. Here is the error message: dan...@ibex:~/Desktop/python$ python3 str_format2Daniel.py Traceback (most recent call last): File "str_format2Daniel.py", line 8, in print ("{0} is

Re: hash and __eq__

2009-05-30 Thread Terry Reedy
Aaron Brady wrote: I am writing a mapping object, and I want to ask about the details of __hash__ and __eq__. IIUC if I understand correctly, the Python dict's keys' hash codes are looked up first in O( 1 ), then all the matching hash entries are compared on equality in O( n ). That is, the has

Re: Q: finding distance between 2 time's

2009-05-30 Thread jkv
mar...@hvidberg.net wrote: > Thanks both > > The first answer is quite instuctive, the other one might be the one > I'll use in t I didn't receive the other answer, could you please forward it to me? > So 2x thanks. You are welcome. I took another look at your code, and you can compress it all to

Python 2.6 for Windows 64-bit AMD

2009-05-30 Thread dineshv
I upgraded from Python 2.5.4 to Python 2.6.2 under the Windows 64-bit AMD version, but no external libraries (eg. pyparsing and Numpy 1.3) work. I noticed a few odd things: i. pyparsing could not find an entry for Python 2.6.2 in the Wondows Registry ii. Python 2.6.2 only allows per-machine inst

Re: multiprocessing / forking memory usage

2009-05-30 Thread Aahz
In article , Randall Smith wrote: > >I'm trying to get a grasp on how memory usage is affected when forking >as the multiprocessing module does. I've got a program with a parent >process using wx and other memory intensive modules. It spawns child >processes (by forking) that should be very l

Re: scripting and uploading in Python

2009-05-30 Thread Aahz
In article <3c1f0711-8da8-4610-bf8e-679eff0fa...@21g2000vbk.googlegroups.com>, Mark Tarver wrote: > >Generally I'd like to bring myself up to speed on scripting in >Python. Any good reads - dead tree or otherwise? Assuming you have any programming experience, start with the Python tutorial: h

Re: hash and __eq__

2009-05-30 Thread Arnaud Delobelle
Piet van Oostrum writes: >> Aaron Brady (AB) wrote: > >>AB> I am writing a mapping object, and I want to ask about the details of >>AB> __hash__ and __eq__. IIUC if I understand correctly, the Python >>AB> dict's keys' hash codes are looked up first in O( 1 ), then all the >>AB> matching ha

Re: decoding keyboard input when using curses

2009-05-30 Thread Arnaud Delobelle
Arnaud Delobelle writes: [...] > I can pipe the stream of output from getch() directly through an ^^^ I mean *can't* > instance of codecs.getreader('utf-8') because getch() sometimes returns > the integer values of the 'special keys'. [...] I reread my post 3 times before sending it, honest!

decoding keyboard input when using curses

2009-05-30 Thread Arnaud Delobelle
Hi all, I am looking for advice on how to use unicode with curses. First I will explain my understanding of how curses deals with keyboard input and how it differs with what I would like. The curses module has a window.getch() function to capture keyboard input. This function returns an integer

Re: how to free memory allocated by a function call via ctypes

2009-05-30 Thread Benjamin Peterson
Tzury Bar Yochay gmail.com> writes: > > My question is how do I free the memory allocated when I call this > function using ctypes The return type of ctypes.create_string_buffer() will call free() when it is garbage collected. -- http://mail.python.org/mailman/listinfo/python-list

Re: IndexError: tuple index out of range

2009-05-30 Thread MRAB
Invert wrote: My simple python script gives me an error when I try to execute it. Here is the error message: dan...@ibex:~/Desktop/python$ python3 str_format2Daniel.py Traceback (most recent call last): File "str_format2Daniel.py", line 8, in print ("{0} is {1} years old

Re: hash and __eq__

2009-05-30 Thread Piet van Oostrum
> Aaron Brady (AB) wrote: >AB> I am writing a mapping object, and I want to ask about the details of >AB> __hash__ and __eq__. IIUC if I understand correctly, the Python >AB> dict's keys' hash codes are looked up first in O( 1 ), then all the >AB> matching hash entries are compared on equali

Re: CRLF when doing os.system("ls -l") while using curses !!!

2009-05-30 Thread Piet van Oostrum
> lsk040365 (l) wrote: >l> Can you provide me with some sort of example possibly--I have been >l> fighting this for a while and I wouldn't be using curses but I have >l> designed the program with the extended ascii characters thereby making >l> a nice UI...? Nice UI This is so 70's :=)

how to free memory allocated by a function call via ctypes

2009-05-30 Thread Tzury Bar Yochay
Hi, Suppose I have the following function char *generateMessage(char *sender, char *reciever, char *message) ; now in c I would normally do char *msg = generateMessage(sender, reciever, message); // do something free(msg); My question is how do I free the memory allocated when I call this funct

IndexError: tuple index out of range

2009-05-30 Thread Invert
My simple python script gives me an error when I try to execute it. Here is the error message: dan...@ibex:~/Desktop/python$ python3 str_format2Daniel.py > Traceback (most recent call last): > File "str_format2Daniel.py", line 8, in > print ("{0} is {1} years old {3} and ".format(name, age

Re: hash and __eq__

2009-05-30 Thread Aaron Brady
On May 30, 12:11 pm, Dennis Lee Bieber wrote: > On Sat, 30 May 2009 11:20:47 -0700 (PDT), Aaron Brady > declaimed the following in > gmane.comp.python.general: > > > P.S.  I always feel like my posts should start like, "A mapping object > > am writing I."  Not too many verbs you can do that with

Re: Python and Glade: window not showing

2009-05-30 Thread Sven Arduwie
On 30 mei, 21:02, Dave Angel wrote: > Sven Arduwie wrote: > > On 30 mei, 17:02, Sven Arduwie wrote: > > >> Can anyone help a python newbie and tell me why the simple window I > >> created in Glade is not showing? > > >> This is the XML generated by Glade 3: > >> > >> > >>   > >>   > >>   > >

Re: Python and Glade: window not showing

2009-05-30 Thread Dave Angel
Sven Arduwie wrote: On 30 mei, 17:02, Sven Arduwie wrote: Can anyone help a python newbie and tell me why the simple window I created in Glade is not showing? This is the XML generated by Glade 3: True And this is the Python code: #!/usr/bin/env pyt

Re: Python and Glade: window not showing

2009-05-30 Thread Sven Arduwie
On 30 mei, 17:02, Sven Arduwie wrote: > Can anyone help a python newbie and tell me why the simple window I > created in Glade is not showing? > > This is the XML generated by Glade 3: > > >   >   >   >     True >     >     >       >     >   > > > And this is the Python code: > #!/usr/b

hash and __eq__

2009-05-30 Thread Aaron Brady
I am writing a mapping object, and I want to ask about the details of __hash__ and __eq__. IIUC if I understand correctly, the Python dict's keys' hash codes are looked up first in O( 1 ), then all the matching hash entries are compared on equality in O( n ). That is, the hash code just really na

Re: CRLF when doing os.system("ls -l") while using curses !!!

2009-05-30 Thread lsk040365
On May 29, 6:35 pm, Piet van Oostrum wrote: > > lkenne...@gmail.com (l) wrote: > >l> Here is the code and as you can see for yourself, the output is not > >l> coming out on the screen with CRLF like it should.  How do I fix this? > > Don't use curses. > > Curses puts the terminal in raw mode (

[RELEASED] Python 3.1 Release Candidate 1

2009-05-30 Thread Benjamin Peterson
On behalf of the Python development team, I'm happy to announce the first release candidate of Python 3.1. Python 3.1 focuses on the stabilization and optimization of the features and changes that Python 3.0 introduced. For example, the new I/O system has been rewritten in C for speed. File syst

Re: MySQLdb 1.2.2 + python 2.6.2

2009-05-30 Thread Piet van Oostrum
> monogeo (m) wrote: >m> Hi all, >m> Are MySQLdb 1.2.2 and python 2.6.2 compatible? I went to >m> http://sourceforge.net/project/showfiles.php?group_id=22307, it >m> doesn't say it is compatible or not. >m> When trying to install MySQLdb 1.2.2 on my machine which is running >m> python 2.6.2

Re: How to ask smart questions question

2009-05-30 Thread Aahz
In article <960af9f3-c445-4d6d-b277-76a123ee4...@s28g2000vbp.googlegroups.com>, Carl Banks wrote: >On May 26, 7:48=A0am, Gary Herron wrote: >> >> The proper response to a question like this has to be >> =A0 =A0http://www.catb.org/~esr/faqs/smart-questions.html >> as anything else is complete gue

Compiling and transporting modules/libraries in python

2009-05-30 Thread Abe
Hi all - I hope this is a simple question, but I've been running in circles trying to figure it out myself. Is there a good way to wrap up a library (e.g. numpy or matplotlib) so that I can use it on another machine without actually installing it? I use python at a home office and in a univ

PyQt4 + WebKit

2009-05-30 Thread dudekksoft
Hello, I need to grab clicked links in QWebView. Everything is fine when I use linkClicked() signal. LinkDelegationPolicy is set to DelegateAllLinks and there is a problem. If some site has Javascript my procedure receives QUrl from linkClicked, next calls: webView.setUrl(url) #Where "url" is rec

Python and Glade: window not showing

2009-05-30 Thread Sven Arduwie
Can anyone help a python newbie and tell me why the simple window I created in Glade is not showing? This is the XML generated by Glade 3: True And this is the Python code: #!/usr/bin/env python import pygtk pygtk.require("2.0") import gtk class HelloWor

Re: Questions about regex

2009-05-30 Thread Rob Williscroft
wrote in news:fe9f707f-aaf3-4ca6-859a-5b0c63904fc0 @s28g2000vbp.googlegroups.com in comp.lang.python: > text = re.sub('(\<(/?[^\>]+)\>)', "", text)#remove the HTML > Python has a /r/ (raw) string literal type for regex's: text = re.sub( r'(\<(/?[^\>]+)\>)', "", text ) In raw strings p

Re: What text editor is everyone using for Python

2009-05-30 Thread edexter
On May 30, 6:28 am, "Hendrik van Rooyen" wrote: > "Lie Ryan" wrote: > > norseman wrote: > > > Suggestion: > > > Take a look at the top two most used OS you use and learn the default > > > (most often available) text editors that come with them. > > > Which means Notepad on Windows? > > you could

Re: Questions about regex

2009-05-30 Thread Steven D'Aprano
On Fri, 29 May 2009 11:26:07 -0700, Jared.S.Bauer wrote: > Hello, > > I'm new to python and I'm having problems with a regular expression. I > use textmate as my editor and when I run the regex in textmate it works > fine, but when I run it as part of the script it freezes. Could anyone > help me

Re: Q: finding distance between 2 time's

2009-05-30 Thread Steven D'Aprano
On Sat, 30 May 2009 12:06:55 +0200, jkv wrote: > I added a few lines to your script, and now it ought to only print files > newer than 3601 seconds (3600 seconds is one hour). ... > #if file newer than one hour print a line > if time_difference < 3601: That's a potential off-by-one erro

Re: What text editor is everyone using for Python

2009-05-30 Thread Hendrik van Rooyen
"Lie Ryan" wrote: > norseman wrote: > > Suggestion: > > Take a look at the top two most used OS you use and learn the default > > (most often available) text editors that come with them. > > Which means Notepad on Windows? you could live dangerously and use WordPad... - Hendrik -- http://mail

Re: Q: finding distance between 2 time's

2009-05-30 Thread martin
Thanks both The first answer is quite instuctive, the other one might be the one I'll use in the code, it's nicely compact and clear. So 2x thanks. :-) Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Browser based Canvas UI?

2009-05-30 Thread Ken Seehart
CTO wrote: On May 30, 4:12 am, Ken Seehart wrote: A couple years ago I stumbled upon an interesting technology but I can't seem to find it, and I can remember what it is called. Unfortunately this makes it difficult to search for. I am am aware of several partial matches (items that meet a

Re: Questions about regex

2009-05-30 Thread bearophileHUGS
Jared.S., even if a regex doesn't look like a program, it's like a small program written in a strange language. And you have to test and comment your programs. So I suggest you to program in a more tidy way, and add unit tests (doctests may suffice here) to your regexes, you can also use the verbos

Re: Q: finding distance between 2 time's

2009-05-30 Thread jkv
Hi Martin, What i usally do is to convert the two times to seconds since epoch and compare the two values in seconds. You can use time.mktime to convert localtime to seconds since epoch. I added a few lines to your script, and now it ought to only print files newer than 3601 seconds (3600 seconds

Re: How does Python's OOP feel?

2009-05-30 Thread Ken Seehart
Benjamin Kaplan wrote: On Fri, May 29, 2009 at 9:41 PM, Lie Ryan > wrote: Ikon wrote: > I'm rather new to Python. I have PHP for my main language and I do > some Java. They all have a very strict OO schema. As I red through > Python's tutorial it sea

Q: finding distance between 2 time's

2009-05-30 Thread martin
I made this little script (below) to look througt a dir to see if there are any files newer than .e.g. 1 hour. I have the loop through the dir working and can retreive file time as well as present time. both time variables are in the format returned by time.localtime() My question: How do I find t

Re: How to reuse TCP listening socket immediately after it was connected at least once?

2009-05-30 Thread Thomas Bellman
Lawrence D'Oliveiro wrote: > In message , Thomas Bellman wrote: >> Speaking as a sysadmin, running applications for production, >> programs not using SO_REUSEADDR should be taken out and shot. >> Not using SO_REUSEADDR means forcing a service interruption of >> half an hour (IIRC) if for some r

Re: How does Python's OOP feel?

2009-05-30 Thread Teguh Iskanto
On Sat, May 30, 2009 at 2:50 PM, Benjamin Kaplan wrote: > > > On Fri, May 29, 2009 at 9:41 PM, Lie Ryan wrote: > >> Ikon wrote: >> > I'm rather new to Python. I have PHP for my main language and I do >> > some Java. They all have a very strict OO schema. As I red through >> > Python's tutorial i

Re: Browser based Canvas UI?

2009-05-30 Thread CTO
On May 30, 4:12 am, Ken Seehart wrote: > A couple years ago I stumbled upon an interesting technology but I can't > seem to find it, and I can remember what it is called.  Unfortunately > this makes it difficult to search for.  I am am aware of several partial > matches (items that meet a subset o

Re: Python, Tkinter and popen problem

2009-05-30 Thread Piet van Oostrum
> norseman (n) wrote: >n> Piet van Oostrum wrote: norseman (n) wrote: >>> >n> I have tried both and Popen2.popen2(). >n> os.popen runs both way, contrary to docs. >>> >>> What do you mean `os.popen runs both way'? >n> It reads from child while console writes directly to child -

Browser based Canvas UI?

2009-05-30 Thread Ken Seehart
A couple years ago I stumbled upon an interesting technology but I can't seem to find it, and I can remember what it is called. Unfortunately this makes it difficult to search for. I am am aware of several partial matches (items that meet a subset of the requirement listed below). Does anyon

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-30 Thread Stefan Behnel
byron wrote: > I am using the lxml.etree library to validate an xml instance file > with a specified schema that contains the data types of each element. > This is some of the internals of a function that extracts the > elements: > > schema_doc = etree.parse(schema_fn) > schema = e