Re: [Tutor] Question on regular expressions

2006-05-25 Thread Kent Johnson
Andrew Robert wrote: The python method inserts extra blank lines after each hex value line. Does anyone know why this might be? Is the print statement inserting a artificial new line character? Yes, this is a feature of print, it always inserts a newline. To avoid this, use

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Great! Taking this a little further along, I wrote the converted file to a new file using: import re,sys output = open(r'e:\pycode\out_test.txt','wb') for line in open(r'e:\pycode\sigh.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s:

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Kent Johnson
Andrew Robert wrote: Taking this a little further along, I wrote the converted file to a new file using: import re,sys output = open(r'e:\pycode\out_test.txt','wb') for line in open(r'e:\pycode\sigh.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: '%%%2X' %

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, I tried: output = open(r'e:\pycode\new_test.txt','wb') for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) % ord(s.group()), line)) This generated the traceback:

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Kent Johnson
Andrew Robert wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, I tried: output = open(r'e:\pycode\new_test.txt','wb') for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) % ord(s.group()), line))

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Danny Yoo
for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) % ord(s.group()), line)) Let's add some whitespace. output.write(re.sub(r'([^\w\s])', lambda s: chr(

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 When I alter the code to: import re,sys output = open(r'e:\pycode\new_test.txt','wb') for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) , line) output.close() I get the

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 lol.. Glutton for punishment I guess. I tried removing the last parentheses but I then get an error that two arguments are passed when three are expected. Danny Yoo wrote: for line in open(r'e:\pycode\out_test.txt','rb') : output.write(

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Kent Johnson
Andrew Robert wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 When I alter the code to: import re,sys output = open(r'e:\pycode\new_test.txt','wb') for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) ,

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Kent, Sorry for causing so much trouble. I am not married to either a single or multi-line solution one way or another. Just a solution that works. Based on something by Danny Yoo provided, I had started with something like: import

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Everyone, Thanks for all of your patience on this. I finally got it to work. Here is the completed test code showing what is going on. Not cleaned up yet but it works for proof-of-concept purposes. #!/usr/bin/python import re,base64 #

Re: [Tutor] Question on regular expressions (fwd)

