Re: loose methods : Smalltalk asPython

2006-12-27 Thread Steven D'Aprano
On Tue, 26 Dec 2006 22:49:30 -0500, Jan Theodore Galkowski wrote: > Hi. > > One of the things I'd like to do with Python is find a way to > consistently implement Smalltalk's "loose methods". This is a > capability whereby additional methods can be added dynamically to > existing classes. You

File write() problem

2006-12-27 Thread apriebe47
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass configfile = file('config.txt', 'w') serverPassword = configfile.readline() if serverPassword == '':

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-27 Thread Xah Lee
Dear Jon Harrop, Thanks for the informative reply. I don't know OpenGL, but i think it is a low-level crap, and have done the industry huge irreparable damage the same way unix has. This wikipedia excerpt from http://en.wikipedia.org/wiki/QuickDraw_3D summarize my sentiment: «Most 3D toolkits c

Re: File write() problem

2006-12-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, apriebe47 wrote: > configfile = file('config.txt', 'w') > serverPassword = configfile.readline() Here you open a file for writing and try to read a line. This raises an exception: In [1]: configfile = file('test.txt', 'w') In [2]: configfile.readline() -

Re: Persistent variables in python

2006-12-27 Thread Duncan Booth
"buffi" <[EMAIL PROTECTED]> wrote: > Is this concidered bad coding practice since I guess persistent > variables in functions are not meant to be? > There is a problem that this trick only works for functions and not for methods as it assumes that there is a global name through which you can ac

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-27 Thread Raff
Xah Lee wrote: > Dear Jon Harrop, > > Thanks for the informative reply. > > I don't know OpenGL, but i think it is a low-level crap, and have done > the industry huge irreparable damage the same way unix has. OpenGL is low level, that's right, but it is not crap. OpenGL is hardware independent,

Re: File write() problem

2006-12-27 Thread apriebe47
Marc 'BlackJack' Rintsch wrote: > > configfile = file('config.txt', 'w') > > serverPassword = configfile.readline() Hrm. When I run the code that I posted I don't seem to get those errors. > Please post the exact code you have trouble with. Don't retype it -- copy > and paste it. from getpass

Re: BeautifulSoup bug when ">>>" found in attribute value

2006-12-27 Thread Duncan Booth
John Nagle <[EMAIL PROTECTED]> wrote: > And this came out, via prettify: > > url="http%3A//www.apartmentsapart.com/Europe/Spain/Madrid/FAQ"> >value="/images/offersBanners/sw04.swf?binfot=We offer > fantastic rates for selected weeks or days!!&blinkt=Click here > >>>&linkurl=/Europe/

Re: loose methods : Smalltalk asPython

2006-12-27 Thread Luc Heinrich
Jan Theodore Galkowski <[EMAIL PROTECTED]> wrote: > Comments? Suggestions? -- Luc Heinrich -- http://mail.python.org/mailman/listinfo/python-list

Re: File write() problem

2006-12-27 Thread rzed
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: > Marc 'BlackJack' Rintsch wrote: > >> > configfile = file('config.txt', 'w') >> > serverPassword = configfile.readline() > > Hrm. When I run the code that I posted I don't seem to get those > errors. > >> Please post the exact code you have t

Re: Mod_python

2006-12-27 Thread Maxim Sloyko
Lad wrote: > In my web application I use Apache and mod_python. > I allow users to upload huge files( via HTTP FORM , using POST method) > I would like to store the file directly on a hard disk and not to > upload the WHOLE huge file into server's memory first. > Can anyone suggest a solution? Th

Re: Fuzzy string comparison

2006-12-27 Thread Duncan Booth
"John Machin" <[EMAIL PROTECTED]> wrote: > To compare two strings, take copies, and: Taking a copy of a string seems kind of superfluous in Python. -- http://mail.python.org/mailman/listinfo/python-list

Stani's Python Editor is looking for a new webhost

2006-12-27 Thread mark
Dear Stani, Very much wishing you a new and great web host for the new year. I feel and read also from so many that you are doing a great service for Python users an d being an example of the Free software movement. i thank you very much and hope you will be back on the web soon. What help do yo

Re: Fuzzy string comparison

