Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
... print letter > ... last -= 1 > ... What is vehicle[index] ? What if I change index, say, index = index + 1 Now what is vehicle[index] ? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > Hi John, > > (1) vehicle[index] is: 'c' > (2) If index = index = 1, so vehicle[index] becomes: > 'a' What I'm getting at here is that, by changing index, we can change which letter we are lookin

Re: [Tutor] Newbie: Passing variable into re.compile

2006-03-29 Thread John Fouhy
On 30/03/06, Jerome Jabson <[EMAIL PROTECTED]> wrote: > import re > > arg1 = '10" > > p = re.compile(r + arg1 + '\.(\d+\.\d+\.\d+)') Have a look at string substitutions :-) --- http://docs.python.org/lib/typesseq-strings.html p = re.compil

Re: [Tutor] file?

2006-04-03 Thread John Fouhy
does not exist!' sys.exit() ziparchive = zipfile.ZipFile(inputfilename, 'r') # ... -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Space the final frontier!

2006-04-04 Thread John Corry
,dial= 028 90 79 0154, dial= ['002, borfiled, dial= 02890 618521, dial=\n'] 002, borfiled, dial= 02890 618521, dial= 002, borfiled, dial= 02890 618521, dial= ['003, newcomp, dial=02890419689, dial='] 003, newcomp, dial=02890419689, dial= 003, new

[Tutor] Space the final frontier

2006-04-05 Thread John Corry
ne) y = line x = "\n" z = y + x input2.write(z) del input del input2 Thanks again, John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question about list

2006-04-10 Thread John Fouhy
ple, list)): print len(item) else: print 1 May I ask why you're doing this? This feels like a situation where you need to think clearly what your goals are before you go diving towards a solution :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread John Fouhy
lements] dec.sort() elements = [x[1] for x in dec] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Can anyone help me plz

2006-04-13 Thread John Brokaw
I'am very new to pygame, and python and any help would help me so much thx. I have no idea whats wrong the chimp.py ex. works perfect, but when I get to http://rene.f0o.com/mywiki/LECTURETHREE, I get so stuck becuz the call window = pygame.display.set_mode((468, 60)) makes a window like it should

[Tutor] Databases

2006-04-13 Thread John Corry
knowledge with databses. I have created and modified some gadfly databases but on a very simple level. Any help would be greatly appreciated. Thanks, John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John CORRY
d.dbf') OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified', 6044)   What am I doing wrong and what do I need to do?  Any help would be greatly appreciated.   Thanks,   John.  

[Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John CORRY
d.dbf') OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified', 6044)   What am I doing wrong and what do I need to do?  Any help would be greatly appreciated.   Thanks,   John.  

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John Corry
Liam, Thanks for the quick response. I have changed the code so that dsn is now DSN. However I get the same error. Any other thoughts? Regards, John. -Original Message- From: Liam Clarke [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:02 To: [EMAIL PROTECTED] Cc: tutor@python.org

[Tutor] odbc

2006-04-15 Thread John CORRY
t][ODBC Driver Manager] Data source name not found and no default driver specified', 6044)     It gives me the same error that I am experiencing when I run my code.  Does this mean that I have not installed something that I need or have not installed

Re: [Tutor] odbc

2006-04-15 Thread John Corry
this what I need to log onto with python first before I access the database file? Regards, John. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Kent Johnson Sent: 15 April 2006 15:40 Cc: tutor@python.org Subject: Re: [Tutor] odbc John CORRY wrote: >

[Tutor] Good Hustle Hit the Showers!

