Newsgroups: comp.lang.python
From: Steve Howell <showel...@yahoo.com>
Date: Sat, 26 May 2007 13:05:02 -0700 (PDT)
Local: Sun, May 27 2007 6:05 am
Subject: Re: ten small Python programs
--- Steven Bethard <steven.beth...@gmail.com> wrote: > Very cool! Do you mind putting this up on the Wiki Done. > somewhere so that we > can link to it more easily? Maybe something like: > <nitpick> I think I fixed them, please see Wiki to verify. > Though the code should probably follow PEP 8 > guidelines, e.g. > under_scores instead of camelCase for object and > method names: > http://www.python.org/dev/peps/pep-0008/ > > class ShoppingCart: I think the problem here is that it's hard to write a > > def __init__(self): self.items = [] > > def buy(self, item): > self.items.append(item) > > def boughtItems(self): return self.items > > myCart = ShoppingCart() > > myCart.buy('apple') > > myCart.buy('banana') > > print myCart.boughtItems() > I think boughtItems() is probably not a good example > def select_items(self, prefix): useful class in less than 10 lines of code. Can somebody else give it a try? Although I didn't call it out in the email, I tried to Did I miss any basic concepts in the first 10 ___________________________________________________________________________ _________Yahoo! oneSearch: Finally, mobile search You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||