Re: [Tutor] Random Q on Python's internals?

2005-10-31 Thread Danny Yoo
> I was perusing the standard library, and was wondering if anyone knew > how the internals of Python work, roughly or no. > > Basically, I assume os.pipe() resides in a DLL somewhere, yet when I > open up Python24.DLL in PEexplorer I can't find mention of pipes > anywhere... Hi Liam, os.pipe(

Re: [Tutor] while/if/elif/else loops

2005-10-31 Thread Alan Gauld
> import random > > > while tosses = 100<0: > coin = randrange(1) You need to preped random: coin = random.randrange(1) Otherwise it looks OKAlthough > tosses +=1 > if coin == 0: > heads +=1 > print "Heads" You might want to output the count too print heads, " heads"

Re: [Tutor] Turning kwargs into scalars

2005-10-31 Thread Danny Yoo
On Mon, 31 Oct 2005, Steve Bergman wrote: > Say I have a function: > > def f(self, **kwargs) : > > and I want to take the key/value pairs and create a set of variables > with the names of the keys. > > For example, if I say: > > f(x=5, y=2) > > I want to create local variables 'x' and 'y' in the

[Tutor] Random Q on Python's internals?

2005-10-31 Thread Liam Clarke
Hi all, I was perusing the standard library, and was wondering if anyone knew how the internals of Python work, roughly or no. Basically, I assume os.pipe() resides in a DLL somewhere, yet when I open up Python24.DLL in PEexplorer I can't find mention of pipes anywhere... am I looking the right

[Tutor] Turning kwargs into scalars

2005-10-31 Thread Steve Bergman
Say I have a function: def f(self, **kwargs) : and I want to take the key/value pairs and create a set of variables with the names of the keys. For example, if I say: f(x=5, y=2) I want to create local variables 'x' and 'y' in the function, with values of 5 and 2 respectively. How could I d

Re: [Tutor] help with prime number program

2005-10-31 Thread Danny Yoo
On Mon, 31 Oct 2005, Kent Johnson wrote: > Norman Silverstone wrote: > > I am a beginner so, I hope what I give, makes sense. In it's simplest > > form what is wrong with :- > > > > n = input("Enter a number") > > if n % 2 != 0 and n % 3 != 0: > >print n, " Is a prime number" > > > This only

Re: [Tutor] while/if/elif/else loops

2005-10-31 Thread R. Alan Monroe
> while tosses = 100<0: I didn't run the program, but this immediately caught my eye as looking kind of suspect. Was it a typo? Most programs usually have a need for comparisons of equal, or greater/less, but it's really rare to need both combined in one statement... Also if you really _do_ want

Re: [Tutor] : [Slightly OT] Using Python to intercept audio from a program

2005-10-31 Thread Orri Ganel
By the way, if it makes a difference, the program I intend to attempt this with is Rhapsody , a part of the RealPlayer collection of media software. -- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it. ___

Re: [Tutor] Talking to UDPServer

2005-10-31 Thread Johan Geldenhuys
Maybe you could tel us if you already have the server listening on the socket that you expec connections on? If, yes, do you want an example of how a client connects to that socket? Johan Carroll, Barry wrote: Greetings:   I am writing a browser-based interface to a server

[Tutor] : [Slightly OT] Using Python to intercept audio from a program

2005-10-31 Thread Orri Ganel
Title: [Tutor]: [Slightly OT] Using Python to intercept audio from a program Hello all, A week or two ago I sent in a few emails regarding using threads in automating conversion between wav's and mp3's using lame.  However, the program I use to generate these wav's, Audacity (a great program,

Re: [Tutor] Talking to UDPServer

2005-10-31 Thread Kent Johnson
Carroll, Barry wrote: > I am writing a browser-based interface to a server program which extends > SocketServer.UDPServer. The program listens on a well-known socket, > receiving commands, verifying them and using their content to drive our > test hardware, returning status to the client. The

Re: [Tutor] while/if/elif/else loops

2005-10-31 Thread Pujo Aji
Let's comment something:1. If you have error please show us your error message.2. When you code python be aware of indention, be persistent for example use tab space 4.3. import should be on the top of your code. 4. to choose random between integer 1 or 0 use randint(0,1)5. your last code use Print

[Tutor] Talking to UDPServer

2005-10-31 Thread Carroll, Barry
Greetings:   I am writing a browser-based interface to a server program which extends SocketServer.UDPServer.  The program listens on a well-known socket, receiving commands, verifying them and using their content to drive our test hardware, returning status to the client.  The current cl

Re: [Tutor] Tainted characters and CGI

2005-10-31 Thread Tim Johnson
* John Fouhy <[EMAIL PROTECTED]> [051031 14:16]: > On 01/11/05, Tim Johnson <[EMAIL PROTECTED]> wrote: > > Hello: > > I need to tighten my handling of CGI transmissions. > > I particular, I need to develop a strategy of safely dealing > > with "tainted" characters. > > A friend of mine has written

Re: [Tutor] (no subject)