2006-12-27 Thread Jorge Godoy
"Steve Bergman" <[EMAIL PROTECTED]> writes: > I'm looking for a module to do fuzzy comparison of strings. I have 2 > item master files which are supposed to be identical, but they have > thousands of records where the item numbers don't match in various > ways. One might include a '-' or have le

Re: Fuzzy string comparison

2006-12-27 Thread John Machin
Duncan Booth wrote: > "John Machin" <[EMAIL PROTECTED]> wrote: > > > To compare two strings, take copies, and: > > Taking a copy of a string seems kind of superfluous in Python. You are right, I really meant don't do: original = original.strip().replace().replace() (a strange way of d

Re: Persistent variables in python

2006-12-27 Thread buffi
> There is a problem that this trick only works for functions and not for > methods as it assumes that there is a global name through which you can > access the function. I didn't really see any issue with this since methods can store the persistant data from the method inside the class containing

Re: loose methods : Smalltalk asPython

2006-12-27 Thread bearophileHUGS
Steven D'Aprano: > You can't modify the built-in classes. I'm not sure that it is a good idea > to allow built-ins to be modified. When I see an int, I like the fact that > I know what the int can do, and I don't have to worry about whether it has > been modified by some piece of code elsewhere. I

Re: Iterating over several lists at once

2006-12-27 Thread Gal Diskin
On Dec 13, 3:47 pm, "Gal Diskin" <[EMAIL PROTECTED]> wrote: > Hi, > I am writing a code that needs to iterate over 3 lists at the same > time, i.e something like this: > > for x1 in l1: > for x2 in l2: > for x3 in l3: > print "do something with", x1, x2, x3 > > What I need

Re: Fuzzy string comparison

2006-12-27 Thread Steven D'Aprano
On Wed, 27 Dec 2006 02:52:42 -0800, John Machin wrote: > > Duncan Booth wrote: >> "John Machin" <[EMAIL PROTECTED]> wrote: >> >> > To compare two strings, take copies, and: >> >> Taking a copy of a string seems kind of superfluous in Python. > > You are right, I really meant don't do: > orig

Re: loose methods : Smalltalk asPython

2006-12-27 Thread Jean-Paul Calderone
On Wed, 27 Dec 2006 19:03:12 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >You can't modify the built-in classes. I'm not sure that it is a good idea >to allow built-ins to be modified. When I see an int, I like the fact that >I know what the int can do, and I don't have to worry about wheth

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-27 Thread Ravi Teja
Xah Lee wrote: > Regarding VisualPython... i saw a demo in 2002 by a professor > friend. I think it is good. Though, why is its licensing not GPL or > otherwise Open Source? That's kinda odd since Pyhton is. You are confusing VPython with Activestate's Visual Python IDE plugin for Visual Studio.

USB Missile.

2006-12-27 Thread Bobby
I am trying to create a python version of the M&S USB Missile Launcher code for Windows. I am basing it off one designed for linux. I note the following about dependencies: Requirements: - 0. python (>=2.3) -Fine 1. libusb (>=0.1.2) -Fine, however the wind

how can I modify an imported variable ?

2006-12-27 Thread yomgui
I've tried this: import MyPackage if MyPackage.aVariable is None: MyPackage.aVariable = True but when I tried to access MyPackage.aVariable from another file (ie through an other import) the value is still None. how can I do this thanks yomgui -- http://mail.python.org/mailman/listinfo/

Re: Mod_python

2006-12-27 Thread Lad
Maxim Sloyko wrote: > Lad wrote: > > In my web application I use Apache and mod_python. > > I allow users to upload huge files( via HTTP FORM , using POST method) > > I would like to store the file directly on a hard disk and not to > > upload the WHOLE huge file into server's memory first. > > C

Re: how can I modify an imported variable ?

2006-12-27 Thread Jean-Paul Calderone
On Wed, 27 Dec 2006 14:50:18 GMT, yomgui <[EMAIL PROTECTED]> wrote: >I've tried this: > >import MyPackage >if MyPackage.aVariable is None: > MyPackage.aVariable = True > >but when I tried to access MyPackage.aVariable from another file >(ie through an other import) the value is still None. > >

Combining C and Python

