Re: [Tutor] comparing almost equal strings

2007-02-08 Thread thomas coopman
Hi, On Thu, 08 Feb 2007 13:07:41 +0100 Christopher Arndt <[EMAIL PROTECTED]> wrote: > thomas coopman schrieb: > > I need a function that groups almost equal strings. It seems most > > easy to me, to do this with a hash function. > > What do you mean be "almost equal"? By which criterium? Spelli

Re: [Tutor] Converting \x0e to string 0e in python

2007-02-08 Thread Kent Johnson
Sudarshana KS wrote: > Hi, > > Currently i have data with the following type - Which is a x509 > certificate obtained from SSL server done. I need this to be converted > to normal string, so that i can use the load_certificate method of > OpenSSL, which takes string as the argument. The below

Re: [Tutor] Range of float value

2007-02-08 Thread Daniel Yoo
On Thu, 8 Feb 2007, Johan Geldenhuys wrote: > OK, this what I wanted: > > I have a value: a = 48.41 > > My lowValue is: lowValue = 48.35 > My highValue is : highvalue = 48.45 Range does not work on floats: it's meant to work on integers. > I though that it could be possible to have a range b

[Tutor] Property Question (Was: RE: Overloading assignment operator)

2007-02-08 Thread Carroll, Barry
> -Original Message- > From: Tony Cappellini [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 08, 2007 5:41 PM > To: Carroll, Barry > Subject: re:Overloading assignment operator > > Hello Barry > > I'm trying to understand you post > > my question is, should this line > > result = p

[Tutor] Converting \x0e to string 0e in python

2007-02-08 Thread Sudarshana KS
Hi, Currently i have data with the following type - Which is a x509 certificate obtained from SSL server done. I need this to be converted to normal string, so that i can use the load_certificate method of OpenSSL, which takes string as the argument. Kindly help me. cert= '\x00\x01\xa20\x82\x0

Re: [Tutor] file open error

2007-02-08 Thread Bill Campbell
On Thu, Feb 08, 2007, Jalil wrote: > > Hey guys, > I have this simple code and i cant seem to get it to run. > here is the code. > from os import * > import re > hostname =raw_input("Host name : ") or '' > mac_addr =input("Mac address : ") > filename='/etc/dhcpd.conf' > fh=open(fi

Re: [Tutor] file open error

2007-02-08 Thread John Fouhy
On 09/02/07, Jalil <[EMAIL PROTECTED]> wrote: Hi Jalil, Because you're doing this: > from os import * It means that when you get to this line: > fh=open(filename) You're actually calling os.open, which is lower-level than the standard open() and expects different arguments. Many people recom

[Tutor] file open error

2007-02-08 Thread Jalil
Hey guys, I have this simple code and i cant seem to get it to run. here is the code. from os import * import re hostname =raw_input("Host name : ") or '' mac_addr =input("Mac address : ") filename='/etc/dhcpd.conf' fh=open(filename) m = re.match(hostname,fh.readlines()) if m!=None: m.gro

Re: [Tutor] Debugging

2007-02-08 Thread John Fouhy
On 09/02/07, Toon Pieton <[EMAIL PROTECTED]> wrote: > Hey friendly users! > > I have a question considering debugging: is it possible to get the current > code line that is being executed? Are you using pdb [the python debugger]? If you have a script 'myscript.py', you can start the script like t

[Tutor] Debugging

2007-02-08 Thread Toon Pieton
Hey friendly users! I have a question considering debugging: is it possible to get the current code line that is being executed? Thanks in advance! Toon Pieton ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Range of float value

2007-02-08 Thread Kent Johnson
Johan Geldenhuys wrote: > OK, this what I wanted: > > I have a value: a = 48.41 > > My lowValue is: lowValue = 48.35 > My highValue is : highvalue = 48.45 > > if a <= lowValue: > print 'value below limit' > > if a >= highValue: > print value above limit' > > I though that it could

Re: [Tutor] Range of float value

2007-02-08 Thread Johan Geldenhuys
OK, this what I wanted: I have a value: a = 48.41 My lowValue is: lowValue = 48.35 My highValue is : highvalue = 48.45 if a <= lowValue: print 'value below limit' if a >= highValue: print value above limit' I though that it could be possible to have a range between 48.35 and 48.45

Re: [Tutor] Range of float value

2007-02-08 Thread Kent Johnson
Luke Paireepinart wrote: > Kent Johnson wrote: >> Luke Paireepinart wrote: >>> Kent Johnson wrote: You can't generate all the float values in a range. (OK, you probably could, but it would not be practical or useful.) You can test for a value in a range, e.g. if 48.35 <= a <=

Re: [Tutor] Range of float value

2007-02-08 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: >> Kent Johnson wrote: > >>> You can't generate all the float values in a range. (OK, you >>> probably could, but it would not be practical or useful.) You can >>> test for a value in a range, e.g. >>> if 48.35 <= a <= 48.45: >>> >> Kent: >> Why d

Re: [Tutor] Range of float value

2007-02-08 Thread Andre Engels
2007/2/8, Johan Geldenhuys <[EMAIL PROTECTED]>: Hi all, I have a value that ranges between 48.01 and 48.57. a Float value in other words. I want to look at changes in the value. If my normal range is between 48.35 and 48.45, how will I identify the value below 48.35 and above 48.45 ? Somethi

Re: [Tutor] Range of float value

2007-02-08 Thread Kent Johnson
Luke Paireepinart wrote: > Kent Johnson wrote: >> You can't generate all the float values in a range. (OK, you probably >> could, but it would not be practical or useful.) You can test for a >> value in a range, e.g. >> if 48.35 <= a <= 48.45: >> > Kent: > Why does this work? It is explicitl

Re: [Tutor] Range of float value

2007-02-08 Thread Luke Paireepinart
Kent Johnson wrote: > Johan Geldenhuys wrote: > >> Hi all, >> >> I have a value that ranges between 48.01 and 48.57. a Float value in >> other words. >> >> I want to look at changes in the value. If my normal range is between >> 48.35 and 48.45, how will I identify the value below 48.35 an

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Kent Johnson
Paulino wrote: > Yes that is the problem. > > But I canot control all the the encodings in every PC that the script is > to be run... The problem is in your *editor* not in Python. You have to control the encoding the *editor* expects. At least that is my guess - your complaint is that you can

Re: [Tutor] Program Control

2007-02-08 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Maybe I'm asking the wrong question. This appears that a module is a > external program. What I've seen on some programs but don't fully > understand is something of the sort: def main() and a def sub() and def > add(). It appears that the program has calls to each

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Eike Welk
The Kate editor has also modelines, similar to the python interpreter: http://kate-editor.org/article/katepart_modelines HTH, Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Paulino
Yes that is the problem. But I canot control all the the encodings in every PC that the script is to be run... Paulino Kent Johnson escreveu: > > I think the problem you are having is with the source code encoding, > not sys.stdout.encoding. Probably your editor on linux expects a > differen

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Paulino
Yes I have that declaration in my script. Paulino > Send Tutor mailing list submissions to > tutor@python.org > > # -*- coding: iso-8859-1 -*- If you put this at the first line of your .py files (of course replace iso-8859-1 with whatever encoding you use) I think this should do the

Re: [Tutor] Program Control

2007-02-08 Thread [EMAIL PROTECTED]
Maybe I'm asking the wrong question. This appears that a module is a external program. What I've seen on some programs but don't fully understand is something of the sort: def main() and a def sub() and def add(). It appears that the program has calls to each of these sections. The term module

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Kent Johnson
Paulino wrote: > Hi everyone! > > I have some strings that include special characters, to be displayed in > widget labels ( PyQt4 ). > The output changes in diferent OS's due to diferent sys.stdout encoding > > Not only the labels in the GUI change, but the source file strings are > altered whe

Re: [Tutor] Range of float value

2007-02-08 Thread Kent Johnson
Johan Geldenhuys wrote: > Hi all, > > I have a value that ranges between 48.01 and 48.57. a Float value in > other words. > > I want to look at changes in the value. If my normal range is between > 48.35 and 48.45, how will I identify the value below 48.35 and above 48.45? > > Something I t

Re: [Tutor] Program Control

2007-02-08 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I am learning Python and have written several small programs of > increasing complexity but so far they are all "linear" programs meaning > that they are meant to do one thing. I have yet to fully understand > program control in order to go to and return form modules

[Tutor] Range of float value

2007-02-08 Thread Johan Geldenhuys
Hi all, I have a value that ranges between 48.01 and 48.57. a Float value in other words. I want to look at changes in the value. If my normal range is between 48.35 and 48.45, how will I identify the value below 48.35 and above 48.45? Something I tried was: for a in range(48.35, 48.45):

Re: [Tutor] comparing almost equal strings

2007-02-08 Thread Christopher Arndt
thomas coopman schrieb: > I need a function that groups almost equal strings. It seems most easy > to me, to do this with a hash function. What do you mean be "almost equal"? By which criterium? Spelling, Pronounciation? Semantics? > I think I once read something about it, but I can't find it,

[Tutor] Program Control

2007-02-08 Thread [EMAIL PROTECTED]
I am learning Python and have written several small programs of increasing complexity but so far they are all "linear" programs meaning that they are meant to do one thing. I have yet to fully understand program control in order to go to and return form modules (I think this is the correct term).

[Tutor] resetting the python interpreter through manipulating globals()

2007-02-08 Thread Yi Qiang
Hi, I have a program that talks to a python interpreter through pexpect (don't bother asking why ;). What I would like to do is occasionally "reset" the interpreter to the state it would be in if it had just been launched. I assumed I could simply clear out the globals() dictionary, minus

Re: [Tutor] same output on diferent sys.stdout.encodings

2007-02-08 Thread Michael Lange
On Wed, 07 Feb 2007 17:30:26 + Paulino <[EMAIL PROTECTED]> wrote: > Hi everyone! > > I have some strings that include special characters, to be displayed in > widget labels ( PyQt4 ). > The output changes in diferent OS's due to diferent sys.stdout encoding > > Not only the labels in the GU

[Tutor] comparing almost equal strings

2007-02-08 Thread thomas coopman
Hi, I need a function that groups almost equal strings. It seems most easy to me, to do this with a hash function. So I would write a hash function like this: string = string.replace(" ", "").lower()[0:6] and then hash the string chars, but it should detect minor typo's, so words with one diffe