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

2005-05-24 Thread Alan G
> 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. Consuming 100% CPU won't make much difference, the CPU is running all

[Tutor] ASCII characters

2005-05-24 Thread John Carmona
I need to print all the ASCII characters within a string, how would I delimit for example to print the first 100 only? Many thanks JC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
John Carmona wrote: > I need to print all the ASCII characters within a string, how would I > delimit for example to print the first 100 only? Many thanks A string is a sequence and supports sequence operations including slices. So s[:100] gives the first 100 chars of a string. You might be i

Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-24 Thread Shidai Liu
On 5/23/05, Tony Meyer <[EMAIL PROTECTED]> wrote: > I have the local machine's administration privilege.[...]> When I run the command as you point out, I got the following> messages>> (5, 'InitiateSystemShutdown', 'Access is denied.') The process itself needs to have the privilege.  This message ha

[Tutor] Python Date picker

2005-05-24 Thread Alberto Troiano
Hey everyone I've been searching (with no luck by the way) for a date picker combo or something like it What I need to do is validate a date field (better if it's already done) and I want to know if anyone knows about a code to do that (a made code, don't mean you to do my work). I was hoping

Re: [Tutor] Filtering Spreadsheet Data

2005-05-24 Thread Mike Hansen
> Subject: > [Tutor] Filtering Spreadsheet Data > From: > Luke Jordan <[EMAIL PROTECTED]> > Date: > Mon, 23 May 2005 15:30:33 -0500 > To: > tutor@python.org > > To: > tutor@python.org > > > Hi All, > > I have several frighteningly cumbersome reports to review at my new > job. I would like to wr

Re: [Tutor] Filtering Spreadsheet Data

2005-05-24 Thread Max Noel
On May 24, 2005, at 14:22, Mike Hansen wrote: > Excel has some nice database-like queries itself. Take a look at > Advanced Filter > in Help. You can essentially query a worksheet and even send the > results to a > different worksheet. I'd imagine that once you got the query > working, you

[Tutor] Python won't play wav file

2005-05-24 Thread Joseph Quigley
I can't get: import wave as w def manipulate(): manipulate = raw_input("Type 'help' for help\nManipulate>> ") if manipulate == "play": w.tell() elif manipulate == "back()": main_menu() def open(): while True: file_name = raw_input("Open: ")

[Tutor] Sorting a directory

2005-05-24 Thread Jonas Melian
Hi all, I have to working with the files lines in this directory: ::: dir_locales = "/usr/share/i18n/locales/" for line in fileinput.input(glob.glob(os.path.join\ (dir_locales, "*_[A-Z][A-Z]"))): ... ::: The problem is that the directory otuput is: aa_DJ aa_ER aa_ET af_ZA ... and

Re: [Tutor] Sorting a directory

2005-05-24 Thread Kent Johnson
Jonas Melian wrote: > Hi all, > > I have to working with the files lines in this directory: > > ::: > dir_locales = "/usr/share/i18n/locales/" > > for line in fileinput.input(glob.glob(os.path.join\ > (dir_locales, "*_[A-Z][A-Z]"))): > ... > > ::: > > The problem is that the direct

Re: [Tutor] Sorting a directory

2005-05-24 Thread Jonas Melian
Kent Johnson wrote: >>and i would sort this files by the 2 last letters, so: > > The sort() method of a mutable sequence is very powerful. Docs for it are > here: > http://docs.python.org/lib/typesseq-mutable.html > > The key= parameter of sort() allows you to provide a function which, given a

Re: [Tutor] Sorting a directory

2005-05-24 Thread Kent Johnson
Jonas Melian wrote: > Kent Johnson wrote: >>files = glob.glob(os.path.join(dir_locales, "*_[A-Z][A-Z]")) >>files.sort(key=lastTwoChars) # Note: NOT key=lastTwoChars() > > I get: > :: > files.sort(key=lastTwoChars) > TypeError: sort() takes no keyword arguments > :: > > Could it be by the Python

Re: [Tutor] passing variables between frames?

2005-05-24 Thread Jeff Peery
ok, thanks. that makes sense; however I do not know how to pass a variable from my parent frame to the dialog.  I have tried this before unsuccessfully. could you provide a quick example of how to pass a variable to a dialog from a frame. I am not sure how this works. thanks.   JeffKent Johnson <[E

Re: [Tutor] Sorting a directory

2005-05-24 Thread Pujo Aji
you can sort listsource based on listkey For example: you have listsource = ['c','b','a'] and listkey = [2,3,1] # this will be used to sort listsource. def sortbasedlist(sources,keys): #combine (key,sources) Kombin = [(keys[i],sources[i]) for i in range(len(sources))] Kombin.sort() return

[Tutor] strip is deprecated, so what do I use?

2005-05-24 Thread William O'Higgins
As the subject says, I was looking for an analog to chomp, and found strip() and friends (rstrip() and lstrip()), but they are deprecated. I'm happy to forgo their use in preparation for 3.0 (I figure we're going to live the rest of our lives in the future, we might as well be ready) but I need an

[Tutor] Wizards in Tkinter

2005-05-24 Thread William O'Higgins
I am writing a small application that takes a user through a set of steps - like a wizard. What I need is an idea how I can start with a window, have the use click "Next" and get another window. My understanding is that it is undesirable to have more than one mainloop per program. Thanks. -- y

Re: [Tutor] ASCII characters

2005-05-24 Thread John Carmona
Thanks Kent for the reply, I am actually having trouble to find the solution of the following exercise: ## Write a for loop that prints the ASCII code of each character in a string name S.## I am ok with the for loop, put I don't know how get to print the ASCII code of each character with a st

Re: [Tutor] strip is deprecated, so what do I use?

2005-05-24 Thread William O'Higgins
On Tue, May 24, 2005 at 01:16:21PM -0400, Michael P. Reilly wrote: > On 5/24/05, William O'Higgins <[EMAIL PROTECTED]> wrote: > > As the subject says, I was looking for an analog to chomp, and found > strip() and friends (rstrip() and lstrip()), but they are deprecated. > I'm happy to

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
John Carmona wrote: > Thanks Kent for the reply, I am actually having trouble to find the > solution of the following exercise: > > ## Write a for loop that prints the ASCII code of each character in a > string name S.## > > I am ok with the for loop, put I don't know how get to print the ASCII

Re: [Tutor] ASCII characters

2005-05-24 Thread D. Hartley
I have a question: what is the "opposite" of hex()? (i.e., like ord and chr). If I have '0x73', how can I get back to 115 or s? Thanks! ~Denise > You need the ord() function and maybe hex() also: > >>> ord('s') > 115 > >>> hex(ord('s')) > '0x73' > > Kent > >

Re: [Tutor] ASCII characters

2005-05-24 Thread Kent Johnson
D. Hartley wrote: > I have a question: what is the "opposite" of hex()? (i.e., like ord > and chr). If I have > > '0x73', how can I get back to 115 or s? I don't know a really clean way to do this because '0x73' is not a legal input value for int(). The simplest way is to use eval(): >>> eva

Re: [Tutor] ASCII characters

2005-05-24 Thread Danny Yoo
On Tue, 24 May 2005, Kent Johnson wrote: > D. Hartley wrote: > > I have a question: what is the "opposite" of hex()? (i.e., like ord > > and chr). If I have > > > > '0x73', how can I get back to 115 or s? > > I don't know a really clean way to do this because '0x73' is not a legal > input value

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

2005-05-24 Thread Lee Harr
>I can't get: > >import wave as w > >... to play a .wav music file. I tried w.play() but got an error that >module has no attribute 'play'. >What do I use to get it to play? Strangely... I do not believe the wave module is meant to actually _play_ a wav file. It looks to me like it is only inte

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

2005-05-24 Thread Kent Johnson
Lee Harr wrote: >>I can't get: >> >>import wave as w >> > > > >>... to play a .wav music file. I tried w.play() but got an error that >>module has no attribute 'play'. >>What do I use to get it to play? > > > > Strangely... I do not believe the wave module is meant to actually > _play_ a wav

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

2005-05-24 Thread Max Noel
On May 24, 2005, at 02:49, Joseph Quigley wrote: > ... to play a .wav music file. I tried w.play() but got an error that > module has no attribute 'play'. > What do I use to get it to play? > Thanks, The wave module is meant to read, write and manipulate (transform, filter, whatever) WAV

[Tutor] Anyone doing the riddles?

2005-05-24 Thread D. Hartley
Hello all! I was just thinking: if there are people on here who are still doing the python riddles (or are interested in talking about them), I could start an off-tutor thread so that we could chat about them without clogging up the tutor mailing list for others? If you are interested, drop me an

Re: [Tutor] Python Date picker

2005-05-24 Thread Lee Harr
>What I need to do is validate a date field (better if it's already done) >and >I want to know if anyone knows about a code to do that (a made code, don't >mean you to do my work). I was hoping to find a calendar combo box as in >Visual Basic DropDown Calendar For which GUI system? py-qt has Da

Re: [Tutor] Python Date picker

2005-05-24 Thread Alberto Troiano
Completeley forgot, :D I'm working over Windows, Python 2.3., GUI Tkinter Thanks in advanced Alberto http://graphics.hotmail.com/emvamp.gif"; width=12> Gaucho >From: "Lee Harr" <[EMAIL PROTECTED]> >To: tutor@python.org >Subject: Re: [Tutor] Python Date picker >Date: Wed, 25 May 2005 01:5

[Tutor] xml

2005-05-24 Thread D. Hartley
And just in case anyone *isnt* working on the riddles: anyone have a pointer to a *SIMPLE* intro to xml as used in python? I looked in the library and there are about 11 xml-related modules. Perhaps something 'remote'. ;) ___ Tutor maillist