2006-12-27 Thread Osiris
I found this text about combining C-code with Pyton scripting on the P2P networks in PDF: Python Scripting for Computational Science Hans Petter Langtangen Simula Research Laboratory and Department of Informatics University of Oslo amazon and others have it in print. software for the text is her

newbie question: any better way to write this code?

2006-12-27 Thread neoedmund
i want to let a byte array to be xor with some value. but code show below i wrote seems not so .. good..., any better way to write such function? thanks. [code] def xor(buf): bout=[] for i in range(len(buf)): x = ord(buf[i]) x ^= 123 b

M2Crypto running error

2006-12-27 Thread Croteam
Hello, I was install M2Crypto-0.17beta1.win32-py2.4,and when I run it, I get the error: >>> import M2Crypto Traceback (most recent call last): File "", line 1, in -toplevel- import M2Crypto File "C:\Python24\Lib\site-packages\M2Crypto\__init__.py", line 14, in -toplevel- import __m2

Re: newbie question: any better way to write this code?

2006-12-27 Thread Jean-Paul Calderone
On 27 Dec 2006 07:18:22 -0800, neoedmund <[EMAIL PROTECTED]> wrote: >i want to let a byte array to be xor with some value. >but code show below i wrote seems not so .. good..., any better way to >write such function? thanks. >[code] >def xor(buf): > bout=[] > for i in range(len(buf)): >

persistant gloabl vars (very newbie) ?

2006-12-27 Thread Stef Mientki
hi all, I'm investigating the possibilities to replace MatLab with Python (+NumPy +SciPy). I'm a very newbie, I just typed my first characters and calculated the sum of 2 and 3 in Python. My application is a Delphi program, for data-acquisition and real-time data analysis. The real-time analysis

Re: newbie question: any better way to write this code?

