Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-20 Thread Bob Gailer
[EMAIL PROTECTED] wrote: > dear fellow Python enthusiasts: > > in the last year I have been experimenting with Python, and I set out > to create a function that, given a number of items and a maximum > number of items per row, would generate a table of rows of items. > However, there is one par

Re: [Tutor] Running program from Python

2007-07-20 Thread Kent Johnson
Tino Dai wrote: > =You might also want to try: > http://docs.python.org/lib/ipc.html to see if that is what you need Specifically the subprocess module which is the most modern way to start an external program. Kent ___ Tutor maillist - Tutor@python.

Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-20 Thread Bob Gailer
[EMAIL PROTECTED] wrote: > dear fellow Python enthusiasts: > > in the last year I have been experimenting with Python, and I set out > to create a function that, given a number of items and a maximum > number of items per row, would generate a table of rows of items. > However, there is one par

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Jerry Hill
On 7/20/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > Is there a straightforward way to find out if all characters in one string > are present in a second string? I like this one: all(char in string.printable for char in testString) >>> testString = "qwerty\buiop" >>> all(char in string.printabl

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Kent Johnson
Terry Carroll wrote: > Is there a straightforward way to find out if all characters in one string > are present in a second string? > > Basically, I have a string s, and I want to print it out only if every > character in it is printable (because I accidentally brought my PC loudly > to its knees

Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-20 Thread Bob Gailer
[EMAIL PROTECTED] wrote: > dear fellow Python enthusiasts: > > in the last year I have been experimenting with Python, and I set out > to create a function that, given a number of items and a maximum > number of items per row, would generate a table of rows of items. > However, there is one par

[Tutor] Python program design

2007-07-20 Thread Doug Glenn
I have a question on program design. The program will be a catalog of portable media (DVD, CD, flash drive, floppy, etc). I am currently in the preliminary stages of design and I currently would like to get input on what the best method would be for initially gathering the data and what format i

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Bob Gailer
Luke Paireepinart wrote: > Terry Carroll wrote: > >> Is there a straightforward way to find out if all characters in one string >> are present in a second string? >> >> Basically, I have a string s, and I want to print it out only if every >> character in it is printable (because I accidentally

[Tutor] don't repeat yourself; question about code optimization

2007-07-20 Thread tpc247
dear fellow Python enthusiasts: in the last year I have been experimenting with Python, and I set out to create a function that, given a number of items and a maximum number of items per row, would generate a table of rows of items. However, there is one part where I believe I violate the prime

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Dave Kuhlman
On Fri, Jul 20, 2007 at 06:46:13PM -0700, Terry Carroll wrote: > Is there a straightforward way to find out if all characters in one string > are present in a second string? > > Basically, I have a string s, and I want to print it out only if every > character in it is printable (because I accide

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Luke Paireepinart
Terry Carroll wrote: > Is there a straightforward way to find out if all characters in one string > are present in a second string? > > Basically, I have a string s, and I want to print it out only if every > character in it is printable (because I accidentally brought my PC loudly > to its knees

Re: [Tutor] Running another program from Python

2007-07-20 Thread Carlos Daniel Ruvalcaba Valenzuela
There is also os.system which should work in a similar way as Matlab system. You pass a string with the command and arguments. The downside of system is that it opens an entire shell and environment for the program being run, you only have the return value from the application. Other options can b

[Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Terry Carroll
Is there a straightforward way to find out if all characters in one string are present in a second string? Basically, I have a string s, and I want to print it out only if every character in it is printable (because I accidentally brought my PC loudly to its knees printing a few thousand BEL char

Re: [Tutor] Running program from Python

2007-07-20 Thread Tino Dai
On 7/20/07, Chris Smith <[EMAIL PROTECTED]> wrote: Howdy, I am working on some research. I'm trying to optimize the performance of an antenna. For the simulation of the antenna it would be easiest to use an antenna software package that I have in my lab. I know that Matlab can call the antenna

[Tutor] Running another program from Python

2007-07-20 Thread Chris Smith
Howdy, I am working on some research. I'm trying to optimize the performance of an antenna. For the simulation of the antenna it would be easiest to use an antenna software package that I have in my lab. I know that Matlab can call the antenna software through a command called system. Matlab a

[Tutor] Running program from Python

2007-07-20 Thread Chris Smith
Howdy, I am working on some research. I'm trying to optimize the performance of an antenna. For the simulation of the antenna it would be easiest to use an antenna software package that I have in my lab. I know that Matlab can call the antenna software through a command called system. Matlab a

Re: [Tutor] scrips again

2007-07-20 Thread Luke Paireepinart
Deby Campbell wrote: > > Hi , I've been using the IDLE python but when I try to make scrips with a > > word editor, but when I try to use them in the commend prompt it says > there > is no such file or directory except when I use the first one I made. So I > thought I would just use the one tha

[Tutor] scrips again

2007-07-20 Thread Deby Campbell
Hi , I've been using the IDLE python but when I try to make scrips with a word editor, but when I try to use them in the commend prompt it says there is no such file or directory except when I use the first one I made. So I thought I would just use the one that worked but for some reason i

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread Bob Gailer
shawn bright wrote: > If i have a thread, of type threading.Thread > that i initiate with an __init__ > in the > def run(self): > while 1: > do some stuff > > > is there a way i can stop this thread and restart this thread from > within itself ? A thread may suspend itself using one

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread Kent Johnson
shawn bright wrote: > ok, how would i have it re-initialize itself ? > > yes, i want to do this on a failure condition. > something wrapped in a try - except Nothing magic, it's just code. Something like this: def run(self): while 1: # (re)initialization code goes here while 1:

[Tutor] another question ( unrelated )

2007-07-20 Thread shawn bright
If i have a thread, of type threading.Thread that i initiate with an __init__ in the def run(self): while 1: do some stuff is there a way i can stop this thread and restart this thread from within itself ? thanks ___ Tutor maillist - Tu

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread shawn bright
ok, how would i have it re-initialize itself ? yes, i want to do this on a failure condition. something wrapped in a try - except its long and complicated dealing with talking to a dataserver over ip and passing byte streams back and forth. i just need to do this for testing to see where someth

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread Kent Johnson
shawn bright wrote: > If i have a thread, of type threading.Thread > that i initiate with an __init__ > in the > def run(self): > while 1: > do some stuff > > > is there a way i can stop this thread and restart this thread from > within itself ? No. A thread stops by exiting the

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread Luke Paireepinart
shawn bright wrote: > If i have a thread, of type threading.Thread > that i initiate with an __init__ > in the > def run(self): > while 1: > do some stuff > > > is there a way i can stop this thread and restart this thread from > within itself ? Speaking from a purely theoretical st

Re: [Tutor] question about datetime object

2007-07-20 Thread Kent Johnson
shawn bright wrote: > Hello there, > > if i have a python datetime object, what is the easiest way to make it > into epoch seconds ? impIn [1]: import datetime In [2]: now = datetime.datetime.now() In [4]: now.timetuple() Out[4]: (2007, 7, 20, 11, 56, 58, 4, 201, -1) In [5]: import calendar In [

[Tutor] question about datetime object

2007-07-20 Thread shawn bright
Hello there, if i have a python datetime object, what is the easiest way to make it into epoch seconds ? thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] scrips

2007-07-20 Thread Dave Kuhlman
On Thu, Jul 19, 2007 at 11:04:38PM -0700, Deby Campbell wrote: > > > Hi , I?ve been using the IDLE python but when I try to make > scrips with a word editor, but when I try to use them in the commend prompt it > says there is no such file or directory except when I use the first one I > made. >

Re: [Tutor] odd bug

2007-07-20 Thread christopher . henk
try adding: print "current block:", one_char_box print "zeros: ", zero_count to the lines just below your if statement that you think is called only once. This way you know how many times its called and you might be able to find the error. Chris Henk Allison Transmission phone: 317.242.2569

Re: [Tutor] reading random line from a file

2007-07-20 Thread Aditya Lal
A bug: The function random.randint(a,b) include both ends i.e. b is also included. Thus for file with single line a=0,b=1 my algo will give an IndexError. Significance of number 4096 : file is stored in blocks of size 2K/4K/8K (depending upon the machine). file seek for an offset goes block by blo

[Tutor] scrips

2007-07-20 Thread Deby Campbell
Hi , I’ve been using the IDLE python but when I try to make scrips with a word editor, but when I try to use them in the commend prompt it says there is no such file or directory except when I use the first one I made. So I thought I would just use the one that worked but for some reason it still