Setting timeout for read api

2006-03-04 Thread Swaroop
PLS HELP..I am working on socket programming as part of my final year project. I want to know how to set a timeout on read api that reads from a socket. Is it possible using SIGALRM signal?Will setting O_NONBLOCK flag of the socket help? Is there any other way to do it? --

Re: add an asynchronous exception class

2006-03-04 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes: PEP 348 addresses this by moving special exceptions out of the Exception hierarchy: http://www.python.org/peps/pep-0348.html I see that suggestion was rejected (it needed changing the semantics of except:). Also, PEP 348 was rejected and is a

Re: Setting timeout for read api

2006-03-04 Thread Paul Rubin
Swaroop [EMAIL PROTECTED] writes: PLS HELP..I am working on socket programming as part of my final year project. I want to know how to set a timeout on read api that reads from a socket. Is it possible using SIGALRM signal?Will setting O_NONBLOCK flag of the socket help? Is there any other way

Re: do design patterns still apply with Python?

2006-03-04 Thread Paul Rubin
Paul Boddie [EMAIL PROTECTED] writes: Sandboxed code is a real obvious one. I don't disagree that this is true in general, but is that actually covered in the design patterns book [1] or in other related literature? It's been a while since I looked at the design patterns book and I don't

Re: socket freezes

2006-03-04 Thread Steve Holden
Dennis Lee Bieber wrote: On Fri, 03 Mar 2006 20:12:22 +, Luis P. Mendes [EMAIL PROTECTED] declaimed the following in comp.lang.python: I'm beggining to suspect that the problem has to do with a discontinual of service of the ISP. It provides me a dynamic IP address not a static one.

Re: add an asynchronous exception class

2006-03-04 Thread Steven D'Aprano
On Sat, 04 Mar 2006 08:41:48 +0100, Fredrik Lundh wrote: Paul Rubin wrote: I'd like to suggest adding a builtin abstract class to Python called AsynchronousException, which would be a subclass of Exception. The only asynchronous exception I can think of right now is KeyboardInterrupt, so

Re: stripping spaces in front of line

2006-03-04 Thread Steve Holden
[EMAIL PROTECTED] wrote: hi wish to ask a qns on strip i wish to strip all spaces in front of a line (in text file) f = open(textfile,rU) while (1): line = f.readline().strip() if line == '': break print line f.close() in textfile, i added

Re: add an asynchronous exception class

2006-03-04 Thread Robert Kern
Paul Rubin wrote: Fredrik Lundh [EMAIL PROTECTED] writes: PEP 348 addresses this by moving special exceptions out of the Exception hierarchy: http://www.python.org/peps/pep-0348.html I see that suggestion was rejected (it needed changing the semantics of except:). Also, PEP 348 was

build windows module for python-2.4

2006-03-04 Thread william
Does any one having working python 2.4 compiler can give some details on how to set it up ? I've read lot of different website, but some are outdated, others referencing dead links, ... I would just use an existing python 2.3 module (VC6) to python-2.4. I think the best is to recompile it with

Re: stripping spaces in front of line

2006-03-04 Thread Peter Otten
[EMAIL PROTECTED] wrote: f = open(textfile,rU) while (1): line = f.readline().strip() if line == '': break print line f.close() Be warned that your code doesn't read the whole file if that file contains lines with only whitespace characters. If you

Re: How to Mount/Unmount Drives on Windows?

2006-03-04 Thread Christos Georgiou
On 25 Feb 2006 18:06:15 -0800, rumours say that [EMAIL PROTECTED] might have written: Hello, snip I do not know how to mount or unmount drives on Windows. I think that it could possibly be done with a DOS command (using os.system()). mountvol is the command you want. I know it's in winxp, I

Re: Making a tiny script language using python: I need a string processing lib

2006-03-04 Thread Christos Georgiou
On 2 Mar 2006 17:53:38 -0800, rumours say that Sullivan WxPyQtKinter [EMAIL PROTECTED] might have written: I do not know if there is any lib specially designed to process the strings in scipt language. for example: I hope to process the stringprint a,b,c,d,e in the formcommand argumentlist and

Re: Writing an OPC client with Python ?

