From amonroe at columbus.rr.com Tue Feb 3 13:27:55 2015 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Tue, 3 Feb 2015 07:27:55 -0500 Subject: [CentralOH] =?utf-8?q?2015-01-30_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gcXVvdGluZywgZG9jc3RyaW5ncywgaGVhcHEsIHNv?= =?utf-8?q?rted=2C_spam=2C_zen=2C_memoize=2C_recursion?= In-Reply-To: <20150131150520.59199892.jep200404@columbus.rr.com> References: <20150131150520.59199892.jep200404@columbus.rr.com> Message-ID: <1225199478.20150203072755@columbus.rr.com> The topic of online regex previewers came up last Friday. I just stumbled across this one, which looks pretty handy. http://jex.im/regulex/#!embed=false&flags=&re=^%28a|b%29*%3F%24 Alan From eric at intellovations.com Tue Feb 3 23:10:36 2015 From: eric at intellovations.com (Eric Floehr) Date: Tue, 3 Feb 2015 17:10:36 -0500 Subject: [CentralOH] pandas cheat sheet and practical business python In-Reply-To: References: Message-ID: Thanks for this list, Daniel! These are great resources which I will definitely refer to. I have on my list to learn pandas for some weather analysis I'm doing, which I've been told pandas would excel at. On Sat, Jan 10, 2015 at 12:52 PM, pybokeh wrote: > Hello List, > Thought I share my pandas cheat sheet that I have made that focuses on > common data manipulations that I use at work: > > http://nbviewer.ipython.org/github/pybokeh/ipython_notebooks/blob/master/pandas/PandasCheatSheet.ipynb > > This is a notebook that someone else has made that shows how you could do > some complex data filtering with pandas also: > http://nbviewer.ipython.org/gist/phobson/6006004/selections.ipynb > > Also, this web site contains a few good examples of practical uses for > Python: > http://pbpython.com/ > > Have a nice weekend! > > - Daniel > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Thu Feb 5 02:39:37 2015 From: eric at intellovations.com (Eric Floehr) Date: Wed, 4 Feb 2015 20:39:37 -0500 Subject: [CentralOH] Python Parsing Puzzle In-Reply-To: References: <20141206153401.37fbd230.jep200404@columbus.rr.com> Message-ID: These are all great solutions! Quite a few different implementations, and I'm glad everyone had fun with it. Just for closure, I realized I never shared the solution that I created prior to posting the puzzle. My solution was closest to XY's in that I used Python abstract syntax tree parsing library (ast). This is the same code that parses Python code, and I took advantage of the fact that the formulas were valid Python code (with a little sanitizing, like XY did). I ended up making a generator, that parsed the formula and returned pairs of variable name and the coefficient, like so: def coefficients(op): # Parse the string formula and turn into AST if isinstance(op, str): for coefficent in coefficients(ast.parse(op).body[0].value): yield coefficent # If there is only a number, it's the constant elif isinstance(op, ast.Num): yield 'CONST', op.n # If the operator is multiplication, it's a variable, coefficient pair elif isinstance(op.op, ast.Mult): yield op.right.id, op.left.n else: # We want all pairs to be added, so negate the coefficient if subtraction if isinstance(op.op, ast.Sub): negate(op.right) # Just a helper function # Split the tree and work on each half for coefficient in itertools.chain(coefficients(op.left), coefficients(op.right)): yield coefficient You can pass in the string formula line, and use it like this: for name, coefficient in coefficients(formula_string): ... do something ... Thanks again everyone! On Sun, Dec 7, 2014 at 3:34 PM, Erik Welch wrote: > Thanks for posting the puzzle, Eric. It's great to see the different > approaches people are taking. > > Here's my solution using regular expressions and pandas (which I'm sure > could be cleaned up and simplified): > > http://nbviewer.ipython.org/url/pastebin.com/raw.php/%3Fi%3DS7fRWFwS > > Cheers, > Erik > > On Sat, Dec 6, 2014 at 11:37 PM, Thomas Winningham > wrote: > >> I was curious about ast as well. I played with it once one time. So it is >> true that parsing then shouldn't evaluate the code? I'm trying to think if >> there are there any other possible "gotchas" ? I guess I should just read >> more. I always figured things like Hy and PyPy make extensive use of >> concepts in this general area. I played once on time with parser generators >> in Java until I found a different solution for whatever I was doing. I >> guess had I ever taken a compiler class I may know better how to Google >> these things, or even post about them, heh. >> On Dec 6, 2014 8:58 PM, "iynaix" wrote: >> >>> My solution: http://pastebin.com/nbGprTtV >>> >>> Quick explanation: >>> >>> As the formulas are basically valid python, minus undefined identifiers, >>> I sanitize the formulas a little, then feed the formulas into the python >>> ast module (https://docs.python.org/2/library/ast.html). >>> >>> Some quick walking of the parse tree yields the needed numbers and >>> coefficients, which is then placed into a dict. Parsing an ast does not >>> trigger an eval, so it should be safe, if that is a concern. After that >>> it's just python data structure manipulation, pretty straightforward. >>> >>> This was pretty fun! Always wanted to play with the python ast module, >>> but never had a problem to apply it on. >>> >>> Cheers, >>> Xianyi >>> >>> On Sun, Dec 7, 2014 at 4:34 AM, wrote: >>> >>>> On Sat, 6 Dec 2014 10:59:21 -0500, Eric Floehr >>>> wrote: >>>> >>>> > How would you solve this problem? >>>> >>>> Release early, release often: http://colug.net/python/dojo/20141206/ >>>> >>>> I would normally use grep, awk, sed, awk, tr, and friends, >>>> but here's some very sloppy Python code to start things. >>>> >>>> What program, ala indent or cb, do folks like for cleaning up >>>> Python code? >>>> _______________________________________________ >>>> CentralOH mailing list >>>> CentralOH at python.org >>>> https://mail.python.org/mailman/listinfo/centraloh >>>> >>> >>> >>> _______________________________________________ >>> CentralOH mailing list >>> CentralOH at python.org >>> https://mail.python.org/mailman/listinfo/centraloh >>> >>> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Thu Feb 5 02:55:14 2015 From: eric at intellovations.com (Eric Floehr) Date: Wed, 4 Feb 2015 20:55:14 -0500 Subject: [CentralOH] Python Puzzle: Day generator Message-ID: Here is a group puzzle. I am interested in everyone's solutions. I will post a link to my solution, which can also be refactored if you'd like a refactoring challenge. My timelapse code has a lot of places where I need to iterate through days. So I thought to make a function that works like range() only with dates. Here is the spec: 1. Takes an optional start date, end date, and step. 2. Start date and end date can either be python date objects or strings of form "YYYY-MM-DD" 3. Step is number of days between steps, negative means step backwards 4. If end date is greater than start date and step is not specified, step will be 1 5. If start date is greater than end date and step is not specified, step will be -1 6. If end date is not specified, it will be the same as start date 7. If start date in not specified, it will be yesterday Examples: >>> for day in day_generator('2014-03-01', '2014-03-10'): ... print day 2014-03-01 2014-03-02 2014-03-03 2014-03-04 2014-03-05 2014-03-06 2014-03-07 2014-03-08 2014-03-09 2014-03-10 >>> for day in day_generator('2014-11-16', '2014-10-31', -4): ... print day 2014-11-16 2014-11-12 2014-11-08 2014-11-04 2014-10-31 And my solution (open to refactoring): https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Feb 5 03:41:22 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Wed, 4 Feb 2015 21:41:22 -0500 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: References: Message-ID: <20150204214122.60490b1c.jep200404@columbus.rr.com> On Wed, 4 Feb 2015 20:55:14 -0500, Eric Floehr wrote: > Here is a group puzzle. > My timelapse code has a lot of places where I need to iterate through days. What type should the generated objects be? str? datetime.date? (for which print yields different output) Sometimes, once I see some solution, it's hard to imagine other approaches, so I am avoiding looking at your code until I've written my own. From andrewcfitzgerald at gmail.com Thu Feb 5 04:28:18 2015 From: andrewcfitzgerald at gmail.com (Andrew Fitzgerald) Date: Wed, 4 Feb 2015 22:28:18 -0500 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: References: Message-ID: One small change to your gist: https://gist.github.com/Fitzoh/4f698d5014b3768ebbeb/revisions On Wed, Feb 4, 2015 at 8:55 PM, Eric Floehr wrote: > Here is a group puzzle. I am interested in everyone's solutions. I will > post a link to my solution, which can also be refactored if you'd like a > refactoring challenge. > > My timelapse code has a lot of places where I need to iterate through > days. So I thought to make a function that works like range() only with > dates. > > Here is the spec: > > 1. Takes an optional start date, end date, and step. > 2. Start date and end date can either be python date objects or > strings of form "YYYY-MM-DD" > 3. Step is number of days between steps, negative means step backwards > 4. If end date is greater than start date and step is not specified, > step will be 1 > 5. If start date is greater than end date and step is not specified, > step will be -1 > 6. If end date is not specified, it will be the same as start date > 7. If start date in not specified, it will be yesterday > > Examples: > > >>> for day in day_generator('2014-03-01', '2014-03-10'): > ... print day > > 2014-03-01 > 2014-03-02 > 2014-03-03 > 2014-03-04 > 2014-03-05 > 2014-03-06 > 2014-03-07 > 2014-03-08 > 2014-03-09 > 2014-03-10 > > >>> for day in day_generator('2014-11-16', '2014-10-31', -4): > ... print day > > 2014-11-16 > 2014-11-12 > 2014-11-08 > 2014-11-04 > 2014-10-31 > > And my solution (open to refactoring): > https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 > > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Feb 5 08:06:01 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 5 Feb 2015 02:06:01 -0500 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: References: Message-ID: <20150205020601.3add0fb5.jep200404@columbus.rr.com> On Wed, 4 Feb 2015 20:55:14 -0500, Eric Floehr wrote: > Here is a group puzzle. I am interested in everyone's solutions. > ... I need to iterate through days. > So I thought to make a function that works like range() only with dates. See http://colug.net/python/cohpy/20150205/ for what I did before looking at your code. > And my solution (open to refactoring): > https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 Here's some refactoring comments, and comparison to my code, particularly of my cell #5. First, some easy PEP 8 stuff: Use isinstance() instead of type() == str Delete the spaces inside the [] of your comprehensions I like day= in timedelta(day=1) in your code. It documents the value. Likewise for days= at the bottom. .strptime() in my code makes short work of parsing YYYY-MM-DD strings. Your start_day is None is more correct than my not start_date. Because of your range test, I see that your loop only goes once for bad step polarities, instead of the infinite loop I feared. It would be good to tighten up the specification for what behavior is desired for whacko step polarity. Does the polarity handling in your day_generator() make your other code do nothing gracefully? The names range_start and range_end are misleading. Better names would be range_min and range_max. Looking at your min()/max() lines, I wish there were a minmax() function that returned a tuple, kind of like divmod() does for division. Can your while loop be simplified to the following? while range_min <= current_day <= range_max: I like the way that testing against both the min and max, avoids the need to figure out which single test would suffice. Doing from datetime import in your code made your other code easier to read than mine. Even though my having d and start_date refer to the same object causes no bug, your current_day = copy(start_day) is more prudent than my d = start_date. Of course, I could just claim that d is a pronoun for start_date. :-) Your day_step is a better argument name than my terse step, because yours documents the value better. I'm a little surprised I did not take advantage of elif for my isinstance() code. What else did I miss? From iynaix at gmail.com Thu Feb 5 08:19:57 2015 From: iynaix at gmail.com (iynaix) Date: Thu, 5 Feb 2015 15:19:57 +0800 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: <20150205020601.3add0fb5.jep200404@columbus.rr.com> References: <20150205020601.3add0fb5.jep200404@columbus.rr.com> Message-ID: Use isinstance(x, basestring) instead of isinstance(x, str) for python 2.x as basestring handles both 'str' and 'unicode' string types in python 2.x. This is not needed in python 3.x since all strings are now unicode and there is only one 'str' to rule them all. More detailed explanation and example here: http://stackoverflow.com/a/1979107 Cheers, XY On Thu, Feb 5, 2015 at 3:06 PM, wrote: > On Wed, 4 Feb 2015 20:55:14 -0500, Eric Floehr > wrote: > > > Here is a group puzzle. I am interested in everyone's solutions. > > > ... I need to iterate through days. > > So I thought to make a function that works like range() only with dates. > > See http://colug.net/python/cohpy/20150205/ > for what I did before looking at your code. > > > And my solution (open to refactoring): > > https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 > > Here's some refactoring comments, and comparison to my code, > particularly of my cell #5. > > First, some easy PEP 8 stuff: > > Use isinstance() instead of type() == str > Delete the spaces inside the [] of your comprehensions > > I like day= in timedelta(day=1) in your code. It documents the value. > Likewise for days= at the bottom. > > .strptime() in my code makes short work of parsing YYYY-MM-DD strings. > Your start_day is None is more correct than my not start_date. > > Because of your range test, I see that your loop only goes once > for bad step polarities, instead of the infinite loop I feared. > It would be good to tighten up the specification for what > behavior is desired for whacko step polarity. Does the > polarity handling in your day_generator() make your other > code do nothing gracefully? > > The names range_start and range_end are misleading. > Better names would be range_min and range_max. > > Looking at your min()/max() lines, I wish there were a minmax() > function that returned a tuple, kind of like divmod() does for > division. > > Can your while loop be simplified to the following? > > while range_min <= current_day <= range_max: > > I like the way that testing against both the min and max, > avoids the need to figure out which single test would suffice. > > Doing from datetime import in your code made your other code > easier to read than mine. > > Even though my having d and start_date refer to the same object > causes no bug, your current_day = copy(start_day) is more prudent > than my d = start_date. Of course, I could just claim that d > is a pronoun for start_date. :-) > > Your day_step is a better argument name than my terse step, > because yours documents the value better. > > I'm a little surprised I did not take advantage of elif for > my isinstance() code. > > What else did I miss? > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Feb 5 09:19:30 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 5 Feb 2015 03:19:30 -0500 Subject: [CentralOH] Python Puzzle: Day generator: Merged In-Reply-To: <20150205020601.3add0fb5.jep200404@columbus.rr.com> References: <20150205020601.3add0fb5.jep200404@columbus.rr.com> Message-ID: <20150205031930.76dd97da.jep200404@columbus.rr.com> On Thu, 5 Feb 2015 02:06:01 -0500, jep200404 at columbus.rr.com wrote: > On Wed, 4 Feb 2015 20:55:14 -0500, Eric Floehr wrote: > > > Here is a group puzzle. I am interested in everyone's solutions. > > > ... I need to iterate through days. > > So I thought to make a function that works like range() only with dates. > > See http://colug.net/python/cohpy/20150205/ > for what I did before looking at your code. > > And my solution (open to refactoring): > > https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 New code merges Eric's and my ideas. http://nbviewer.ipython.org/url/colug.net/python/cohpy/20150205/cohpy-20150205-day-generator-20150205-0255.ipynb http://colug.net/python/cohpy/20150205/cohpy-20150205-day-generator-20150205-0255.ipynb > I like day= in timedelta(day=1) in your code. It documents the value. > Likewise for days= at the bottom. Was day= (instead of days=) a bug? What else did I miss? From eric at intellovations.com Thu Feb 5 13:42:42 2015 From: eric at intellovations.com (Eric Floehr) Date: Thu, 5 Feb 2015 07:42:42 -0500 Subject: [CentralOH] Python Puzzle: Day generator: Merged In-Reply-To: <20150205031930.76dd97da.jep200404@columbus.rr.com> References: <20150205020601.3add0fb5.jep200404@columbus.rr.com> <20150205031930.76dd97da.jep200404@columbus.rr.com> Message-ID: On Thu, Feb 5, 2015 at 3:19 AM, wrote: > > Was day= (instead of days=) a bug? > I could say I deliberately added that as a test to see how many people caught it :-D. In reality, it is a bug, and makes very apparent my lack of a test case that exercises that branch of the code. Whoops... I'll just exit slowly now... -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Feb 5 15:10:13 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 5 Feb 2015 09:10:13 -0500 Subject: [CentralOH] basestring not found in Learning Python In-Reply-To: References: <20150205020601.3add0fb5.jep200404@columbus.rr.com> Message-ID: <20150205091013.13281e96.jep200404@columbus.rr.com> On Thu, 5 Feb 2015 15:19:57 +0800, iynaix wrote: > Use isinstance(x, basestring) instead of isinstance(x, str) for python 2.x Thanks. This seems to not be explained in Learning Python. I am surprised that I am not able to find an instance of basestring in Learning Python 5th edition. From joe at joeshaw.org Thu Feb 5 15:59:11 2015 From: joe at joeshaw.org (Joe Shaw) Date: Thu, 5 Feb 2015 09:59:11 -0500 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: References: Message-ID: Hi, Here's my solution, although I didn't read the spec carefully before I wrote it so it behaves incorrectly: https://gist.github.com/joeshaw/3e4172b5adc034a9771b Oops. Namely, if end_date is not specified, the generator yields forever and if start_date is not specified, it is today. It also always assumes a step of 1, so an end_date in the past without explicit step=-1 results in zero values being yielded... that's a side effect of the infinite iteration. Joe On Wed, Feb 4, 2015 at 8:55 PM, Eric Floehr wrote: > Here is a group puzzle. I am interested in everyone's solutions. I will > post a link to my solution, which can also be refactored if you'd like a > refactoring challenge. > > My timelapse code has a lot of places where I need to iterate through > days. So I thought to make a function that works like range() only with > dates. > > Here is the spec: > > 1. Takes an optional start date, end date, and step. > 2. Start date and end date can either be python date objects or > strings of form "YYYY-MM-DD" > 3. Step is number of days between steps, negative means step backwards > 4. If end date is greater than start date and step is not specified, > step will be 1 > 5. If start date is greater than end date and step is not specified, > step will be -1 > 6. If end date is not specified, it will be the same as start date > 7. If start date in not specified, it will be yesterday > > Examples: > > >>> for day in day_generator('2014-03-01', '2014-03-10'): > ... print day > > 2014-03-01 > 2014-03-02 > 2014-03-03 > 2014-03-04 > 2014-03-05 > 2014-03-06 > 2014-03-07 > 2014-03-08 > 2014-03-09 > 2014-03-10 > > >>> for day in day_generator('2014-11-16', '2014-10-31', -4): > ... print day > > 2014-11-16 > 2014-11-12 > 2014-11-08 > 2014-11-04 > 2014-10-31 > > And my solution (open to refactoring): > https://gist.github.com/efloehr/3e1dd639f3c5c1b064b7 > > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Feb 5 17:02:00 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 5 Feb 2015 11:02:00 -0500 Subject: [CentralOH] Python Puzzle: Day generator: Factor Out Arg Parsing, Simplify Loop Test In-Reply-To: References: Message-ID: <20150205110200.2dea630e.jep200404@columbus.rr.com> On Thu, 5 Feb 2015 09:59:11 -0500, Joe Shaw wrote: > https://gist.github.com/joeshaw/3e4172b5adc034a9771b I had not thought of factoring out the parsing of date arguments as you did. Doing so yields: def _parse_date_argument(date_, default): if date_ is None: date_ = default elif isinstance(date_, str): date_ = datetime.strptime(date_, '%Y-%m-%d').date() return date_ def day_generator(start_date=None, end_date=None, day_step=1): yesterday = date.today() - timedelta(days=1) start_date = _parse_date_argument(start_date, yesterday) end_date = _parse_date_argument(end_date, start_date) day_step = timedelta(abs(day_step)) if end_date < start_date: day_step = -day_step min_date = min(start_date, end_date) max_date = max(start_date, end_date) # print(start_date, end_date, day_step, min_date, max_date) d = copy(start_date) while min_date <= d <= max_date: yield d d += day_step >From https://gist.github.com/joeshaw/3e4172b5adc034a9771b while True: if not _in_range(d): break ... can be simplified as: while _in_range(d): ... How does your code behave if your day_generator is passed a datetime.date object for date arguments (as compared to passing a datetime.datetime object)? From joe at joeshaw.org Thu Feb 5 17:19:42 2015 From: joe at joeshaw.org (Joe Shaw) Date: Thu, 5 Feb 2015 11:19:42 -0500 Subject: [CentralOH] Python Puzzle: Day generator: Factor Out Arg Parsing, Simplify Loop Test In-Reply-To: <20150205110200.2dea630e.jep200404@columbus.rr.com> References: <20150205110200.2dea630e.jep200404@columbus.rr.com> Message-ID: Hi, On Thu, Feb 5, 2015 at 11:02 AM, wrote: > > How does your code behave if your day_generator is passed > a datetime.date object for date arguments (as compared to > passing a datetime.datetime object)? > It blows up. I've fixed it in the gist. Thanks, Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmknapp at gmail.com Thu Feb 5 21:53:55 2015 From: jmknapp at gmail.com (Joe Knapp) Date: Thu, 5 Feb 2015 15:53:55 -0500 Subject: [CentralOH] Python Puzzle: Day generator In-Reply-To: References: Message-ID: Thinking about taking this 9-week edX/MITx course starting March 5: Introduction to Computational Thinking and Data Science (with python) https://www.edx.org/course/introduction-computational-thinking-data-mitx-6-00-2x-0#.VNPWbGjnQ2s Joe From jep200404 at columbus.rr.com Sat Feb 7 22:08:55 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sat, 7 Feb 2015 16:08:55 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-06_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gZGphbmdvLCBldWxlciAjMTIsICMyLCByZXByIGFi?= =?utf-8?q?use=2C_factors=2C_interference=2C_moire=2C_heterodyning=2C_numb?= =?utf-8?q?ers_in_the_attic?= Message-ID: <20150207160855.7bc5e8f4.jep200404@columbus.rr.com> Party #1 https://pypi.python.org/pypi/pandas Party #2 had many questions about Django, needs to do homework You read book: http://www.djangobook.com/en/2.0/index.html Chapters 1 through 8 inclusive Chapter 14 for session stuff sqlite3 In restrospect, for the person's limited needs, maybe Django is overkill. Party #3 https://projecteuler.net/problem=2 generate even fibonacci numbers [CentralOH] 2013-05-30 ?? Scribbles ??/??? https://mail.python.org/pipermail/centraloh/2013-June/001698.html http://mail.python.org/pipermail/centraloh/attachments/20130531/f0ee5532/attachment.obj nested generators and tuple unpacking [CentralOH] 2013-06-07 ?? Scribbles ??/??? https://mail.python.org/pipermail/centraloh/2013-June/001718.html Put code from both elegant nested generator technique and plain functions in one ipython notebook. See http://colug.net/python/dojo/20150206. http://hackertyper.net/ # Air guitar for typing. Brandon rhodes' adventure http://pyvideo.org/video/522/pyohio-2011--sunday-lightning-talks http://pyvideo.org/video/522/ See http://colug.net/python/dojo/20150206 for abusing __repr__(). vim ^Wv to split existing pane into two panes side by side cursor stays in left pane ^Ws to split existing pane into two panes one above other cursor stays in top pane Party #4 Euler #12 factor() was terribly slow Play with http://linux.die.net/man/1/factor. Need to work through examples by hand. How many factors do the following numbers have? Korean Air Lines Flight 007 2 4 8 16 32 64 What pattern do you see? 3 9Korean Air Lines Flight 007 27 81 243 What pattern do you see? 6 12 24 48 96 What pattern do you see? 6 18 54 162 What pattern do you see? 4 12 36 108 324 What pattern do you see? Have you seen enough patterns to figure out a formula for determining how many factors a number has? Did not have Ipython Notebook installed, so used tmpnb.org, but lousy Wifi frustrated that. Wifi reception at Panera wp:Interference (wave propagation) wp:Node (physics) wp:Standing wave wp:Reflections of signals on conducting lines wp:Radio_Shack#2015_Bankruptcy http://opensource.com/business/15/2/how-linux-philosophy-affects-you http://www.linuxlinks.com/article/20150201134045961/BeginnerBooks.html What do you get when you combined Uber with Car2Go? wp:??? http://en.wiktionary.org/wiki/?#Usage_notes wp:Tally_marks#Clustering wp:Attic wp:Attic numerals wp:Greek numerals wp:Roman numerals wp:Arabic numerals wp:Hindu?Arabic numeral system wp:hanjin http://english.chosun.com/site/data/html_dir/2015/02/03/2015020301467.html wp:Korean Air Lines Flight 007 wp:Korean Air Flight 801 wp:Shin Ki-ha https://en.wiktionary.org/wiki/? wp:Shin Ramyun Eddie Harris - Listen Here - The Electrifying Eddie Harris Desert Queen - Janet Wallach From pybokeh at gmail.com Fri Feb 13 15:32:26 2015 From: pybokeh at gmail.com (pybokeh) Date: Fri, 13 Feb 2015 06:32:26 -0800 Subject: [CentralOH] conda.io - using conda for virtual environments and package management Message-ID: Hello List, I know virtualenv gets a lot of mention for making virtual environments, but I recommend conda instead. Check out http://conda.io/ for more info. - Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Fri Feb 13 15:38:19 2015 From: eric at intellovations.com (Eric Floehr) Date: Fri, 13 Feb 2015 09:38:19 -0500 Subject: [CentralOH] conda.io - using conda for virtual environments and package management In-Reply-To: References: Message-ID: Hi Daniel, What are the things you like about conda over virtualenv? -Eric On Fri, Feb 13, 2015 at 9:32 AM, pybokeh wrote: > Hello List, > I know virtualenv gets a lot of mention for making virtual environments, > but I recommend conda instead. Check out http://conda.io/ for more info. > > - Daniel > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pybokeh at gmail.com Fri Feb 13 16:20:25 2015 From: pybokeh at gmail.com (pybokeh) Date: Fri, 13 Feb 2015 07:20:25 -0800 Subject: [CentralOH] conda.io - using conda for virtual environments and package management In-Reply-To: References: Message-ID: I think the real advantage is if you are on Windows or don't want to compile packages from source. Since conda is part of Anaconda distribution, there are already many popular pre-compiled binaries readily available and Continuum IO the company behind Anaconda usually do a decent job of quickly getting the latest version of their packages pushed out. If a package is not available in Anaconda, you can still install it using pip. Also this is subjective, but I prefer the conda's more user-friendly command line arguments over virtualenv's commands. For example, if you want to create an environment for a specific python version, in conda it is just python=2.7 or python=3.4 whereas in virtualenv, you have to provide the full path to the python interpreter. This is about all I can think of off the top of my head. I used to use virtualenv, but I guess I got less patient over the years waiting on compiling a package from source. - Daniel On Feb 13, 2015 9:38 AM, "Eric Floehr" wrote: > Hi Daniel, > > What are the things you like about conda over virtualenv? > > -Eric > > > On Fri, Feb 13, 2015 at 9:32 AM, pybokeh wrote: > >> Hello List, >> I know virtualenv gets a lot of mention for making virtual environments, >> but I recommend conda instead. Check out http://conda.io/ for more info. >> >> - Daniel >> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Fri Feb 13 16:52:49 2015 From: eric at intellovations.com (Eric Floehr) Date: Fri, 13 Feb 2015 10:52:49 -0500 Subject: [CentralOH] conda.io - using conda for virtual environments and package management In-Reply-To: References: Message-ID: Thanks! Having binary packages is a huge benefit, especially for Windows users. I know that I generally just rely on "with-site-packages" for virtualenv when I need big packages that need compiled like numpy, scipy, etc. because it's such a pain to get all the libraries, etc. and verify correct compilation. I'll have to check it out... On Fri, Feb 13, 2015 at 10:20 AM, pybokeh wrote: > I think the real advantage is if you are on Windows or don't want to > compile packages from source. Since conda is part of Anaconda > distribution, there are already many popular pre-compiled binaries readily > available and Continuum IO the company behind Anaconda usually do a decent > job of quickly getting the latest version of their packages pushed out. If > a package is not available in Anaconda, you can still install it using pip. > > Also this is subjective, but I prefer the conda's more user-friendly > command line arguments over virtualenv's commands. For example, if you > want to create an environment for a specific python version, in conda it is > just python=2.7 or python=3.4 whereas in virtualenv, you have to provide > the full path to the python interpreter. > > This is about all I can think of off the top of my head. I used to use > virtualenv, but I guess I got less patient over the years waiting on > compiling a package from source. > > - Daniel > On Feb 13, 2015 9:38 AM, "Eric Floehr" wrote: > >> Hi Daniel, >> >> What are the things you like about conda over virtualenv? >> >> -Eric >> >> >> On Fri, Feb 13, 2015 at 9:32 AM, pybokeh wrote: >> >>> Hello List, >>> I know virtualenv gets a lot of mention for making virtual environments, >>> but I recommend conda instead. Check out http://conda.io/ for more >>> info. >>> >>> - Daniel >>> >>> _______________________________________________ >>> CentralOH mailing list >>> CentralOH at python.org >>> https://mail.python.org/mailman/listinfo/centraloh >>> >>> >> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Mon Feb 16 19:43:24 2015 From: eric at intellovations.com (Eric Floehr) Date: Mon, 16 Feb 2015 13:43:24 -0500 Subject: [CentralOH] February Monthly Meeting -- Go for Pythonistas Message-ID: Next Monday, February 23, starting at 6pm, we will be having our monthly meeting. Please RSVP Here: http://www.meetup.com/Central-Ohio-Python-Users-Group/events/220561065/ We will be meeting at Pillar, as usual. Pillar will provide food and drink (thanks Pillar!). Informal meeting starts at 6pm, with the talk starting at 6:30pm. We will finish no later than 8:30pm to adjourn to the informal meeting. Go has sometimes been called the child of C and Python, with built-in async. This month, Joe Shaw will introduce the Go programming language from the perspective of a Python programmer. In particular he'll look at PEP-20, the Zen of Python, and how its principles apply to Go. He'll demonstrate some of the ways he feels Go embodies the Zen, in some ways better and other ways not as well. Jim Prior will also show a few things from his Python grab bag. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Mon Feb 16 20:05:06 2015 From: eric at intellovations.com (Eric Floehr) Date: Mon, 16 Feb 2015 14:05:06 -0500 Subject: [CentralOH] COhPy February After-Meeting Message-ID: Please RSVP Here: http://www.meetup.com/Central-Ohio-Python-Users-Group/events/220561615/ Since parking is good, and there are generally ample tables and good food and drink we will continue our recent tradition of adjourning to Brazenhead on Fifth for the monthly meeting after-meeting. This is an inclusive informal social gathering after the formal meeting and presentations. It is equally likely topics will be Python or non-Python related. Brazenhead has lots of yummy food choices, and many non-alcoholic beverages. Drinking is neither encouraged nor discouraged, and your choices will be respected by the group. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Tue Feb 17 21:03:18 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 17 Feb 2015 15:03:18 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-13_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gR0lTLCBnZW9kamFuZ28sIFBvc3RHSVMsIFRJR0VS?= =?utf-8?q?=2C_Proton=2C_tuples=2C_default_functions=2C_LPtHW_ex39?= Message-ID: <20150217150318.7a192916.jep200404@columbus.rr.com> To get good answers, consider following the advice in the links below. http://catb.org/~esr/faqs/smart-questions.html http://web.archive.org/web/20090627155454/www.greenend.org.uk/rjk/2000/06/14/quoting.html wp: prefix means Wikipedia wp:To Serve Man postgresql PostGIS django geodjango http://geodjango.org/ wp:GIS wp:tigger wp:TIGER wp:OpenStreetMap wp:emacs wp:vim wp:Proton therapy wp:Bragg peak $183M each more than a car factory costs Way to go pybokeh! pybokeh's pandas cheatsheet notebook has been posted to: http://nb.bianp.net/sort/views/ https://nbviewer.ipython.org/github/pybokeh/ipython_notebooks/blob/master/pandas/PandasCheatSheet.ipynb https://github.com/brandon-rhodes/astronomy-notebooks wp:SPSS https://mail.python.org/pipermail/centraloh/2013-June/001718.html wp:PyPy https://pypi.python.org/pypi/ http://et1337.github.io/shaders/ http://www.pyohio.org/ O'Reilly offered 2014 attendees free ebooks. Can default values evaluate a function each time? http://nbviewer.ipython.org/url/colug.net/python/dojo/20150213/dojo-20150213-default-arg-evaluation.ipynb More notebooks: http://www.colug.net/python/dojo/20150213/ https://www.pytennessee.org/schedule/ http://pytennessee.tumblr.com/post/106799437321/pytn-profiles-eric-floehr-and-stratasan Way to go Austin! Go to tmpnb.org and navigate to the following notebook communities / desertpy / pandas-intro-godber-jan-2014 It looks like he was doing weather. The URL I used follows, but it was almost certainly ephemeral. https://tmp07.tmpnb.org/user/jVJAA0x8xsDt/tree/communities/desertpy/pandas-intro-godber-jan-2014 very local, very short term weather forecasts http://www.nooly.com/ whocalled.us has an API (not whocalled.me) written on a napkin with a Sharpie: tempered in a crucible of ignorance Online tutorials such as Zed's Learning Python the Hard Way are helpful, but have problems. For example: https://mail.python.org/pipermail/centraloh/2014-November/002217.html From jep200404 at columbus.rr.com Thu Feb 19 23:12:01 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 19 Feb 2015 17:12:01 -0500 Subject: [CentralOH] Python Lunch Message-ID: <20150219171201.6bb72dc2.jep200404@columbus.rr.com> How about Python lunch Monday at Guachos or Mazah? Los Guachos Taqueria 1376 Cherry Bottom Rd, Gahanna los-guachos.com the gringas are very good! Mazah 1453 Grandview Ave, Columbus mazah-eatery.com Which do you favor? What time? Eric chose 11:15 or 11:30 to beat rush last year. From herrold at owlriver.com Fri Feb 20 21:01:27 2015 From: herrold at owlriver.com (R P Herrold) Date: Fri, 20 Feb 2015 15:01:27 -0500 (EST) Subject: [CentralOH] Python Lunch In-Reply-To: <20150219171201.6bb72dc2.jep200404@columbus.rr.com> References: <20150219171201.6bb72dc2.jep200404@columbus.rr.com> Message-ID: On Thu, 19 Feb 2015, jep200404 at columbus.rr.com wrote: > How about Python lunch Monday at Guachos or Mazah? > > Los Guachos Taqueria > 1376 Cherry Bottom Rd, Gahanna > los-guachos.com > the gringas are very good! there is also an Guachos on Hard Rd, north of Centennial High School and Bethel Road, also with yummy gringas, and lime wedges and the onion garnish -- Russ herrold From jep200404 at columbus.rr.com Sat Feb 21 17:49:13 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sat, 21 Feb 2015 11:49:13 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-20_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gRXVsZXIgIzEsIFBhc2NhbCdzIHRyaWFuZ2xlLCBt?= =?utf-8?q?inmaxsums=2C_toolz=2Ecurried=2Epipe=2C_=5F=2C_Lenovo=2C_termcap?= =?utf-8?q?=2C_*_ipsum=2C_sentiment_analysis=2C_jupyter/ipython=2C_ASCII?= =?utf-8?q?=2C_ggplot/matplotlib=2C_spyre?= Message-ID: <20150221114913.7bcefa76.jep200404@columbus.rr.com> Lenovo man in the middle chrome ie certificate http://arstechnica.com/security/2015/02/lenovo-pcs-ship-with-man-in-the-middle-adware-that-breaks-https-connections/ man xterm termcap pypy sentiment analysis the quick brown fox jumped over the lazy dog lorem ipsum bacon ipsum mitsubishi has good speech recognition jupyter is language agnostic version of ipython notebook http://jupyter.org/ Ipython notebook is such a good idea that it is being broadened to include other languages, so the Ipython name is being changed to Jupyter. http://www.asciimation.co.nz/ hasciicam bb (demo for aa library) ggplot smokes matplotlib %load_ext rpy2.ipython ggplot https://github.com/yhat/ggplot/ http://blog.yhathq.com/posts/ggplot-for-python.html ipython notebook with widgets r world http://shiny.rstudio.com/gallery/ https://github.com/adamhajari https://github.com/adamhajari/spyre What nice thing in Python was done first in Python? Did idea for Ipython Notebook come from Wolfram Alpha? wolfram alpha http://www.wolframalpha.com/ No: http://blog.fperez.org/2012/01/ipython-notebook-historical.html http://colug.net/python/dojo/20150220/ Pascal's Triangle return row for given level clear, naive: add slices direct calculation Project Euler Problem #1 Someone else was starting on Project Euler, starting with problem #1, so that problem was revisited with direction calculation that avoids iteration. Given sequence of positive and negative integers, return slices with greatest and smallest sums. from toolz.curried import pipe pipe() for _ in range(n): # For when the loop variable is never referenced. Python http://www.coverity.com/press-releases/coverity-finds-python-sets-new-level-of-quality-for-open-source-software/ security through obscurity many eyes make all bugs shallow the cathedral and the bazaar Paul Horn - Inside From mark at microenh.com Sun Feb 22 04:10:16 2015 From: mark at microenh.com (Mark Erbaugh) Date: Sat, 21 Feb 2015 22:10:16 -0500 Subject: [CentralOH] PythonDotNet Message-ID: <54E94898.8050709@microenh.com> Greetings, I am struggling with a hobby project using PythonDotNet. I have an API for an external device written in C# and .NET. I have the C# code. Rather than using IronPython, I am trying to use PythonDotNet with CPython 2.7.9. The C# code was not written with any special consideration of Python. The API implements callback functions. I have been able to write several of the callback functions in Python and they work. But, now I've come across something that I can't figure out, and perhaps it's not supported by PythonDotNet. There is a callback routine that passes a C# array of shorts. the C# function signature is public delegate void DataReadyEventHandler(Panadapter pan, ushort[] data); No matter how I try to code my Python function, I am getting a runtime exception from the PythonRuntime part of PythonDotNet. Is passing this array possible? Thanks, Mark From williamsonkr at gmail.com Sun Feb 22 23:53:12 2015 From: williamsonkr at gmail.com (Kyle Williamson) Date: Sun, 22 Feb 2015 17:53:12 -0500 Subject: [CentralOH] Python and Excel Message-ID: Hello, Need some opinions on what everyone is using in Python to work with CSV files. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pybokeh at gmail.com Mon Feb 23 00:01:10 2015 From: pybokeh at gmail.com (pybokeh) Date: Sun, 22 Feb 2015 18:01:10 -0500 Subject: [CentralOH] Python and Excel In-Reply-To: References: Message-ID: If the csv file is large and won't fit into memory, you can use the csv module and 'lazily' read in the data from the csv file using a generator. Here's an article that covers that: http://districtdatalabs.silvrback.com/simple-csv-data-wrangling-with-python Otherwise, I would use the read_csv() method from the pandas library. - Daniel On Feb 22, 2015 5:53 PM, "Kyle Williamson" wrote: > Hello, > > Need some opinions on what everyone is using in Python to work with > CSV files. Thanks. > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewcfitzgerald at gmail.com Mon Feb 23 00:01:14 2015 From: andrewcfitzgerald at gmail.com (Andrew Fitzgerald) Date: Sun, 22 Feb 2015 18:01:14 -0500 Subject: [CentralOH] Python and Excel In-Reply-To: References: Message-ID: Most of the time I end up using the standard library csv module. https://docs.python.org/2/library/csv.html Pandas is also potentially useful depending on what you're trying to do. http://pandas.pydata.org/pandas-docs/dev/io.html On Sun, Feb 22, 2015 at 5:53 PM, Kyle Williamson wrote: > Hello, > > Need some opinions on what everyone is using in Python to work with > CSV files. Thanks. > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Mon Feb 23 00:31:44 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sun, 22 Feb 2015 18:31:44 -0500 Subject: [CentralOH] Python[, CSV,] and Excel In-Reply-To: References: Message-ID: <20150222183144.55152a44.jep200404@columbus.rr.com> On Sun, 22 Feb 2015 17:53:12 -0500, Kyle Williamson wrote: > Need some opinions on what everyone is using in Python to work > with CSV files. We use the csv module. One can often easily find the dox with useful examples by searching for python and whatever it is that you are messing with. For example, https://duckduckgo.com/html/?q=python+csv https://duckduckgo.com/html/?q=python+csv+excel quickly lead to the relevant dox. Context managers are nifty. Use them. Examples of such are in the dox. You mentioned Excel but not CSV in the Subject and CSV but not Excel in the body of your letter. You might be interested in the excel and excel_tab dialects. From brian.costlow at gmail.com Mon Feb 23 00:49:17 2015 From: brian.costlow at gmail.com (Brian Costlow) Date: Sun, 22 Feb 2015 18:49:17 -0500 Subject: [CentralOH] Python and Excel In-Reply-To: References: Message-ID: You mentioned excel in your subject. I've used this to create actual excel files after manipulating tab data: https://github.com/kennethreitz/tablib But for some relatively small datasets. So I don't know how it holds up for big stuff. On Sun, Feb 22, 2015 at 6:01 PM, Andrew Fitzgerald < andrewcfitzgerald at gmail.com> wrote: > Most of the time I end up using the standard library csv module. > https://docs.python.org/2/library/csv.html > > Pandas is also potentially useful depending on what you're trying to do. > http://pandas.pydata.org/pandas-docs/dev/io.html > > > > On Sun, Feb 22, 2015 at 5:53 PM, Kyle Williamson > wrote: > >> Hello, >> >> Need some opinions on what everyone is using in Python to work with >> CSV files. Thanks. >> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From winningham at gmail.com Mon Feb 23 01:56:14 2015 From: winningham at gmail.com (Thomas Winningham) Date: Sun, 22 Feb 2015 19:56:14 -0500 Subject: [CentralOH] PythonDotNet In-Reply-To: <54E94898.8050709@microenh.com> References: <54E94898.8050709@microenh.com> Message-ID: I had been thinking about this, and while I haven't messed with Python on .NET, I have messed with C# some, as well as other Python on top of another language type arrangements. There must be either one of two things you can do, but the details of which you may be on your own to investigate (sorry): 1. The Python.NET, being dynamically typed, must have some sort of functions to support the static (and more specific) types of the .NET system. This may be something that allows you to specifically create a C# compatible array of unsigned shorts like that second parameter of the function requires. I would imagine a study of the documentation for Python.NET may well reveal some kind of capability like this as a language support library or something similar. I know with say, Jython, it is called Java Interop, same with Clojure on the JVM. 2. You could approach this the other way, and write some C# to wrap this function in a function that does work with Python the way you want or however you can get it to work, then in this new C# function, coerce the types passed in to be an array of unsigned shorts, and pass that to the original function. Best of luck, and let us know if you find anything interesting. Thomas On Sat, Feb 21, 2015 at 10:10 PM, Mark Erbaugh wrote: > Greetings, > > I am struggling with a hobby project using PythonDotNet. I have an API > for an external device written in C# and .NET. I have the C# code. Rather > than using IronPython, I am trying to use PythonDotNet with CPython 2.7.9. > The C# code was not written with any special consideration of Python. > > The API implements callback functions. I have been able to write several > of the callback functions in Python and they work. But, now I've come > across something that I can't figure out, and perhaps it's not supported by > PythonDotNet. There is a callback routine that passes a C# array of > shorts. the C# function signature is > > public delegate void DataReadyEventHandler(Panadapter pan, > ushort[] data); > > No matter how I try to code my Python function, I am getting a runtime > exception from the PythonRuntime part of PythonDotNet. > > Is passing this array possible? > > Thanks, > Mark > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brywilharris at gmail.com Mon Feb 23 15:03:53 2015 From: brywilharris at gmail.com (Bryan Harris) Date: Mon, 23 Feb 2015 09:03:53 -0500 Subject: [CentralOH] Python and Excel In-Reply-To: References: Message-ID: The python CSV module works for large files. Bryan Harris, PE Research Engineer Structures and Materials Evaluation Group University of Dayton Research Institute bryan.harris at udri.udayton.edu http://www.udri.udayton.edu/ 937-229-5561 On Feb 22, 2015 6:49 PM, "Brian Costlow" wrote: > You mentioned excel in your subject. > > I've used this to create actual excel files after manipulating tab data: > https://github.com/kennethreitz/tablib > > But for some relatively small datasets. So I don't know how it holds up > for big stuff. > > On Sun, Feb 22, 2015 at 6:01 PM, Andrew Fitzgerald < > andrewcfitzgerald at gmail.com> wrote: > >> Most of the time I end up using the standard library csv module. >> https://docs.python.org/2/library/csv.html >> >> Pandas is also potentially useful depending on what you're trying to do. >> http://pandas.pydata.org/pandas-docs/dev/io.html >> >> >> >> On Sun, Feb 22, 2015 at 5:53 PM, Kyle Williamson >> wrote: >> >>> Hello, >>> >>> Need some opinions on what everyone is using in Python to work with >>> CSV files. Thanks. >>> >>> _______________________________________________ >>> CentralOH mailing list >>> CentralOH at python.org >>> https://mail.python.org/mailman/listinfo/centraloh >>> >>> >> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Mon Feb 23 16:04:09 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Mon, 23 Feb 2015 10:04:09 -0500 Subject: [CentralOH] Python Lunch: Nevermind In-Reply-To: <20150219171201.6bb72dc2.jep200404@columbus.rr.com> References: <20150219171201.6bb72dc2.jep200404@columbus.rr.com> Message-ID: <20150223100409.6b6aebf1.jep200404@columbus.rr.com> On Thu, 19 Feb 2015 17:12:01 -0500, jep200404 at columbus.rr.com wrote: > How about Python lunch Monday at Guachos or Mazah? It's 10am and I've not heard interest, so nevermind. From bgohar at osc.edu Mon Feb 23 20:33:09 2015 From: bgohar at osc.edu (Basil Mohamed Gohar) Date: Mon, 23 Feb 2015 14:33:09 -0500 Subject: [CentralOH] February Monthly Meeting -- Go for Pythonistas In-Reply-To: References: Message-ID: <54EB8075.3050108@osc.edu> I regretfully cannot attend tonight's meeting, most likely, but I hope it goes well and I look forward to seeing you all again at a future meeting. ------------------------------------------------------------------------ Basil Mohamed Gohar, Web & Interface Applications Manager Ohio Supercomputer Center An Ohio Technology Consortium (OH-TECH) Member 1224 Kinnear Road Columbus, OH 43212 Phone: (614) 688-0979 email: bgohar at osc.edu Learn more about the Ohio Supercomputer Center at https://www.osc.edu. On 2/16/15 1:43 PM, Eric Floehr wrote: > > Next Monday, February 23, starting at 6pm, we will be having our > monthly meeting. > > Please RSVP Here: > http://www.meetup.com/Central-Ohio-Python-Users-Group/events/220561065/ > > We will be meeting at Pillar, as usual. Pillar will provide food and > drink (thanks Pillar!). > > Informal meeting starts at 6pm, with the talk starting at 6:30pm. We > will finish no later than 8:30pm to adjourn to the informal meeting. > > Go has sometimes been called the child of C and Python, with built-in > async. This month, Joe Shaw will introduce the Go programming language > from the perspective of a Python programmer. In particular he'll look > at PEP-20, the Zen of Python, and how its principles apply to Go. > He'll demonstrate some of the ways he feels Go embodies the Zen, in > some ways better and other ways not as well. > > Jim Prior will also show a few things from his Python grab bag. > > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh -------------- next part -------------- An HTML attachment was scrubbed... URL: From winningham at gmail.com Mon Feb 23 20:45:56 2015 From: winningham at gmail.com (Thomas Winningham) Date: Mon, 23 Feb 2015 14:45:56 -0500 Subject: [CentralOH] PythonDotNet In-Reply-To: References: <54E94898.8050709@microenh.com> Message-ID: So I re-read your email, and my reply, and noticed I missed a subtlety, you're trying to get a Python.NET callback to work with a .NET function. This may not work unless the Python.NET allows you to override or somehow annotate a function's accepted types. The "method signature" in Java parlance means that whatever you write in Python is not going to appear like a valid callback method, as the parameters may be of a different type than what the callback allows. There *ought* to be a way to make a Python function that appears to the .NET CLR as having this method signature, but I'm not sure. I guess the same advice applies, but if what I described above doesn't exist, you may be in the C# world more if you can't find a way to explicitly define the Python function's parameter types. Essentially, write C# that can call your Python function, but that C# has to require parameters with the types aligned with the original callback. On Sun, Feb 22, 2015 at 7:56 PM, Thomas Winningham wrote: > I had been thinking about this, and while I haven't messed with Python on > .NET, I have messed with C# some, as well as other Python on top of another > language type arrangements. > > There must be either one of two things you can do, but the details of > which you may be on your own to investigate (sorry): > > 1. The Python.NET, being dynamically typed, must have some sort of > functions to support the static (and more specific) types of the .NET > system. This may be something that allows you to specifically create a C# > compatible array of unsigned shorts like that second parameter of the > function requires. I would imagine a study of the documentation for > Python.NET may well reveal some kind of capability like this as a language > support library or something similar. I know with say, Jython, it is called > Java Interop, same with Clojure on the JVM. > > 2. You could approach this the other way, and write some C# to wrap this > function in a function that does work with Python the way you want or > however you can get it to work, then in this new C# function, coerce the > types passed in to be an array of unsigned shorts, and pass that to the > original function. > > Best of luck, and let us know if you find anything interesting. > > Thomas > > > On Sat, Feb 21, 2015 at 10:10 PM, Mark Erbaugh wrote: > >> Greetings, >> >> I am struggling with a hobby project using PythonDotNet. I have an API >> for an external device written in C# and .NET. I have the C# code. Rather >> than using IronPython, I am trying to use PythonDotNet with CPython 2.7.9. >> The C# code was not written with any special consideration of Python. >> >> The API implements callback functions. I have been able to write several >> of the callback functions in Python and they work. But, now I've come >> across something that I can't figure out, and perhaps it's not supported by >> PythonDotNet. There is a callback routine that passes a C# array of >> shorts. the C# function signature is >> >> public delegate void DataReadyEventHandler(Panadapter pan, >> ushort[] data); >> >> No matter how I try to code my Python function, I am getting a runtime >> exception from the PythonRuntime part of PythonDotNet. >> >> Is passing this array possible? >> >> Thanks, >> Mark >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brywilharris at gmail.com Mon Feb 23 23:05:52 2015 From: brywilharris at gmail.com (Bryan Harris) Date: Mon, 23 Feb 2015 17:05:52 -0500 Subject: [CentralOH] Job opportunity at Cincinnati Children's Hospital Message-ID: Hey all, I had a head hunter contact me looking for a programmer for a job with Cincinnati Children's. Is it appropriate to post job openings to this list? Bryan On Feb 23, 2015 2:46 PM, "Thomas Winningham" wrote: > So I re-read your email, and my reply, and noticed I missed a subtlety, > you're trying to get a Python.NET callback to work with a .NET function. > This may not work unless the Python.NET allows you to override or somehow > annotate a function's accepted types. The "method signature" in Java > parlance means that whatever you write in Python is not going to appear > like a valid callback method, as the parameters may be of a different type > than what the callback allows. There *ought* to be a way to make a Python > function that appears to the .NET CLR as having this method signature, but > I'm not sure. > > I guess the same advice applies, but if what I described above doesn't > exist, you may be in the C# world more if you can't find a way to > explicitly define the Python function's parameter types. Essentially, write > C# that can call your Python function, but that C# has to require > parameters with the types aligned with the original callback. > > On Sun, Feb 22, 2015 at 7:56 PM, Thomas Winningham > wrote: > >> I had been thinking about this, and while I haven't messed with Python on >> .NET, I have messed with C# some, as well as other Python on top of another >> language type arrangements. >> >> There must be either one of two things you can do, but the details of >> which you may be on your own to investigate (sorry): >> >> 1. The Python.NET, being dynamically typed, must have some sort of >> functions to support the static (and more specific) types of the .NET >> system. This may be something that allows you to specifically create a C# >> compatible array of unsigned shorts like that second parameter of the >> function requires. I would imagine a study of the documentation for >> Python.NET may well reveal some kind of capability like this as a language >> support library or something similar. I know with say, Jython, it is called >> Java Interop, same with Clojure on the JVM. >> >> 2. You could approach this the other way, and write some C# to wrap this >> function in a function that does work with Python the way you want or >> however you can get it to work, then in this new C# function, coerce the >> types passed in to be an array of unsigned shorts, and pass that to the >> original function. >> >> Best of luck, and let us know if you find anything interesting. >> >> Thomas >> >> >> On Sat, Feb 21, 2015 at 10:10 PM, Mark Erbaugh wrote: >> >>> Greetings, >>> >>> I am struggling with a hobby project using PythonDotNet. I have an API >>> for an external device written in C# and .NET. I have the C# code. Rather >>> than using IronPython, I am trying to use PythonDotNet with CPython 2.7.9. >>> The C# code was not written with any special consideration of Python. >>> >>> The API implements callback functions. I have been able to write several >>> of the callback functions in Python and they work. But, now I've come >>> across something that I can't figure out, and perhaps it's not supported by >>> PythonDotNet. There is a callback routine that passes a C# array of >>> shorts. the C# function signature is >>> >>> public delegate void DataReadyEventHandler(Panadapter pan, >>> ushort[] data); >>> >>> No matter how I try to code my Python function, I am getting a runtime >>> exception from the PythonRuntime part of PythonDotNet. >>> >>> Is passing this array possible? >>> >>> Thanks, >>> Mark >>> _______________________________________________ >>> CentralOH mailing list >>> CentralOH at python.org >>> https://mail.python.org/mailman/listinfo/centraloh >>> >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at joeshaw.org Tue Feb 24 15:23:30 2015 From: joe at joeshaw.org (Joe Shaw) Date: Tue, 24 Feb 2015 09:23:30 -0500 Subject: [CentralOH] February Monthly Meeting -- Go for Pythonistas In-Reply-To: References: Message-ID: Hi, Thanks again for allowing me to talk last night about Go. My slides are online here: https://go-talks.appspot.com/github.com/joeshaw/talks/cohpy/zen.slide#1 and the source is available here: https://github.com/joeshaw/talks Let me know if you have any questions. Joe On Mon, Feb 16, 2015 at 1:43 PM, Eric Floehr wrote: > Next Monday, February 23, starting at 6pm, we will be having our monthly > meeting. > > Please RSVP Here: > http://www.meetup.com/Central-Ohio-Python-Users-Group/events/220561065/ > > We will be meeting at Pillar, as usual. Pillar will provide food and drink > (thanks Pillar!). > > Informal meeting starts at 6pm, with the talk starting at 6:30pm. We will > finish no later than 8:30pm to adjourn to the informal meeting. > > Go has sometimes been called the child of C and Python, with built-in > async. This month, Joe Shaw will introduce the Go programming language from > the perspective of a Python programmer. In particular he'll look at PEP-20, > the Zen of Python, and how its principles apply to Go. He'll demonstrate > some of the ways he feels Go embodies the Zen, in some ways better and > other ways not as well. > > Jim Prior will also show a few things from his Python grab bag. > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Tue Feb 24 15:29:43 2015 From: eric at intellovations.com (Eric Floehr) Date: Tue, 24 Feb 2015 09:29:43 -0500 Subject: [CentralOH] February Monthly Meeting -- Go for Pythonistas In-Reply-To: References: Message-ID: Thanks for your talk last night, Joe! I learned a lot about Go and also made me think about Python in a different way. Cheers, Eric On Tue, Feb 24, 2015 at 9:23 AM, Joe Shaw wrote: > Hi, > > Thanks again for allowing me to talk last night about Go. My slides are > online here: > > https://go-talks.appspot.com/github.com/joeshaw/talks/cohpy/zen.slide#1 > > and the source is available here: > > https://github.com/joeshaw/talks > > Let me know if you have any questions. > > Joe > > On Mon, Feb 16, 2015 at 1:43 PM, Eric Floehr > wrote: > >> Next Monday, February 23, starting at 6pm, we will be having our monthly >> meeting. >> >> Please RSVP Here: >> http://www.meetup.com/Central-Ohio-Python-Users-Group/events/220561065/ >> >> We will be meeting at Pillar, as usual. Pillar will provide food and >> drink (thanks Pillar!). >> >> Informal meeting starts at 6pm, with the talk starting at 6:30pm. We will >> finish no later than 8:30pm to adjourn to the informal meeting. >> >> Go has sometimes been called the child of C and Python, with built-in >> async. This month, Joe Shaw will introduce the Go programming language from >> the perspective of a Python programmer. In particular he'll look at PEP-20, >> the Zen of Python, and how its principles apply to Go. He'll demonstrate >> some of the ways he feels Go embodies the Zen, in some ways better and >> other ways not as well. >> >> Jim Prior will also show a few things from his Python grab bag. >> >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> >> > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Tue Feb 24 16:34:28 2015 From: eric at intellovations.com (Eric Floehr) Date: Tue, 24 Feb 2015 10:34:28 -0500 Subject: [CentralOH] Goroutines in Python Message-ID: All, Go is a pretty cool language, and Joe did a great job introducing it last night. By all means, play with it, try it, etc. It may work better than Python for your needs. One of the things that intrigued me the most was goroutines. I've been playing with Python 3 on and off, and one of the biggest new features of Python 3.4 is the introduction of asynchronous IO and light-weight coroutines (goroutines are mostly like coroutines). If you want to play around with Python's version of these Go topics, there are a number of great resources, including Brian Costlow's async talk at the last PyOhio (links in the gist below). I dug around for some examples of fetching URLs using the new asyncio, as I currently use heavy-weight threads to pull about 17,000 unique URLs every day, and am looking to improve that (there are plans for 10x the number of URLs). So Joe's URL fetching example was of particular interest. So I took a quick stab at recreating it. I cheated a little by using a third-party library that has native support for asyncio (aiohttp), but with a little more work, requests can be adapted for asyncio. If you don't have a binary aiohttp library available for your system, it requires gcc and python-dev (source) to build. I also added optional throttling via a semaphore. You can set how many HTTP requests you want to issue at any one time. You'll have to uncomment some code for that... as it runs, it fires them all off at once. Anyway, here is the gist with the Go version and the Python version, along with links to some good docs and videos on ayncio in Python. https://gist.github.com/efloehr/d3626762835aa2de83b8 Cheers, Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Tue Feb 24 18:53:59 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 24 Feb 2015 12:53:59 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-23_=E6=9C=83=E8=AD=B0_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz86IE1yLiBSb29uZXksIEFwcmlsIEZvb2wsIERhdGFi?= =?utf-8?q?ase_Migration=3A_SQLAlchemy/Alembic_versus_Django_ORM=2C_go=2C_?= =?utf-8?q?memoization=2C_closure=2C_dict=2Eget=28=29=2C_dict=2Esetdefault?= =?utf-8?q?=28=29=2C_well_tempered_Lars_on_Mars=2C_C++_in_iPython_notebook?= Message-ID: <20150224125359.070a46d3.jep200404@columbus.rr.com> Thanks again to Pillar with Raymond Chandler for hosting us. Pillar is a very generous host again. The Thai pizza was very good. We look forward to seeing posted: technique for doing C++ in Ipython notebook Joe Shaw's slides Jim Reed's slides video of K Lars Lohn's PyTn presentation https://www.pytennessee.org/schedule/presentation/66/ wp: prefix means Wikipedia To get good answers, consider following the advice in the links below. http://catb.org/~esr/faqs/smart-questions.html http://web.archive.org/web/20090627155454/www.greenend.org.uk/rjk/2000/06/14/quoting.html What is the name of the album released in the 1970s that had well tempered stuff done on a synthesizer? Was it done by somebody other than Glenn Gould? were in Pillar's "Launchpad" (west) native resolution of the right projector seems to be 1920x1080 in spite of label on wall that says "MAX RES 1680X1050". The label on the HDMI 2 button is inverted top for bottom. Need to take key cap off, and flip the label over. On the control panel, hit the left or right button to select which projector one wants to select an input for, then hit input button for which input one want to connect to the selected projector. We had much less difficulty with these projectors than in the Forge. wifi worked fine automatically whacking video modes messed up xfce Lars' presentation at PyTN somebody showed a video of it on their phone jim prior reviewed memoization argument packing and unpacking memoization is a technique used to make a function faster by remembering and returning previously calculated results, so that which remembers calculated return values of a functioninvolved a function that wp:Closure (computer programming) Closures are a wierd thing which can make your head wobble the first time one encounters them. Watching Brandon Rhodes' video "Names, Objects, and Plummeting From The Cliff" will help one understand persistance with closures. http://pyvideo.org/video/542/ Links for the Ipython notebook used in the presentation are in the scribbles previously posted to the list and archived at the following URL. https://mail.python.org/pipermail/centraloh/2015-January/002312.html Should have spent less time on .items() and argument unpacking. After the presentation, someone suggested using the .get() method of dictionaries, to avoid the 'if x not in results:' test. Unfortunately, the .get() method does not change the dictionary, so we would have to explicitly save the result, so helper would be defined as: def helper(x): results[x] = results.get(x, f(x)) return results[x] That 'results[x] = ' is a bit ugly. Of course, someone really meant to suggest the .setdefault() method, which yields elegant code: def helper(x): return results.setdefault(x, f(x)) Unfortunately, a problem with both of them is that f(x) is _always_ called, defeating the purpose of memoization. The new notebook showing how bad the .get() and .setdefault() methods were will be at colug.net/python/cohpy/20150223/ need to put on my github account Eric wants to put that content on a cohpy account at github. joe shaw Gave presentation on Go language, comparing its virtues with those of The Zen of Python PEP #20 https://www.python.org/dev/peps/pep-0020/ Using the Zen of Python was a good template for the presentation. Functions can return arbitrary number of values, similar to python. We look forward to Joe posting his slides. jim reed Mars lander COD3: C under very strict rules 2.5M lines of code for Mars thing had very low defect rate, 5 total defects or was it 5 defects per million lines? The C code was tested with 25 k lines of Python code? Python has unusually low defect rate in python itself. http://www.coverity.com/press-releases/coverity-finds-python-sets-new-level-of-quality-for-open-source-software/ We look forward to Jim posting his slides also. question: migration ability: sqlalchemy versus django ORM Alembic is the thing for migration for SQLAlchemy, but don't know enough to compare with Django ORM's migration support. (People know one or the other but not both.) April Fool's paraphased and misinterpreted Three high school students, Aaron, Bob, and Chuck who were into theatre decided to put on an April Fool's day prank in the lunch room near the area where they usually ate with their friends. Aaron and Bob made a list of plausible things that would provoke each other and practiced an escalating confrontation that would lead to a fight between them. Chuck's role was to keep everyone else (who did not know the confrontation was all fake) away from Aaron and Bob so the confrontation could go on. On April 1st, the mock confrontation was staged. At one point Bob slammed Aaron against a door which made a big sound down the hall. Then the vice-principle comes in to see Aaron slumped down with Bob standing nearby. Chuck volunteers "Bob hit Aaron". The veep chastises Bob, noting that they have talked about this before, telling Aaron and Bob to come with him. On the way to his office, he stops at the intersection of two halls. The veep and Bob have an escalating conversation. Several times Bob tries to tell the veep that the veep does not understand the situation, but the veep keeps cutting him off until the veep says to Bob "No, _you_ don't understand the situation. April Fool's.". Aaron and Chuck had talked to the veep beforehand. The veep was in on it but not Bob. Bob is stunned at the turn of events, curses all those involved and walked away very peeved. Bob stayed peeved for a long time. What could Mr. Rooney have learned from that? From james at atlantixeng.com Tue Feb 24 19:00:29 2015 From: james at atlantixeng.com (James Bonanno) Date: Tue, 24 Feb 2015 13:00:29 -0500 Subject: [CentralOH] Additional Go Language Influences In-Reply-To: References: Message-ID: <54ECBC3D.1020904@atlantixeng.com> Looking over the Go programming language, it seems to me to have similar syntax to Ada and VHDL languages, and the general paradigms of concurrency are emulated in memory versus truly parallel processes. What I like about it is the light overhead of the concurrency. This is the first software language that I've seen come close to this type of methodology. I know the presenter mentioned Pascal as an influence, but I would also mention these other languages. Will Python develop a lightweight concurrency model? --James From joe at joeshaw.org Tue Feb 24 19:53:36 2015 From: joe at joeshaw.org (Joe Shaw) Date: Tue, 24 Feb 2015 13:53:36 -0500 Subject: [CentralOH] Additional Go Language Influences In-Reply-To: <54ECBC3D.1020904@atlantixeng.com> References: <54ECBC3D.1020904@atlantixeng.com> Message-ID: Hi, On Tue, Feb 24, 2015 at 1:00 PM, James Bonanno wrote: > Looking over the Go programming language, it seems to me to have similar > syntax to Ada and VHDL languages, and the general paradigms of concurrency > are emulated in memory versus truly parallel processes. What I like about > it is the light overhead of the concurrency. This is the first software > language that I've seen come close to this type of methodology. I know the > presenter mentioned Pascal as an influence, but I would also mention these > other languages. Thanks for the info. I am not too familiar with Ada or VHDL. The basis of Go's concurrency is a series of papers on Communicating Sequential Processes (CSP) from 1978. http://en.wikipedia.org/wiki/Communicating_sequential_processes This is also where Erlang gets its concurrency model from. As you mention, though, there is a pretty big difference in that Go's are all within a single process. There are both advantages and disadvantages to this, and the lightness of creating goroutines is one of them. Other than C, the most direct ancestor of Go (and its source of concurrency syntax) comes from a small language called Newsqueak ( http://en.wikipedia.org/wiki/Newsqueak) that was also created by Rob Pike. Its influence comes largely from CSP and Smalltalk. > Will Python develop a lightweight concurrency model? Python has some external projects which have introduced the idea of "green threads", such as greenlet and gevent. However, I think Go's greatest strength is that the concurrency is baked in at a very fundamental level in the language and runtime. Gevent for instance does some pretty scary monkeypatching of various low-level functions in places like the socket and os modules to achieve concurrency. I think to get the kind of concurrency Go enjoys would require a Python 4-like re-breaking of the language syntax, which I think would be a tough sell. Maybe it could be done incrementally, I'm not sure. One of the things I like best about Go is that goroutines allow you to write code in a very linear, sequential, non-concurrent fashion and add asynchronicity later. If you look at my first example from the talk, the concurrent URL fetcher: https://github.com/joeshaw/talks/blob/master/cohpy/fetch.go notice that the fetch() function does not involve concurrency at all. It is how we use and compose that function later inside main() that makes the concurrency work. It's a best practice in Go that APIs you write should not expose goroutines or channels but instead act synchronously. The consumers of your API should have the freedom to make them asynchronous by running them in a goroutine. While I think the asyncio stuff in Python is really great and a big improvement over things like gevent (or even Twisted), like C#'s async/await syntax it "infects" your code by making it necessary to yield within (or in C#, mark async) any code that needs to run asynchronously. It can become a fairly large burden to convert code from being synchronous to asynchronous because it often affects large portions of your call stack. Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From herrold at owlriver.com Tue Feb 24 20:10:52 2015 From: herrold at owlriver.com (R P Herrold) Date: Tue, 24 Feb 2015 14:10:52 -0500 (EST) Subject: [CentralOH] =?iso-2022-jp?b?MjAxNS0wMi0yMyAbJEJQcjVEGyhCIFNjcmli?= =?iso-2022-jp?b?Ymxlcw==?= In-Reply-To: <20150224125359.070a46d3.jep200404@columbus.rr.com> References: <20150224125359.070a46d3.jep200404@columbus.rr.com> Message-ID: On Tue, 24 Feb 2015, jep200404 at columbus.rr.com wrote: > Python has unusually low defect rate in python itself. > http://www.coverity.com/press-releases/coverity-finds-python-sets-new-level-of-quality-for-open-source-software/ it is a curious press release that lacks a date on it, but this one does -- Russ herrold From jep200404 at columbus.rr.com Tue Feb 24 20:46:45 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 24 Feb 2015 14:46:45 -0500 Subject: [CentralOH] Dates for Coverity Python Defect Rate Report In-Reply-To: References: <20150224125359.070a46d3.jep200404@columbus.rr.com> Message-ID: <20150224144645.257d50ac.jep200404@columbus.rr.com> On Tue, 24 Feb 2015 14:10:52 -0500 (EST), R P Herrold wrote: > On Tue, 24 Feb 2015, jep200404 at columbus.rr.com wrote: > > > Python has unusually low defect rate in python itself. > > http://www.coverity.com/press-releases/coverity-finds-python-sets-new-level-of-quality-for-open-source-software/ > > it is a curious press release that lacks a date on it, but > this one does Try 2013-08-29 for the following (likely posted on 2013-09-02). Was the scanning done in 2012? http://www.itrpress.com/cp/2013/2013-09-02_300813-Python-Scan-Spotlight-PR.pdf Other links: http://wpcme.coverity.com/wp-content/uploads/2013-Coverity-Scan-Spotlight-Python.pdf https://scan.coverity.com/news I wonder what the defect rate for systemd is. Andrew Tridgell was not at the meeting. wp:Samba_(software) wp:Andrew_Tridgell From eric at intellovations.com Tue Feb 24 21:05:36 2015 From: eric at intellovations.com (Eric Floehr) Date: Tue, 24 Feb 2015 15:05:36 -0500 Subject: [CentralOH] Additional Go Language Influences In-Reply-To: References: <54ECBC3D.1020904@atlantixeng.com> Message-ID: > Will Python develop a lightweight concurrency model? > > > Python has some external projects which have introduced the idea of "green > threads", such as greenlet and gevent. However, I think Go's greatest > strength is that the concurrency is baked in at a very fundamental level in > the language and runtime. Gevent for instance does some pretty scary > monkeypatching of various low-level functions in places like the socket and > os modules to achieve concurrency. > I agree that baking in concurrency at a fundamental level is Go's greatest strength. I would argue however, that Python has baked in almost to the same level concurrency, and that you rarely if ever need to use third-party green thread implementations any more. The main concepts are that generators are semi-coroutines, coroutines allow for concurrency, and cocurrency is not multi-threading. Both Python and Go by default implement concurrency on a single thread/virtual processor. Go's advantages are that it is slightly easier to grok goroutines because of less syntactic sugar needed (like the event loop is implicit not explicit), and that you can more easily introduce additional (virtual) processors (via runtime.GOMAXPROCS) whereas in Python it's a little more difficult to introduce multi-threaded concurrency. Also, Go's asynchronous I/O is built-in to the standard I/O libraries in Go (that's changing in Python though). > I think to get the kind of concurrency Go enjoys would require a Python > 4-like re-breaking of the language syntax, which I think would be a tough > sell. Maybe it could be done incrementally, I'm not sure. > I don't agree with this at all. To get everything that Go has, the way it has it, maybe. But if you want to write Go, write Go. But to enjoy concurrency as Go enjoys it (but perhaps implemented differently), it's already there in Python. One of the things I like best about Go is that goroutines allow you to > write code in a very linear, sequential, non-concurrent fashion and add > asynchronicity later. If you look at my first example from the talk, the > concurrent URL fetcher: > > https://github.com/joeshaw/talks/blob/master/cohpy/fetch.go > > notice that the fetch() function does not involve concurrency at all. > Right, but the reason that works is because Go provides non-blocking HTTP and File operations by default. In Python 3 we get non-blocking file I/O, and via third-party libs we can get non-blocking HTTP (aiohttp) and hopefully that will be added in soon as more people convert to the non-blocking sockets in Python 3. So the only advantage with Go is that it isn't hindered by some blocking legacy code, which is true of any shiny new language. It is how we use and compose that function later inside main() that makes > the concurrency work. It's a best practice in Go that APIs you write > should not expose goroutines or channels but instead act synchronously. > The consumers of your API should have the freedom to make them asynchronous > by running them in a goroutine. > So how is Go's: for i := range sites { site := sites[i] go func() { resultCh <- fetch(site) }() } for res := range resultCh { fmt.Println(res) } that different from Python 3's (assuming fetch used non-blocking http and file i/o, as Go): def func(site): result = yield from fetch(site) print result funcs = [func(u) for u in sites] asyncio.get_event_loop().run_until_complete(funcs) Sure you don't have channels in this example, but we don't really need them. And Go's event loop is implicit. I don't claim to be an expert in Python 3's asyncio so there may be even better ways to do this, but I don't really see any huge Go advantage or difference here. While I think the asyncio stuff in Python is really great and a big > improvement over things like gevent (or even Twisted), like C#'s > async/await syntax it "infects" your code by making it necessary to yield > within (or in C#, mark async) any code that needs to run asynchronously. > It can become a fairly large burden to convert code from being synchronous > to asynchronous because it often affects large portions of your call stack. > Coroutines have been first-class Python since 2.5, so sure, it's not baked in from the beginning. So a Go programmer is more likely to use async and goroutines from the beginning. But I don't understand how making non-concurrent code in Go concurrent any less "infectious" than making non-concurrent code in Python concurrent? As noted from my example above, it's no more "burdensome" to make non-concurrent "fetch()" in either Go or Python concurrent. Anyway, I do enjoy what Go offers, and have been very interested in the language. It does offer some cleaner syntax and built-in stuff, as well as bringing less baggage :-) that make it appealing. Cheers, Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at joeshaw.org Tue Feb 24 22:27:04 2015 From: joe at joeshaw.org (Joe Shaw) Date: Tue, 24 Feb 2015 16:27:04 -0500 Subject: [CentralOH] Additional Go Language Influences In-Reply-To: References: <54ECBC3D.1020904@atlantixeng.com> Message-ID: Hi Eric, On Tue, Feb 24, 2015 at 3:05 PM, Eric Floehr wrote: > > I think to get the kind of concurrency Go enjoys would require a Python >> 4-like re-breaking of the language syntax, which I think would be a tough >> sell. Maybe it could be done incrementally, I'm not sure. >> > > I don't agree with this at all. To get everything that Go has, the way it > has it, maybe. But if you want to write Go, write Go. But to enjoy > concurrency as Go enjoys it (but perhaps implemented differently), it's > already there in Python. > That's a good point, well said. > One of the things I like best about Go is that goroutines allow you to >> write code in a very linear, sequential, non-concurrent fashion and add >> asynchronicity later. If you look at my first example from the talk, the >> concurrent URL fetcher: >> >> https://github.com/joeshaw/talks/blob/master/cohpy/fetch.go >> >> > notice that the fetch() function does not involve concurrency at all. >> > > Right, but the reason that works is because Go provides non-blocking HTTP > and File operations by default. > The main difference is that the Go runtime handles this, rather than pushing it onto the programmer. The code you write in Go appears synchronous and the runtime handles yielding to other goroutines, whereas in Python you have to explicitly yield. (I wonder if this is something the Python runtime could handle. I have some vague notion that another Python implementation like PyPy or stackless Python might in fact do this.) So how is Go's: > > for i := range sites { > site := sites[i] > go func() { > resultCh <- fetch(site) > }() > } > > for res := range resultCh { > fmt.Println(res) > } > > > that different from Python 3's (assuming fetch used non-blocking http and > file i/o, as Go): > > def func(site): > result = yield from fetch(site) > print result > > funcs = [func(u) for u in sites] > asyncio.get_event_loop().run_until_complete(funcs) > > Sure you don't have channels in this example, but we don't really need > them. And Go's event loop is implicit. I don't claim to be an expert in > Python 3's asyncio so there may be even better ways to do this, but I don't > really see any huge Go advantage or difference here. > This part is basically the same, but inside the fetch() function the Go looks like it is a linear, blocking function while the Python one still has an explicit yield in it (res = yield from aiohttp.get(site)) which transforms it from returning a simple value to returning a generator. You're right about the channel... it's not really necessary in the Go version either. A better example might be this one from my code camp talk: https://github.com/joeshaw/talks/blob/master/codecamp/concurrency2.go There I'm using channels more to build a pipeline: three independent, concurrently running "machines": one that reads lines from /usr/share/dict/words, one that gathers definitions from the OS X directory services with 10 concurrent workers, and one that prints out the definitions. While I think the asyncio stuff in Python is really great and a big >> improvement over things like gevent (or even Twisted), like C#'s >> async/await syntax it "infects" your code by making it necessary to yield >> within (or in C#, mark async) any code that needs to run asynchronously. >> It can become a fairly large burden to convert code from being synchronous >> to asynchronous because it often affects large portions of your call stack. >> > > Coroutines have been first-class Python since 2.5, so sure, it's not baked > in from the beginning. So a Go programmer is more likely to use async and > goroutines from the beginning. > > But I don't understand how making non-concurrent code in Go concurrent any > less "infectious" than making non-concurrent code in Python concurrent? > "Infectious" was perhaps a bad word choice because of its negative connotation. But what I meant by that was that to turn blocking Python code into asyncio-friendly code you must yield a generator and either (a) find a drop-in replacement like aiohttp more or less is for requests or (b) use threading to bridge the blocking library with asyncio. With the generator you need to explicitly unwrap it with something like `run_until_complete` (and so it looks a lot like a Promise to me). C# 5 is similar in that functions have to be explicitly tagged `async` and then `await` when in Python you would `yield`. Quickly you can get into a situation where functions are nested and cascading yields. This was a common thing on a project I worked on in Javascript (on Mozilla's spidermonkey, which had co-routines) where we had implemented promises. It's definitely an improvement on "callback hell" common in Node.js code but I think is still trickier than the straightforwardness of Go's flow. As mentioned earlier, the implicit event loop and yielding to the runtime in Go make it unnecessary. > Anyway, I do enjoy what Go offers, and have been very interested in the > language. It does offer some cleaner syntax and built-in stuff, as well as > bringing less baggage :-) that make it appealing. > Yeah, and I am not hating on Python, by the way. I love it and still use it. I remember the bad old days of pre-coroutine Twisted deferreds and asyncio is a breath of fresh air. The closer Python can get to Go's strengths in concurrency are positive for everyone... especially if you strongly prefer Python to Go otherwise. :) Happy feelings all around. I won't drag out the thread any longer, but there was a great blog post about asyncio recently: http://www.onebigfluke.com/2015/02/asyncio-is-for-composition.html and a follow-up: http://www.onebigfluke.com/2015/02/ghost-of-threading-past.html Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Wed Feb 25 01:41:55 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 24 Feb 2015 19:41:55 -0500 Subject: [CentralOH] _ for variables that are never referenced In-Reply-To: <20150221114913.7bcefa76.jep200404@columbus.rr.com> References: <20150221114913.7bcefa76.jep200404@columbus.rr.com> Message-ID: <20150224194155.32577a53.jep200404@columbus.rr.com> On Sat, 21 Feb 2015 11:49:13 -0500, jep200404 at columbus.rr.com wrote: > for _ in range(n): # For when the loop variable is never referenced. Python examples >>> from random import randint >>> for _ in range(5): ... print randint(0, 10-1) ... 8 4 7 4 1 >>> [randint(0, 10-1) for _ in range(5)] [0, 9, 2, 2, 9] >>> Go Using _ for name of unused variables is standard practice in Go. The _ is called the blank identifier. Joe Shaw address this in his presentation. For example, see line 267 of https://github.com/joeshaw/talks/blob/master/cohpy/zen.slide for _, row := range table { ... From jep200404 at columbus.rr.com Wed Feb 25 01:46:13 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 24 Feb 2015 19:46:13 -0500 Subject: [CentralOH] =?utf-8?b?MjAxNS0wMi0yMyDmnIPorbAgU2NyaWJibGU6IE9T?= =?utf-8?q?U_Hackathon_Sponsor?= Message-ID: <20150224194613.4e68dd4a.jep200404@columbus.rr.com> Andrew Kubara said that OSU was looking for a sponsor for its Hackathon. From jep200404 at columbus.rr.com Wed Feb 25 01:54:33 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 24 Feb 2015 19:54:33 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-23_=E6=9C=83=E8=AD=B0_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz86IGdvLCB3ZWxsIHRlbXBlcmVkIExhcnMgb24gTWFy?= =?utf-8?q?s=2C_C++_in_iPython_notebook?= In-Reply-To: <20150224125359.070a46d3.jep200404@columbus.rr.com> References: <20150224125359.070a46d3.jep200404@columbus.rr.com> Message-ID: <20150224195433.650db0ca.jep200404@columbus.rr.com> On Tue, 24 Feb 2015 12:53:59 -0500, jep200404 at columbus.rr.com wrote: > We look forward to seeing posted: > Joe Shaw's slides He already posted them: https://github.com/joeshaw/talks/tree/master/cohpy Thanks Joe! > video of K Lars Lohn's PyTn presentation Perhaps http://www.youtube.com/watch?v=lAK6WdGZKA0 > technique for doing C++ in Ipython notebook > Jim Reed's slides (or URLs) still waiting From eric at intellovations.com Wed Feb 25 02:02:01 2015 From: eric at intellovations.com (Eric Floehr) Date: Tue, 24 Feb 2015 20:02:01 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-23_=E6=9C=83=E8=AD=B0_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz86IGdvLCB3ZWxsIHRlbXBlcmVkIExhcnMgb24g?= =?utf-8?q?Mars=2C_C++_in_iPython_notebook?= In-Reply-To: <20150224195433.650db0ca.jep200404@columbus.rr.com> References: <20150224125359.070a46d3.jep200404@columbus.rr.com> <20150224195433.650db0ca.jep200404@columbus.rr.com> Message-ID: > still waiting > He commented directly on the Meetup page: """ Thanks for all who stayed in for my continuing talk on using If's for decision making correctly for Python. Here's a link to my code: https://github.com/profjrr/COhPy2015.git And the link to the NASA/JPL coding standards as discussed: http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf Thanks again, Professor Reed... """ -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian.costlow at gmail.com Wed Feb 25 04:36:41 2015 From: brian.costlow at gmail.com (Brian Costlow) Date: Tue, 24 Feb 2015 22:36:41 -0500 Subject: [CentralOH] =?utf-8?q?2015-02-23_=E6=9C=83=E8=AD=B0_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz86IGdvLCB3ZWxsIHRlbXBlcmVkIExhcnMgb24g?= =?utf-8?q?Mars=2C_C++_in_iPython_notebook?= In-Reply-To: References: <20150224125359.070a46d3.jep200404@columbus.rr.com> <20150224195433.650db0ca.jep200404@columbus.rr.com> Message-ID: Some more bits of K Lahrs talk https://www.youtube.com/watch?v=GHyh-UKAPxQ https://www.youtube.com/watch?v=ja3RNHPpQEw In the second clip, be sure to watch the musical score for some extra "programmer" notation. On Tue, Feb 24, 2015 at 8:02 PM, Eric Floehr wrote: > > still waiting >> > > He commented directly on the Meetup page: > > """ > > Thanks for all who stayed in for my continuing talk on using If's for > decision making correctly for Python. > > Here's a link to my code: > https://github.com/profjrr/COhPy2015.git > > And the link to the NASA/JPL coding standards as > discussed: > http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf Thanks again, > Professor Reed... > > """ > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Wed Feb 25 16:29:05 2015 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Wed, 25 Feb 2015 10:29:05 -0500 Subject: [CentralOH] =?utf-8?b?MjAxNC0xMS0xNCDpgZPloLQgU2NyaWJibGVzOiBy?= =?utf-8?q?unning=5F*_--=3E_toolz=2Eaccumulate?= In-Reply-To: <20141117095541.747e03f8.jep200404@columbus.rr.com> References: <20141117095541.747e03f8.jep200404@columbus.rr.com> Message-ID: <20150225102905.08dd7a07.jep200404@columbus.rr.com> On Mon, 17 Nov 2014 09:55:41 -0500, jep200404 at columbus.rr.com wrote: > def running_op(iterable, op=operator.add, initial=0): > running_result = initial > for element in iterable: > running_result = op(running_result, element) > yield running_result > > def running_sum(iterable, initial=0): > sum_ = initial > for element in iterable: > sum_ += element > yield sum_ Compare those with toolz.accumulate(). import toolz from operator import add, mul print list(toolz.accumulate(add, [1, 2, 3, 4, 5])) print list(toolz.accumulate(mul, [1, 2, 3, 4, 5])) print reduce(add, [1, 2, 3, 4, 5]) print reduce(mul, [1, 2, 3, 4, 5]) http://colug.net/python/cohpy/20131029/