2006-04-15 Thread John Corry
Hi, Good advice. I configured the ODBC data sources as advised and I am now able to query my database files. Thanks, John. -Original Message- From: Lloyd Kvam [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 16:04 To: [EMAIL PROTECTED] Cc: Kent Johnson; Tutor Python Subject: Re: [Tutor

[Tutor] Didn't take long to hit my next wall!

2006-04-15 Thread John CORRY
? where cost_grid_id = ? and finish_dro = ?', ( a, c,b,))     db.commit() c.close()   Any suggestions would be greatly appreciated.   Thanks,   John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] School Boy Error

2006-04-15 Thread John CORRY
t; b = 91.4 a = 95.00   import mx.ODBC import mx.ODBC.Windows db = mx.ODBC.Windows.DriverConnect('DSN=vfp') c = db.cursor() c.execute(stat, listy[-1])    db.commit() c.close()   I get the following error:   TypeError: parameters must be a list

[Tutor] School Boy error

2006-04-16 Thread John CORRY
#x27;, '0', '105', '182.9', '38.08', '83', '0', '117', '198.1', '41.42', '90', '0', '127', '223.5', '48.77', &#

[Tutor] School Boy Error

2006-04-16 Thread John CORRY
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,) Traceback (most recent call last):   File "C:\Python24\Lib\site-packages\databasemanager.py", line 31, in ?     c.execute(stat, sql_list) TypeError: parameters must be a list of tuples   Unfortunately sql_list gives the same error.   Thanks

[Tutor] School Boy Error - Update

2006-04-16 Thread John CORRY
, '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0') Traceback (most recent call last):   File "C:\Python24\Lib\site-packages\databasemanager.py", line 35, in ?     c.execute(stat, sql_list) ProgrammingError: ('37000', 200, '[Microsoft][ODBC Visual FoxPro Driver]Syntax error.', 4347)   I assume this error is telling me that the database does not like the syntax of the data I am importing.  The data that I am importing is actually data that I exported, so I know that it is in the right order and the right amount.  The only thing that I can think of is that, the database requires floats for the numbers instead of strings.  I assume that the numbers in listy[0] are now strings.  Am I now going to have to throw listy[0] through a function to make the numbers into floats or is there another way to do this?   Am I on the right track?   Thanks,   John.   ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] My Name is John and I copy and paste

2006-04-18 Thread John CORRY
id = ? and finish_dro = ?', ( float(row[58]), row[0], float(row[2])))     c.execute('UPDATE cost_grid SET ie_rrp_19 = ? where cost_grid_id = ? and finish_dro = ?', ( float(row[59]), row[0], float(row[2])))     c.execute('UPDATE cost_grid SET cost_20 = ? where cost_grid_id = ? and finish_dro = ?', ( float(row[60]), row[0], float(row[2])))     c.execute('UPDATE cost_grid SET rrp_20 = ? where cost_grid_id = ? and finish_dro = ?', ( float(row[61]), row[0], float(row[2])))     c.execute('UPDATE cost_grid SET ie_rrp_20 = ? where cost_grid_id = ? and finish_dro = ?', ( float(row[62]), row[0], float(row[2])))         db.commit()     c.close()      Thanks,   John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-19 Thread John Fouhy
gt; for c in s[::-2]: > ... odd = c + odd > ... > >>> String slicing will actually produce strings :-) eg: >>> s = '987654321' >>> s1, s2 = s[::-2], s[-2::-2] >>> s1 '13579' >>> s2 '2468' -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Importing Modules

2006-04-24 Thread John Connors
G'day, I'm having trouble understanding the difference between, import sys and from sys import * It seems to me they both do the same thing. John _ New year, new job – there's more than 100,00 job

[Tutor] How to compile _tkinter in Fedora Core 4

2006-04-25 Thread John Hsu
ected on linux2: test_tcl ... John Hsu ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to compile _tkinter in Fedora Core 4

2006-04-25 Thread John Connors
G'day John, There is a problem with a recent python update and fedora, if you go to http://forums.fedoraforum.org/ and do a search in the forum for tkinter and/or idle you will find the fix. I'm running Fedora Core 5 and found I had to install tkinter, I had to do a yum insta

[Tutor] Checking in lists

