[Tutor] small floating point number problem

2006-02-07 Thread Smith
I just ran into a curious behavior with small floating points, trying to find the limits of them on my machine (XP). Does anyone know why the '0.0' is showing up for one case below but not for the other? According to my tests, the smallest representable float on my machine is much smaller than 1

Re: [Tutor] Finding bottom level directories, and command-line arguments

2006-02-07 Thread Simon Gerber
Hi Danny, Thanks for the advice. > It might be interesting to write a function that takes an arbitrary > directory, and returns 'True' if that directory is a bottom-level > directory. Can you write this function? I've got this: --- def isBottomDir(path): for item in os.listdir(path):

Re: [Tutor] Finding bottom level directories, and command-line arguments

2006-02-07 Thread Danny Yoo
On Wed, 8 Feb 2006, Simon Gerber wrote: > I watch many different TV shows on my PC, as many of us do. But I am > sick and tired of forgetting which episode I was up to. So, in a > prodigious effort to avoid ever using, say, a pen, I am working on a > script to take over some of my brain's memory

[Tutor] Finding bottom level directories, and command-line arguments

2006-02-07 Thread Simon Gerber
G'day Tutors, I watch many different TV shows on my PC, as many of us do. But I am sick and tired of forgetting which episode I was up to. So, in a prodigious effort to avoid ever using, say, a pen, I am working on a script to take over some of my brain's memory handling. When complete, I will si

Re: [Tutor] I would like to learn python ASAP

2006-02-07 Thread Danny Yoo
On Tue, 7 Feb 2006, guy wrote: > I am in the QA field, and am learning Java as well in school but must QA > jobs today require one to know some scripting language. I do know SQL (Using > MySQL) and have writing small starting python and java scripts like > calc.py/java and other print statements

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Michael Lange
On Tue, 07 Feb 2006 06:02:45 -0500 Kent Johnson <[EMAIL PROTECTED]> wrote: > > One way to make this code thread-safe is to use a threading.Condition() > instead of a boolean variable: > > thread 1 does: > > self.lock.acquire() > if condition: > self.name = 'bob' > else:

[Tutor] I would like to learn python ASAP

2006-02-07 Thread guy
Hello, My name is Guy and I live in San Francisco, I would like to learn python ASAP and am looking for a tutor. I know there are many sites out there that can help me self learn it but I am out of a job and it looks like if I learn Python as a scripting language I could speed up the process :-) I

Re: [Tutor] Python DB

2006-02-07 Thread Matt Williams
You might also want to have a look at DABO; I don't know how well it work on a handheld, though. http://dabodev.com/about Matt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why None?

2006-02-07 Thread Danny Yoo
On Tue, 7 Feb 2006, Christopher Spears wrote: > I get it! Have printFood return a string! > > def printFood(self): > return self.food.foodName Yup. *grin* Do one more thing though: call the function something other than 'printFood' now, since it clearly isn't doing any printing

Re: [Tutor] Why None?

2006-02-07 Thread Christopher Spears
I get it! Have printFood return a string! def printFood(self): return self.food.foodName Now I don't get the weird output anymore! -Chris --- Danny Yoo <[EMAIL PROTECTED]> wrote: > > Hi Chris, > > I'm going to be a little insidous and bring some > ideas from the textbook > "

Re: [Tutor] Why None?

2006-02-07 Thread Sean Perry
Hey Chris, check out this version. class Food: def __init__(self, name): self.name = name class Customer: def __init__(self,name): self.name = name self.food = None # 0 is for numbers def placeOrder(self, foodName, employee): print "%s: Hi %s!" %

Re: [Tutor] Why None?

2006-02-07 Thread Danny Yoo
Hi Chris, I'm going to be a little insidous and bring some ideas from the textbook "How to Design Programs." (http://htdp.org) Let's annotate each interesting method with what the method expects to take in, and what it expects to return. > def placeOrder(self, foodName, employee): We c

[Tutor] Why None?

2006-02-07 Thread Christopher Spears
Here is some code I wrote: class Food: def __init__(self, name): Food.foodName = name class Customer: def __init__(self,name): Customer.name = name Customer.food = 0 def placeOrder(self, foodName, employee): p

Re: [Tutor] stuck again - socket connection

2006-02-07 Thread nephish
Yeah, looking over it right now as a point of fact. thanks. Looks like exactly what i need. cheers shawn On Tue, 2006-02-07 at 10:43 -0800, Danny Yoo wrote: > > > from the docs, the byte stream is supposed to look like this: > > > [problem cut] > > > > so. how do i make 200 occupy 4 bytes ?

Re: [Tutor] stuck again - socket connection