2006-03-04 Thread Jarek Zgoda
pierlau napisał(a): You can call methods/functions in a .dll using ctypes. http://starship.python.net/crew/theller/ctypes/ I have tried with ctypes. I acheived to load the library it works when I use following instructions : print windll.OPCDAAuto or print cdll.OPCDAAuto (i see an

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Roy Smith: I like to create a top-level exception class to encompass all the possible errors in a given module, then subclass that. This way, if you want to catch anything to goes wrong in a call, you can catch the top-level exception class without having to enumerate them all. What do you

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
James Stroud: Which suggests that try: except HTTPException: will be specific enough as a catchall for this module. The following, then, should catch everything you mentioned except the socket timeout: Your conclusion may be (almost) right in this case. I just don't like this approach.

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Peter Hansen: Good code should probably have a very small set of real exception handling cases, and one or two catchalls at a higher level to avoid barfing a traceback at the user. Good point. A catchall seems like a bad idea, since it also catches AttributeErrors and other bugs in the

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Paul Rubin http://[EMAIL PROTECTED]: We have to get Knuth using Python. Perhaps a MIX emulator and running TeXDoctest on his books will convince him.. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: build windows module for python-2.4

2006-03-04 Thread Steve Holden
[EMAIL PROTECTED] wrote: Does any one having working python 2.4 compiler can give some details on how to set it up ? I've read lot of different website, but some are outdated, others referencing dead links, ... I would just use an existing python 2.3 module (VC6) to python-2.4. I think

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Steven D'Aprano: ExpectedErrors = (URLError, IOError) ErrorsThatCantHappen = try: process_things() except ExpectedErrors: recover_from_error_gracefully() except ErrorsThatCantHappen: print Congratulations! You have found a program bug! print For a $327.68 reward, please send the

Re: How to except the unexpected?

2006-03-04 Thread Jorge Godoy
Rene Pijlman [EMAIL PROTECTED] writes: With low coverage, yes. But unit testing isn't the answer for this particular problem. For example, yesterday my app was surprised by an httplib.InvalidURL since I hadn't noticed this could be raised by robotparser (this is undocumented). If that fact

Re: How to except the unexpected?

2006-03-04 Thread Roy Smith
Rene Pijlman [EMAIL PROTECTED] wrote: A catchall seems like a bad idea, since it also catches AttributeErrors and other bugs in the program. All of the things like AttributeError are subclasses of StandardError. You can catch those first, and then catch everything else. In theory, all

Re: Package organization: where to put 'common' modules?

2006-03-04 Thread Kent Johnson
fortepianissimo wrote: Say I have the following package organization in a system I'm developing: A |B |C |D I have a module, say 'foo', that both package D and B require. What is the best practice in terms of creating a 'common' package that hosts 'foo'? I want

Re: Write a GUI for a python script?

2006-03-04 Thread [EMAIL PROTECTED]
Another option would be FarPy GUIE: http://farpy.holev.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Jorge Godoy: Rene Pijlman: my app was surprised by an httplib.InvalidURL since I hadn't noticed this could be raised by robotparser (this is undocumented). It isn't undocumented in my module. From 'pydoc httplib': That's cheating: pydoc is reading the source :-) What I meant was, I'm

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Roy Smith: In theory, all exceptions which represent problems with the external environment (rather than programming mistakes) should derive from Exception, but not from StandardError. Are you sure? The class hierarchy for built-in exceptions is: Exception +-- StandardError |

Help with os.spawnv

2006-03-04 Thread Damon Pettitt
I'm not sure if this is how I'm supposed to post, but I saw a thread entitled, Help with os.spawnv, that I wanted to respond to. I believe if you change the variable pyScript from: E:\\Documents and Settings\\Administrator\\Desktop\\Ian\\GIS\\Python\\subProcess2.py to 'E:\Documents and

Re: Package organization: where to put 'common' modules?

2006-03-04 Thread Jorge Godoy
Kent Johnson [EMAIL PROTECTED] writes: What I do is run always from the base directory (violates your first requirement). I make a util package to hold commonly used code. Then B and D both use from util import foo In Python 2.5 you will be able to say (in D, for example) from ..util

Re: Writing an OPC client with Python ?

2006-03-04 Thread F. GEIGER
About a year ago I dev'ed a host app in Python (2.3 at that time) to control a KUKA KR16 robot. Comm was over OPC. The OPC 2.0 server was inst'ed on the KRC2. What I was needed to do, was to install the appropriate (i.e. delivere together w/ the server) client software and to take Mark Hammonds

Re: Win32api, pyHook, possibly win32com, not sure XD, thats why I'm posting