2006-04-26 Thread John Connors
r because the second way does what I want but I would like to know why the first way doesn't work and if the syntax is wrong why doesn't it return an error. John PS I apologise if this is a duplicate, hotmail did some kind of spam check when I trie

Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
G'day Payal, I had trouble understanding the namespaces section of the tutorial too but it all clicked the other day when Alan explained the difference between import first and from first import * John >Hi, >In Alan's tutorial I haven't got the example of print42() ev

Re: [Tutor] Alan Gauld's tut - namespaces

2006-04-26 Thread John Connors
understood that I couldn't understand the namespaces part of the tutorial. John _ Bounce Back from sickness and injury today. http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fclk%2Eatdmt%2Ecom%2FMOS%2Fgo%2Fnnmsngem001007mos

Re: [Tutor] how to *really* copy a list

2006-04-27 Thread John Fouhy
new list. eg: def mirror(seq): end = seq[:-1] end.reverse() return seq + end Finally, just a side comment: You can use slicing to reverse the end for you as well. So, we could rewrite the last function as: def mirror(seq): end = seq[-2::-1] return seq + en

[Tutor] How Big Is Too Big?

2006-04-29 Thread John Connors
much? John _ New year, new job – there's more than 100,00 jobs at SEEK http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=752315885&_r=Jan05_tagline&_m=EXT ___

[Tutor] Silly Dice Game

2006-04-29 Thread John Connors
gain != "y": break if dieLeft == 0: dieLeft = 6 print "\nYou used all the dice and must roll again" print "\n\nYour total score for that round was %d" % (totalScore) playAgain = raw_input("\nPlay again? (y/n) &quo

Re: [Tutor] Silly Dice Game

2006-04-29 Thread John Fouhy
On 30/04/06, John Connors <[EMAIL PROTECTED]> wrote: > The wife and I play a silly dice game and I thought it would be a good > challange for me to write it as a program. No specific question, just > wondering if my technique is ok and is there anything that could be done > bet

Re: [Tutor] Silly Dice Game

2006-04-29 Thread John Connors
G'day John, >If I were you, I would look at separating more of my program out into >functions. Good use of functions will make your program more >readable, easier to debug, and easier to change, should the rules of >your dice game change :-) Yes, the rules change on a regular

[Tutor] question about run time

2006-05-02 Thread Ertl, John
with compiling but I am not sure. Any ideas how to speed this up? I am running python 2.4 on a RHE3.0 cluster. Thanks, John Ertl ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
Kent, The files are very small (a few hundred lines). Maybe it is a network issue? But then why is it always slow the first time in the morning? I don't know network stuff but that seams a bit strange. Thanks, John Ertl -Original Message- From: Kent Johnson [mailto:[

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
Kent, I will check with the systems guys...and the Perl guys down the hall to see if they have the same problem. Thanks for the help. John Ertl -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Tuesday, May 02, 2006 12:27 PM

Re: [Tutor] question about run time

2006-05-02 Thread Ertl, John
odeAmount) print "Your memory usage is %s KB and your inode usage is %s" % (myUse.memTotal,myUse.inodeTotal) print "Your memory limit is %s KB and your inode limit is %s" % (myUse.memLimit, myUse.inodeLimit) if myUse.memLimit < myUse.memTotal or myUse.inodeLimit < m

Re: [Tutor] simple question about numeric types