2006-02-07 Thread Danny Yoo
> from the docs, the byte stream is supposed to look like this: > [problem cut] > > so. how do i make 200 occupy 4 bytes ? Hi Nephish, Have you had a chance to look at the 'struct' module yet? http://www.python.org/doc/lib/module-struct.html __

Re: [Tutor] newbie problem

2006-02-07 Thread Danny Yoo
On Tue, 7 Feb 2006, josip wrote: > I can't solve this, someone please help. Since this is a homework problem, we're limited in what we can say here. Can you simplify the problem a bit? Can you write a program that asks for stars, and just prints out that many stars? That is, ignore for now

Re: [Tutor] lunch.py

2006-02-07 Thread Ian Jones
In article <[EMAIL PROTECTED]>, Christopher Spears <[EMAIL PROTECTED]> wrote: > When I run the program, I get the following error [snip] The simple mechanical error is that when you're substituting more than one value, you need to wrap the value list in parens: print "%s, I want, %s plea

Re: [Tutor] Python - Embedded mysql server

2006-02-07 Thread Danny Yoo
On Tue, 7 Feb 2006, Paul Kraus wrote: > Anyone know where I can find information about how to embedd mysql into > a python application. I need my hand held. I have worked with mysql a > lot. I understand how to use python to manipulate a mysql database. What > I want to know is how to embedded a

Re: [Tutor] lunch.py

2006-02-07 Thread Sean Perry
Christopher Spears wrote: > I'm working on a program where a Customer orders Food > from an Employee. Here is what I have so far: > > class Food: > def __init__(self, name): > Food.foodName = name > what you want here is 'self.name = name' then in your code later you can do:

[Tutor] installing python the latest python programme

2006-02-07 Thread Gil Tucker
Hi to all, Whenever I try to install python 2.2 and later on Win. 2000 It never properly sets up on the compter. I usually only get the command section but the IDE never shows up. Maybe somebody has an idea or a tip as to what`s going on here. Cheers Gil

[Tutor] newbie problem

2006-02-07 Thread josip
Hi, I am learning Python trought one course. I can't solve this, someone please help.     Write a loop that prints 20 characters on the screen. Always 20. But it is made up of stars (*), which are printed first, and exclamation marks (!) that complete the line. Your program will first ask the use

[Tutor] stuck again - socket connection

2006-02-07 Thread nephish
ok, i am stuck again. from the docs, the byte stream is supposed to look like this: 'S' 'T' 'X' [length indicator] [message type] [message] 'E' 'N' 'X' the length indicator it says is a four byte integer number of a value N ( N would be how long the message body is ) the message ty

[Tutor] lunch.py

2006-02-07 Thread Christopher Spears
I'm working on a program where a Customer orders Food from an Employee. Here is what I have so far: class Food: def __init__(self, name): Food.foodName = name class Customer: def __init__(self,name): Customer.name = name def placeOrder(self

[Tutor] Python - Embedded mysql server

2006-02-07 Thread Paul Kraus
Anyone know where I can find information about how to embedd mysql into a python application. I need my hand held. I have worked with mysql a lot. I understand how to use python to manipulate a mysql database. What I want to know is how to embedded a database into my application. -- Paul Kraus

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Bernard Lebel
Hi Kent, To answer your first concern, not all changes need to be intercepted by one the child thread. I have not given out all the details about the program, but if the parent thread gets certain values from the database, it will take actions that may affect the child thread other than just by se

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-07 Thread Kent Johnson
Liam Clarke wrote: > On 2/7/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Liam Clarke wrote: >> >>>Hi all, >>> >>>About to embark on my first foray into threading, and rather unsure of >>>initial approach. I have a basic UDPServer from SocketServer running >>>using serve_forever(). I'd like to s

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Kent Johnson
Bernard Lebel wrote: > Hi Kent, > > I have put together a little script to give a rough idea about what > the program does. > > http://www.bernardlebel.com/scripts/nonxsi/help/bl_threadtest.py In this code, there is no guarantee that callMeWhenAttributeChanged() will see every change to oBernar

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Kent Johnson
Michael Lange wrote: > I have used a boolean to control access to a variable that is used by two > threads, > as in this example: > > thread 1 does: > > while self.locked: > pass > self.locked = 1 > if condition: > self.name = 'bob' > else: > self.name = '

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Michael Lange
On Mon, 06 Feb 2006 18:34:18 -0500 Kent Johnson <[EMAIL PROTECTED]> wrote: > > It sounds like you have some attributes that you are using as flags to > allow one thread to control another. There are definitely some pitfalls > here. You probably want to use threading.Condition or Queue.Queue to