Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Michael Selik
On Tue, Aug 9, 2016 at 2:31 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > Hello, > > In online forums sometimes people complain that they end up having to test > constantly for None, or that a function's argument has a specific type / > shape (which immediately brings the followi

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Michael Selik
On Tue, Aug 9, 2016 at 2:59 PM Chris Angelico wrote: > On Wed, Aug 10, 2016 at 4:51 AM, Michael Selik > wrote: > > "File-like" is a good example. Rather than go through the frustration of > a > > formal definition for what is file-like, stay productive and

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Michael Selik
On Tue, Aug 9, 2016 at 3:22 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > I'm actually looking for ways to minimize run time errors, so that would > include TypeError and AttributeError. > > In your "File-like" example having type information would prevent me from > even passing

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Michael Selik
On Wed, Aug 10, 2016 at 1:22 AM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > 1) catching exceptions at the point where you care, 2) > preemptively check for certain runtime conditions to avoid exceptions 3) > write as many tests as possible 4) learn to live with runtime errors. >

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Tue, Aug 9, 2016 at 9:31 PM Steven D'Aprano wrote: > > http://steve-yegge.blogspot.com.au/2008/05/dynamic-languages-strike-back.html Great link. I enjoyed the video, too. https://www.youtube.com/watch?v=tz-Bb-D6teE Buried deep in the QA section, there's a comment from the audience (I'll par

Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016 at 1:41 PM Cai Gengyang wrote: > I managed to get this piece of code to work : > > >>> print("This program calculates mpg.") > This program calculates mpg. > >>> milesdriven = input("Enter miles driven:") > Enter miles driven: 50 > >>> milesdriven = float(milesdriven) > >>> g

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016, 4:34 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > > I've been trying to find (without success so far) an example of a situation > where the dynamic features of a language like Python provides a clear > advantage over languages with more than one type. > On

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Michael Selik
On Wed, Aug 10, 2016, 6:44 PM Juan Pablo Romero Méndez < jpablo.rom...@gmail.com> wrote: > As to why I asked that, there are several reasons: I have a very concrete > need right now to find pragmatic ways to increase code quality, reduce > number of defects, etc. in a Python code base. But also I

Re: Advice on optimizing a Python data driven rules engine

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 10:57 AM Malcolm Greene wrote: > Background: I'm building a rules engine for transforming rows of data > being returned by csv DictReader, eg. each row of data is a dict of column > name to value mappings. My rules are a list of rule objects whose > attributes get referen

Re: Asynchronous programming

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano wrote: > That ... looks wrong. You're taking something which looks like a procedure > in the first case (trn.execute), so it probably returns None, and yielding > over it. Even it that's not wrong, and it actually returned something which > you ign

Re: Asynchronous programming

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 11:46 AM Michael Selik wrote: > On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano < > steve+pyt...@pearwood.info> wrote: > >> That ... looks wrong. You're taking something which looks like a procedure >> in the first case (trn.execu

Re: Print function not working

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 1:38 PM MRAB wrote: > On 2016-08-11 18:18, Chris Angelico wrote: > > On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra > > wrote: > >> I have installed IDLE 3.5.1 and wrote the following to check if print > is working. When it runs, I do not see anything is printed: > >> >

Re: What's the best way to minimize the need of run time checks?

2016-08-12 Thread Michael Selik
On Fri, Aug 12, 2016, 7:11 AM Steven D'Aprano wrote: > > [1] Are there programming language aware spell checkers? If not, there > should be. > A good autocomplete is much like a spell-checker. I have far fewer spelling errors when using an editor with autocomplete. > -- https://mail.python.org

Re: Creating dictionary of items from Excel with mutliple keys

2016-08-13 Thread Michael Selik
On Sat, Aug 13, 2016 at 12:46 PM Atri Mahapatra wrote: > I am trying to create a following dictionary. I am reading data from excel > Rather than using xlrd or other tools to read from excel, can you save the file as CSV (comma-separated values)? I think you'll find Python's csv module is very p

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread Michael Selik
On Sun, Aug 14, 2016 at 2:21 PM Atri Mahapatra wrote: > I have a list of dictionaries which look like this: > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, > 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] > > I would like to find the first index in the list of d

Re: Finding the first index in a list greater than a particular value