[Tutor] Fwd: xml

2005-05-24 Thread Max Noel
(meh, forgot to click "reply-all" again) Begin forwarded message: > From: Max Noel <[EMAIL PROTECTED]> > Date: May 24, 2005 23:01:39 BDT > To: "D. Hartley" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] xml > > > > On May 24, 2005, at 22:59, D. Hartley wrote: > > >> anyone have a pointer to a *SIMPLE

Re: [Tutor] Wizards in Tkinter

2005-05-24 Thread jfouhy
Quoting William O'Higgins <[EMAIL PROTECTED]>: > I am writing a small application that takes a user through a set of > steps - like a wizard. What I need is an idea how I can start with a > window, have the use click "Next" and get another window. My > understanding is that it is undesirable to ha

Re: [Tutor] xml

2005-05-24 Thread jfouhy
Quoting "D. Hartley" <[EMAIL PROTECTED]>: > anyone have a pointer to a *SIMPLE* intro to xml as used in python? I > looked in the library and there are about 11 xml-related modules. > > Perhaps something 'remote'. ;) Use ElementTree! (google for it) -- John. __

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

2005-05-24 Thread Alan G
Joseph, I don't know if this will help or not, but some observations: > def manipulate(): > manipulate = raw_input("Type 'help' for help\nManipulate>> ") > if manipulate == "play": > w.tell() > elif manipulate == "back()": > main_menu() You expect the user to typ

