Re: [Tutor] Question regarding list editing (in place)

2008-02-14 Thread David J. Weller-Fahy
Sorry for the delayed reply - the list software was "helping" me by not sending me the list copy. Heh. * Kent Johnson <[EMAIL PROTECTED]> [2008-02-05 13:43]: > bob gailer wrote: >> dirs = [dir for dir in dirs if not dir.startswith(u'.')] > > Except to filter the directory list for os.walk() you

Re: [Tutor] designing POOP

2008-02-14 Thread Tiger12506
> Now I'm curious. > > MVC is one of the oldest, best established and well proven design > patterns going. It first appeared in Smalltalk in the late 1970's and > has been copied in almost every GUI and Web framework ever since. > I've used it on virtually(*) every GUI I've ever built(**) to the >

Re: [Tutor] most efficient way to do this

2008-02-14 Thread bob gailer
Christopher Spears wrote: > I created a file called arrays.py: > > #!/usr/bin/python > > locations = ["/home/", > "/office/" , > "/basement/" , > "/attic/"] > > Now I want to add the word "chris" on to each element > of the locations list, so I wrote another script > called chris_arrays.py: > > #!/

Re: [Tutor] most efficient way to do this

2008-02-14 Thread Alan Gauld
"Christopher Spears" <[EMAIL PROTECTED]> wrote > from arrays import locations > > add_on = "chris" > new_loc = [] > > for i in range(len(locations)): >new_loc.append(locations[i] + add_on) > > print new_loc > > Is this the most efficient way to do this? No. For a start you could use a

Re: [Tutor] designing POOP

2008-02-14 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote > Ah yes... I don't like the Model-View-Controller architecture. That > the > major reason why I dislike most information available on C++. This > is a > personal issue though. The Model-View-Controller is a very common > thing, and > everyone but me would

[Tutor] most efficient way to do this

2008-02-14 Thread Christopher Spears
I created a file called arrays.py: #!/usr/bin/python locations = ["/home/", "/office/" , "/basement/" , "/attic/"] Now I want to add the word "chris" on to each element of the locations list, so I wrote another script called chris_arrays.py: #!/usr/bin/python/ from arrays import locations add

Re: [Tutor] read from standard input

2008-02-14 Thread Tiger12506
> while 1 < 2: while 1: or while True: is more common >x = raw_input() raw_input() always return a string, no matter what you type in. >if type(x) != int or x == 11: type(x) is always x can never be 11, but can possibly be '11'. (Notice quotes indicating string instead of integer) If

Re: [Tutor] designing POOP

2008-02-14 Thread Tiger12506
> Hmm. Not to me. The second version couples the game state with the > display. I would rather have True... > This is an example of Model-View-Controller architecture (google it). > Notice that the Game and Display are now reusable (maybe there are both > GUI and text interfaces to the game, f

Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread Arun Srinivasan
On Thu, Feb 14, 2008 at 11:41 AM, Arun Srinivasan <[EMAIL PROTECTED]> wrote: > > On Thu, Feb 14, 2008 at 5:27 AM, bob gailer <[EMAIL PROTECTED]> wrote: > > > > Arun Srinivasan wrote: > > > I'm trying to learn Python, and I decided to try kata 2 from the > > > CodeKate website. It's basically j

Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread Arun Srinivasan
On Thu, Feb 14, 2008 at 5:27 AM, bob gailer <[EMAIL PROTECTED]> wrote: > > Arun Srinivasan wrote: > > I'm trying to learn Python, and I decided to try kata 2 from the > > CodeKate website. It's basically just a challenge to implement a > > binary search in different ways. > > > > I wrote an implem

Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread bob gailer
Arun Srinivasan wrote: > I'm trying to learn Python, and I decided to try kata 2 from the > CodeKate website. It's basically just a challenge to implement a > binary search in different ways. > > I wrote an implementation that works, but I'm confused as to why. > > def chop(search_int, sorted_li

Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread Alan Gauld
"Arun Srinivasan" <[EMAIL PROTECTED]> wrote > I wrote an implementation that works, but I'm confused as to why. > > def chop(search_int, sorted_list): >if len(sorted_list) == 1 or 2: |This is not doing what you think it is. Pythopn sees this as: if ( len(sorted_list == 1) or 2: So it eval