Re: Combining C and Python

2006-12-27 Thread Osiris
On Wed, 27 Dec 2006 16:12:02 +0100, Osiris <[EMAIL PROTECTED]> wrote: >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 >Unive

Re: Hooking any/all 'calls'

2006-12-27 Thread fumanchu
Kevin Little wrote: > In Python 2.4 or 2.5, what is the easiest way to hook any and all > callables such that designated code is executed at the very start and > end of each call? (Yes, I'm trying to come up with a little debugging > tool!:) Is there a single metaclass who's "__call__" method can b

Re: I'm having trouble understanding scope of a variable in a subclass

2006-12-27 Thread Pyenos
Pyenos <[EMAIL PROTECTED]> writes: > Thanks for clarifying the definitions of nested class and > subclass. However, it did not solve my original problem, and I have > redefined my question: > > class Class1: > class Class2: > class Class3: > def __init__(self): >

Re: I'm having trouble understanding scope of a variable in a subclass

2006-12-27 Thread Pyenos
Thanks for clarifying the definitions of nested class and subclass. However, it did not solve my original problem, and I have redefined my question: class Class1: class Class2: class Class3: def __init__(self): self.var="var" class Class4:

Re: Passing variable number of named arguments

2006-12-27 Thread Ramashish Baranwal
Carsten Haese wrote: > 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- > > > > T

Re: I'm having trouble understanding scope of a variable in a subclass

2006-12-27 Thread Steven D'Aprano
On Thu, 28 Dec 2006 15:31:26 +1100, Pyenos wrote: > Approach 1: > > class Class1: > class Class2: > def __init__(self):self.variable="variable" > > class Class3: > def method():print Class1().Class2().variable #problem These are NE

re: loose methods: Smalltalk asPython

2006-12-27 Thread Jan Theodore Galkowski
>> > 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 important goals. okay.

Re: I'm having trouble understanding scope of a variable in a subclass

2006-12-27 Thread Pyenos
class Class1: class Class2(Class1): variable="variable" class Class3(Class2): print Class1().Class2().variable #problem Also, why is this wrong? -- http://mail.python.org/mailman/listinfo/python-list

Re: socket.gaierror: (-2, 'Name or service not known')

2006-12-27 Thread flamesrock
Ahh that works! thanks a bunch Gabriel Gabriel Genellina wrote: > At Thursday 28/12/2006 00:11, flamesrock wrote: > > > >The problem is that, while the login opener works, the > >update_city_params opener does not. It returns the following error: > >[EMAIL PROTECTED] ~/send $ python send.py > >Tra

I'm having trouble understanding scope of a variable in a subclass

2006-12-27 Thread Pyenos
Approach 1: class Class1: class Class2: def __init__(self):self.variable="variable" class Class3: def method():print Class1().Class2().variable #problem Approach 1.1: class Class1: class Class2:

Re: socket.gaierror: (-2, 'Name or service not known')

2006-12-27 Thread Gabriel Genellina
It may be a bug in Python, or in the sockets implementation, or somewhere. Anyway, choose_boundary() should be robust enough to catch the possible exception and act accordingly, I think. The underlying bug was already reported and solved: http://sourceforge.net/tracker/index.php?func=detail&

Re: socket.gaierror: (-2, 'Name or service not known')

2006-12-27 Thread Gabriel Genellina
At Thursday 28/12/2006 00:11, flamesrock wrote: The problem is that, while the login opener works, the update_city_params opener does not. It returns the following error: [EMAIL PROTECTED] ~/send $ python send.py Traceback (most recent call last): File "send.py", line 14, in ? opener.open

Re: DOS, UNIX and tabs

2006-12-27 Thread Steven D'Aprano
On Wed, 27 Dec 2006 20:15:33 +0100, Sebastian 'lunar' Wiesner wrote: > 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

re: loose methods: Smalltalk asPython

2006-12-27 Thread Jan Theodore Galkowski
[snipness] >I don't think the response was meant to say that it must be bad but >that it won't show up as feature in Python as long as the BDFL thinks >it's bad. [snipness] oh, i was not proposing any change to the language. it's fine as it is. i would be reluctant to change it. i want it chan

socket.gaierror: (-2, 'Name or service not known')

2006-12-27 Thread flamesrock
Hi, Basically, I'm trying to send a multipart form to a server using some code from aspn.. here it is: MultipartPostHandler: http://pastie.caboo.se/29833 import MultipartPostHandler, urllib2, cookielib cookies = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cook

Re: Persistent variables in python

2006-12-27 Thread Steven D'Aprano
On Wed, 27 Dec 2006 10:11:11 -0800, [EMAIL PROTECTED] wrote: > >> 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_c

Re: loose methods : Smalltalk asPython

2006-12-27 Thread Steven D'Aprano
On Wed, 27 Dec 2006 09:28:17 -0500, Jean-Paul Calderone wrote: > 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 th

Re: can't instantiate following inner class

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 23:55, Gian Mario Tagliaretti wrote: class One(object): def __init__(self): whatever don't forget to call __init__ on new style classes otherwise you can pass arbitrary arguments when instantiating the class e.g.: one = One(a, b) but python will silently ig

Re: Hooking any/all 'calls'

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 23:07, Kevin Little wrote: In Python 2.4 or 2.5, what is the easiest way to hook any and all callables such that designated code is executed at the very start and end of each call? (Yes, I'm trying to come up with a little debugging tool!:) Is there a single metaclass who

Re: Python 2.4.4 vs. 2.3.6

2006-12-27 Thread Jonathan Smith
I would say 2.4.4, since it has the latest bugfixes of the series most distros use. --- Sent with ChatterEmail+ True push email for the Treo Smartphone http://get.chatteremail.com -Original Message- From: [EMAIL PROTECTED] Date: Wednesday, Dec 27, 2006 9:05 pm Subject:

Hooking any/all 'calls'

2006-12-27 Thread Kevin Little
In Python 2.4 or 2.5, what is the easiest way to hook any and all callables such that designated code is executed at the very start and end of each call? (Yes, I'm trying to come up with a little debugging tool!:) Is there a single metaclass who's "__call__" method can be wrapped to do this? TIA,

Python 2.4.4 vs. 2.3.6

2006-12-27 Thread sndive
My top priority is stability of the interpreter. With that in mind which version should I get: 2.4.4, 2.3.6 or something else. I will be using gcc 2.3.2(x86), 3.3(arm) and 3.4.3(arm) to cross compile it depending on the (embedded) platform. Thank you. -- http://mail.python.org/mailman/listinfo/

Re: Help with small program

2006-12-27 Thread gokkog
"Paul Watson 写道: Interesting impl in Python! I am wondering what if the requirement is to find the minimum number of coins which added to the "fin" sum... -- http://mail.python.org/mailman/listinfo/python-list

Re: can't instantiate following inner class

2006-12-27 Thread Gian Mario Tagliaretti
Larry Bates wrote: > Proper way is: > > class One: > def __init__(self): > self.Two=Two() > > Of course Two must be a proper class definition also. > > class Two: > def __init__(self): > self.Three=Three() > > class Three: > pass just as a side note probably it wou

Re: can't instantiate following inner class

2006-12-27 Thread buffi
Pyenos wrote: > class One: > Two() #can't instantiate > class Two: > Three() #can't instantiate > class Three:pass Python parses code from top to bottom. Since it first tries to read the class One and finds the class Two inside it, it throws an error since it is not defined yet. R

Re: DOS, UNIX and tabs

2006-12-27 Thread Erik Johnson
"Ben Finney" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "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 indent

Re: DOS, UNIX and tabs

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 20:09, Ben Finney wrote: > The python style guide [1] recommends four spaces per indentation > level. > > [1] http://www.python.org/dev/peps/pep-0008/ It's not quite absolute on the topic: For new projects, spaces-only are strongly recommended over tabs. Of course

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

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 20:37, Pyenos wrote: class Model: def fuck(self):print "fuck!" class View: Model() #this part is fine class Controller: def __init__(self): self.Model=Model() Controller().Model.fuck() #actually slight problem in previous solution

Re: can't instantiate following inner class

2006-12-27 Thread Larry Bates
Pyenos wrote: > class One: > Two() #can't instantiate > class Two: > Three() #can't instantiate > class Three:pass > > > You keep posting examples with the same problems that others have addressed. It appears you are trying to write Python in a way that some "other" language wor

Re: Superclass for Errors?

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 17:13, tac-tics wrote: For exceptions, I can simply use a catch-all except statement like: try: ... except Exception, error: JOptionPane.showMessageDialog(self, "Error: %s" % error) Normally, I could simply use a regular except: but then I don't have

can't instantiate following inner class

2006-12-27 Thread Pyenos
class One: Two() #can't instantiate class Two: Three() #can't instantiate class Three:pass -- http://mail.python.org/mailman/listinfo/python-list

Re: Fuzzy string comparison

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 18:59, John Machin wrote: > Thanks, all. Yes, Levenshtein seems to be the magic word I was looking > for. (It's blazingly fast, too.) In case you need something more, this article is a good starting point: Record Linkage: A Machine Learning Approach, A Toolbox, and A D

Re: DOS, UNIX and tabs

2006-12-27 Thread Roel Schroeven
Ben schreef: > 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 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: 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: 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().

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

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

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

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

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

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

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

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

  1   2   >