Re: [Tutor] (no subject). Ord and Chr query

2005-05-26 Thread Tim Johnson
* Kent Johnson <[EMAIL PROTECTED]> [050526 14:16]: > John Carmona wrote: > > Sorry I should have been clearer with the query perhaps. > > Alan I am just going through the book "Learning Python" written by Lutz and > > Ascher, and this is part of one exercise. I am still having problem in > > putt

Re: [Tutor] (no subject). Ord and Chr query

2005-05-26 Thread Kent Johnson
John Carmona wrote: > Sorry I should have been clearer with the query perhaps. > Alan I am just going through the book "Learning Python" written by Lutz and > Ascher, and this is part of one exercise. I am still having problem in > putting my head around in writting even very simple script. I can

Re: [Tutor] Program to lock folders under win32

2005-05-26 Thread jfouhy
Quoting Mark Kels <[EMAIL PROTECTED]>: > I want to make a program to lock folders (so the user can only access > them if he knows the password) under win32, the only problem is that I > have no idea how to start or what to do. Do you guys have any ideas of > how to do it? Is your program going to

Re: [Tutor] pattern matching problem

2005-05-26 Thread Alan G
> I have to write a function that will return the index of a line like this: > > gvcdgvcgdvagTVTVTVTVTVTHUXHYGSXUHXSU > > where it first becomes capital letters. I'd go with a regex search for that one... Alan g. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] better resolution on time.sleep()?

2005-05-26 Thread Alan G
> Rumor has it that Alan G may have mentioned these words: > > >Consuming 100% CPU won't make much difference, the CPU is running all > >the time anyway (when its not asleep). > > Not mine... my laptop runs a Crusoe processor, and it can automatically > scale itself from 300Mhz to 933Mhz. It's cal

Re: [Tutor] (no subject). Ord and Chr query

2005-05-26 Thread Alan G
Hi John, > Alan I am just going through the book "Learning Python" written by Lutz and > Ascher, and this is part of one exercise. I suspected it might be something you were doing just to explore. Lutz and Ascher is a great book but they do assume some knowledge of programming and computer concep

Re: [Tutor] (no subject). Ord and Chr query

2005-05-26 Thread John Carmona
Pujo, Alan, John and Ben, thanks for the input. Sorry I should have been clearer with the query perhaps. Alan I am just going through the book "Learning Python" written by Lutz and Ascher, and this is part of one exercise. I am still having problem in putting my head around in writting even very

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Alan G
> Is there a way to create an empty function definition with no lines of code > in it? In my coding style I will often do this ( in other languages ) for > RAD just to remind myself that I will need to implement the function later. > Use pass def f(): pass also works for classes: class MyClass:

Re: [Tutor] python problem

2005-05-26 Thread Alan G
> i'm trying to write a code that handle errors help > > def print_menu(): ... Personally I try to get the menu function to return the value selected that way the meniu options and the code to check it is all wrapped up in the same place. But that is only a side issue... > while menu_choice != 5

Re: [Tutor] pattern matching problem

2005-05-26 Thread Danny Yoo
On 26 May 2005 [EMAIL PROTECTED] wrote: > One of the worst I think was doing loads of real spazzy stuff trying to > split whole files in to lists of letters and use string methods to find > the first uppercase one. Hi Chris, An approach like this might work. Rather than read the whole thing i

Re: [Tutor] Program to lock folders under win32

2005-05-26 Thread Danny Yoo
On Thu, 26 May 2005, Mark Kels wrote: > I want to make a program to lock folders (so the user can only access > them if he knows the password) under win32, the only problem is that I > have no idea how to start or what to do. Do you guys have any ideas of > how to do it? Hi Mark, Out of curios

Re: [Tutor] pattern matching problem

2005-05-26 Thread cgw501
One of the worst I think was doing loads of real spazzy stuff trying to split whole files in to lists of letters and use string methods to find the first uppercase one. The re tutorial has sorted it out for me. I figured this was the way to go, I just couldn't work out how to get the index valu

Re: [Tutor] pattern matching problem

2005-05-26 Thread Danny Yoo
On 26 May 2005 [EMAIL PROTECTED] wrote: > I have to write a function that will return the index of a line like this: > > gvcdgvcgdvagTVTVTVTVTVTHUXHYGSXUHXSU > > where it first becomes capital letters. I've had about a hundred > different ideas of the best way to do this, but always seem to hit

[Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Lloyd Kvam
An alternative to pass is raise NotImplementedError This has the advantage/disadvantage of providing a meaningful exception when you start testing and forget to provide some processing logic for a stub function. pass will simply return None when used for a function body. I nearly always

Re: [Tutor] Expression order problem

2005-05-26 Thread Danny Yoo
On Thu, 26 May 2005, William O'Higgins wrote: > I am running into problems with script evaluation order - specifically, > the Python interpreter seems to read and execute scripts line by line. Hi William, Ah! This happens to me too; one common idiom to avoid definition-order issues like this

[Tutor] pattern matching problem

2005-05-26 Thread cgw501
Hi, I have to write a function that will return the index of a line like this: gvcdgvcgdvagTVTVTVTVTVTHUXHYGSXUHXSU where it first becomes capital letters. I've had about a hundred different ideas of the best way to do this, but always seem to hit a fatal flaw. Any thoughts? Thanks, Chris __

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Danny Yoo
> Is there a way to create an empty function definition with no lines of > code in it? In my coding style I will often do this ( in other languages > ) for RAD just to remind myself that I will need to implement the > function later. Hi Nick, I agree with the others; using the no-op statement '

Re: [Tutor] python problem

2005-05-26 Thread Andrei
Feziwe Mpondo sanbi.ac.za> writes: > i'm trying to write a code that handle errors help I think the indentation was screwed up. > while menu_choice != 5: > menu_choice = input("Type in a number (1-5):") I'd avoid using input. Use raw_input instead. > break break stops a loop. So you

Re: [Tutor] better resolution on time.sleep()?

2005-05-26 Thread Roger Merchberger
Rumor has it that Alan G may have mentioned these words: > > I'm running an application that has a polling loop to check a serial >port > > for certain signals, and on my laptop I can get about 6700 samples >per > > second, which (of course) consumes 100% CPU; which may impact >battery life. > >Co

Re: [Tutor] Expression order problem

2005-05-26 Thread Andrei
William O'Higgins utoronto.ca> writes: > This is a problem if you are used to Perl, where the whole script is > parsed first (Perl also auto-vivifies variables, but that's a different > problem for a different day). Here is a test script: The Python compiler parses the whole script too, can't c

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Nick Lunt
Hi John, you can use 'pass' . This works the same as with exceptions, eg try: open('somefile') except IOError: pass so we can have class doNothing: def __init__(self): pass def boring(self, other): pass Hope that helps :) Nick --

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Gooch, John
Thanks Kent! -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Thursday, May 26, 2005 9:52 AM To: Gooch, John Cc: tutor@python.org Subject: Re: [Tutor] Are Empty "Placeholder" Functions possible? Gooch, John wrote: > Is there a way to create an empty function definit

[Tutor] Expression order problem

2005-05-26 Thread William O'Higgins
I am running into problems with script evaluation order - specifically, the Python interpreter seems to read and execute scripts line by line. This is a problem if you are used to Perl, where the whole script is parsed first (Perl also auto-vivifies variables, but that's a different problem for a d

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Kent Johnson
Gooch, John wrote: > Is there a way to create an empty function definition with no lines of code > in it? In my coding style I will often do this ( in other languages ) for > RAD just to remind myself that I will need to implement the function later. A block cannot be empty but there is a placeho

[Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Gooch, John
Is there a way to create an empty function definition with no lines of code in it? In my coding style I will often do this ( in other languages ) for RAD just to remind myself that I will need to implement the function later. Example: For a file handling class, I may need functions such as copy,d

[Tutor] python problem

2005-05-26 Thread Feziwe Mpondo
hi i'm trying to write a code that handle errors help def print_menu(): print '1. Print Phone Numbers' print '2. Add a Phone Number' print '3. Remove a Phone Number' print '4. Lookup a Phone Number' print '5. Quit' print numbers = {} menu_choice = 0 print_menu() while men

[Tutor] Program to lock folders under win32

2005-05-26 Thread Mark Kels
Hi list. I want to make a program to lock folders (so the user can only access them if he knows the password) under win32, the only problem is that I have no idea how to start or what to do. Do you guys have any ideas of how to do it? Thanks! -- 1. The day Microsoft makes something that doesn'

Re: [Tutor] Am I making this harder than it needs to be?

2005-05-26 Thread Ron Phillips
Ron Phillips wrote:>> short version: I  need a way to get max and min E and N out of >> [(E0,N0),(E1,N1)...(En,Nn)] without reordering the list>>> Kent Johnson [EMAIL PROTECTED]> 5/25/2005 10:19 AM >>>For Python < 2.4 you need another set of [ ] e.g. min([e for e,n in coordList]) I knew I was wo

Re: [Tutor] (no subject)

2005-05-26 Thread Ben Vinger
Or like this: for x in range (0,256): print ord(chr(x)), ': ', chr(x) (you could just print x, instead of ord(chr(x)), but then you would not be using ord) Ben --- Pujo Aji <[EMAIL PROTECTED]> wrote: > Actually you can do the same way: > > # Convert intAscii to charAscii > S = [chr

Re: [Tutor] (no subject)

2005-05-26 Thread Alan G
> S = [chr(x) for x in range (0,256)] > for x in S: > print x, for x in range(256): print chr(x), > The next step is to use the built-in functin ord() in order to convert each > character to an ASCII integer. That will give you the numbers 0..255 ord() is simply the inverse of chr() so tha

Re: [Tutor] Python won't play .wav file

2005-05-26 Thread Alan G
> And if I'm on Linux or programing for Mac? Sadly sound is one of those things that tends to be system dependant. There is a Sun audio module somewhere too... On the Mac I believe its a Quicktime thing using the MacPython libraries. The good news is that I think PyGame provides a platform inde

Re: [Tutor] (no subject)

2005-05-26 Thread Pujo Aji
Actually you can do the same way: # Convert intAscii to charAscii S = [chr(x) for x in range(0,256)] for x in S: print x #Convert charAscii to intAscii AsciiInt = [ord(x) for x in S] for x in AsciiInt: print x Best Regards, pujo On 5/26/05, John Carmona <[EMAIL PROTECTED