Re: easy question, how to double a variable

2009-09-23 Thread Casey Webster
On Sep 22, 9:57 am, Grant Edwards wrote: > > No, no, no.  The plan is to do his homework for him so that > he's incompetent when he graduates and won't be competition for > the rest of us who did do our homework. Don't forget the Peter principal --- we might end up working for him! Btw, I can't

Re: Suggestions for Python MapReduce?

2009-07-22 Thread Casey Webster
On Jul 22, 5:27 am, Phillip B Oldham wrote: > I understand that there are a number of MapReduce frameworks/tools > that play nicely with Python (Disco, Dumbo/Hadoop), however these have > "large" dependencies (Erlang/Java). Are there any MapReduce frameworks/ > tools which are either pure-Python,

Re: Python Equivalent for dd & fold

2009-07-16 Thread Casey Webster
On Jul 16, 10:12 am, seldan24 wrote: > On Jul 15, 1:48 pm, Emile van Sebille wrote: > > > > > On 7/15/2009 10:23 AM MRAB said... > > > >> On Jul 15, 12:47 pm, Michiel Overtoom wrote: > > >>> seldan24 wrote: > > what can I use as the equivalent for the Unix 'fold' command? > > >>> def fold(s

Re: PEP368 and pixeliterators

2009-07-02 Thread Casey Webster
On Jul 2, 4:32 am, Joachim Strömbergson wrote: > But, wouldn't it be more Pythonic and simpler to have an iterator that > iterates over all pixels in an image? Starting with upper left corner > and moving left-right and (line by line) to lower right. This would > change the code above to: Unless

Re: performance problem with time.strptime()

2009-07-02 Thread Casey Webster
On Jul 2, 7:30 am, Nils Rüttershoff wrote: > Rec = > re.compile(r"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*") > Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] "GET /foo HTTP/1.0" 200 - > "-" "www.example.org" "-" "-" "-"' I'm not sure how

Re: strip char from list of strings

2009-05-19 Thread Casey Webster
On May 18, 3:30 pm, Laurent Luce wrote: > I have the following list: > > [ 'test\n', test2\n', 'test3\n' ] > > I want to remove the '\n' from each string in place, what is the most > efficient way to do that ? > > Regards, > > Laurent Do you _really_ need to do this in place? If not, the simple

Re: How complex is complex?

2009-03-18 Thread Casey Webster
On Mar 18, 1:30 pm, Kottiyath wrote: > When we say readability counts over complexity, how do we define what > level of complexity is ok? > For example: > Say I have dict a = {'a': 2, 'c': 4, 'b': 3} > I want to increment the values by 1 for all keys in the dictionary. > So, should we do:>>> for k

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Casey Webster
On Mar 15, 2:00 pm, tinn...@isbd.co.uk wrote: > No, it's perfectly possible applying simple logic.  My reminder > program manages it perfectly well.  I have, for example, two sets of > three monthly reminders. > >     One starts on Jan 19th and repeats three monthly, that means Jan >     19th, Apri

Re: Compute working days

2009-03-14 Thread Casey Webster
How about: from datetime import date, timedelta # Define the weekday mnemonics to match the date.weekday function (MON, TUE, WED, THU, FRI, SAT, SUN) = range(7) def workdays(start_date, end_date, whichdays=(MON,TUE,WED,THU,FRI)): ''' Calculate the number of working days between two dates