Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-07 Thread Danny Yoo
-- Forwarded message -- Date: Fri, 7 Apr 2006 21:05:33 -0600 From: Jesse <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Beginner question (variables, namespaces...) I tried redefining the "higher-order" variables as functions, but it didn't quite work.

[Tutor] Watch and control access to an executable

2006-04-07 Thread Bill Burns
Hi Tutors! I have a problem that I've solved using Python, and I want to know if I've done a good job :-) Here's the problem: At my work we have a Windows network. On a network drive lives a program that a couple people need to access (there's a shortcut on each user's Desktop to the executable).

Re: [Tutor] Unittest not running all test cases

2006-04-07 Thread Carroll, Barry
Kent: > -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: Friday, April 07, 2006 3:59 PM > To: Carroll, Barry > Subject: Re: [Tutor] Unittest not running all test cases > > Carroll, Barry wrote: > > Kent: > > > > I just rechecked my class names, and there are no du

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
> > buy_containers = roundup(need/container) > > > Yeah, rather than code these as explicit variables, I'd strongly recommend > rewriting each of these as functions. Concretely: > > def buy_containers(stock, weekly_quota, container): > return roundup(need(stock, weekly_quota) - extra(stock,

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Bob Gailer
Jesse wrote: > Why is it that when one variable is assigned a value in terms of > another variable, assigning a new value to the first doesn't change > the value of the second? This is giving me a huge headache, since I > have a bunch of variables defined in terms of one another, and I want > t

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
On Fri, 7 Apr 2006, Jesse wrote: > Why is it that when one variable is assigned a value in terms of another > variable, assigning a new value to the first doesn't change the value of > the second? Hi Jesse, If you have a "variable" that depends on the values of other parameters, that's just be

[Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Jesse
Why is it that when one variable is assigned a value in terms of another variable, assigning a new value to the first doesn't change the value of the second? This is giving me a huge headache, since I have a bunch of variables defined in terms of one another, and I want to be able to dynamically up

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Liam Clarke
Well, thanks very much Kent, Hugo and Danny. I went with the "never-ending blocking queues" and sentinel data approach. When running tests with a continual stream of packets being received 3ms apart, CPU usage peaked at 15%, was usually around 7-9%, and when deployed the packets will separated by

Re: [Tutor] Unittest not running all test cases

2006-04-07 Thread Carroll, Barry
Kent: I just rechecked my class names, and there are no duplicates. I was careful to preface all of the classes in testsymc39 with 'C39...', and used 'S25...' in testsym25. Likewise, the classes in each module have names that describe the type of data being tested, so names are unique within eac

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Liam Clarke
Thanks very much all. :) I'll have a crack this afternoon and let you know. Kent - the increase in the queue size for the socket server is to allow for any delay in processing packets; it has a default queue size of 5 and then it starts rejecting packets; more of a safety policy when reducing CPU

Re: [Tutor] string formatting question

2006-04-07 Thread Karl Pflästerer
On 7 Apr 2006, [EMAIL PROTECTED] wrote: > Sorry I didn't make my question clearer. Bascially I > want to replace this line: > > address="64.41.134.60"/> > > With: > > address="64.41.134.60"/> > > So the regex grouping are that I want to keep > portNumber= and tcpORudp= and replace the values. >

Re: [Tutor] Unittest not running all test cases

2006-04-07 Thread Kent Johnson
Carroll, Barry wrote: > Greetings: > > I'm not certain this is the right forum for this question. If not, please point me to the correct one. > > I am using the unittest module to test a package our team is writing. > I presently have three modules of test cases and a top level module to run the

[Tutor] Unittest not running all test cases

2006-04-07 Thread Carroll, Barry
Greetings: I'm not certain this is the right forum for this question. If not, please point me to the correct one. I am using the unittest module to test a package our team is writing. I presently have three modules of test cases and a top level module to run the entire suite. The hierarch

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Danny Yoo
On Fri, 7 Apr 2006, Kent Johnson wrote: > Hugo Gonz�lez Monteverde wrote: > > You are not using the optional timeout and blocking which 'get' provides (!) > > > > Try setting it and see your CPU usage go down. This will implement > > blocking, and the queue will be used as soon as data is there.

Re: [Tutor] string formatting question

2006-04-07 Thread Kent Johnson
Jerome Jabson wrote: > Hi Kent, > > Sorry I didn't make my question clearer. Bascially I > want to replace this line: > > address="64.41.134.60"/> > > With: > > address="64.41.134.60"/> > > So the regex grouping are that I want to keep > portNumber= and tcpORudp= and replace the values. > Wh