2006-05-25 Thread Terry Carroll
On Thu, 25 May 2006, Alan Gauld wrote: In general I prefer to use string formatting to convert into hex format. I'm a big fan of hexlify: from binascii import hexlify s=abc-123 hexlify(s) '6162632d313233' ___ Tutor maillist -

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Alan Gauld
for line in open(r'e:\pycode\out_test.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), 16))) % ord(s.group()), line)) This generated the traceback: File E:\pycode\sample_decode_file_specials_from_hex.py, line 8 output.write( re.sub(r'([^\w\s])', lambda s:

[Tutor] Question on regular expressions

2006-05-24 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Everyone, I have two Perl expressions If windows: perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt If posix perl -ple 's/([^\w\s])/sprintf(%%%2X, ord $1)/ge' somefile.txt The [^\w\s] is a negated expression stating that

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Danny Yoo
perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt Hi Andrew, Give me a second. I'm trying to understand the command line switches: (Looking in 'perl --help'...) -p assume loop like -n but print line also, like sed -l[octal] enable line ending

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Karl Pflästerer
On 24 Mai 2006, [EMAIL PROTECTED] wrote: I have two Perl expressions If windows: perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt If posix perl -ple 's/([^\w\s])/sprintf(%%%2X, ord $1)/ge' somefile.txt The [^\w\s] is a negated expression stating that any character

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wow!!.. That awesome! My goal was not to make it a one-liner per-se.. I was simply trying to show the functionality I was trying to duplicate. Boiling your one-liner down into a multi-line piece of code, I did: #!c:\python24\python import

Re: [Tutor] Question on regular expressions (fwd)

2006-05-24 Thread Danny Yoo
[forwarding to tutor, although it looks like Andrew's making some good headway from other messages] -- Forwarded message -- Date: Wed, 24 May 2006 14:59:43 -0400 From: Andrew Robert [EMAIL PROTECTED] To: Danny Yoo [EMAIL PROTECTED] Subject: Re: [Tutor] Question on regular

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Kent Johnson
Andrew Robert wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wow!!.. That awesome! My goal was not to make it a one-liner per-se.. I was simply trying to show the functionality I was trying to duplicate. Boiling your one-liner down into a multi-line piece of code, I did:

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Alan Gauld
a = open(r'e:\pycode\csums.txt','rb').readlines() for line in a: print re.sub(r'([^\w\s])', lambda s: '%%%2X' % ord(s.group()), line) Or just for line in open(r'e:\pycode\csums.txt','rb'): print. Breaking down the command, you appear to be calling an un-named function to act

Re: [Tutor] Question on regular expressions (fwd)

2006-05-24 Thread Alan Gauld
Your code put me right on track. - From that point, I crafted the following code. What is confusing is how to take the captured character and transform it into a 3 digit hex value. In general I prefer to use string formatting to convert into hex format. print %3X% % myValue you can

[Tutor] question about ic.py on Mac OS X

2006-05-21 Thread Ishwinder Kaur Banga
MAC OS version 10.4.6 Python Version 2.4.1 Problem is that the url is valid but the python icglue tells me that it is not found Please help Error Traceback (most recent call last): File dialect.py, line 166, in ?

[Tutor] Question on option parser

2006-05-16 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Everyone, I have a program that I'd would like to enhance flexibility in calling. Is there a way to leverage optionparser so it can accept input from both command line and a configuration file? Current code block is: # # Parse command

Re: [Tutor] Question on option parser

2006-05-16 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Kent, If I understood correctly, you meant something like this? # # Parse command line options and automatically build help/usage # display # if len(sys.argv) == 2: infile= open(sys.argv[1],rb).read()

Re: [Tutor] Question on option parser

2006-05-16 Thread Karl Pflästerer
On 16 Mai 2006, [EMAIL PROTECTED] wrote: Is there a way to leverage optionparser so it can accept input from both command line and a configuration file? Current code block is: # # Parse command line options and automatically build # help/usage display # parser =

[Tutor] question regarding subprocess.Popen

2006-05-09 Thread Yi Qiang
Hi list, I am launching another python program in my python daemon like this: pobj = subprocess.Popen(tlsmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,

Re: [Tutor] question about run time

2006-05-03 Thread Hugo González Monteverde
I have made scripts that work on many files (sometimes just some tens) and appears that filesystem structure caching in Linux is very efficient. That's why it runs very fast later. I've seen this in Slackware, Debian, and RH, so I guess it's just a linux/FS/disk thing. Try doing 'find'

[Tutor] question about run time

2006-05-02 Thread Ertl, John
I have been using python for sometime...and occasionally I noticed significant delay before the code would run but unitl now I have been able to write it off to other things. Now I have a short script that I wrote to check some files and print out a few lines. I have noticed that usually the

Re: [Tutor] question about run time

2006-05-02 Thread Kent Johnson
Ertl, John wrote: I have been using python for sometime...and occasionally I noticed significant delay before the code would run but unitl now I have been able to write it off to other things. Now I have a short script that I wrote to check some files and print out a few lines. I have

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
PROTECTED] Sent: Tuesday, May 02, 2006 12:06 PM To: Ertl, John Cc: tutor@python.org Subject:Re: [Tutor] question about run time Ertl, John wrote: I have been using python for sometime...and occasionally I noticed significant delay before the code would run but unitl now I have been

Re: [Tutor] question about run time

2006-05-02 Thread Kent Johnson
PROTECTED] Sent: Tuesday, May 02, 2006 12:06 PM To: Ertl, John Cc: tutor@python.org Subject: Re: [Tutor] question about run time Ertl, John wrote: I have been using python for sometime...and occasionally I noticed significant delay before the code would run but unitl now I have

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
Cc: tutor@python.org Subject:Re: [Tutor] question about run time Ertl, John wrote: Kent, The files are very small (a few hundred lines). Maybe it is a network issue? But then why is it always slow the first time in the morning? I don't know network stuff but that seams a bit

Re: [Tutor] question about run time

2006-05-02 Thread Danny Yoo
I have been using python for sometime...and occasionally I noticed significant delay before the code would run but unitl now I have been able to write it off to other things. Now I have a short script that I wrote to check some files and print out a few lines. I have noticed that

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
myUse.sendEmail(%s memory/inode limit reached on gpfs % myUse.userName) -Original Message- From: Danny Yoo [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 1:32 PM To: Ertl, John Cc: tutor@python.org Subject:Re: [Tutor] question about run time I have been using python

Re: [Tutor] question about run time

2006-05-02 Thread Danny Yoo
Hi John, You can try something like the profiler, which will say where most of the program's time is being spent. We can find documentation on the Python profiler here: http://www.python.org/doc/lib/profile.html From a rough, low-level standpoint, there are tools like 'top' on Linux

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
Kent Johnson schrieb: Gregor Lingl wrote: Hi all of you, ... from copy import deepcopy class Vec(tuple): def __new__(cls, x, y): return tuple.__new__(cls, (x,y)) def __abs__(self): return (self[0]**2+self[1]**2)**0.5 ## more methods ...

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Kent Johnson
Gregor Lingl wrote: Thanks, Kent for the hint. It works (of course). Skimming through this part of the docs I discovered, that there is a special method __deepcopy__. So I also tried using this, adding def __deepcopy__(self,visit): return self to my Vec class,

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
Kent Johnson schrieb: Gregor Lingl wrote: Thanks, Kent for the hint. It works (of course). Skimming through this part of the docs I discovered, that there is a special method __deepcopy__. So I also tried using this, adding def __deepcopy__(self,visit): return self

[Tutor] question concerning deepcopy

2006-04-28 Thread Gregor Lingl
Hi all of you, I've some Vector class, which is a subclass of tuple and which is working satisfactorily since long in different contexts. Now I've constructed objects with attributes of Vec-type, which I wanted to deepcopy. But that doesn't work, because I can't (deep)copy Vec-s: from copy

Re: [Tutor] question concerning deepcopy

2006-04-28 Thread Kent Johnson
Gregor Lingl wrote: Hi all of you, I've some Vector class, which is a subclass of tuple and which is working satisfactorily since long in different contexts. Now I've constructed objects with attributes of Vec-type, which I wanted to deepcopy. But that doesn't work, because I can't

Re: [Tutor] Question About Function Arguments and Returned Results

2006-04-11 Thread Richard Querin
On 4/11/06, Kent Johnson [EMAIL PROTECTED] wrote: There is no need to pass the class object in to the function, you cancreate it in the function and return it. A class might be nice becauseit gives names to the various values. A dict can also be used for this. Do what feels right :-)To be more

Re: [Tutor] Question About Function Arguments and Returned Results

2006-04-11 Thread Kent Johnson
Richard Querin wrote: On 4/11/06, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: There is no need to pass the class object in to the function, you can create it in the function and return it. A class might be nice because it gives names to the various

[Tutor] Question about list

2006-04-10 Thread Hoffmann
Hello, I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i len(list1): print list1[i] i += 1 Ok. This script will generate as the output each element of the original list, one per line: spam! 2 ['Ted', 'Rock'] I also would like to print

Re: [Tutor] Question about list

2006-04-10 Thread John Fouhy
Hi Hoffmann, On 11/04/06, Hoffmann [EMAIL PROTECTED] wrote: I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i len(list1): print list1[i] i += 1 Have you read about for loops? The pythonic way of looping through a list is to do

Re: [Tutor] Question about list

2006-04-10 Thread Matthew White
Hi Hoffman, It is often useful to use the for construct to process items in a list. e.g.: list1 = [ 'spam!', 2, ['Ted', 'Rock']] for item in list: ...print item spam! 2 ['Ted', 'Rock'] If you pass a list to the len() function, it will return the number of elenents in the list. e.g.: x

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- John Fouhy [EMAIL PROTECTED] wrote: Hi Hoffmann, On 11/04/06, Hoffmann [EMAIL PROTECTED] wrote: I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i len(list1): print list1[i] i += 1 Have you read about for loops?

Re: [Tutor] Question about list

2006-04-10 Thread Terry Carroll
On Mon, 10 Apr 2006, Hoffmann wrote: Hello, I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i len(list1): print list1[i] i += 1 Ok. This script will generate as the output each element of the original list, one per line:

Re: [Tutor] Question about list

2006-04-10 Thread Danny Yoo
On Mon, 10 Apr 2006, Hoffmann wrote: I also would like to print the length of each element of that list: spam! = 1 element 2 = 1 element ['Ted', 'Rock'] = 2 elements Could anyone, please, give me some hints? The problem is slightly weird, just because you need to clarify what it

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- Terry Carroll [EMAIL PROTECTED] wrote: On Mon, 10 Apr 2006, Hoffmann wrote: Hello, I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i len(list1): print list1[i] i += 1 Ok. This script will generate as the

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- Matthew White [EMAIL PROTECTED] wrote: Hi Hoffman, It is often useful to use the for construct to process items in a list. e.g.: list1 = [ 'spam!', 2, ['Ted', 'Rock']] for item in list: ...print item spam! 2 ['Ted', 'Rock'] If you pass a list to the len() function, it

Re: [Tutor] Question about large numbers of arguments

2006-04-05 Thread Python
On Wed, 2006-04-05 at 12:34 +0100, Alan Gauld wrote: Suppose you have a situation where you have a large number of command-line options that you will parse with getopt. You want to keep track of these as you move around in the code and do various things. Is it more Pythonic to: Have

Re: [Tutor] Question about large numbers of arguments

2006-04-05 Thread Hugo González Monteverde
Dana Robinson wrote: Have the functions take large numbers of parameters. or Create an options class to pass the options around. Pythonically, I heard the distinct scream of DICTIONAR in my head. Hugo ___ Tutor maillist -

[Tutor] question...

2006-02-20 Thread Samantha Warbey
I have blocks of text (in notebook files currently) that I need to read 3 and analyse 3 characters at a time. [This is because I'm studying genes and codons are three characters in length]. How do I do this using python? I've currently only been able to find ways of analysing text line by line,

Re: [Tutor] question...

2006-02-20 Thread Danny Yoo
On Mon, 20 Feb 2006, Samantha Warbey wrote: I have blocks of text (in notebook files currently) that I need to read 3 and analyse 3 characters at a time. [This is because I'm studying genes and codons are three characters in length]. How do I do this using python? I've currently only been

[Tutor] question about ascii and bytes

2006-02-06 Thread nephish
ok, so i have sparce documentation from a server that i need to make a socket connection with. the server wants to get info a certain way. Each message has to start with an ascii STX (literally the three letters, not the standart ascii 'STX') then it has to have another four bytes that give the

Re: [Tutor] question about ascii and bytes

2006-02-06 Thread Alan Gauld
the server wants to get info a certain way. Each message has to start with an ascii STX (literally the three letters, not the standart ascii 'STX') then it has to have another four bytes that give the length of the message, then the message itself, then end with an ascii ENX (again,the three

Re: [Tutor] question !

2005-12-20 Thread Danny Yoo
On Mon, 19 Dec 2005, Krava Magare wrote: How can I remove and add record ( dictionary type) to a file. Hi Krava, H... I have to admit that I don't understand the question yet. *grin* It looks like you're already pickling lists into your file. Picking dictionaries should be similar;

Re: [Tutor] question !

2005-12-20 Thread Brian van den Broek
Krava Magare said unto the world upon 2005-12-19 17:31: How can I remove and add record ( dictionary type) to a file. This is the program that I'm working on: the program should create a text file, print the contents of the text file, read the file after it's been created, add a record

[Tutor] question !

2005-12-19 Thread Krava Magare
How can I remove and add record ( dictionary type) to a file. This is the program that I'm working on: the program should create a text file, print the contents of the text file, read the file after it's been created, add a record and print the contents of the file, remove a record(s) from the

[Tutor] Question

2005-11-29 Thread Douglass, Erik
I am a bit new to the *nix environment, as well as brand new to Python (perhaps I am biting of a bit much, I know). I was wondering if someone could point me in a direction to get started in this environment. What apps to code in, is there an interactive mode? Specifically FreeBSD 6.0

Re: [Tutor] Question

2005-11-29 Thread John Fouhy
On 30/11/05, Douglass, Erik [EMAIL PROTECTED] wrote: I am a bit new to the *nix environment, as well as brand new to Python (perhaps I am biting of a bit much, I know). I was wondering if someone could point me in a direction to get started in this environment. What apps to code in, is there

Re: [Tutor] Question

2005-11-29 Thread Danny Yoo
I am a bit new to the *nix environment, as well as brand new to Python (perhaps I am biting of a bit much, I know). I was wondering if someone could point me in a direction to get started in this environment. Hi Erik, I agree; I'd recommend getting used to operating your new Unix

Re: [Tutor] question about serial coms

2005-11-15 Thread Python
The device at the far end of the serial connection is echoing what you write back to you. This is a convenience for someone typing at a terminal, but a nuisance when you are programming. The easier way out is to turn echoing off at the far device. Failing that, you will want to provide a copy

Re: [Tutor] question about ord

2005-11-15 Thread Kent Johnson
nephish wrote: Hey there, i am using a script to change a byte into an integer like this: a = the byte value = ord(a) but i cant find the operation that can change it back to a byte. chr() See http://docs.python.org/lib/built-in-funcs.html Kent --

Re: [Tutor] question about ord

2005-11-15 Thread Liam Clarke-Hutchinson
] [mailto:[EMAIL PROTECTED] On Behalf Of nephish Sent: Wednesday, 16 November 2005 9:46 a.m. To: tutor Subject: [Tutor] question about ord Hey there, i am using a script to change a byte into an integer like this: a = the byte value = ord(a) but i cant find the operation

Re: [Tutor] question about ord

2005-11-15 Thread Python
chr(value) chr(ord('a')) == 'a' True On Tue, 2005-11-15 at 14:46 -0600, nephish wrote: Hey there, i am using a script to change a byte into an integer like this: a = the byte value = ord(a) but i cant find the operation that can change it back to a byte. i am sure its

Re: [Tutor] question about ord

2005-11-15 Thread nephish
) You nmay want to check the docs for the struct module at python.org on that pattern. Liam Clarke-Hutchinson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of nephish Sent: Wednesday, 16 November 2005 9:46 a.m. To: tutor Subject: [Tutor

[Tutor] question about serial coms

2005-11-14 Thread nephish
Hey there, i am developing on a linux computer with the serial module. Now, i already am able to recieve info from a serial RS232 device and process everything ok. What i need to do now is write to the serial device, but i also need to be able to not interrupt the script that is reading

Re: [Tutor] question about serial coms

2005-11-14 Thread Hugo González Monteverde
Hi Nephish, Are you using pyserial or rolling your own? Normally you can write and read to the /dev/ttySXX file at the same time; since they're special files, not ordinary files, the driver handles that. Handling both writing and reading in your program's flow control is a wholly different

Re: [Tutor] question about serial coms

2005-11-14 Thread nephish
Yeah, i am using pyserial, i think, in debian its called python serial and i use import serial to get things going. Really easy, just wanted to know about this stuff before i start scrambling this like so many eggs. i will not be using two different scripts, but likely two threads in the same

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
: tutor Subject: Re: [Tutor] question about serial coms Hi Nephish, Are you using pyserial or rolling your own? Normally you can write and read to the /dev/ttySXX file at the same time; since they're special files, not ordinary files, the driver handles that. Handling both writing and reading

Re: [Tutor] question about serial coms

2005-11-14 Thread nephish
and another one to handle the writes. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hugo González Monteverde Sent: Tuesday, 15 November 2005 7:36 a.m. To: nephish Cc: tutor Subject: Re: [Tutor] question about serial coms Hi Nephish, Are you using

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
port Release lock Cheers Hans -Original Message- From: nephish [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 November 2005 10:47 a.m. To: Hans Dushanthakumar Cc: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms well thats encouraging, did you have to do

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms ok, lock is something you wrote yourself ? i can't find it in the docs. However, i think i can essentially build the same thing. the serial module i use is pyserial. pyserial.sourceforge.net. the docs are a wee bit

Re: [Tutor] question about serial coms

2005-11-14 Thread nephish
Hans -Original Message- From: nephish [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 November 2005 11:23 a.m. To: Hans Dushanthakumar Cc: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms ok, lock is something you wrote yourself ? i can't find

Re: [Tutor] question about serial coms

2005-11-14 Thread Bennett, Joe
PROTECTED] Sent: Tuesday, 15 November 2005 11:23 a.m. To: Hans Dushanthakumar Cc: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms ok, lock is something you wrote yourself ? i can't find it in the docs. However, i think i can essentially build the same

Re: [Tutor] question about serial coms

2005-11-14 Thread nephish
] Sent: Tuesday, 15 November 2005 10:47 a.m. To: Hans Dushanthakumar Cc: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms well thats encouraging, did you have to do anything special to prevent an error when trying to read or write

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
PROTECTED] Sent: Tuesday, 15 November 2005 2:10 p.m. To: [EMAIL PROTECTED] Cc: Hans Dushanthakumar; tutor Subject: Re: [Tutor] question about serial coms oh yeah, i will need this too! sk On Mon, 2005-11-14 at 17:04 -0800, Bennett, Joe wrote: I have been working with pyserial. One question I have

Re: [Tutor] question about serial coms

2005-11-14 Thread Bennett, Joe
I think so, what I'm doing is opening a text file, reading line 1 and writing that text to the serial port. Then read line 2 and so on... So it mimics a string rather than a list or dictionary. But I would think this would give you a similiar result. I can try it to confirm. Here is the entire

Re: [Tutor] Question about resetting values

2005-11-11 Thread Hugo González Monteverde
Subject: Re: [Tutor] Question about resetting values I am writing a Blackjack program, and was wondering how to reset the values to zero, e.g. cash = 0? Yes, that's how you do it. Now what is the bit you don't understand? Alan G Author of the Learn to Program web tutor http

Re: [Tutor] Question about an re

2005-10-28 Thread w chun
- -: \d+/?\d* - - - -ie 1 or more digits followed by 0 or 1 slashes followed by 0 or more digits. this looks like it'll also accept invalid data, such as 1/ ... i think there's some more tweaking involved to get it so that if there's a '/', there is at least one digit afterwards. -- wesley

Re: [Tutor] Question about an re

2005-10-28 Thread Kent Johnson
w chun wrote: - -: \d+/?\d* - - - -ie 1 or more digits followed by 0 or 1 slashes followed by 0 or more digits. this looks like it'll also accept invalid data, such as 1/ ... i think there's some more tweaking involved to get it so that if there's a '/', there is at least one digit

Re: [Tutor] question about try except

2005-10-27 Thread Alan Gauld
and i am using some try / except statements. the problem is, that even though my script does not crash, i dont know the exact error. IT sounds like your try/except is masking the error. Its usually a good idea to NOT Use try/except when developing your code, then go back and put it in when

Re: [Tutor] Question about an re

2005-10-27 Thread Ed Singleton
OR tests for the truth of the first thing then the truth of the second. The first part of your OR is always true, so it doesn't test the second. What you really want to do is look for a digit and then look for more digits or a slash and some more digits. So: : \d(\d+|/\d+) but this is easier

Re: [Tutor] question about try except

2005-10-27 Thread Kent Johnson
nephish wrote: Hey there, i am writing some (for me) pretty complicated stuff for work that really needs to work. i have looked at exception handling in the Learning Python book. and i am using some try / except statements. the problem is, that even though my script does

Re: [Tutor] question about try except

2005-10-27 Thread w chun
On 10/26/05, nephish [EMAIL PROTECTED] wrote: Yeah, cool. i am just starting this part. i am glad i started with python. thanks for the help if your app is willing to tolerate errors/crashes, then i would take alan's advice and just letting the errors happen, as opposed to being so careful

Re: [Tutor] question about try except

2005-10-27 Thread Kent Johnson
w chun wrote: if your app is willing to tolerate errors/crashes, then i would take alan's advice and just letting the errors happen, as opposed to being so careful with (and integrating Kent's suggestion for the full traceback with): try: BLOCK except Exception, e: print e,

Re: [Tutor] Question about an re

2005-10-27 Thread -Terry-
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Today (Oct 27, 2005) at 9:29am, Ed Singleton spoke these wise words: - -OR tests for the truth of the first thing then the truth of the second. - - - -The first part of your OR is always true, so it doesn't test the second. - - - -What you really

[Tutor] question about try except

2005-10-26 Thread nephish
Hey there, i am writing some (for me) pretty complicated stuff for work that really needs to work. i have looked at exception handling in the Learning Python book. and i am using some try / except statements. the problem is, that even though my script does not crash, i

Re: [Tutor] question about try except

2005-10-26 Thread Hugo González Monteverde
Yes, You can catch an error object along with the exception, as in: try: fileo = open(nofile) except IOError, e: print Alas..., e As you see, the error object has a string representation equal wo what normally the python interpreter prints... Alas... [Errno 2] No such file or

Re: [Tutor] question about try except

2005-10-26 Thread nephish
Thanks Hugo, Now that i know where to look appreciate your help. -sk On Wed, 2005-10-26 at 21:27 -0600, Hugo González Monteverde wrote: Yes, You can catch an error object along with the exception, as in: try: fileo = open(nofile) except IOError, e: print Alas..., e As

Re: [Tutor] question about try except

2005-10-26 Thread w chun
i am writing some (for me) pretty complicated stuff for work that really needs to work. i have looked at exception handling... and i am using some try / except statements. the problem is, that even though my script does not crash, i dont know the exact error.

Re: [Tutor] question about try except

2005-10-26 Thread nephish
Yeah, cool. i am just starting this part. i am glad i started with python. thanks for the help sk On Wed, 2005-10-26 at 21:32 -0700, w chun wrote: i am writing some (for me) pretty complicated stuff for work that really needs to work. i have looked at exception handling...

[Tutor] question about pychart

2005-10-14 Thread nephish
Hey there, i have a simple app that plots some numbers sent by a field sensor with respect to time. i am trying to do this in pychart, but the problem is, when the numbers come in, they do so at almost random times. y shows the value sent by the sensor x plots the time that the value came in.

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
Hi Negroup, First off, you may want to use os.path.join to create paths - path = 'categories/%s' % self.name could be - path = os.path.join(categories, self.name) This will ensure minimum hassle if you ever want to use this across multiple OS. Also, it looks a little tidier, and IMAO,

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
Erk, I of course meant - path = os.path.join('categories', self.name) On 8/10/05, mailing list [EMAIL PROTECTED] wrote: Hi Negroup, First off, you may want to use os.path.join to create paths - path = 'categories/%s' % self.name could be - path = os.path.join(categories, self.name)

Re: [Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-10 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 23:31: Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?. Nathan Nathan, I write this

[Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-09 Thread Nathan Pinno
Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?. Nathan ---Early to bed,Early

Re: [Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-09 Thread luke
Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?. hope this points you in the right direction Nathan. -Luke #start of program

[Tutor] Question About chdir()

2005-08-08 Thread Don Parris
The book, Programming Python, shows an example of os.chdir() on the Windows platform, as follows: os.chdir(r'c:\temp') What's the 'r' for? It didn't seem to make any difference in how Python works - at least not on the surface. Thanks, Don -- DC Parris GNU Evangelist http://matheteuo.org/

<    4   5   6   7   8   9   10   >