2005-10-31 Thread Hugo González Monteverde
Do you need time to see the output? Then why don't you just use time.sleep(5) after each command? Hugo Roberts, Alice wrote: > Well, I'm looking into os.spawnl with os.P_WAIT, now. > > Thanks, > ___ Tutor maillist - Tutor@python.org http://mail.pyt

Re: [Tutor] Tainted characters and CGI

2005-10-31 Thread John Fouhy
On 01/11/05, Tim Johnson <[EMAIL PROTECTED]> wrote: > Hello: > I need to tighten my handling of CGI transmissions. > I particular, I need to develop a strategy of safely dealing > with "tainted" characters. A friend of mine has written a module that may be useful to you: """ zstr is an extension

Re: [Tutor] Tainted characters and CGI

2005-10-31 Thread Tim Johnson
* Ron Weidner <[EMAIL PROTECTED]> [051031 12:38]: > > > --- Tim Johnson <[EMAIL PROTECTED]> wrote: > > > Hello: > > I need to tighten my handling of CGI transmissions. > > I particular, I need to develop a strategy of safely > > dealing with "tainted" characters. > > Ahh... tainted characters.

[Tutor] while/if/elif/else loops

2005-10-31 Thread Zameer Manji
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I'm new to programming and python. I've have recently been experimenting with while/if/elif/else loops and I've created a simple number guessing game. Now I want to create a coin tossing game, but I don't know how to structure it in python. The code

Re: [Tutor] Tainted characters and CGI

2005-10-31 Thread Ron Weidner
--- Tim Johnson <[EMAIL PROTECTED]> wrote: > Hello: > I need to tighten my handling of CGI transmissions. > I particular, I need to develop a strategy of safely > dealing with "tainted" characters. Ahh... tainted characters. If by "tainted" you mean not UTF-8, there is a c tool called "iconv"

Re: [Tutor] Newbie Question - Python vs Perl

2005-10-31 Thread Tim Johnson
* Scott Clausen <[EMAIL PROTECTED]> [051030 16:30]: > As a newbie to Python I'd like to know if someone can tell me some > strengths and weaknesses of this language. The reason I'm asking is a > friend told me I should learn Perl over Python as it's more > prevalent. I'm going to be using it

[Tutor] Tainted characters and CGI

2005-10-31 Thread Tim Johnson
Hello: I need to tighten my handling of CGI transmissions. I particular, I need to develop a strategy of safely dealing with "tainted" characters. I'd appreciate any pointers to documentation and resources regarding this matter, as well as comments and caveats. At this time and for the forseeable f

Re: [Tutor] (no subject)

2005-10-31 Thread Roberts, Alice
Well, I'm looking into os.spawnl with os.P_WAIT, now. Thanks, -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Monday, October 31, 2005 1:57 PM To: Roberts, Alice; tutor@python.org Subject: Re: [Tutor] (no subject) > My os.system() isn't waiting for exit status, jumpi

Re: [Tutor] (no subject)

2005-10-31 Thread Alan Gauld
> My os.system() isn't waiting for exit status, jumping right into next > os.system(). Are you sure it isn't just running very quickly? The time it takes to display stuff on a screen is significant - all those phosphorescent pixels :-) os.system doesn't have to wait for that so it tends to run p

Re: [Tutor] (no subject)

2005-10-31 Thread Andrew P
If I'm not mistaken, that's the Pythonwin debugger spitting messages to the interactive prompt. I just used it to step through your your games framework example :) Being the first time I'd used any Python debugger, it didn't occur to me that the look of it was non-standard. I actually got the sa

[Tutor] (no subject)

2005-10-31 Thread Roberts, Alice
Hi,   My os.system() isn’t waiting for exit status, jumping right into next os.system().   import os   DIR = 'v:/pam/batch/ambac/' CMD1 = DIR + 'Prices_Prep.cmd' CMD2 = DIR + 'positions.cmd' CMD3 = DIR + 'ftp_hub.cmd' CMD4 = DIR + 'import_prices.cmd'   try:         os.system(

Re: [Tutor] (no subject)

2005-10-31 Thread Alan Gauld
> When I ran in debugger, calling the FTP library invokes a no SOCKS > module error that the ftplib seems to be trying to access. Can you tell us which debugger you are using? I don't recognise what's going on here. >>> --Call-- This looks like the Python interactive prompt, but whats the --C

Re: [Tutor] help with prime number program

2005-10-31 Thread Alan Gauld
> n = input("Enter a number") > if n % 2 != 0 and n % 3 != 0: > print n, " Is a prime number" > > Comments please. According to this 25 is a prime number Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] (no subject)

2005-10-31 Thread Andrew P
Before you hit the debugger, it might be a good idea to just run the script normally, either at the command line, or inside IDLE/Pythonwin. Doing so will spit out: Traceback (most recent call last): File "", line 1, in ? NameError: name 'ftplib' is not defined Because you imported with: from

Re: [Tutor] Newbie Question - Python vs Perl

2005-10-31 Thread Andrew P
If you are interested in learning another tool, please, start with Python. If you are interested in scripting UNIX, Perl is a fine choice. There prevalence matters, and quite a bit. But sys admins are usually very Perl-centric, and in my experience monolingual, and a bit of an insular community

[Tutor] (no subject)

2005-10-31 Thread Roberts, Alice
Good morning,   I’m migrating from DOS scripting to Python, and need a little help.  I got this sample from a Google search that brought me to effbot.org, http://effbot.org/librarybook/ftplib.htm.  Also, I plugged in all my variables when I tested, but replaced with generics for this emai

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
> > Thank you for your comment which, if I understand you correctly, implies > > that prime numbers greater than 25 will not be recognised. Surely, that > > cannot be correct. However, if it is correct, could you please > > demonstrate what you mean for my education. > > More precisely, it will g

Re: [Tutor] help with prime number program

2005-10-31 Thread Kent Johnson
Norman Silverstone wrote: > On Mon, 2005-10-31 at 06:12 -0500, Kent Johnson wrote: > >>Norman Silverstone wrote: >> >>>I am a beginner so, I hope what I give, makes sense. In it's simplest >>>form what is wrong with :- >>> >>>n = input("Enter a number") >>>if n % 2 != 0 and n % 3 != 0: >>> print

Re: [Tutor] help with prime number program

2005-10-31 Thread Glen Wheeler
From: "Norman Silverstone" <[EMAIL PROTECTED]> > On Mon, 2005-10-31 at 06:12 -0500, Kent Johnson wrote: >> Norman Silverstone wrote: >> > I am a beginner so, I hope what I give, makes sense. In it's simplest >> > form what is wrong with :- >> > >> > n = input("Enter a number") >> > if n % 2 != 0 an

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
On Mon, 2005-10-31 at 06:12 -0500, Kent Johnson wrote: > Norman Silverstone wrote: > > I am a beginner so, I hope what I give, makes sense. In it's simplest > > form what is wrong with :- > > > > n = input("Enter a number") > > if n % 2 != 0 and n % 3 != 0: > >print n, " Is a prime number" > >

Re: [Tutor] compare

2005-10-31 Thread Liam Clarke
> > > >1 # calc.py > >2 def calc(seq): > >3 maximum = 0 > >4 max_item = [] > >5 for i in seq: > >6 product = (i[0]*100 + i[1]*10 + i[2]) * (i[3]*10 + i[4]) > >7 if product > maximum: > >8maximum = product > >9max_item = i > > 10 el

Re: [Tutor] help with prime number program

2005-10-31 Thread Kent Johnson
Norman Silverstone wrote: > I am a beginner so, I hope what I give, makes sense. In it's simplest > form what is wrong with :- > > n = input("Enter a number") > if n % 2 != 0 and n % 3 != 0: >print n, " Is a prime number" > This only gives the correct answer if n < 25. You can't test against

Re: [Tutor] help with prime number program

2005-10-31 Thread Norman Silverstone
> I am trying to write a program that will figure out if a number is prime > or not. Currently this is the code that I have: > > import math > > def main(): > > number=input("Please enter a positive whole number greater than 2: ") > for value in range(2, number-math.sqrt): > if

Re: [Tutor] compare

2005-10-31 Thread Johan Geldenhuys
In your code that line is not executed. And if it was at some stage, it will give you an error. max_item is a list and you cannot put a string and a list together: "TypeError: cannot concatenate 'str' and 'list' objects". What are trying to do with this line? 'maximum = 0' and so product will

Re: [Tutor] Newbie Question - Python vs Perl

2005-10-31 Thread Liam Clarke
On 10/31/05, Scott Clausen <[EMAIL PROTECTED]> wrote: > As a newbie to Python I'd like to know if someone can tell me some > strengths and weaknesses of this language. The reason I'm asking is a > friend told me I should learn Perl over Python as it's more > prevalent. I'm going to be using it on

Re: [Tutor] Newbie Question - Python vs Perl

2005-10-31 Thread Jan Eden
Hi Scott, Scott Clausen wrote on 30.10.2005: >As a newbie to Python I'd like to know if someone can tell me some >strengths and weaknesses of this language. The reason I'm asking is >a friend told me I should learn Perl over Python as it's more >prevalent. I'm going to be using it on a Mac. > >I

Re: [Tutor] Newbie Question - Python vs Perl

2005-10-31 Thread Alan Gauld
> friend told me I should learn Perl over Python as it's more > prevalent. I'm going to be using it on a Mac. In that case you should switch to a PC because they are more prevalent. Also you should learn to program in COBOL since its the most prevalent of all computer languages. And yet most fol

[Tutor] compare

2005-10-31 Thread Shi Mu
What does this line 11 mean in the following code? 1 # calc.py 2 def calc(seq): 3 maximum = 0 4 max_item = [] 5 for i in seq: 6 product = (i[0]*100 + i[1]*10 + i[2]) * (i[3]*10 + i[4]) 7 if product > maximum: 8maximum = product 9max_ite