[Tutor] need futher explaining

2007-08-06 Thread Dale Pearl
I'm reading Beginning Python - From Novice to Professional by Magnus Lie Hetland (an Apress book) and there is a code example that I need further explaining on to fully grasp. There is a section with samle code of: names = ['anne', 'beth', 'george', 'damon'] ages = [12, 45, 32, 102] for i in range

Re: [Tutor] Batch file copy script

2007-08-06 Thread Luke Paireepinart
Majid wrote: > Hi all, > I am new to Python and this mailing list. I wondered if someone would be > kind enough to give me a basic python skeleton to achieve the following. > > Many thanks in advance > Majid > > - > > > Here are the assumptions: > > 1. we have

Re: [Tutor] Batch file copy script

2007-08-06 Thread bhaaluu
Greetings Majid, https://shipit.ubuntu.com/ The Ubunty people will ship a set of 5 CDs of the latest release to you, absolutely free. Go to the above site and fill out your shipping information. I have done this in the past, and they ship promptly. Why 5 CDs? It costs the same to ship 1 or 5, and

Re: [Tutor] need futher explaining

2007-08-06 Thread bhaaluu
Greetings, I'm also a beginner to Python, but I think I can answer your question. One of the best ways to learn about how anything in Python works is to use the Python interactive interpreter, so, away we go (follow along, please): >>> names = ['anne', 'beth', 'george', 'damon'] >>> print names [

Re: [Tutor] Batch file copy script