2006-03-04 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Is there a way to hide a python instance from the Task Manager process list? Try sony's rootkit. Or any other. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: do design patterns still apply with Python?

2006-03-04 Thread Paul Novak
A lot of the complexity of design patterns in Java falls away in Python, mainly because of the flexibility you get with dynamic typing. For a Pythonic Perspective on Patterns, Python Programming Patterns by Thomas W. Christopher is definitely worth tracking down. It looks like it is out of

Re: How to except the unexpected?

2006-03-04 Thread Roy Smith
In article [EMAIL PROTECTED], Rene Pijlman [EMAIL PROTECTED] wrote: Roy Smith: In theory, all exceptions which represent problems with the external environment (rather than programming mistakes) should derive from Exception, but not from StandardError. Are you sure? The class

Re: do design patterns still apply with Python?

2006-03-04 Thread Bo Yang
Paul Novak 写道: A lot of the complexity of design patterns in Java falls away in Python, mainly because of the flexibility you get with dynamic typing. I agree with this very much ! In java or C++ or all such static typing and compiled languages , the type is fixed on in the compile phrase ,

Re: do design patterns still apply with Python?

2006-03-04 Thread Bo Yang
Paul Novak : A lot of the complexity of design patterns in Java falls away in Python, mainly because of the flexibility you get with dynamic typing. I agree with this very much ! In java or C++ or all such static typing and compiled languages , the type is fixed on in the compile phrase , so

Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
I have made and recently posted a libary I made to do Modular Arithmetic and Prime numbers on my website at http://www.geocities.com/brp13/Python/index.html . I am currently in a crypotology class, and am working on building a RSA public key cryptology system for a class project. I am building

Re: socket freezes

2006-03-04 Thread Luis P. Mendes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thank you all for your suggestions. Luis P. Mendes -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFECb5AHn4UHCY8rB8RAmeLAKCmSVfTvgQ94NPnJlD2QqdbMwVFXACdGFAh

Re: Python advocacy in scientific computation

2006-03-04 Thread Terry Hancock
On 3 Mar 2006 17:33:31 -0800 sturlamolden [EMAIL PROTECTED] wrote: 1. Time is money. Time is the only thing that a scientist cannot afford to lose. Licensing fees for Matlab is not an issue. If we can spend $1,000,000 on specialised equipment we can pay whatever Mathworks or Lahey charges as

spliting on :

2006-03-04 Thread s99999999s2003
hi i have a file with xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx:yyy i wanna split on : and get all the yyy and print the whole line out so i did print line.split(:)[-1] but line 4 and 5 are not printed as there is no : to

Re: spliting on :

2006-03-04 Thread Duncan Booth
[EMAIL PROTECTED] wrote: print line.split(:)[-1] but line 4 and 5 are not printed as there is no : to split. It should print a blank at least. how to print out lines 4 and 5 ? eg output is yyy yyy yyy yyy if : in line: print line.split(:)[-1] else: print what's the

Re: Write a GUI for a python script?

2006-03-04 Thread Bill Maxwell
On Fri, 3 Mar 2006 07:19:34 -0500, Peter Decker [EMAIL PROTECTED] wrote: I started with wxPython and struggled with it for a long time. I was able to get the job done, but using it never seemed natural. Then I found the Dabo project, whose ui module wraps wxPython into a much more Pythonic,

Re: add an asynchronous exception class

2006-03-04 Thread Christian Stapfer
Paul Rubin http://[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Fredrik Lundh [EMAIL PROTECTED] writes: PEP 348 addresses this by moving special exceptions out of the Exception hierarchy: http://www.python.org/peps/pep-0348.html I see that suggestion was rejected (it needed

Re: Python advocacy in scientific computation

2006-03-04 Thread Alex Martelli
Terry Hancock [EMAIL PROTECTED] wrote: In fact, if I had one complaint about Python, it was the with a suitable array of add-ons caveat. The proprietary alternative had all of that rolled into one package (abeit it glopped into one massive and arcane namespace), whereas there was no Python

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
I have discoved that the mod function isn't quite right in dealing with powers, but, I'll have it fixed shortly. -- http://mail.python.org/mailman/listinfo/python-list

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Alex Martelli
Tuvas [EMAIL PROTECTED] wrote: ... to make sure. For simpler than going to the website, I used the ranint I assume you mean random.randint here. function to pick a random prime number, then ran it through the miller rabin primality test. It's a probabalistic test, which means it isn't

