Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Rich Lovely
2009/7/4 Angus Rodgers : >>Date: Sat, 04 Jul 2009 13:26:12 +0100 >>From: Angus Rodgers >>Message-ID: > My response to this [but see the afterthought below!] is that I > definitely need to put into the documentation string something > like "*** THIS FUNCTION IS HIGHLY VULNERABLE TO A MALICIOUS US

Re: [Tutor] reading variables in a data set?

2009-07-04 Thread Emile van Sebille
On 7/4/2009 9:09 AM Steven Buck said... Dear Python Tutor, I'm doing econometric work and am a new user of Python. I have read several of the tutorials, but haven't found them useful for a newbie problem I've encountered. I've used a module (StataTools) from (http://presbrey.mit.edu/PyDTA ) to

Re: [Tutor] reading variables in a data set?

2009-07-04 Thread Luke Paireepinart
Pardon me, I don't have time to address all of your questions; however, Steven Buck wrote: I gather it's now a list where each element of the list is an observation (a vector) for one household. The name of my list is "data"; I gather Python recognizes the first observation by: data[1] . No, th

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Alan Gauld
"Angus Rodgers" wrote You can miss out a few else clauses, especially after the try/excepts: --- while get_bool("Continue?"): try: key = eval(raw_input("Key value of type " + key_typ.__name__ + ": ")) except StandardError: print "That's not a Python expression!" if not isin

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Angus Rodgers
>Date: Sat, 4 Jul 2009 19:52:56 +0100 >From: "Alan Gauld" >Message-ID: > >You can miss out a few else clauses, especially after >the try/excepts: > >--- >while get_bool("Continue?"): >try: key = eval(raw_input("Key value of type " + key_typ.__name__ + ": ")) >except StandardErr

[Tutor] reading variables in a data set?

2009-07-04 Thread Steven Buck
Dear Python Tutor, I'm doing econometric work and am a new user of Python. I have read several of the tutorials, but haven't found them useful for a newbie problem I've encountered. I've used a module (StataTools) from (http://presbrey.mit.edu/PyDTA ) to get a Stata ".dta" file into Python. In Sta

Re: [Tutor] Stack unwind using exceptions.

2009-07-04 Thread Kent Johnson
On Sat, Jul 4, 2009 at 3:56 PM, Noufal Ibrahim wrote: > Hello everyone, > > Would it be considered unorthodox or 'wrong' in some sense for me to use an > exception to unwind the stack and return to a caller for a recursive > function? > > I need to do a depth first search and when I find the right

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Lie Ryan
Angus Rodgers wrote: >> Date: Sat, 04 Jul 2009 13:26:12 +0100 >> From: Angus Rodgers >> Message-ID: >> >> (retention: 1 day) > > This is just a quick(ish!) response to the feedback so far. > > I realise, now, that I should have quoted what the exercise i

[Tutor] Stack unwind using exceptions.

2009-07-04 Thread Noufal Ibrahim
Hello everyone, Would it be considered unorthodox or 'wrong' in some sense for me to use an exception to unwind the stack and return to a caller for a recursive function? I need to do a depth first search and when I find the right element to just stop the whole thing, and get back to the cal

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Alan Gauld
"Angus Rodgers" wrote > (i) trapping the exception StandardError may, for all I know, > be a daft thing to do; Not daft but not that common. Mainly because use of eval() is kind of frownedoon for security reasons. (See below.) > (iv) correlatively with (iii), my indentation perhaps looks a >

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Angus Rodgers
>Date: Sat, 04 Jul 2009 13:26:12 +0100 >From: Angus Rodgers >Message-ID: > > (retention: 1 day) This is just a quick(ish!) response to the feedback so far. I realise, now, that I should have quoted what the exercise in the book was asking for, to explain

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Lie Ryan
Angus Rodgers wrote: > > Any comments? (I don't expect the Spanish Inquisition!) > In addition to what others have mentioned: - use string formatting instead of concatenation as they're usually more readable (and faster too?): ans = raw_input(question + ' ' + true[0] + ' or ' + false[1] + '? ')

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Rich Lovely
2009/7/4 Angus Rodgers : > > Fear not, I won't post all my exercises to the Tutor list!  But > when I seem to be doing something a little elaborate, it seems a > good idea to ask if I'm doing anything silly.  In this exercise: > >   (retention: 1 day) > > my /

Re: [Tutor] Popen problem with a pipe sign "|"

2009-07-04 Thread Sander Sweers
Again, You need to also post to the list!! On Fri, 2009-07-03 at 22:32 -0400, Shawn Gong wrote: > I see what you mean. However in my case the | sign simply constitute an > argument. I'm actually calling devenv.com, which is the MS VS2005's building > command. The whole command looks like: > "...

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Daniel Woodhouse
I had a look at your code, and refactored it a bit. See my modifications at http://python.pastebin.com/m50acb143 You'll noticed I removed one of your functions completely (it was unnecessary) and the get_dict() function is not so heavily nested. Some ideas: raw_input returns a string, so we can s

[Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Angus Rodgers
Fear not, I won't post all my exercises to the Tutor list! But when I seem to be doing something a little elaborate, it seems a good idea to ask if I'm doing anything silly. In this exercise: (retention: 1 day) my /conscious/ worries are: (i) trappin

Re: [Tutor] fnmatch -or glob question

2009-07-04 Thread Damon Timm
Hi Kent and Allen - thanks for the responses ... I was sure there was some part of the "search" I wasn't getting, but with your follow-up questions it seemed something else was amiss ... So, I went back to re-create the problem with some more python output to show you and realized my mistake. Sig

Re: [Tutor] fnmatch -or glob question

2009-07-04 Thread Alan Gauld
"Damon Timm" wrote And I thought I could just construct something for glob or fnmatch like: glob.glob("DSC_0065*.jpg") --or-- fnmatch.fnmatch(file, "DSC_0065*.jpg") But I'm not getting anywhere. Can you give is a clue as to what you are getting? What is happening and what do you experct