2006-05-02 Thread John Fouhy
complex) Well, for one, you can simplify that line to: if isinstance(v, (int, float)): (also, you might want to check if it's a long as well --- ie: isinstance(v, (int, float, long))) Another possibility, maybe: try: int(v) except ValueError, TypeError: pass -- John. __

[Tutor] Books

2006-05-03 Thread John Connors
a book for my birthday. So I was wondering (bearing in mimd that I'm only 2 or 3 steps above total beginner), what is the one book on python that I shouldn't be without? John _ realestate.com.au: the biggest ad

Re: [Tutor] Halting execution

2006-05-03 Thread Ertl, John
Matthew, Not sure if ipython is different but have you tried sys.exit("stoping now") You could also put in a flag to turn the printing on and off so it wont print it out when you are testing. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On

Re: [Tutor] Halting execution

2006-05-03 Thread Ertl, John
I agree I should be a bit more careful about giving examples that are quick fixes as opposed to best practice. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hugo González Monteverde Sent: Wednesday, May 03, 2006 12:05 PM To: tutor@python.o

[Tutor] 2 Combo Boxes! What was I thinking?

2006-05-04 Thread John CORRY
ombo3.child.append_text(“Tue”)   The combobox3 is populated on the GUI but instead of being a drop down list it appears as a string on one line and looks like this: MonTue   I have to confess I am not really sure what I am doing.  I just guessed at putting the child command in.  It gets me close

[Tutor] Nested list comprehensions

2006-05-05 Thread John Clark
somone has a way of reading the nested list comprehension syntax that makes sense, I would appreciate it if you would share it. Thanks, -John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] 2 Combo Boxes! What was I thinking?

2006-05-06 Thread John CORRY
ombo3.child.append_text(“Tue”)   The combobox3 is populated on the GUI but instead of being a drop down list it appears as a string on one line and looks like this: MonTue   I have to confess I am not really sure what I am doing.  I just guessed at putting the child command in.  It gets me close

[Tutor] Stumbled onto the answer!

2006-05-06 Thread John CORRY
store.append (["Wed"])     store.append (["Thu"])     store.append (["Fri"])     store.append (["Sat"])     store.append (["Sun"])        combo2.set_model(store)     combo2.set_text_column(0)     com

[Tutor] Button Signals

2006-05-07 Thread John CORRY
assing in the tag returned by one of the signal connect methods, you can disconnect a signal handler. How do I find out what the integer tag is, so that I can put this in my code?   I have tried the pygtk faq page but it is currently unavailable.   Any help greatly appreciated.   Thanks,   Joh

Re: [Tutor] Button Signals

2006-05-07 Thread John CORRY
Liam,   Thanks for the prompt reply.  That is working for me.   Regards,   John,   -Original Message- From: Liam Clarke [mailto:[EMAIL PROTECTED] Sent: 07 May 2006 13:06 To: [EMAIL PROTECTED] Cc: tutor@python.org Subject: Re: [Tutor] Button Signals   Hi John, I&#x

[Tutor] trouble with re

2006-05-08 Thread Ertl, John
I have a file with 10,000 + lines and it has a coma delimited string on each line. The file should look like: DFRE,ship name,1234567 FGDE,ship 2, ,sdfsf The ,sdfsf line is bad data Some of the lines are messed up...I want to find all lines that do not end in a comma or seven digits and do som

Re: [Tutor] trouble with re

2006-05-08 Thread Ertl, John
Kent, Thanks for the nock on the head, that has bitten me before. Taking out the spaces worked great. Thanks again, John Ertl -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Monday, May 08, 2006 10:53 AM Cc: tutor

Re: [Tutor] Python media player?

2006-05-08 Thread John Fouhy
ld be much clearer > in Python. pyMedia, maybe? I got that from the cheese shop (under the links menu at python.org): http://cheeseshop.python.org/pypi/PyMedia/1.2.3.0 See also http://cheeseshop.python.org/pypi?:action=browse&asdf=338. -- John. __

[Tutor] Problems with Treeview

2006-05-13 Thread John CORRY
ack (most recent call last):   File "C:\Documents and Settings\Johnc\Projects\project7\shopcall.py", line 1 , in callback53     result = model.get_value(iter,0) TypeError: iter must be a GtkTreeIter   What do I need to assign to iter to make

[Tutor] Treeview

2006-05-14 Thread John CORRY
1     print lookup   Technically this is the first solution that I have been able to post on the mailing list.  Does this mean I am improving?  Or does it not count as I have solved my own problem?   Regards,   John.   ___ Tutor mailli

Re: [Tutor] Nested list comprehensions

2006-05-14 Thread John Fouhy
The python translation would be something like: fibs = [0, 1] + [ a+b for (a, b) in zip(fibs, fibs[1:])] But you can't quite do that in python :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Nested list comprehensions

2006-05-14 Thread John Fouhy
0.240615497221 23 28657 0.365666586116 24 46368 0.827867508301 25 75025 2.14721368219 26 121393 4.08266218193 27 196418 20.1769099145 Hmm, do you know an easy way to check how much memory python is using? My HDD was swapping like crazy by the end of that.. -- John. ___

Re: [Tutor] Calendar Module

2006-05-22 Thread John Fouhy
nt the output. For example: >>> s = 'Hello\n World!\n-\n --- \n - \n' >>> s 'Hello\n World!\n-\n --- \n - \n' >>> print s Hello World! - --- - >>> Or, you could try typing "p

Re: [Tutor] Hex conversion strangeness

2006-05-24 Thread John Fouhy
plays the result of every expression you type. In this case, the result of int('0x21', 16) is an integer, and python displays integers in base 10 by default --- hence, you see 33. By the way, you can enter integers in base 8 or base 16, if you want: >>> 0x21, 041 (33, 33) &g

[Tutor] Not Really Questions

2006-06-04 Thread John Connors
a beginner I can look at Python code and have a very good idea of what is happening and why unless it's written in OOP style in which case I have no idea. John _ Read, write and reply to Hotmail on you

Re: [Tutor] FileDialogBox in Tkinter

2006-06-05 Thread John Fouhy
ed another import statement --- 'import Tkinter' or 'from Tkinter import *' won't bring it in. New Mexico Tech has a good reference too: http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html It's a bit old, but a lot of it is still accurate, and it goes into

Re: [Tutor] Combo Box in Tkinter

2006-06-06 Thread John Fouhy
Check out Python MegaWidgets (pmw.sourceforge.net). On 07/06/06, Keo Sophon <[EMAIL PROTECTED]> wrote: > Hi, > > Is there any Combo Box in Tkinter? I looked for it but only found list box. > Might it be list box having any option to make itself as a combo box? > > Thanks, > Phon >

Re: [Tutor] Offtopic observation

2006-06-07 Thread John Fouhy
wer becomes apparent approximately five seconds _after_ I send off my question.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] lambda and creating GUIs

2006-06-15 Thread John Fouhy
t" should be at the same level), and provided you aren't using the name "onQuit" somewhere else in that method, this code should be a dropin replacement for the line you quote. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Delete directories recursively

2006-06-16 Thread John Corry
ror, inst:    print OSError    os.chmod(inst.filename, 0666)    self.zaps()   Regards,   John. -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Amresh KulkarniSent: 16 June 2006 16:27To: tutor@python.orgSubject: [Tutor] Delete d

Re: [Tutor] lambda and creating GUIs

2006-06-16 Thread John Fouhy
h it. Try this: def show(e): print e print 'Class:', e.__class__ print 'Members:' for attr in dir(e): print '%s: %s' % (attr, getattr(e, attr)) button.connect("clicked", show) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beginner question(s)

2006-06-18 Thread John Fouhy
> Also, does anyone know of a PDA that would run python? Some of the new Nokias run python: http://www.forum.nokia.com/python -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Writing an "Alt-Enter"

2006-06-19 Thread John Fouhy
can feed it strings with newlines in them and it will produce the output you want. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to check a files size

2006-06-28 Thread John Fouhy
On 29/06/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > See shutil.copyfile() Why isn't this function in the os module with the other file commands? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Wiget

2006-06-29 Thread John Fouhy
ur button is clicked. So, every time you click the button, "tries" gets set to 1. I assume you have a class derived from Frame -- can you think how to store your "tries" value in your Frame object? (do you know the difference between local variables and object attributes?) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Splitting

2006-07-09 Thread John Fouhy
On 10/07/06, Abhinav Gaurav <[EMAIL PROTECTED]> wrote: > > Hi, > > Thanks for your help! I am wondering if it works fine then why it failing on > my comp. And what is the remedy for it? What version of python are you running? -- John.

Re: [Tutor] Splitting

2006-07-09 Thread John Fouhy
On 10/07/06, Abhinav Gaurav <[EMAIL PROTECTED]> wrote: > John Fouhy <[EMAIL PROTECTED]> wrote: > > What version of python are you running? > 1.5.2 is the version. Right. Well, you're slightly over 7 years out of date :-) Do you have the ability to upgrade? You or

Re: [Tutor] How can I copy files recursively?

2006-07-10 Thread John Fouhy
alk to walk your directory structure. Something like: source = '/ipodder' dest = '/foo/bar' for root, dirs, files in os.walk(source): for f in files: os.rename(os.path.join(root, f), os.path.join(dest, f)) (although I would do a test run first, if I were you, since I o

Re: [Tutor] no loops

2006-07-11 Thread John Fouhy
gt; iteration, but I am not sure how I could implement it. Hi Chris, You are using iteration. That's what loops are :-) Perhaps you meant to say "recursion", which is where a function calls itself. You could solve this recursively, but I think Gregor's comm

Re: [Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread John Fouhy
ht be more efficient to make it into a set first --- keepSet = set(lstKeepers) for key in myDict.keys(): if key not in keepSet: del myDict[key] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] abs beginner first project

2006-07-12 Thread John Fouhy
're using an intel mac :-/ ) and the rest should be fun stuff with data structures. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] email anonymizing

2006-07-13 Thread John Fouhy
On 14/07/06, anil maran <[EMAIL PROTECTED]> wrote: > i want to know how to generate > [EMAIL PROTECTED] => [EMAIL PROTECTED] > and then how do i do the translation > [EMAIL PROTECTED] => [EMAIL PROTECTED] Hi Anil, Do you have any programming experience in ot

Re: [Tutor] Help with strings and lists.

2006-07-13 Thread John Fouhy
list comprehensions and the max() function), then use string formatting operators to lay everything out :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
t position 0 and is four characters long. Now, if you asked for "a[bcd]*b$", that would be a different matter! HTH :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
ou what attributes the match object has. Or you can read the documentation --- a combination of both approaches usually works quite well :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Comparing times

2006-07-18 Thread John Fouhy
uld be able to compare directly with other time tuples. # untested def cmptime(s1, s2): """Compare two times as strings in %H:%M:%S format.""" return cmp(time.strptime(s1, '%H:%M:%S'), time.strptime(s2, '%H:%M:%S')) -- John. _

Re: [Tutor] removing a card

2006-07-19 Thread John Fouhy
posted.. I presume you meant to type: def __cmp__(self, other) ? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Help me make it look pretty!

2006-07-20 Thread John CORRY
looking for a way to keep the numbers right justified.   Any suggestions or comments as always are greatly appreciated.   Regards,   John.     def callback36(self,data,text37,text38,text39,text40,text41,text42,label):     a = text37.get_text()         b = text38.get_text

Re: [Tutor] Using python to create and save a Ms Word file

2006-07-20 Thread John Fouhy
can also read through the generated code itself; it's more helpful than you might expect :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] : finding out if the horizontal scrollbar on a Tix.CheckList is being used or not

2006-07-21 Thread John Fouhy
, but one thing you could try playing with: tkFont.Font instances support a .measure method. So, if f is a tkFont.Font, then f.measure('hello world!') will return how many pixels wide that string would be on the screen. You could maybe compare

[Tutor] Good teamwork!

2006-07-21 Thread John CORRY
later!   I have downloaded the ValidatedEntry extension and had a quick look at it. It looks like it will sort out my validation problems.   A good team effort!   Thanks,   John.       ___ Tutor maillist - Tutor@python.org http

[Tutor] loops to assign variables

2006-07-22 Thread John CORRY
= "entry%s" % (str(x))             text_x = self.wTree.get_widget(ent)   Is it possible to do what I want it to do?  Am I on the right lines?  Any help or advice would be greatly appreciated.   Thanks,   John. __

Re: [Tutor] Is there a method like this already?

2006-07-24 Thread John Fouhy
e instances, then (date1-date2) is a datetime.timedelta, and (date1-date2).days is the number of days in the timedelta. Reading the documentation helps! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's the invalid syntax?

2006-07-24 Thread John Fouhy
On 25/07/06, Nathan Pinno <[EMAIL PROTECTED]> wrote: > > What's the invalid syntax? I don't know, what did python tell you when you tried to run the code? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] confused by linked queue