Easy immutability in python?

2006-03-04 Thread Terry Hancock
Is there an *easy* way to make an object immutable in python? Or perhaps I should say one obvious way to do it? Oughtn't there to be one? I've found a thread on how to do this[1], which essentially says something like redefine __setattr__, __delattr__, __hash__, __eq__, __setitem__, delitem__

Re: Python advocacy in scientific computation

2006-03-04 Thread Michael Tobis
There is a range of folks doing scientific programming. Not all of them are described correctly by your summary, but many are. The article is aimed not at them, but rather at institutions that develop engineered Fortran models using multipuurpose teams and formal methods. I appreciate your

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Well, the RSA element's never going to encrypt more than a small, 1 block system except under rare occasions, the primary encryption will be AES128. Thanks for the help though! -- http://mail.python.org/mailman/listinfo/python-list

Re: spliting on :

2006-03-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: hi i have a file with xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx:yyy xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx:yyy i wanna split on : and get all the yyy and print the whole line out so i did print line.split(:)[-1] but line 4 and 5

Re: Python advocacy in scientific computation

2006-03-04 Thread Brian Blais
sturlamolden wrote: Typically a scientist need to: 1. do a lot of experiments 2. analyse the data from experiments 3. run a simulation now and then unless you are a theorist! in that case, I would order this list backwards. 1. Time is money. Time is the only thing that a

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Okay, the bug in my code has been fixed, it should work alot better now... I thought I had tested the power function, but I appearently wasn't even close... But now it works just fine. I guess you are right, I will have to work on a better system to be cryptologically secure. But, at least I have

Re: re-posting: web.py, incomplete

2006-03-04 Thread _wolf
ok, that does it! [EMAIL PROTECTED] a lot! sorry first of all for my adding to the confusion when i jumped to comment on that ``-u`` option thing---of course, **no -u option** means **buffered**, positively, so there is buffering and buffering problems, **with -u option** there is **no buffer**,

Re: Write a GUI for a python script?

2006-03-04 Thread Peter Decker
On 3/4/06, Bill Maxwell [EMAIL PROTECTED] wrote: Dabo does look really nice, but seems like it has a ways to go yet. I downloaded it a couple of weeks ago, and the very first thing I wanted to do doesn't seem to be supported. I tried to create a simple application with a Notebook control

Re: Easy immutability in python?

2006-03-04 Thread jess . austin
Since this is a container that needs to be immutable, like a tuple, why not just inherit from tuple? You'll need to override the __new__ method, rather than the __init__, since tuples are immutable: class a(tuple): def __new__(cls, t): return tuple.__new__(cls, t) cheers, Jess --

Re: How to except the unexpected?

2006-03-04 Thread Roman Susi
Rene Pijlman wrote: Paul Rubin http://[EMAIL PROTECTED]: We have to get Knuth using Python. Perhaps a MIX emulator and running TeXDoctest on his books will convince him.. Or maybe Python written for MIX... -Roman -- http://mail.python.org/mailman/listinfo/python-list

license preamble template

2006-03-04 Thread Xah Lee
I noticed, that in just about all emacs programs on the web (elisp code), it comes with this template text as its preamble: ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software

Re: Easy immutability in python?

2006-03-04 Thread jess . austin
To be clear, in this simple example I gave you don't have to override anything. However, if you want to process the values you place in the container in some way before turning on immutability (which I assume you must want to do because otherwise why not just use a tuple to begin with?), then

generators shared among threads

2006-03-04 Thread jess . austin
hi, This seems like a difficult question to answer through testing, so I'm hoping that someone will just know... Suppose I have the following generator, g: def f() i = 0 while True: yield i i += 1 g=f() If I pass g around to various threads and I want them to always be

Re: do design patterns still apply with Python?

2006-03-04 Thread jess . austin
msoulier wrote: I find that DP junkies don't tend to keep things simple. +1 QOTW. There's something about these political threads that seems to bring out the best quotes. b^) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to except the unexpected?

2006-03-04 Thread Bruno Desthuilliers
Rene Pijlman a écrit : Jorge Godoy: Rene Pijlman: my app was surprised by an httplib.InvalidURL since I hadn't noticed this could be raised by robotparser (this is undocumented). It isn't undocumented in my module. From 'pydoc httplib': That's cheating: pydoc is reading the source :-)

The old round off problem?