Re: [Tutor] string formatting question

2006-04-07 Thread Jerome Jabson
Hi Kent, Sorry I didn't make my question clearer. Bascially I want to replace this line: With: So the regex grouping are that I want to keep portNumber= and tcpORudp= and replace the values. Which will be varibles in my code. The question is more on the string formatting in the replace. Ho

Re: [Tutor] function caller

2006-04-07 Thread Alan Gauld
> Hi, Hi, > Can someone explain me function and caller relationship when passing > arguments? There is an explanation of this in vitually any tutorial on Python. Haver you read any of these? Have you any experience in other languages that we can relate an explanation too? For example, you co

Re: [Tutor] string formatting question

2006-04-07 Thread Alan Gauld
> My problem now is how do I construct the replace > statement? > twork = m_sock.sub('\1 %s \2 %s', % port_num % proto, > twork) The format operator takes a tuple: twork = m_sock.sub('\1 %s \2 %s' % (port_num, proto), twork) So I removed the comma after the string, used a single percent operat

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Kent Johnson
Hugo González Monteverde wrote: > You are not using the optional timeout and blocking which 'get' provides (!) > > Try setting it and see your CPU usage go down. This will implement > blocking, and the queue will be used as soon as data is there.Set > block > to True and a timeout if yo

Re: [Tutor] string formatting question

2006-04-07 Thread Kent Johnson
Jerome Jabson wrote: > Hello, > > I'm trying to replace some strings in a line of text, > using some regex functions. My question is: If there's > more then one regex grouping I want to replace in one > line of a file, how can I use the String Formatting > operator (%s) in two places? Hi Jerome,

[Tutor] string formatting question

2006-04-07 Thread Jerome Jabson
Hello, I'm trying to replace some strings in a line of text, using some regex functions. My question is: If there's more then one regex grouping I want to replace in one line of a file, how can I use the String Formatting operator (%s) in two places? Here's the line it matches in the file: Her

Re: [Tutor] Quick question,

2006-04-07 Thread Hugo González Monteverde
Carlos Benevides wrote: > Hi, > > Can someone tell me what the r before the expression means, as in > "re.compile(r'(\.exe|\.zip|\.pif|\.scr|\.ps|\.pdf|\.ppt)$')"? It is not specific to regular expressions, it is called a raw string. http://docs.python.org/tut/node5.html ___

Re: [Tutor] function caller

2006-04-07 Thread Hugo González Monteverde
josip wrote: > Can someone explain me function and caller relationship when passing > arguments? Hi... what do you mean? Is there something specific you're not getting if you take a look at: http://www.ibiblio.org/obp/thinkCSpy/chap03.htm http://docs.python.org/tut/node6.html#SECTION00660

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Hugo González Monteverde
Liam Clarke wrote: > Each thread's run() method basically looks like this - > > while True: > try: > data = self.queue.get(False) > self.DAO.send_data(data) > except Empty: > if self.shutdown: > pr

Re: [Tutor] Quick question,

2006-04-07 Thread Noufal Ibrahim
On Fri, April 7, 2006 8:23 pm, Carlos Benevides wrote: > Hi, > > Can someone tell me what the r before the expression means, as in > "re.compile(r'(\.exe|\.zip|\.pif|\.scr|\.ps|\.pdf|\.ppt)$')"? r is the way of making a string "raw". This means that escape characters will not be interpreted. Here

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Kent Johnson
Liam Clarke wrote: > Hi, > > I've developed what would be my largest Python app to date. And, going > from the crude Windows Task Manager, it's trying to use as much CPU > time as it can get when it's idle. > > This, no doub,t is due to my design. > > I have an UDP socket server, a packet crunch

[Tutor] Quick question,

2006-04-07 Thread Carlos Benevides
Hi, Can someone tell me what the r before the expression means, as in "re.compile(r'(\.exe|\.zip|\.pif|\.scr|\.ps|\.pdf|\.ppt)$')"? I've seen regular expressions both ways, and I've seen them work with or without the r. Just wondering what it does, or if it makes a difference. Thanks. ___

[Tutor] function caller

2006-04-07 Thread josip
Hi,   Can someone explain me function and caller relationship when passing arguments?   Thanks How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listin

[Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Liam Clarke
Hi, I've developed what would be my largest Python app to date. And, going from the crude Windows Task Manager, it's trying to use as much CPU time as it can get when it's idle. This, no doub,t is due to my design. I have an UDP socket server, a packet cruncher, and a DAO. Each resides in it's o