2006-07-24 Thread John Fouhy
|| cargo-\| \---+/\---+/ | | \|/ \|/ "cargo""more cargo" Hope this helps; if not, ask more questions :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] The In Operator

2006-07-26 Thread John Fouhy
icient, and this is equivalent to using "in" in recent versionf of python. (ie: "key in dict" is equivalent to "dict.has_key(key)") (are you new to programming in general, or just python in particular?) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] syntax error

2006-07-31 Thread John Fouhy
elf.head.cargo self.last.next = node self.last = node HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (*args, **kwargs)

2006-08-05 Thread John Fouhy
return _range(0, args[0], 1) elif len(args) == 2: return _range(args[0], args[1], 1) else: return _range(args[0], args[1], args[2])# could replace this with: return _range(*args) def _range(start, stop, step): # etc HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to use

2006-08-05 Thread John Fouhy
On 05/08/06, anil maran <[EMAIL PROTECTED]> wrote: > list comprehensions to return a dictionary Well, hyou can use the dict function. eg: dict((x, x**x) for x in range(10)) -- John. ___ Tutor maillist - Tutor@python.org http://mail.p

Re: [Tutor] creating a method name on the fly

2006-08-07 Thread John Fouhy
... self.buttons[label] = b It means that all the information about your GUI is brought together in one place where it's easy to see, and all the mechanical work is pushed off to one side :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] creating a method name on the fly