2016-08-15 Thread Michael Selik
On Mon, Aug 15, 2016 at 2:01 AM Jussi Piitulainen < jussi.piitulai...@helsinki.fi> wrote: > There is a tradition of returning -1 when no valid index is found. > Sometimes it's better to break with tradition. Raise a ValueError. No silent errors, and all that Zen. -- https://mail.python.org/mailm

Re: What's the best way to minimize the need of run time checks?

2016-08-17 Thread Michael Selik
On Sun, Aug 14, 2016 at 11:01 AM wrote: > On Sunday, August 14, 2016 at 7:09:47 AM UTC+1, Paul Rubin wrote: > > Steven D'Aprano writes: > > > If the Python community rallies around this "record" functionality and > > > takes to it like they took too namedtuple > > > > I like namedtuple and I thin

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Fri, Aug 19, 2016 at 5:01 AM Lawrence D’Oliveiro wrote: > It is handy to be able to keep complex expressions together sometimes, > when breaking them up would simply obscure their structure. To avoid lines > getting long, why not take advantage of the two available screen/page > dimensions to

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro wrote: > > p0 = (0, 0) > > p1 = (major_dim, 0) > > colour_stops = (0, rect_1_colour), (1, complement(rect_1_colour)) > > rect_1_pattern = qah.Pattern.create_linear(p0, p1, colour_stops) > > That’s an example of what I mean about

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Sat, Aug 20, 2016 at 8:43 PM Michael Selik wrote: > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro < > lawrenced...@gmail.com> wrote: > >> > p0 = (0, 0) >> > p1 = (major_dim, 0) >> > colour_stops = (0, rect_1_colour), (1, compleme

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Sun, Aug 21, 2016 at 12:31 AM Lawrence D’Oliveiro wrote: > On Sunday, August 21, 2016 at 12:44:21 PM UTC+12, Michael Selik wrote: > > > > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro wrote: > > > >>> if any(not isinstance(obj, I

Re: Two-Dimensional Expression Layout

2016-08-21 Thread Michael Selik
On Sun, Aug 21, 2016, 3:06 AM Lawrence D’Oliveiro wrote: > On Sunday, August 21, 2016 at 6:49:19 PM UTC+12, Michael Selik wrote: > > > Indeed it is, not sure why. > > Moral: It helps to understand the code you’re criticizing, before you > start criticizing, not after. >

Re: repeat items in a list

2016-03-30 Thread Michael Selik
I prefer itertools.chain.from_iterable to the sum trick. >>> from itertools import chain >>> lst = list('abc') >>> list(chain.from_iterable([s]*3 for s in lst)) ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'] On Tue, Mar 29, 2016 at 5:28 PM Vito De Tullio wrote: > Random832 wrote: > > > How do

Re: Suggestion: make sequence and map interfaces more similar

2016-04-01 Thread Michael Selik
> On Mar 31, 2016, at 10:02 AM, Marko Rauhamaa wrote: > > However, weirdly, dicts have get but lists don't. Read PEP 463 for discussion on this topic. https://www.python.org/dev/peps/pep-0463/ -- https://mail.python.org/mailman/listinfo/python-list

Re: The next major Python version will be Python 8

2016-04-01 Thread Michael Selik
It suddenly occurred to me that if Microsoft announced it's Ubuntu-in-Windows feature today, no one would believe it. On Thu, Mar 31, 2016 at 11:55 PM Steven D'Aprano wrote: > On Fri, 1 Apr 2016 11:13 am, Chris Angelico wrote: > > > Now's the time to get in with the ideas. My proposal is that Py

Re: Set type for datetime intervals

2016-04-01 Thread Michael Selik
On Fri, Apr 1, 2016 at 1:32 AM Nagy László Zsolt wrote: > Does anyone know a library that already implements these functions? > What do you not like about the ones on PyPI? https://pypi.python.org/pypi?%3Aaction=search&term=interval&submit=search Depending on the resolution you want, you might

Re: Set type for datetime intervals

2016-04-01 Thread Michael Selik
Whoops, I mixed up tasks. Here's what I meant: def interval(start, stop, precision=60): a, b = start.timestamp(), stop.timestamp() return set(range(a, b, precision)) On Fri, Apr 1, 2016 at 4:31 PM Michael Selik wrote: > On Fri, Apr 1, 2016 at 1:32 AM Nagy Lász

Re: Drowning in a teacup?

2016-04-01 Thread Michael Selik
Give this a shot def snap(keyword, words): matches = [i for i, s in enumerate(words) if s.startswith(keyword)] for i in matches: lst.insert(0, lst.pop(i)) Your current implementation is reassigning the local variable ``mylist`` to a new list inside the function. O

Re: [beginner] What's wrong?

2016-04-01 Thread Michael Selik
Humans have always had trouble with this, in many contexts. I remember being annoyed at folks saying the year 2000 was the first year of the new millennium, rather than 2001. They'd forgotten the Gregorian calendar starts from AD 1. On Fri, Apr 1, 2016, 6:58 PM Mark Lawrence via Python-list < pyth

Re: [beginner] What's wrong?

2016-04-01 Thread Michael Selik
On Sat, Apr 2, 2016, 12:28 AM Random832 wrote: > On Fri, Apr 1, 2016, at 19:29, Michael Selik wrote: > > Humans have always had trouble with this, in many contexts. I remember > > being annoyed at folks saying the year 2000 was the first year of the new > > millennium, rat

Re: Drowning in a teacup?

2016-04-01 Thread Michael Selik
On Sat, Apr 2, 2016, 1:46 AM Vito De Tullio wrote: > Fillmore wrote: > > > I need to scan a list of strings. If one of the elements matches the > > beginning of a search keyword, that element needs to snap to the front > > of the list. > > I know this post regards the function passing, but, on yo

Re: Drowning in a teacup?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016 at 6:32 AM Peter Otten <__pete...@web.de> wrote: > Vito De Tullio wrote: > > > Michael Selik wrote: > > > >>> > I need to scan a list of strings. If one of the elements matches the > >>> > beginning of a search keyword, th

Re: [beginner] What's wrong?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016 at 4:16 AM Chris Angelico wrote: > On Sat, Apr 2, 2016 at 3:27 PM, Random832 wrote: > > On Fri, Apr 1, 2016, at 19:29, Michael Selik wrote: > >> Humans have always had trouble with this, in many contexts. I remember > >> being annoyed at folks s

Re: [beginner] What's wrong?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016, 3:40 PM Marko Rauhamaa wrote: > Terry Reedy : > > > On 4/2/2016 12:44 PM, Marko Rauhamaa wrote: > > > >> Nowadays software companies and communities are international. > > > > Grade school classrooms, especially pre-high school, are not. > > Parenthetically, English teachers

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Michael Selik
I might be overlooking something, but raw_input (Python 2) and input (Python 3) won't return the input from sys.stdin until you type ENTER. Or did I misunderstand the question? On Sat, Apr 2, 2016 at 6:30 PM BartC wrote: > On 02/04/2016 23:16, Ned Batchelder wrote: > > On Saturday, April 2, 2016

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread Michael Selik
How do you know when you're done typing the name of the file? It's hard to get tone right on the internet, so I'll clarify: this is not a rhetorical question and I mean you, LoopIO, not a generic person. On Sun, Apr 3, 2016, 8:40 PM Loop.IO wrote: > On Sunday, April 3, 2016 at 8:32:06 PM UTC+1,

Re: Plot/Graph

2016-04-03 Thread Michael Selik
Indeed there is. Every example in the gallery shows the code to produce it. http://matplotlib.org/gallery.html On Sun, Apr 3, 2016, 8:05 PM Muhammad Ali wrote: > > Hi, > > Could anybody tell me that how can I plot graphs by matplotlib and get > expertise in a short time? I have to plot 2D plots

Re: Best Practices for Internal Package Structure

2016-04-04 Thread Michael Selik
On Mon, Apr 4, 2016 at 6:04 PM Sven R. Kunze wrote: > Hi Josh, > > good question. > > On 04.04.2016 18:47, Josh B. wrote: > > My package, available at https://github.com/jab/bidict, is currently > laid out like this: > > > > bidict/ > > ├── __init__.py > > ├── _bidict.py > > ├── _common.py > > ├─

Re: Best Practices for Internal Package Structure

2016-04-05 Thread Michael Selik
> On Apr 5, 2016, at 7:49 PM, Sven R. Kunze wrote: > >> On 05.04.2016 19:59, Chris Angelico wrote: >> On Wed, Apr 6, 2016 at 3:38 AM, Sven R. Kunze wrote: Your package is currently under 500 lines. As it stands now, you could easily flatten it to a single module: bidict.py

Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-05 Thread Michael Selik
It seems coding a generic interval and intervalset will bring a variety of difficult design choices. If I were you, I'd forget making it generic and build one specifically for the application you have in mind. That way you can ignore most of these feature discussions. > On Apr 5, 2016, at 2:59

Re: Import graphics error

2016-04-05 Thread Michael Selik
> On Apr 5, 2016, at 5:17 PM, Nicolae Morkov wrote: > > I copied the code from Python from everyone page 67. > Following the instructions The graphic modules by John Zelle I copied into > the python lacation ,to be easier to find the path . Please be more specific. What is the python

Re: python script for .dat file

2016-04-05 Thread Michael Selik
What code have you written so far? > On Apr 5, 2016, at 5:27 PM, Muhammad Ali wrote: > >> On Tuesday, April 5, 2016 at 9:07:54 AM UTC-7, Oscar Benjamin wrote: >>> On 5 April 2016 at 16:44, Muhammad Ali wrote: On Tuesday, April 5, 2016 at 8:30:27 AM UTC-7, Joel Goldstick wrote: On Tue,

Re: Best Practices for Internal Package Structure

2016-04-06 Thread Michael Selik
On Wed, Apr 6, 2016, 2:51 AM Steven D'Aprano wrote: > On Wed, 6 Apr 2016 05:56 am, Michael Selik wrote: > > [Sven R. Kunze] > >> If you work like in the 80's, maybe. Instead of scrolling, (un)setting > >> jumppoints, or use splitview of the same file, i

Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-06 Thread Michael Selik
On Tue, Apr 5, 2016, 10:46 PM Nagy László Zsolt wrote: > > >> How about creating two classes for this? One that supports zero sized > >> intervals, and another that doesn't? > > If you don't want zero sized intervals, just don't put any in it. You > > don't have a separate list type to support ev

Re: Promoting Python

2016-04-06 Thread Michael Selik
On Wed, Apr 6, 2016, 12:51 PM Marko Rauhamaa wrote: > BartC : > Really, there's only one high-level construct you can't live without: > the "while" statement. Virtually every Python program has at least one > "while" statement, and in general, it is unavoidable. > > Basic programs, on the other h

Re: Checking function's parameters (type, value) or not ?

2016-04-06 Thread Michael Selik
> On Apr 6, 2016, at 2:07 PM, ast wrote: > > I would like to know if it is advised or not to test > a function's parameters before running it, e.g > for functions stored on a public library ? > > def to_base(nber, base=16, use_af=True, sep=''): > assert isinstance(nber, int) and nber >= 0 >

Re: functools puzzle

2016-04-06 Thread Michael Selik
> On Apr 6, 2016, at 6:57 PM, George Trojan - NOAA Federal > wrote: > > The module functools has partial() defined as above, then overrides the > definition by importing partial from _functools. That would explain the > above behaviour. My question is why? A couple speculations why an author m

Re: functools puzzle

2016-04-06 Thread Michael Selik
On Wed, Apr 6, 2016 at 8:16 PM George Trojan - NOAA Federal < george.tro...@noaa.gov> wrote: > My basic question is how to document functions created by > functools.partial, such that the documentation can be viewed not only by > reading the code. Of course, as the last resort, I could create my o

Re: recursive methods require implementing a stack?

2016-04-07 Thread Michael Selik
On Thu, Apr 7, 2016, 7:51 AM Charles T. Smith wrote: > On Wed, 06 Apr 2016 20:28:47 +, Rob Gaddi wrote: > > > Charles T. Smith wrote: > > > >> I just tried to write a recursive method in python - am I right that > local > >> variables are only lexically local scoped, so sub-instances have the

Re: Enum questions.

2016-04-13 Thread Michael Selik
On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous >one > > 2) Given two Enum values, iterate over the values

Re: Looking for feedback on weighted voting algorithm

2016-04-14 Thread Michael Selik
On Thu, Apr 14, 2016, 7:37 PM justin walters wrote: > On Apr 14, 2016 9:41 AM, "Martin A. Brown" wrote: > > > > > > Greetings Justin, > > > > >score = sum_of_votes/num_of_votes > > > > >votes = [(72, 4), (96, 3), (48, 2), (53, 1), (26, 4), (31, 3), (68, 2), > (91, 1)] > > > > >Specifically,

Re: How to parameterize unittests

2016-04-15 Thread Michael Selik
On Fri, Apr 15, 2016, 11:16 AM Steven D'Aprano wrote: > On Fri, 15 Apr 2016 06:20 pm, Antoon Pardon wrote: > > >>> I see, that's going to be a lot of cut & pastes. > > (3) In your editor, run a global Find and Replace "avltree -> self.tree". > You will need to inspect each one rather than do it a

Re: Looking for feedback on weighted voting algorithm

2016-04-15 Thread Michael Selik
On Fri, Apr 15, 2016, 7:56 PM wrote: > On Thursday, April 14, 2016 at 1:48:40 PM UTC-7, Michael Selik wrote: > > I suggest not worrying about sanitizing inputs. If someone provides bad > > data, Python will do the right thing: stop the program and print an > > explanati

Re: Dynamic inputs

2016-04-16 Thread Michael Selik
On Sat, Apr 16, 2016, 9:41 AM durgadevi1 < srirajarajeswaridevikr...@gmail.com> wrote: > what does dynamic inputs mean and how is it implemented in python > programming? > In what context did you hear or read the phrase "dynamic inputs"? > -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido sees the light: PEP 8 updated

2016-04-16 Thread Michael Selik
On Sat, Apr 16, 2016, 10:56 AM Marko Rauhamaa wrote: > Chris Angelico : > > > On Sat, Apr 16, 2016 at 6:06 PM, Marko Rauhamaa > wrote: > >> It doesn't really matter one way or another. The true WTF is that it's > >> been changed. > > > > Why? Was PEP 8 inscribed on stone tablets carried down fro

Re: Dynamic inputs

2016-04-17 Thread Michael Selik
On Sun, Apr 17, 2016, 7:01 AM durgadevi1 < srirajarajeswaridevikr...@gmail.com> wrote: > On Saturday, April 16, 2016 at 5:31:39 PM UTC+8, Michael Selik wrote: > > On Sat, Apr 16, 2016, 9:41 AM durgadevi1 < > > srirajarajeswaridevikr...@gmail.com> wrote: > > > &

Re: How much sanity checking is required for function inputs?

2016-04-17 Thread Michael Selik
On Sun, Apr 17, 2016, 4:35 PM Christopher Reimer < christopher_rei...@icloud.com> wrote: > Greetings, > > I'm currently building a chess engine to learn the finer details of > Python. When I learned all flavors of Java in community college a decade > ago, we had to sanity check the hell out of the

Re: How much sanity checking is required for function inputs?

2016-04-19 Thread Michael Selik
On Mon, Apr 18, 2016 at 1:05 AM Christopher Reimer < christopher_rei...@icloud.com> wrote: > On 4/17/2016 3:18 PM, Michael Selik wrote: > > > I'd rather turn the question around: how much sanity checking is > > necessary or useful? You'll find the answer is &qu

Re: Python packages for hydrology and DEM

2016-04-19 Thread Michael Selik
On Tue, Apr 19, 2016 at 2:21 AM Xristos Xristoou wrote: > I want to ask for hydrology python packages with complete function to > calculate hydrology tasks like fill,flow direction,flow accumulator and > more?or how can i find genetic algorithms for to do this tasks to finaly > create a complete

Re: How much sanity checking is required for function inputs?

2016-04-19 Thread Michael Selik
On Tue, Apr 19, 2016 at 11:23 PM Christopher Reimer < christopher_rei...@icloud.com> wrote: > On 4/19/2016 1:02 AM, Michael Selik wrote: > > > Why relocate rather than remove? What message would you provide that's > > better than ``KeyError: 42`` with a trace

Re: Creating Dict of Dict of Lists with joblib and Multiprocessing

2016-04-20 Thread Michael Selik
On Wed, Apr 20, 2016 at 10:50 AM Sims, David (NIH/NCI) [C] < david.si...@nih.gov> wrote: > Hi, > > Cross posted at > http://stackoverflow.com/questions/36726024/creating-dict-of-dicts-with-joblib-and-multiprocessing, > but thought I'd try here too as no responses there so far. > > A bit new to pyt

Re: Detecting repeated subsequences of identical items

2016-04-20 Thread Michael Selik
On Wed, Apr 20, 2016 at 11:11 PM Steven D'Aprano wrote: > I want to group [repeated] subsequences. For example, I have: > "ABCABCABCDEABCDEFABCABCABCB" > and I want to group it into repeating subsequences. I can see two > ways... How can I do this? Does this problem have a standard name and/or >

Re: Detecting repeated subsequences of identical items

2016-04-20 Thread Michael Selik
On Thu, Apr 21, 2016 at 2:35 AM Michael Selik wrote: > On Wed, Apr 20, 2016 at 11:11 PM Steven D'Aprano > wrote: > >> I want to group [repeated] subsequences. For example, I have: >> "ABCABCABCDEABCDEFABCABCABCB" >> and I want to group it into rep

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Michael Selik
On Thu, Apr 21, 2016 at 2:55 AM Vlastimil Brom wrote: > 2016-04-21 5:07 GMT+02:00 Steven D'Aprano : > > I want to group subsequences. > > "ABCABCABCDEABCDEFABCABCABCB" > > ABC ABC ABCDE ABCDE F ABC ABC ABC B > > or: > > ABC ABC ABC D E A B C D E F ABC ABC ABC B > > if I am not missing something,

Re: How much sanity checking is required for function inputs?

2016-04-22 Thread Michael Selik
On Fri, Apr 22, 2016, 1:26 AM Stephen Hansen wrote: > On Thu, Apr 21, 2016, at 08:33 PM, Christopher Reimer wrote: > > On 4/21/2016 7:20 PM, Stephen Hansen wrote: > > > I... that... what... I'd forget that link and pretend you never went > > > there. Its not helpful. > > > > I found it on the Int

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Selik
On Sat, Apr 23, 2016 at 9:01 PM Christopher Reimer < christopher_rei...@icloud.com> wrote: > On 4/21/2016 9:46 PM, Ethan Furman wrote: > > Oh! and Enum!!! ;) > > OMG! I totally forgot about Enum. Oh, look. Python supports Enum. Now I > don't have to roll my own! > > Hmm... What do we use Enum for

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Selik
On Sat, Apr 23, 2016 at 9:31 PM Christopher Reimer < christopher_rei...@icloud.com> wrote: > On 4/21/2016 10:25 PM, Stephen Hansen wrote: > > > > Why not, 'color in ("black", "white")'? > > Checkers seems popular around here. What if I want to change "white" to > "red," as red and black is a commo

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Selik
On Sun, Apr 24, 2016, 1:51 AM Steven D'Aprano wrote: > On Sun, 24 Apr 2016 12:34 pm, Michael Torrie wrote: > > > There are many aspects to Pythonic programming, not just OOP. For > > example using modules to store shared state for your program components > > is very pythonic, rather than using c

Re: How much sanity checking is required for function inputs?

2016-04-24 Thread Michael Selik
On Sun, Apr 24, 2016 at 2:08 PM Steven D'Aprano wrote: > On Sun, 24 Apr 2016 04:40 pm, Michael Selik wrote: > > I think we're giving mixed messages because we're conflating > "constants" and globals that are expected to change. > > When you talk abo

Re: Query regarding python 2.7.11 release

2016-04-29 Thread Michael Selik
>From searching bugs.python.org, I see that issues referencing CVE-2014-7185, CVE-2013-1752, and CVE-2014-1912 have all been marked as closed. I don't see any issues referencing CVE-2014-4650 via Python's bug tracker, but did spot it on Red Hat's. It appears to be related to issue 21766 ( http://b

Re: Conditionals And Control Flows

2016-05-04 Thread Michael Selik
On Wed, May 4, 2016 at 10:46 AM Cai Gengyang wrote: > I am trying to understand the boolean operator "and" in Python. It is > supposed to return "True" when the expression on both sides of "and" are > true > Not exactly, because they will short-circuit. Take a look at the docs. ( https://docs.py

Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access

2016-05-04 Thread Michael Selik
On Wed, May 4, 2016, 6:51 PM DFS wrote: > Both of the following python commands successfully create a SQLite3 > datafile which crashes Access 2003 immediately upon trying to open it > (via an ODBC linked table). > Have you tried using Access 2013? On the other hand, a SQLite3 file created in VB

Re: pylint woes

2016-05-07 Thread Michael Selik
On Sat, May 7, 2016 at 12:56 PM DFS wrote: > |mixed-indentation|186 | I always use tab > Don't mix tabs and spaces. I suggest selecting all lines and using your editor to convert spaces to tabs. Usually there's a feature to "tabify". > +-++ >

Re: python - handling HTTP requests asynchronously

2016-05-07 Thread Michael Selik
On Fri, May 6, 2016 at 3:01 AM wrote: > The PDF is generated through an external API. Since currently is generated > on demand, this is handled synchronously via an HTTP request/response. Are you sending the request or are you receiving the request? If you are sending, you can just use threads

Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-09 Thread Michael Selik
You're saying that wasn't a coded message? On Sun, May 8, 2016, 10:44 PM srinivas devaki wrote: > I'm so sorry, forgot to lock my phone. > On May 9, 2016 9:01 AM, "srinivas devaki" > wrote: > > > f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubbv GB hbu hbu > > fjbjfbbbufhbvh VB have fqb

Re: What should a decorator do if an attribute already exists?

2016-05-10 Thread Michael Selik
On Tue, May 10, 2016 at 11:48 AM Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > > I have a decorator that adds an attribute to the decorated function: > >inner.instrument = instrument > >return inner > > the original instrument is still accessible as f.__wrapped__.instr

Re: python - handling HTTP requests asynchronously

2016-05-10 Thread Michael Selik
On Sat, May 7, 2016 at 4:46 PM wrote: > Il giorno sabato 7 maggio 2016 21:04:47 UTC+2, Michael Selik ha scritto: > > On Fri, May 6, 2016 at 3:01 AM wrote: > > > > > The PDF is generated through an external API. Since currently is > generated > > > on demand,

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
On Fri, May 13, 2016 at 12:27 PM David Shi via Python-list < python-list@python.org> wrote: > I lost my indexes after grouping in Pandas. > I managed to rest_index and got back the index column. > But How can I get back a index row? > Was the grouping an aggregation? If so, the original indexes a

Re: Distinction between “class” and “type”

2016-05-13 Thread Michael Selik
On Fri, May 13, 2016 at 1:10 AM Ben Finney wrote: > Howdy all, > > Ever since Python's much-celebrated Grand Unification of classes and > types, I have used those terms interchangeably: every class is a type, > and every type is a class. > > That may be an unwise conflation. With the recent rise

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
grouping? > > Regards. > > David > > > On Friday, 13 May 2016, 17:57, Michael Selik > wrote: > > > > > On Fri, May 13, 2016 at 12:27 PM David Shi via Python-list < > python-list@python.org> wrote: > > I lost my indexes after grouping in Pandas.

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
Just in case I misunderstood, why don't you make a little example of before and after the grouping? This mailing list does not accept attachments, so you'll have to make do with pasting a few rows of comma-separated or tab-separated values. On Fri, May 13, 2016 at 3:56 PM Michael Se

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-13 Thread Michael Selik
On Fri, May 13, 2016 at 2:41 AM Gregory Ewing wrote: > Dirk Bächle wrote: > > I'm currently following the "Factory" pattern (more or less) as I know > > it from C++ and similar languages. > > This statement sets off alarm bells for me. If you're using some > design pattern in Python just because

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
u'KY', u'LA', u'MA', u'MD', u'ME', u'MI', > u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', u'NM', u'NV', >

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
39.0, 40.0, 41.0, 42.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, > 50.0, > 51.0, 53.0, 54.0, 55.0, 56.0], > dtype='float64', name=u'StateFIPS') > > > Regards. > > > David > > > > On Friday, 13 May 2016, 21:43,

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
What have code you tried? What error message are you receiving? On Fri, May 13, 2016, 5:54 PM David Shi wrote: > Hello, Michael, > > How to convert a float type column into an integer or label or string type? > > > On Friday, 13 May 2016, 22:02, Michael Selik > wrote:

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
to a dictionary, so that I > can put values back properly. > > > I like to use sid as index, some way. > > > Regards. > > > David > > > > On Friday, 13 May 2016, 22:58, Michael Selik > wrote: > > > What have code you tried? What error message

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
It looks like you're getting a Series. Apparently more that one row has the same index. On Fri, May 13, 2016 at 11:30 PM Michael Selik wrote: > What were you hoping to get from ``df[0]``? > When you say it "yields nothing" do you mean it raised an error? What was > the

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
ct. Are there anything to be > typed in Python, to reveal objects. > > Regards. > > David > > > On Saturday, 14 May 2016, 4:30, Michael Selik > wrote: > > > What were you hoping to get from ``df[0]``? > When you say it "yields nothing" do you mean

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
You might also be interested in "Python for Data Analysis" for a thorough discussion of Pandas. http://shop.oreilly.com/product/0636920023784.do On Sat, May 14, 2016 at 10:29 AM Michael Selik wrote: > David, it sounds like you'll need a thorough introduction to the basics of