2006-03-04 Thread sam
Hello all, I am taking a class in scientific programming at the local college. My problem is that the following difference produces round off errors as the value of x increases. For x = 19 the diference goes to zero.I understand the problem, but am curious as to whether their exists a solution. I

Is there a WSGI sollutions repository somewhere

2006-03-04 Thread Damjan
It seems that WSGI support starts to flourish is there some document or a web site that tracks what's out there, some place to pick and choose WSGI components? -- http://mail.python.org/mailman/listinfo/python-list

Re: PyQt issue

2006-03-04 Thread Damjan
Because you wrote curentText - note the missing t. :) You mean the missing 'r' :) -- http://mail.python.org/mailman/listinfo/python-list

Re: generators shared among threads

2006-03-04 Thread Alex Martelli
[EMAIL PROTECTED] wrote: hi, This seems like a difficult question to answer through testing, so I'm hoping that someone will just know... Suppose I have the following generator, g: def f() i = 0 while True: yield i i += 1 g=f() If I pass g around to

Re: Easy immutability in python?

2006-03-04 Thread Terry Hancock
Whoops I forgot to list the reference. Also, I just finished reading the old thread, so I see some damage-control may be needed. On Sat, 4 Mar 2006 11:52:59 -0600 Terry Hancock [EMAIL PROTECTED] wrote: [1] http://news.hping.org/comp.lang.python.archive/28916.html And more specifically, I'm

Re: Python advocacy in scientific computation

2006-03-04 Thread David Treadwell
On Mar 4, 2006, at 5:55 AM, Dennis Lee Bieber wrote: On Fri, 3 Mar 2006 22:05:19 -0500, David Treadwell [EMAIL PROTECTED] declaimed the following in comp.lang.python: My ability to think of data structures was stunted BECAUSE of Fortran and BASIC. It's very difficult for me to give up my

how to record how long i use the intenet

2006-03-04 Thread b53444
use python use ADSL use windows XP i want to record the time when i get on the internet and off the internet into a txt file HOW? -- http://mail.python.org/mailman/listinfo/python-list

Papers on Dynamic Languages

2006-03-04 Thread Jay Parlar
For one of my grad school classes, I'm writing a paper on Dynamic Languages. What a wonderfully vague topic (but at least it'll let me write about Python). Anyway, I want to talk about things like typing disciplines (weak, strong, etc.),class vs. prototype, JIT technologies in dynamic

XP rich text cut-n-paste

2006-03-04 Thread Paddy
Hi, Is their a colourized editor/shell that allows you to cut and paste the colourized text? Idle, SPE, Eclipse, and pythonwin all seem to nicely colourize both command line input as well as editor windows but when I cut and paste (in this case, into OpenOffice Writer), even the paste-special

Re: Easy immutability in python?

2006-03-04 Thread Terry Hancock
On 4 Mar 2006 10:14:56 -0800 [EMAIL PROTECTED] wrote: Since this is a container that needs to be immutable, like a tuple, why not just inherit from tuple? You'll need to override the __new__ method, rather than the __init__, since tuples are immutable: class a(tuple): def __new__(cls,

Re: spliting on :

2006-03-04 Thread Cyril Bazin
Your file looks like a list of IP adresses. You can use the urllib and urllib2 modules to parse IP adresses.import urllib2for line in open(fileName.txt): addr, port = urllib2.splitport(line) print (port != None) and '' or portCyril -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy immutability in python?

2006-03-04 Thread jess . austin
I guess we think a bit differently, and we think about different problems. When I hear, immutable container, I think tuple. When I hear, my own class that is an immutable container, I think, subclass tuple, and probably override __new__ because otherwise tuple would be good enough as is. I'm

Re: Easy immutability in python?

2006-03-04 Thread Alex Martelli
Terry Hancock [EMAIL PROTECTED] wrote: ... I also am not trying to alter the Python language. I am trying to figure out how to most easily fix __setattr__ etc to act immutably, *using* the existing features. I can already do what I want with some 25-30 lines of code repeated each time I

Re: how to record how long i use the intenet

2006-03-04 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: use python use ADSL use windows XP i want to record the time when i get on the internet and off the internet into a txt file HOW? http://en.wikipedia.org/wiki/Water_clock HTH Gerard -- http://mail.python.org/mailman/listinfo/python-list

Re: Python advocacy in scientific computation