2006-08-07 Thread John Fouhy
quit) I sometimes do this: buttonOpts = { 'fg':'white', 'bg':'blue' } packOpts = { I forget :-) } buttons = [('Button 1', None), ('Button 2', None), ('Button 3', root.quit)] for label, callback in buttons: b = Tkinter.Button(label, command=callback, **buttonOpts) b.pack(**packOpts) But, yeah, partial application will be cool :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Rock, Paper, Scissors

2006-08-07 Thread John Fouhy
f you want to be more clever, I understand that RSP programs that always pick what the human picked in the previous round tend to do better than random (unless the human notices, at which point they start doing very badly :-) ). -- John. ___ Tutor maillist

Re: [Tutor] try & except

2006-08-08 Thread John Fouhy
bibl=os.listdir("c:\\klientdata\\") success = True except: wx.MessageBox("Kunde inte läsa käll biblioteket.","Säkerhetskopiering",wx.OK|wx.ICON_ERROR) Of course, it would be nice to give the users another way out of the loop :-) HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Exercise in writing a python function.

2006-08-08 Thread John Fouhy
ing for help on how to translate the description you've given into logic suitable for programming? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Exercise in writing a python function.

2006-08-08 Thread John Fouhy
On 09/08/06, Kermit Rose <[EMAIL PROTECTED]> wrote: > Hello John. > > Thanks for replying. > > In my previous version, I used z as the critical value,. > > Since I created zlim, a function of z, to be passed in as a parameter, I no > longer need z > > in the

Re: [Tutor] searching for a string in a dictionary

2006-08-09 Thread John Fouhy
887436)}> > > there is such a list > > > > how do i search for a particular string say teststring in this list > > This isn't a list in any sense that Python will recognise. > Can you show us the actual data structures please? I thin

Re: [Tutor] searching for a string in a dictionary

2006-08-09 Thread John Fouhy
On 09/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > But type is still not accessible as an attribute. > It looked to me like he wanted a list of dictionaries > in which case it wouyld be: > > if teststring in [s['type'] for s in all_types] Err, tha

<    2   3   4   5   6   7   8   9   10   11   >