Re: Why online forums have bad behaviour

2016-05-14 Thread Michael Selik
On Sat, May 14, 2016 at 8:57 AM Ben Finney wrote: > If you dislike someone's behaviour, consider that they may not have a > well-thought-out or coherent rason for it; and, if pressed to come up > with a reason, we will employ all our faculties to *make up* a reason > (typically without be

Re: How to get a directory list sorted by date?

2016-05-15 Thread Michael Selik
On Sun, May 15, 2016, 10:37 AM Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > On 2016-05-15 11:46, Peter Otten wrote: > >> def sorted_dir(folder): > >> def getmtime(name): > >> path = os.path.join(folder, name) > >> return os.path.getmtime(path) > >> > >> retu

Re: Pandas GroupBy does not behave consistently

2016-05-15 Thread Michael Selik
On Sun, May 15, 2016 at 7:07 AM David Shi wrote: > Hello, Michael, > > Pandas GroupBy does not behave consistently. > > Last time, when we had conversation, I used grouby. It works well. > > Now, I thought to re-write the program, so that I can end up with a clean > script. > > But, the problem

Re: How to create development Python environment on Linux.

2016-05-16 Thread Michael Selik
On Mon, May 16, 2016 at 5:31 PM wrote: > After considering your guidance I think what I will do is install > virtualenv using apt-get and then use that to create a dev environment. Is > it ok to run get-pip.py in a virtual environment? > Recent versions of the virtualenv application create virtu

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-17 Thread Michael Selik
On Tue, May 17, 2016 at 11:18 AM Dirk Bächle wrote: > > > It's not so great to require > > that the user must explicitly ``add`` their derived class after defining > > it. Perhaps that add function could be a decorator? > > Our current API doesn't use decorators at all, since it's also aimed at >