2006-03-04 Thread Terry Hancock
On Sat, 4 Mar 2006 14:23:10 -0500 David Treadwell [EMAIL PROTECTED] wrote: On Mar 4, 2006, at 5:55 AM, Dennis Lee Bieber wrote: On Fri, 3 Mar 2006 22:05:19 -0500, David Treadwell [EMAIL PROTECTED] declaimed the following in comp.lang.python: 3. I demand a general-purpose toolkit, not a

Re: How to except the unexpected?

2006-03-04 Thread James Stroud
Rene Pijlman wrote: Steven D'Aprano: ExpectedErrors = (URLError, IOError) ErrorsThatCantHappen = try: process_things() except ExpectedErrors: recover_from_error_gracefully() except ErrorsThatCantHappen: print Congratulations! You have found a program bug! print For a $327.68

Open source reliability study

2006-03-04 Thread bearophileHUGS
They have used a lot of time and money to find bugs in Python too: http://www.theregister.co.uk/2006/03/03/open_source_safety_report/print.html 0.32 defects per 1,000 lines of code in LAMP, it says. I hope they will show such Python bugs, so Python developers can try to remove them. From the

Re: How to except the unexpected?

2006-03-04 Thread Alex Martelli
James Stroud [EMAIL PROTECTED] wrote: Reraise = (LookupError, ArithmeticError, AssertionError) # And then some try: process_things() except Reraise: raise except: log_error() Why catch an error only to re-raise it? To avoid the following handler[s] -- a pretty

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Paul Rubin
Tuvas [EMAIL PROTECTED] writes: I have made and recently posted a libary I made to do Modular Arithmetic and Prime numbers on my website at http://www.geocities.com/brp13/Python/index.html . I am currently in a crypotology class, and am working on building a RSA public key cryptology system

Re: add an asynchronous exception class

2006-03-04 Thread Paul Rubin
Christian Stapfer [EMAIL PROTECTED] writes: I guess it means the following: Terminating exceptions are exceptions that terminate the *thrower* of the exception. Are you sure? I didn't read it that way. I'm not aware of there ever having been a detailed proposal for resumable exceptions in

Re: The old round off problem?

2006-03-04 Thread Paul Rubin
sam [EMAIL PROTECTED] writes: Hello all, I am taking a class in scientific programming at the local college. My problem is that the following difference produces round off errors as the value of x increases. For x = 19 the diference goes to zero.I understand the problem, but am curious as to

Re: How to except the unexpected?

2006-03-04 Thread Paul Rubin
James Stroud [EMAIL PROTECTED] writes: try: process_things() except Reraise: raise except: log_error() Why catch an error only to re-raise it? This falls under http://c2.com/cgi/wiki?YouReallyArentGonnaNeedThis No, without the reraise, the bare except: clause would

Re: How to except the unexpected?

2006-03-04 Thread James Stroud
Rene Pijlman wrote: James Stroud: Which suggests that try: except HTTPException: will be specific enough as a catchall for this module. The following, then, should catch everything you mentioned except the socket timeout: Your conclusion may be (almost) right in this case. I just don't

Re: spliting on :

2006-03-04 Thread Peter Hansen
Cyril Bazin wrote: Your file looks like a list of IP adresses. You can use the urllib and urllib2 modules to parse IP adresses. import urllib2 for line in open(fileName.txt): addr, port = urllib2.splitport(line) print (port != None) and '' or port Is this what you want to happen

Re: The old round off problem?

2006-03-04 Thread David Treadwell
On Mar 4, 2006, at 4:33 PM, Paul Rubin wrote: sam [EMAIL PROTECTED] writes: Hello all, I am taking a class in scientific programming at the local college. My problem is that the following difference produces round off errors as the value of x increases. For x = 19 the diference goes to

Advice from distutils experts?

2006-03-04 Thread olsongt
I'm doing something a little wierd in one of my projects. I'm generating a C source file based on information extracted from python's header files. Although I can just generate the file and check the result into source control, I'd rather have the file generated during the install process

Re: Papers on Dynamic Languages

2006-03-04 Thread Paul Boddie
Jay Parlar wrote: Anyway, I want to talk about things like typing disciplines (weak, strong, etc.),class vs. prototype, JIT technologies in dynamic languages, interactive interpreters, etc. There are a few classic papers on a number of these topics, but I'll leave it to the papers mentioned

Re: How to except the unexpected?