2006-12-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, neoedmund wrote: > i want to let a byte array to be xor with some value. > but code show below i wrote seems not so .. good..., any better way to > write such function? thanks. > > def xor(buf): > bout=[] > for i in range(len(buf)): > x = ord(buf[i

Re: newbie question: any better way to write this code?

2006-12-27 Thread Peter Otten
neoedmund wrote: > i want to let a byte array to be xor with some value. > but code show below i wrote seems not so .. good..., any better way to > write such function? thanks. > [code] > def xor(buf): > bout=[] > for i in range(len(buf)): > x = ord(buf[i]) >  

getting a process's PID

2006-12-27 Thread eldorado
Hello, I am trying to get python to give me the PID of a process (in this case HUB). I have it working, except for the fact that the output includes \012 (newline). Is there a way to ask python not to give me a newline? Python 1.4 (Oct 14 1997) [C] Copyright 1991-1995 Stichting Mathematisch C

Re: how can I modify an imported variable ?

2006-12-27 Thread yomgui
hi, your sample code works, but mine doesn't. it must be a multi-thread issue. I am certain that I am modifying MyPackage.aVariable before using it. Both threads are importing MyPackage, but the modification of MyPackage.aVariable is not seen by the other thread. is this possible ? is there a tu

re: Smalltalk asPython

2006-12-27 Thread Jan Theodore Galkowski
On Tue, 26 Dec 2006 22:49:30 -0500, Jan Theodore Galkowski wrote: >> Hi. >> >> One of the things I'd like to do with Python is find a way to >> consistently implement Smalltalk's "loose methods". This is a >> capability whereby additional methods can be added dynamically to >> existing classes.

re: loose methods: Smalltalk asPython

2006-12-27 Thread Jan Theodore Galkowski
>Jan Theodore Galkowski <[EMAIL PROTECTED]> wrote: >> Comments? Suggestions? > Luc, don't misunderstand: There's nothing at all wrong with Python nor am I suggesting there is. I'm just exploring how far I can go using its dynamic nature. There's no hope of using loos

popen on windows

2006-12-27 Thread hubritic
I am trying to set off commands on Windows 2003 from python. Specifically, I am trying to use diskpart with a script file (pointed to with path). cmd = ["diskpart", "/s", path] p = Popen(cmd, shell=True) The script is meant to loop through twice. It will do so if I commen

Re: getting a process's PID

2006-12-27 Thread Erik Johnson
"eldorado" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I am trying to get python to give me the PID of a process (in this case > HUB). I have it working, except for the fact that the output includes > \012 (newline). Is there a way to ask python not to give me a newli

Re: How to depress the output of an external module ?

2006-12-27 Thread [EMAIL PROTECTED]
Carl Banks wrote: > Carl Banks wrote: > >> [EMAIL PROTECTED] wrote: >> >>> After some trials I found that put "os.close(1)" before calling the >>> function will depress the output. In fact, "os.close(1)" closed >>> standard output, but I don't know how to open it again after the function's

Re: getting a process's PID

2006-12-27 Thread Duncan Booth
"Erik Johnson" wrote: > There's more than one way to do it! (Oh, sorry, that's Perl...) > > The two most standard ways would be to call strip() on your string to > get one sans both leading and trialing whitespace > > print h.strip() > > or if you know exactly what you've got (i.e., the ne

Re: persistant gloabl vars (very newbie) ?

2006-12-27 Thread Erik Johnson
"Stef Mientki" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a way to run the initialization code from a script(file) once, > to achieve the same effect ? Certainly. This is what Python modules are all about. You should probably read up on those a bit here: http://docs.p

Re: getting a process's PID

2006-12-27 Thread eldorado
On Wed, 27 Dec 2006, Erik Johnson wrote: > "eldorado" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hello, >> >> I am trying to get python to give me the PID of a process (in this case >> HUB). I have it working, except for the fact that the output includes >> \012 (newline).

Re: loose methods: Smalltalk asPython

2006-12-27 Thread Aahz
In article <[EMAIL PROTECTED]>, Jan Theodore Galkowski <[EMAIL PROTECTED]> wrote: > >I think Python is very fine although, arguably, because many are >approaching it from a Java strong-typing static mindset, I bet the space >of design possibilities hasn't been explored thoroughly. We've not had >a

Re: Noobie: Open file -> read characters & multiply

2006-12-27 Thread gonzlobo
Thanks to all that responded. I chose a modified version of Scott's second recommendation: time = line[:8] decoded_File.write( '%00.4f' % (int(time, 16) * .0001) + ', ') 'print >>' added a CRLF that I didn't need, so I went with '.print' (I need to process about 20 values from the remaining bytes

Re: getting a process's PID

2006-12-27 Thread Erik Johnson
"eldorado" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'") > >>> h = g.readlines() > >>> g.close() > >>> h > ['87334\012'] > >>> h = h[:-1] > >>> h > [] Oh, sorry... h is a list here because you are using rea

Re: persistant gloabl vars (very newbie) ?

2006-12-27 Thread Piet van Oostrum
> "Erik Johnson" (EJ) wrote: >EJ> But briefly, probably what you want to do is put some code in a file, say >EJ> init.py: >EJ> # init.py >EJ> X = 3 >EJ> Y = 5 >EJ> # A bunch of other stuff >EJ> And then in your main program, execute >EJ> from init import * >EJ> That w

Re: how can I modify an imported variable ?

2006-12-27 Thread yomgui
actually, it is not linked to threading but to the scope. the second attempt to access MyPackage.aVariable is inside the __init__ of a class and this seems to be the problem. I believe it is a genuine python bug. yomgui -- http://mail.python.org/mailman/listinfo/python-list

Re: BeautifulSoup bug when ">>>" found in attribute value

2006-12-27 Thread John Nagle
Duncan Booth wrote: > John Nagle <[EMAIL PROTECTED]> wrote: > > >>And this came out, via prettify: >> >>>url="http%3A//www.apartmentsapart.com/Europe/Spain/Madrid/FAQ"> >> > value="/images/offersBanners/sw04.swf?binfot=We offer >>fantastic rates for selected weeks or days!!&blinkt=Click

Re: Persistent variables in python

2006-12-27 Thread [EMAIL PROTECTED]
> That's a matter of taste. Try replacing the try...except block with > hasattr: > > def doStuff(): > if hasattr(doStuff, timesUsed): > doStuff.timesUsed += 1 > else: > doStuff.timesUsed = 1 > do_common_code > Ok, it is a matter of taste and I prefer the try/except way

DOS, UNIX and tabs

2006-12-27 Thread Ben
Hi, I have a python script on a unix system that runs fine. I have a python script on a windows system that runs fine. Both use tabs to indent sections of the code. I now want to run them on the same system, actually in the same script by combining bits and pieces. But whatever I try my windows ta

DOS, UNIX and tabs

2006-12-27 Thread Ben
Hi, I have a python script on a unix system that runs fine. I have a python script on a windows system that runs fine. Both use tabs to indent sections of the code. I now want to run them on the same system, actually in the same script by combining bits and pieces. But whatever I try my windows ta

Re: how can I modify an imported variable ?

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 18:10 +, yomgui wrote: > actually, it is not linked to threading but to the scope. > the second attempt to access MyPackage.aVariable > is inside the __init__ of a class > and this seems to be the problem. > > I believe it is a genuine python bug. Please post a minimal b

Re: DOS, UNIX and tabs

2006-12-27 Thread Ben
I've found the unexpand command, which seems to do the trick. However, it outputs to standard output, and I haven't worked out yet how to capture that output to a file... Ben Ben wrote: > Hi, > > I have a python script on a unix system that runs fine. I have a python > script on a windows system

Passing variable number of named arguments

2006-12-27 Thread Ramashish Baranwal
Hi, I need to process few out of a variable number of named arguments in a function and pass the remaining to another function that also takes variable number of named arguments. Consider this simple example, def fun1(**kwargs): print kwargs.keys() def fun2(**kwargs): # get id param

Re: BeautifulSoup bug when ">>>" found in attribute value

2006-12-27 Thread Duncan Booth
John Nagle <[EMAIL PROTECTED]> wrote: > It's worse than that. Look at the last line of BeautifulSoup > output: > > &linkurl;=/Europe/Spain/Madrid/Apartments/Offer/2408" /> > > That "/>" doesn't match anything. We're outside a tag at that point. > And it was introduced by Beautifu

Re: DOS, UNIX and tabs

2006-12-27 Thread Grant Edwards
On 2006-12-27, Ben <[EMAIL PROTECTED]> wrote: > I've found the unexpand command, which seems to do the trick. However, > it outputs to standard output, and I haven't worked out yet how to > capture that output to a file... unexpand file2 -- Grant Edwards grante Yow!

Re: DOS, UNIX and tabs

2006-12-27 Thread Ben
Great - that worked.Thanks! Is that a general method in linux you can always use to redirect standard output to a file? Cheers, Ben Grant Edwards wrote: > On 2006-12-27, Ben <[EMAIL PROTECTED]> wrote: > > I've found the unexpand command, which seems to do the trick. However, > > it outputs to s

Re: Passing variable number of named arguments

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 10:37 -0800, Ramashish Baranwal wrote: >[...] > def fun2(**kwargs): > # get id param > id = kwargs.pop('id', '') > # pass on remaining to fun1 > fun1(kwargs) > > When I try to call fun2 I get the following error- > > TypeError: fun1() takes exactly 0 argument

Re: DOS, UNIX and tabs

2006-12-27 Thread Grant Edwards
On 2006-12-27, Ben <[EMAIL PROTECTED]> wrote: >>> I've found the unexpand command, which seems to do the trick. However, >>> it outputs to standard output, and I haven't worked out yet how to >>> capture that output to a file... >> >> unexpand file2 > Great - that worked.Thanks! > > Is that a gen

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-27 Thread Keith Keller
["Followup-To:" header set, but it's best not to followup at all.] On 2006-12-27, Raff <[EMAIL PROTECTED]> wrote: > Xah Lee wrote: >> I don't know OpenGL, but i think it is a low-level crap, and have done ^^^ >> the industry huge irreparable

Re: Fuzzy string comparison

2006-12-27 Thread Steve Bergman
Thanks, all. Yes, Levenshtein seems to be the magic word I was looking for. (It's blazingly fast, too.) I suspect that if I strip out all the punctuation, etc. from both the itemnumber and description columns, as suggested, and concatenate them, pairing the record with its closest match in the ot

Re: DOS, UNIX and tabs

2006-12-27 Thread Sebastian 'lunar' Wiesner
Ben <[EMAIL PROTECTED]> typed > I have a python script on a windows system that runs fine. Both use > tabs to indent sections of the code. Just a tip for you: In python you never use tabs for indentation. The python style guide [1] recommends four spaces per indentation level. [1] http://www.pyt

Re: getting a process's PID

2006-12-27 Thread eldorado
On Wed, 27 Dec 2006, Erik Johnson wrote: > > "eldorado" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'") > h = g.readlines() > g.close() > h >> ['87334\012'] > h = h[:-1] > h >> [] > > Oh

Re: persistant gloabl vars (very newbie) ?

2006-12-27 Thread Stef Mientki
> other module that has done 'from init import *'. > > If you want that kind of behaviour it is better to use: 'import init' and > refer to the variables as init.X and init.Y so that you can change them. > Whether that is a good idea is another matter. > > There are other reasons for not using th

Re: Iterating over several lists at once

2006-12-27 Thread Erik Johnson
"Gal Diskin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > On Dec 13, 3:47 pm, "Gal Diskin" <[EMAIL PROTECTED]> wrote: > > Hi, > > I am writing a code that needs to iterate over 3 lists at the same > > time, i.e something like this: > > > > for x1 in l1: > > for x2 in l2: >

Re: getting a process's PID

2006-12-27 Thread Sebastian 'lunar' Wiesner
eldorado <[EMAIL PROTECTED]> typed > Hello, > > I am trying to get python to give me the PID of a process (in this > case > HUB). I have it working, except for the fact that the output includes > \012 (newline). Is there a way to ask python not to give me a > newline? > > Python 1.4 (Oct 14 19

Re: Iterating over several lists at once

2006-12-27 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Gal Diskin" <[EMAIL PROTECTED]> wrote: > Hi, > I am writing a code that needs to iterate over 3 lists at the same > time, i.e something like this: > > for x1 in l1: > for x2 in l2: > for x3 in l3: > print "do something with", x1, x2, x3 >

Re: getting a process's PID

2006-12-27 Thread eldorado
On Wed, 27 Dec 2006, Sebastian 'lunar' Wiesner wrote: > eldorado <[EMAIL PROTECTED]> typed > >> Hello, >> >> I am trying to get python to give me the PID of a process (in this >> case >> HUB). I have it working, except for the fact that the output includes >> \012 (newline). Is there a way to as

Superclass for Errors?

2006-12-27 Thread tac-tics
I have a program which has a GUI front-end which that runs a separate thread to handle all the important stuff. However, if there is a problem with the important stuff, I want the GUI to raise a MessageBox alert to indicate this. For exceptions, I can simply use a catch-all except statement like:

Re: getting a process's PID

2006-12-27 Thread Sebastian 'lunar' Wiesner
eldorado <[EMAIL PROTECTED]> typed [snip] > This looks cleaner than the way I was going. I created a file > called ps.py > > #!/usr/local/bin/python > import os > g = os.popen("ps -e -o pid,command") > for line in g.readlines(): > if 'HUB' in line: > pid = line.strip().

Re: How to suppress the output of an external module ?

2006-12-27 Thread MRAB
Scott David Daniels wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > > I'm writing a program which uses an external module written in C > > and calls a function provided by the module to do my job. The > > function produces a lot of output to the stdout. > > > > Is there a way to suppress the out

Re: Superclass for Errors?

2006-12-27 Thread Christian Joergensen
"tac-tics" <[EMAIL PROTECTED]> writes: > I have a program which has a GUI front-end which that runs a separate > thread to handle all the important stuff. However, if there is a > problem with the important stuff, I want the GUI to raise a MessageBox > alert to indicate this. > > For exceptions, I

Re: getting a process's PID

2006-12-27 Thread eldorado
On Wed, 27 Dec 2006, Sebastian 'lunar' Wiesner wrote: > eldorado <[EMAIL PROTECTED]> typed > > Strange!? On my system with Python 2.4 I don't get this error. It is > likely to be a problem of your really ancient python version. Do I > guess correctly from your previous postings, that you're still

Re: Superclass for Errors?

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 12:13 -0800, tac-tics wrote: > I have a program which has a GUI front-end which that runs a separate > thread to handle all the important stuff. However, if there is a > problem with the important stuff, I want the GUI to raise a MessageBox > alert to indicate this. > > For e

ANN: Skimpy CAPTCHA adds WAVE audio, and a problem

2006-12-27 Thread aaronwmail-usenet
SKIMPY CAPTCHA ADDS AUDIO, AND A PROBLEM [or what I did over xmas weekend at the inlaws -- python/web/audio experts skip to the bottom and solve my problem please.] Skimpy Gimpy CAPTCHA now supports WAVE audio output to help people with visual impairments answer Skimpy challenges. Read more, try

Re: Mod_python

2006-12-27 Thread J. Clifford Dyer
Lad wrote: > Maxim Sloyko wrote: >> Lad wrote: >>> In my web application I use Apache and mod_python. >>> I allow users to upload huge files( via HTTP FORM , using POST method) >>> I would like to store the file directly on a hard disk and not to >>> upload the WHOLE huge file into server's memory

re: loose methods: Smalltalk asPython

2006-12-27 Thread Jan Theodore Galkowski
>Guido was opposed to modifying builtin types before Java existed. It's >similar to his opposition to dynamic syntax. Opposition or not, the language definition is there. Surely Smalltalk's OO style can be respected. Smalltalkers have been doing OO in a dynamic context longer than many. There

urllib.urlopen unwanted password prompts - documentation problem

2006-12-27 Thread John Nagle
If you try to open a password protected page with "urllib.urlopen()", you get "Enter username for EnterPassword at example.com:" on standard output, followed by a read for input! This seems to be an undocumented feature, if not a bug. Definitely the documentation for "urllib" should

Feasible in Python ? list of object , with two exeptional objects

2006-12-27 Thread Osiris
Is the following intuitively feasible in Python: I have an array (I come from C) of identical objects, called sections. These sections have some feature, say a length, measured in mm, which is calculated by a method A_length of the instantiation of the Section's class. Only, two elements in the arr

Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-27 Thread Xah Lee
Here's their license: http://www.vpython.org/webdoc/visual/license.txt I read it wrong before. Thanks for correction. This is superb! I'll be looking into vpython! Xah Ravi Teja wrote: > Xah Lee wrote: > > > Regarding VisualPython... i saw a demo in 2002 by a professor > > friend. I think it i

Re: how can I modify an imported variable ?

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 13:45, yomgui wrote: your sample code works, but mine doesn't. it must be a multi-thread issue. I am certain that I am modifying MyPackage.aVariable before using it. Both threads are importing MyPackage, but the modification of MyPackage.aVariable is not seen by the othe

Re: Fuzzy string comparison

2006-12-27 Thread John Machin
Steve Bergman wrote: > Thanks, all. Yes, Levenshtein seems to be the magic word I was looking > for. (It's blazingly fast, too.) > > I suspect that if I strip out all the punctuation, etc. from both the > itemnumber and description columns, as suggested, and concatenate them, > pairing the record

Getting unicode escape sequence from unicode character?

2006-12-27 Thread Kenneth McDonald
Given a Python unicode character (string of length one), how would I find out the \u escape sequence for it? This isn't obvious from the docs I've been looking through. Thanks, Ken -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib.urlopen unwanted password prompts - documentation problem

2006-12-27 Thread John J. Lee
John Nagle <[EMAIL PROTECTED]> writes: >If you try to open a password protected page with "urllib.urlopen()", you > get > > "Enter username for EnterPassword at example.com:" > > on standard output, followed by a read for input! This seems to be an > undocumented feature, if not a bu

Re: Feasible in Python ? list of object , with two exeptional objects

2006-12-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Osiris wrote: > I have an array (I come from C) of identical objects, called sections. > These sections have some feature, say a length, measured in mm, which > is calculated by a method A_length of the instantiation of the > Section's class. > Only, two elements in the arr

Re: Getting unicode escape sequence from unicode character?

2006-12-27 Thread Carl Banks
Kenneth McDonald wrote: > Given a Python unicode character (string of length one), how would I > find out the \u escape sequence for it? This isn't obvious from the > docs I've been looking through. You can use the ord builtin, or the encode method with "unicode_escape": >>> a = u'\u1234' >>>

dbm

2006-12-27 Thread Julien Cigar
Hello list, I have a dbm "database" which needs to be accessed/writed by multiple processes. At the moment I do something like : @with_lock def _save(self): f = shelve.open(self.session_file, 'c') try: f[self.sid] = self.data finally: f.clo

Re: Feasible in Python ? list of object , with two exeptional objects

2006-12-27 Thread Paul McGuire
"Osiris" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the following intuitively feasible in Python: > I have an array (I come from C) of identical objects, called sections. > These sections have some feature, say a length, measured in mm, which > is calculated by a method A_len

Re: Mod_python

2006-12-27 Thread Graham Dumpleton
Maxim Sloyko wrote: > Lad wrote: > > In my web application I use Apache and mod_python. > > I allow users to upload huge files( via HTTP FORM , using POST method) > > I would like to store the file directly on a hard disk and not to > > upload the WHOLE huge file into server's memory first. > > C

re: loose methods: Smalltalk asPython

2006-12-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jan Theodore Galkowski wrote: >>Guido was opposed to modifying builtin types before Java existed. It's >>similar to his opposition to dynamic syntax. > > The other is placing those builtins at the top of their own object > hierarchy. Is "int", properly speaking, a descen

Re: loose methods: Smalltalk asPython

2006-12-27 Thread Carl Banks
Jan Theodore Galkowski wrote: > > We've not had > > an excellent dynamic OO language since Smalltalk, IMO. I would say that "excellence" in object oriented programming is not a strong design goal of Python. Python tries to support OOP well, but not to enhance OOP to the detriment of other, more i

failing to instantiate an inner class because of order of inner classes

2006-12-27 Thread Pyenos
class model:pass class view: model() class controller: model() I can instantiate clsss model from inside class view but I can't instantiate class model from inside controller, due to the nature of python interpreter. I wish to circumvent this restriction by: class model:pass clas

Re: DOS, UNIX and tabs

2006-12-27 Thread Ben Finney
"Sebastian 'lunar' Wiesner" <[EMAIL PROTECTED]> writes: > Just a tip for you: In python you never use tabs for indentation. For some value of "you". > The python style guide [1] recommends four spaces per indentation > level. > > [1] http://www.python.org/dev/peps/pep-0008/ It's not quite absol

Re: failing to instantiate an inner class because of order of inner classes

2006-12-27 Thread Edward Kozlowski
Pyenos wrote: > class model:pass > class view: > model() > class controller: > model() > > I can instantiate clsss model from inside class view but I can't > instantiate class model from inside controller, due to the nature of > python interpreter. > > I wish to circumvent this rest

failing to instantiate an inner class because of its order

2006-12-27 Thread Pyenos
class Model: Controller() class View: Model() class Controller:pass Python interpreter complains that 'Name Error: Controller()' not defined. -- http://mail.python.org/mailman/listinfo/python-list

Re: failing to instantiate an inner class because of order of inner classes

2006-12-27 Thread Pyenos
"Edward Kozlowski" <[EMAIL PROTECTED]> writes: > Pyenos wrote: > > class model:pass > > class view: > > model() > > class controller: > > model() > > > > I can instantiate clsss model from inside class view but I can't > > instantiate class model from inside controller, due to the

Re: getting a process's PID

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 17:33, eldorado wrote: Yes, I was running this on a box that had 1.4 - I just tested it on a box that has 2.3.5 and it runs perfect. Your changes also allow it to be run on the boxes that still have 1.4 Ouch! 1.4 is really really ancient! Even the most conservative li

Re: failing to instantiate an inner class because of its order

2006-12-27 Thread Pyenos
Pyenos <[EMAIL PROTECTED]> writes: > class Model: > Controller() #problem > > class View: > Model() > > class Controller:pass > > > Python interpreter complains that 'Name Error: Controller()' not defined. > Following Edward Kozlowski's advice I can suggest to myself

Re: Persistent variables in python

2006-12-27 Thread Gabriel Genellina
At Tuesday 26/12/2006 21:06, Steven D'Aprano wrote: > It just feels so ugly to use try/except to enable the variable but I've > found it useful at least once. That's a matter of taste. Try replacing the try...except block with hasattr: def doStuff(): if hasattr(doStuff, timesUsed):

Re: persistant gloabl vars (very newbie) ?

2006-12-27 Thread Erik Johnson
> but it's still not quit handy > > # initialization file (init1.py) > import time; > xx = 44 > > # main file was > print xx > x=time.time() > > # main file should become > print init1.xx > x=init1.time.time() > > so even for the "standard" functions like "time" I've to include the > preceeding mo

  1   2   >