2007-08-06 Thread Kent Johnson
Majid wrote: > Here is a possible logic for the script: > > 1. Open the list (C:\py\list.txt). > 2. Until the end of the file >3. Read a line from list.txt (e.g. '/dists/dapper/Release.gpg') >4. Change forward slashes to back slashes (e.g. > '\dists\dapper\Release

Re: [Tutor] need futher explaining

2007-08-06 Thread Kent Johnson
Dale Pearl wrote: > I'm reading Beginning Python - From Novice to Professional by Magnus Lie > Hetland (an Apress book) and there is a code example that I need further > explaining on to fully grasp. > There is a section with samle code of: > names = ['anne', 'beth', 'george', 'damon'] > ages =

[Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
Google Answers folded, but Google has kept the archive accessible. I found this Python script at and modified it for U.S. money denominations: http://www.rcblue.com/Python/changeMaker_revised_for_US_denominations.py I'm still working at

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Dick Moores wrote: > http://www.rcblue.com/Python/changeMaker_revised_for_US_denominations.py > > I'm still working at Python--been at it a while--and thought the > script was ingenious. Do the Tutors agree? Or is it just > run-of-the-mill programming? Could it have been more simply written? I

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
At 06:49 AM 8/6/2007, Kent Johnson wrote: >Dick Moores wrote: >>http://www.rcblue.com/Python/changeMaker_revised_for_US_denominations.py >>I'm still working at Python--been at it a while--and thought the >>script was ingenious. Do the Tutors agree? Or is it just >>run-of-the-mill programming? Cou

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Dick Moores wrote: > Gotta say though, I still don't understand how the defaultdict works here. Did you try the docs? http://docs.python.org/lib/defaultdict-objects.html If coinCount were an ordinary dict, the line coinCount[deno] += 1 would have to be written as coinCount[deno] = coinCoun

Re: [Tutor] sqlite: does "?" work in PRAGMA commands?

2007-08-06 Thread Terry Carroll
On Wed, 1 Aug 2007, Terry Carroll wrote: > Does the "?" approach not work with PRAGMA commands or something; or am I > doing this wrong? Just a quick follow-up on this, in case anyone else cares. My conclusion is that it's not supported. Googling around I found this pysqlite bug report: http:/

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
At 07:44 AM 8/6/2007, Kent Johnson wrote: >Dick Moores wrote: >>Gotta say though, I still don't understand how the defaultdict works here. > >Did you try the docs? >http://docs.python.org/lib/defaultdict-objects.html Yes, but it left me still in the dark. >If coinCount were an ordinary dict, the

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
Dick Moores wrote: > At 06:49 AM 8/6/2007, Kent Johnson wrote: > >> Dick Moores wrote: >> >>> http://www.rcblue.com/Python/changeMaker_revised_for_US_denominations.py >>> I'm still working at Python--been at it a while--and thought the >>> script was ingenious. Do the Tutors agree? Or is i

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
On 8/6/07, Eric Brunson <[EMAIL PROTECTED]> wrote: > > Try something like: > > def makechange( amount, denominations ): > > coins = {} > for d in denominations: > coins[d] = int( amount/d ) > amount = amount%d > > return coins > > Sorry, but could you spell out your poin

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
Multiple subtractions is called division. It's a much more efficient loop. In this version you have exactly as many iterations as denominations. It the original, if you wanted to know how many 200 coins are in 10, you would iterate ~500 times. Here's a timing test: denominations

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
At 10:16 AM 8/6/2007, Eric Brunson wrote: Your point about efficiency is well-taken. >def makechange( amount, denominations ): > > coins = {} > for d in denominations: > coins[d] = int( amount/d ) > amount = amount%d > > return coins OK, I used this this way: ===

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Dick Moores wrote: > At 10:16 AM 8/6/2007, Eric Brunson wrote: > > Your point about efficiency is well-taken. > >> def makechange( amount, denominations ): >> >> coins = {} >> for d in denominations: >> coins[d] = int( amount/d ) >> amount = amount%d >> >> return coins

[Tutor] superscript with easydialogs

2007-08-06 Thread Ben
Hi, I have been working with easydialogs module lately especially the progress bar (for Windows). I would like to put superscript text like (TM) to (™) when calling the label function. I have been looking around the net for some info, and can not find anything about it . It makes me wonder if pyth

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Tiger12506
Nice idea. Written style is average. Other tutors have discussed issues with performance, style, etc. I thought I would mention that whenever I am asked to give my opinion on a script, I compare it to something I have written/would write. In this case, I have already written. In my version, it

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Luke Paireepinart
Dick Moores wrote: > At 10:16 AM 8/6/2007, Eric Brunson wrote: > > Your point about efficiency is well-taken. > > >> def makechange( amount, denominations ): >> >> coins = {} >> for d in denominations: >> coins[d] = int( amount/d ) >> amount = amount%d >> >> return co

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
Dick Moores wrote: > At 10:16 AM 8/6/2007, Eric Brunson wrote: > > Your point about efficiency is well-taken. > >> def makechange( amount, denominations ): >> >> coins = {} >> for d in denominations: >> coins[d] = int( amount/d ) >> amount = amount%d >> >> return coins >

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Ken Oliver
-Original Message- >From: Kent Johnson <[EMAIL PROTECTED]> >Sent: Aug 6, 2007 3:46 PM >To: Dick Moores <[EMAIL PROTECTED]> >Cc: Python Tutor List >Subject: Re: [Tutor] Ingenious script (IMO) > >Dick Moores wrote: >> At 10:16 AM 8/6/2007, Eric Brunson wrote: >> >> Your point about effici

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Ken Oliver wrote: > > -Original Message- >> From: Kent Johnson <[EMAIL PROTECTED]> >> Sent: Aug 6, 2007 3:46 PM >> To: Dick Moores <[EMAIL PROTECTED]> >> Cc: Python Tutor List >> Subject: Re: [Tutor] Ingenious script (IMO) >> >> Dick Moores wrote: >>> At 10:16 AM 8/6/2007, Eric Brunson wr

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Alan Gauld
"Ben" <[EMAIL PROTECTED]> wrote > I have been working with easydialogs module lately > especially the progress bar (for Windows). I would > like to put superscript text like (TM) to (™) when > calling the label function. To do that you will have to use rich text format for the label text and that

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Mon, 6 Aug 2007, Alan Gauld wrote: > "Ben" <[EMAIL PROTECTED]> wrote > > > I have been working with easydialogs module lately > > especially the progress bar (for Windows). I would > > like to put superscript text like (TM) to (?) when > > calling the label function. > > The super-scripting i

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Ken Oliver wrote: > I seem to stumble often with things like > > nz = [ (k,v) for k,v in lst if v!=0] > > I have not been able to wrap my brain around the parentheses. I see > it as reasonable to have the () around the k,v in the tuple in the first instance, but I feel like they should also be ar

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
At 02:17 PM 8/6/2007, you wrote: >Nice idea. Written style is average. Other tutors have discussed issues with >performance, style, etc. I thought I would mention that whenever I am asked >to give my opinion on a script, I compare it to something I have >written/would write. In this case, I have al

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > For the U.S., say the output so far is: > > Enter the cost: 5.77 > Enter the tendered amount: 10 > Your change is $4.23 > What would be the U.S. way of counting back the change? I think we > start with the $5.77, but then what? Dunno about the US but in

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Kent Johnson
Dick Moores wrote: > At 02:17 PM 8/6/2007, you wrote: >> Nice idea. Written style is average. Other tutors have discussed issues with >> performance, style, etc. I thought I would mention that whenever I am asked >> to give my opinion on a script, I compare it to something I have >> written/would w

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Alan Gauld
"Terry Carroll" <[EMAIL PROTECTED]> wrote > > like to put superscript text like (TM) to (T) when > > calling the label function. > > font settings etc. You may be able to find a font that > supports TM as a superscript specifically within its > extended charater set. > > I don't know easydialog

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Tue, 7 Aug 2007, Alan Gauld wrote: > The problem is I don't know whether Windows supports unicode(I suspect > it does nowadays) and if it does whether EasyDialogs supports changing > the system font. I think EasyDialogs is a Mac thing. ___ Tutor m

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Luke Paireepinart
Terry Carroll wrote: > On Tue, 7 Aug 2007, Alan Gauld wrote: > > >> The problem is I don't know whether Windows supports unicode(I suspect >> it does nowadays) and if it does whether EasyDialogs supports changing >> the system font. >> > > I think EasyDialogs is a Mac thing. > Ben mentio

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Mon, 6 Aug 2007, Luke Paireepinart wrote: > Ben mentioned Windows specifically in his original post. > I think that's why Alan was talking about it. Ah. I missed that, thanks. Well, in that case, since I use Windows, I can give it a shot instead of guessing. It turns out, no, Unicode won't

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Tiger12506
> The modern way seems to be to look at the change amount given by the > cash register and count that out starting with dollars... So true... tsk tsk. That's because the teenagers that give you the change do not know how to count it back. What a great idea to write a program that can show them ho

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Tiger12506
> It turns out, no, Unicode won't work, but using x\99 for the TM character > does, at least on my system (no idea if this will be universal): That's strange. Windows is Unicode based! All text operations done in Windows are first converted to unicode, calculated, and then back. That's even been

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Dick Moores
At 08:38 PM 8/6/2007, Tiger12506 wrote: > > The modern way seems to be to look at the change amount given by the > > cash register and count that out starting with dollars... >So true... tsk tsk. > >That's because the teenagers that give you the change do not know how to >count it back. What a grea