2006-03-04 Thread Paul Rubin
James Stroud [EMAIL PROTECTED] writes: approach. Basically this is reverse engineering the interface from the source at the time of writing the app. This is using the source as documentation, there is no law against that. That's completely bogus. Undocumented interfaces in the library

Re: spliting on :

2006-03-04 Thread Cyril Bazin
Ok, ok, there was a mistake in the code. (Of course, it was done on prupose in order to verify if everybody is aware ;-)I don't know why it is preferable to compare an object to the object None using is not. == is, IMHO, more simple. Simple is better than complex. So I use ==. The correct program

Re: spliting on :

2006-03-04 Thread Petr Jakes
I think you're getting caught by the classic and/or trap in Python, trying to avoid using a simple if statement. What do you mean by the classic and/or trap? Can you give an example please? Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list

CallBack

2006-03-04 Thread Ramkumar Nagabhushanam
Hello All, I am trying to integrate the ftpclient (in ftplib) with an application that has been written I C/C++. I am able to delete,send change working directories etc. When I receive data back from the server i.e. Retrieve files, get a directory listing) I want to pass a callback function to the

Re: Random Prime Generator/Modular Arithmetic

2006-03-04 Thread Tuvas
Okay, I don't know if your farmiliar with the miller-rabin primality test, but it's what's called a probabalistic test. Meaning that trying it out once can give fake results. For instance, if you use the number 31 to test if 561 is prime, you will see the results say that it isn't. Mathematically,

Re: How to except the unexpected?

2006-03-04 Thread James Stroud
Paul Rubin wrote: James Stroud [EMAIL PROTECTED] writes: approach. Basically this is reverse engineering the interface from the source at the time of writing the app. This is using the source as documentation, there is no law against that. That's completely bogus. Undocumented interfaces

Re: Advice from distutils experts?

2006-03-04 Thread Robert Kern
[EMAIL PROTECTED] wrote: I'm doing something a little wierd in one of my projects. I'm generating a C source file based on information extracted from python's header files. Although I can just generate the file and check the result into source control, I'd rather have the file generated

Re: How to except the unexpected?

2006-03-04 Thread Paul Rubin
James Stroud [EMAIL PROTECTED] writes: My suggestion was to use some common sense about the source code and apply it. The common sense to apply is that if the source code says one thing and the documentation says another, then one of them is wrong and should be updated. Usually it's the source

Re: Suggestions for documentation generation?

2006-03-04 Thread Bo Peng
kpd wrote: Hello, I have written a C++ library that I've then wrapped with Pyrex. Any suggestions to the best-in-class tool to create documentation for the libraries? I would love to document things in one spot (could be the code) and generate html and PDF from there. Doxygen

Cryptographically random numbers

2006-03-04 Thread Tuvas
Okay, I'm working on devoloping a simple, cryptographically secure number, from a range of numbers (As one might do for finding large numbers, to test if they are prime). My function looks like this: def cran_rand(min,max): if(minmax): x=max max=min min=x

Passing a method indirectly

2006-03-04 Thread swisscheese
I'm trying to write a function that takes an arbitrary object and method. The function applies the method to the object (and some other stuff). I get error Test instance has no attribute 'method' How can I make this work? def ObjApply (object,method): object.method () class Test:

Re: Passing a method indirectly

2006-03-04 Thread André
swisscheese wrote: I'm trying to write a function that takes an arbitrary object and method. The function applies the method to the object (and some other stuff). I get error Test instance has no attribute 'method' How can I make this work? def ObjApply (object,method):

Re: Passing a method indirectly

2006-03-04 Thread Farshid Lashkari
You don't need to pass the object along with the method. The method is bound to the object. Simply call the method by itself: def ObjApply(method): method() class Test: def test1 (self): print Hello def test2 (self): ObjApply(self.test1) ta = Test ()

Re: spliting on :

2006-03-04 Thread Peter Hansen
Cyril Bazin wrote: Ok, ok, there was a mistake in the code. (Of course, it was done on prupose in order to verify if everybody is aware ;-) I don't know why it is preferable to compare an object to the object None using is not. == is, IMHO, more simple. Simple is better than complex.. So I

Re: spliting on :

2006-03-04 Thread Peter Hansen
Petr Jakes wrote: I think you're getting caught by the classic and/or trap in Python, trying to avoid using a simple if statement. What do you mean by the classic and/or trap? Can you give an example please? Sure, see my subsequent reply to Cyril, elsewhere in this thread. (In summary,

  1   2   >