Re: for / while else doesn't make sense

2016-05-20 Thread Michael Selik
On Thu, May 19, 2016 at 1:04 PM Ian Kelly wrote: > On Thu, May 19, 2016 at 10:31 AM, Herkermer Sherwood > wrote: > > Most keywords in Python make linguistic sense, but using "else" in for > and > > while structures is kludgy and misleading. I am under the assumption that > > this was just utiliz

Re: for / while else doesn't make sense

2016-05-21 Thread Michael Selik
On Sat, May 21, 2016, 4:52 PM Erik wrote: > So I guess my question is perhaps whether Python compilers should start > to go down the same path that C compilers did 30 years ago (by starting > to include some linter functionality) > Well, there's that whole optional type hints thing. You should b

Re: numpy problem

2016-05-23 Thread Michael Selik
On Mon, May 23, 2016 at 9:12 AM wrote: > > On 23 mei 2016, at 14:19, Peter Otten <__pete...@web.de> wrote: > > li...@onemanifest.net wrote: > > > >> I've got a 2D array > >> And an array of indexes that for shows which row to keep for each column > >> of values: > >> > >> keep = np.array([2, 3, 1

Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata wrote: > os.mkdir(name) > with open(name + "/__init__.py", 'w') as f: > f.write("X=1") > f.flush() > > Please give me any advices or hints. > This wasn't your question, but you don't need to flu

Re: 2d matrix into Nx3 column data

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 4:57 AM Anup reni wrote: > i would like to transform this: > > -1 0-0.8 0.64 -0.36-0.4 0.16 -0.84 > 0.0 0 -1.00 > 0.4 0.16 -0.84 > 0.8 0.64 -0.36 > > to something like this: > > x y result > id1 -0.8 -10.642 -0.8 0 -0.363

Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 4:26 AM Lawrence D’Oliveiro wrote: > On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote: > > (Note that ‘__init__’ is not a constructor, because it operates on the > > *already constructed* instance, and does not return anything. > > Believe it or not, that *

  1   2   >