Re: [Tutor] Wizards in Tkinter

2005-05-24 Thread Alan G
Your mail came as an attachment so no quoted text, but basically there are two approaches to your problem of a Wizard. In Tkinter you normally use a Frame as your main window. You can pack another Frame inside that frame with your content. When you press next simply unpack frame 1 and pack frame

Re: [Tutor] xml

2005-05-24 Thread Kent Johnson
D. Hartley wrote: > And just in case anyone *isnt* working on the riddles: > > anyone have a pointer to a *SIMPLE* intro to xml as used in python? I > looked in the library and there are about 11 xml-related modules. ElementTree is my choice too. It is simple and easy to use though a bit bar

Re: [Tutor] xml

2005-05-24 Thread D. Hartley
I looked at the page for ElementTree that Max sent out, but I can't understand what it's even talking about. Looking through the python modules it seems like I need xmlrpclib - I created a serverproxy instance, which I want to use to talk to a server - to send it information (in this case, a name),

[Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
I am having trouble understanding the c|Pickle modules. What does serializing and de-serializing objects mean? I have read the below urls and I "think" I understand the process, but I can't visualize the beneifts. Can someone kindly explain pickling in lamens terms? Thanks, Tom http://effbot

Re: [Tutor] Pickling in plain English

2005-05-24 Thread jfouhy
Quoting Tom Tucker <[EMAIL PROTECTED]>: > I am having trouble understanding the c|Pickle modules. What does > serializing and de-serializing objects mean? I have read the below > urls and I "think" I understand the process, but I can't visualize the > beneifts. Can someone kindly explain pickling

Re: [Tutor] xml

2005-05-24 Thread Danny Yoo
On Tue, 24 May 2005, D. Hartley wrote: > I looked at the page for ElementTree that Max sent out, but I can't > understand what it's even talking about. Hello Denise, ElementTree is a third-party module by the Effbot for handling some of the drudgery that is XML parsing: http://effbot.org

Re: [Tutor] Pickling in plain English

2005-05-24 Thread Tom Cloyd
I just want to take a moment to express my deep appreciation for this List. As one who is learning Python as amateur, in my spare moments, and already getting it to do good work for me, these clear, beautifully worked descriptions of basic aspects of Python are simply an ongoing delight for

Re: [Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
John, Thanks that did help. Like usual, I was making it harder than necessary. Tom, I concur! Well put! On 5/24/05, Tom Cloyd <[EMAIL PROTECTED]> wrote: > I just want to take a moment to express my deep appreciation for this > List. As one who is learning Python as amateur, in my spare moments

Re: [Tutor] passing variables between frames?

2005-05-24 Thread Kent Johnson
Jeff Peery wrote: > ok, thanks. that makes sense; however I do not know how to pass a > variable from my parent frame to the dialog. I have tried this before > unsuccessfully. could you provide a quick example of how to pass a > variable to a dialog from a frame. I am not sure how this works. t

[Tutor] Covert numbers to hex fails

2005-05-24 Thread Tom Tucker
Good evening! I am trying to pass a number variable and have it converted to hex. Any recommendations on how to achieve this? Thank you. FAILS -- >>> value = 1234567890 >>> hexoutput = hex('%d' % (value)) Traceback (most recent call last): File "", line 1, in ? TypeError: hex() argume

Re: [Tutor] passing variables between frames?

2005-05-24 Thread Jeff Peery
actually I got it to work! thanks for the help.   JeffKent Johnson <[EMAIL PROTECTED]> wrote: Jeff Peery wrote:> ok, thanks. that makes sense; however I do not know how to pass a > variable from my parent frame to the dialog. I have tried this before > unsuccessfully. could you provide a quick exam

Re: [Tutor] Covert numbers to hex fails

2005-05-24 Thread Tony Meyer
> FAILS > -- > >>> value = 1234567890 > >>> hexoutput = hex('%d' % (value)) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: hex() argument can't be converted to hex Just don't convert the number to a string, e.g: >>> value = 1234567890 >>> hexoutput = hex(value

Re: [Tutor] Covert numbers to hex fails

2005-05-24 Thread Tom Tucker
Thanks!I see the mistake. On 5/24/05, Tony Meyer <[EMAIL PROTECTED]> wrote: > > FAILS > > -- > > >>> value = 1234567890 > > >>> hexoutput = hex('%d' % (value)) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: hex() argument can't be converted to hex >

Re: [Tutor] Covert numbers to hex fails

2005-05-24 Thread ZIYAD A. M. AL-BATLY
On Tue, 2005-05-24 at 22:56 -0400, Tom Tucker wrote: > Good evening! I am trying to pass a number variable and have it > converted to hex. Any recommendations on how to achieve this? Thank > you. > > FAILS > -- > >>> value = 1234567890 > >>> hexoutput = hex('%d' % (value)) > Traceback (