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: 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-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 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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-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 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 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: Call for Assistance

2016-08-09 Thread Michael Selik
On Tue, Aug 9, 2016 at 3:23 AM Charles Ross wrote: > I’ve begun a new book called Meta Python that I’m looking for assistance > with. The book is one I wish was out there, and so am writing. The book is > targeted at experienced programmers who are novice Python users and want to > move from that

Re: Question regarding stdlib distutils strtobool behavior

2016-08-09 Thread Michael Selik
ot sure if those changes are worthwhile. As a side note, we discovered this with some code that was checking `if var > is True` instead of just `if var`. > The Pythonic style is to simply check ``if var`` rather than ``if var is True``. This realizes the flexibility of duck typing -- it

Re: Question regarding stdlib distutils strtobool behavior

2016-08-09 Thread Michael Selik
On Tue, Aug 9, 2016 at 9:26 AM Joseph Bane wrote: > Hello. > > It recently came to my attention that the strtobool function in the > standard library doesn't return Python native boolean values, but rather > returns integer 0 or 1: > > https://hg.python.org/cpython/file/3.5/Lib/distutils/util.py#

Re: Python slang

2016-08-06 Thread Michael Selik via Python-list
On Sat, Aug 6, 2016, 10:10 AM Marco Sulla via Python-list < python-list@python.org> wrote: > On 6 August 2016 at 00:31, Chris Angelico wrote: > > On Sat, Aug 6, 2016 at 8:00 AM, Marco Sulla via Python-list > > wrote: > >> * `dict` instead of `map` > > > > "map" has many other meanings (most nota

Re: Python slang

2016-08-05 Thread Michael Selik
On Fri, Aug 5, 2016 at 10:12 PM Chris Angelico wrote: > That answers the question about True and False, but not about None, > which started the question. Why are instances capitalized here? Is it > simply a matter of grandfathering in, with no specific decision? > When people ask me why the core

Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-04 Thread Michael Selik
On Thu, Aug 4, 2016 at 3:24 PM Malcolm Greene wrote: > Hi Chris, > > Thanks for your suggestions. I would like to capture the specific bad > codes *before* they get replaced. So if a line of text has 10 bad codes > (each one raising UnicodeError), I would like to track each exception's > bad code

Re: usage of functools.partial in in parallelism

2016-08-01 Thread Michael Selik
On Sun, Jul 31, 2016 at 5:47 AM Sivan Greenberg wrote: > That's exactly the answer I was looking for. Thanks. > > I got used too much I guess to solving problems the OOP way, e.g. my code > wraps the session.get invocation with a class to pack together the > arguments and data and also took care

Re: Dynamically call methods where method is known by address vs name

2016-07-22 Thread Michael Selik
On Fri, Jul 22, 2016 at 4:05 PM Malcolm Greene wrote: > I know I can do the following: > > >>> s = 'lower' > >>> getattr(s, 'upper')() > 'LOWER' > > But how could I do the same if I had the method 'address' (better > name???) vs. method name? > > >>> upper_method = s.upper > > How do I combine th

Re: Stupid question, just need a quick and dirty fix

2016-07-22 Thread Michael Selik
On Fri, Jul 22, 2016 at 2:11 AM Steven D'Aprano wrote: > On Fri, 22 Jul 2016 03:18 pm, Michael Selik wrote: > >> On Jul 22, 2016, at 12:39 AM, Jordan Bayless > wrote: > >> > >> Posting the entire code snippet is tough because it's thousands of lines &

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Michael Selik
> On Jul 22, 2016, at 12:39 AM, Jordan Bayless wrote: > > Posting the entire code snippet is tough because it's thousands of lines of > code. You could paste into a GitHub gist (https://gist.github.com/) and share the link. -- https://mail.python.org/mailman/listinfo/python-list

Re: reversed(enumerate(x))

2016-07-20 Thread Michael Selik
> On Jul 20, 2016, at 12:42 PM, Ian Kelly wrote: > >for i, n in reversed(enumerate(x)): pass > > fails with "TypeError: argument to reversed() must be a sequence". So make it a sequence: for i, n in reversed(list(enumerate(x))): pass If ``x`` is very large, you can use your zip/range

Re: Compression of random binary data

2016-07-11 Thread Michael Selik
On Mon, Jul 11, 2016, 10:56 AM wrote: > What kind of statistic law or mathematical conjecture or is it even a > physical law is violated by compression of random binary data? > If you get lucky, you might be able to achieve very good compression. > http://dilbert.com/strip/2001-10-25 Or are y

Re: Quick poll: gmean or geometric_mean

2016-07-10 Thread Michael Selik
On Sun, Jul 10, 2016, 5:08 AM Chris Angelico wrote: > On Sun, Jul 10, 2016 at 8:08 PM, Steven D'Aprano > wrote: > >> Now even the basic IPython shell has autocomplete :-) > > > > Not all shells or editors are IPython, and not all abbreviations are bad. > > Would you rather print, or > > write_va

Re: Quick poll: gmean or geometric_mean

2016-07-10 Thread Michael Selik
On Sun, Jul 10, 2016, 4:56 AM Steven D'Aprano wrote: > On Sun, 10 Jul 2016 05:28 pm, Rustom Mody wrote: > > > From fuzzy memory of sitting in statistics classes decades ago > > filled with μ-σ etc I'd suggest μ gμ hμ > > In all the stats books and references I've seen, μ is always the population

Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Michael Selik
On Sat, Jul 9, 2016, 12:57 PM Robert Kern wrote: > On 2016-07-09 17:13, Michael Selik wrote: > > On Sat, Jul 9, 2016 at 10:17 AM Jason Friedman > wrote: > > > >>> +1 for consistency > > > > What do other languages use? > > R, the m

Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Michael Selik
On Sat, Jul 9, 2016 at 10:17 AM Jason Friedman wrote: > > +1 for consistency > What do other languages use? Even though I generally prefer complete words instead of abbreviations, if an abbreviation is a strong standard across many statistics modules (like "stdev" instead of "standard_deviation

Re: Clean Singleton Docstrings

2016-07-07 Thread Michael Selik
> On Jul 7, 2016, at 7:46 PM, Rob Gaddi > wrote: > > I've got a package that contains a global ensmartened dict that allows > all the various parts of my program to share state. The simplest solution would be to use a module as your singleton. For example, "registry.py" would work. Pydoc wil

Re: Making Classes Subclassable

2016-07-04 Thread Michael Selik
On Mon, Jul 4, 2016, 4:36 AM Lawrence D’Oliveiro wrote: > On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: > > --> "type(obj)" or "obj.__class__" (there are small differences) > > give you the type/class of "obj". > > When would it not be the same? > Old-style classes. > -- https://

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Michael Selik
On Wed, Jun 29, 2016 at 7:11 AM Victor Savu wrote: > Please let me know if you are interested in a more concrete case such as a > domain-specific application (I can think of progress bars, logging, > transfer rate statistics ...). > Yes, please. I'd like to compare the proposed syntax against th

Re: Sharing package data across files

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 3:21 PM wrote: > I'm trying to create a package in which the constituent files share some > state. Apparently, I don't understand scopes, namespaces, and package > semantics as well as I thought I did. Here's the directory structure for a > simplified example: > >exa

Re: fastest way to read a text file in to a numpy array

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 10:08 AM Hedieh Ebrahimi wrote: > File 1 has : > x1,y1,z1 > x2,y2,z2 > > > and file2 has : > x1,y1,z1,value1 > x2,y2,z2,value2 > x3,y3,z3,value3 > ... > > I need to read the coordinates from file 1 and then interpolate a value > for these coordinates on file 2 to the

Re: fastest way to read a text file in to a numpy array

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 9:51 AM Heli wrote: > Is even reading the file in to numpy array the best method or there are > better approaches? > What are you trying to accomplish? Summary statistics, data transformation, analysis...? -- https://mail.python.org/mailman/listinfo/python-list

Re: Iteration, while loop, and for loop

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 9:26 AM Joseph Lee wrote: > > -Original Message- > From: Michael Selik > Sent: Tuesday, June 28, 2016 6:16 AM > > MS: You should not. Use the first version, it's much better. Python > for-loops are preferable to while-loops. > >

Re: Iteration, while loop, and for loop

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 9:34 AM BartC wrote: > On 28/06/2016 14:15, Michael Selik wrote: > > On Tue, Jun 28, 2016 at 8:41 AM Elizabeth Weiss > wrote: > > > >> I do not understand the second code. What is counter? > >> > > > > It looks like

Re: Iteration, while loop, and for loop

2016-06-28 Thread Michael Selik
On Tue, Jun 28, 2016 at 8:41 AM Elizabeth Weiss wrote: > I do not understand the second code. What is counter? > It looks like someone wanted to make a loop induction variable. https://en.wikipedia.org/wiki/Induction_variable > Why do we use this code if we can use the simpler for loop? > You

Re: Language improvement: Get more from the `for .. else` clause

2016-06-27 Thread Michael Selik
On Mon, Jun 27, 2016 at 12:53 AM Victor Savu wrote: > capture the [StopIteration] value in the `else` statement of the `for` loop > I'm having trouble thinking of a case when this new feature is necessary. Can you show a more realistic example? -- https://mail.python.org/mailman/listinfo/python

Re: Proposal: named return values through dict initialization and unpacking

2016-06-26 Thread Michael Selik
On Tue, Jun 21, 2016 at 9:41 PM Steven D'Aprano wrote: > On Tue, 21 Jun 2016 05:34 pm, Ari Freund wrote: > > var3, var1, var2 = **d > > But I don't want to use the key names your function uses. I want to > use names which makes sense for my application > Note that my dict unpacking synt

Re: Is signed zero always available?

2016-06-22 Thread Michael Selik
On Wed, Jun 22, 2016 at 4:53 PM Christopher Reimer < christopher_rei...@icloud.com> wrote: > > On Jun 22, 2016, at 7:59 AM, Grant Edwards > wrote: > > > >> On 2016-06-22, Random832 wrote: > >>> On Wed, Jun 22, 2016, at 10:19, Grant Edwards wrote: > >>> > >>> Is that guaranteed by Python, or just

Re: Proposal: named return values through dict initialization and unpacking

2016-06-21 Thread Michael Selik
On Tue, Jun 21, 2016, 10:14 AM Terry Reedy wrote: > On 6/21/2016 3:34 AM, Ari Freund via Python-list wrote: > > I'd like to run this idea by the community to see if it's PEP worthy and > > hasn't been already rejected. > > > There was a recent (last couple of months?) discussion on python-ideas >

Re: Method Chaining

2016-06-17 Thread Michael Selik
On Fri, Jun 17, 2016, 6:44 PM Michael Selik wrote: > > > On Fri, Jun 17, 2016, 6:42 PM Lawrence D’Oliveiro > wrote: > >> On Saturday, June 18, 2016 at 1:35:06 AM UTC+12, Michael Selik wrote: >> >> > The chained version looks like each method is returning a

Re: Method Chaining

2016-06-17 Thread Michael Selik
On Fri, Jun 17, 2016, 6:42 PM Lawrence D’Oliveiro wrote: > On Saturday, June 18, 2016 at 1:35:06 AM UTC+12, Michael Selik wrote: > > > The chained version looks like each method is returning a modified > > copy. > > As opposed to a modified original? > Correct. Read

Re: Method Chaining

2016-06-17 Thread Michael Selik
On Fri, Jun 17, 2016 at 5:31 AM Steven D'Aprano wrote: > (g.move_to((p1 + p2a) / 2) > .line_to(p1 + (p2 - p1) * frac) > .line_to((p1 + p1a) / 2) > .stroke() > ) > > the parens and indentation more clearly mark this chunk of code as a > unit. I prefer reserving indentation for where they

Re: Method Chaining

2016-06-16 Thread Michael Selik
On Thu, Jun 16, 2016 at 10:53 PM Lawrence D’Oliveiro wrote: > Example from , > concisely expressing a complex drawing sequence: > > (g > .move_to((p1 + p2a) / 2) > .line_to(p1 + (p2 - p1) * frac) > .line_to((p1

Re: for / while else doesn't make sense

2016-06-15 Thread Michael Selik
On Wed, Jun 15, 2016, 10:28 AM Rustom Mody wrote: > Where did the question of "break can be written as goto" come from? > Stephen said the "else" in for-else was "unconditional". He argued that neither the presence nor absence of a break should be considered a condition, because we don't conside

Re: for / while else doesn't make sense

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 10:46 PM Steven D'Aprano wrote: > On Tue, 14 Jun 2016 09:45 am, Michael Selik wrote: > > On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano > > wrote: > >> On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > >> > O

Re: Overriding methods inherited from a superclass with methods from a mixin

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 7:46 PM wrote: > I ... am making an effort to get used to the rtl order as quickly as > possible. > Funny, you keep saying right-to-left. I think the issue is you think the parent class is more important. Fight the power! Youth revolt! In Python, the children are in contr

Re: for / while else doesn't make sense

2016-06-13 Thread Michael Selik
On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano wrote: > On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > > > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > > steve+comp.lang.pyt...@pearwood.info> wrote: > > > >> - run the for block

Re: Overriding methods inherited from a superclass with methods from a mixin

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 2:46 PM wrote: > Thank you for your replies. I don't know if I'm quoting you correctly, I'm > quite confused with Google Groups... not sure if it's a "forum", something > like a mailing list, or both... or neither. > Mailing list. A "forum" in the metaphorical sense, not

Re: Conversion: execfile --> exec

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 1:51 PM Rustom Mody wrote: > looks (to me) like an intent to import the package chaco with no locals > and globals -- Just guessing of course > And without creating a module object. I suppose that means it doesn't get cached in sys.modules either. Not sure if that's a fea

Re: Overriding methods inherited from a superclass with methods from a mixin

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 12:01 AM wrote: > I haven't used Python for some time so I don't feel confident to judge > Yet, you are clearly judging the code you pasted as not OK. Perhaps you guys could help me either convincing me that the bpaste code is > OK > It would be helpful for you to expla

Re: Conversion: execfile --> exec

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016, 10:36 AM Rustom Mody wrote: > On Monday, June 13, 2016 at 7:41:33 PM UTC+5:30, MRAB wrote: > > On 2016-06-13 14:24, Long Yang wrote: > > > The python 2.x command is as following: > > > --- > > > info = {} > > > execfile(join('chaco', '__init__.py'), i

Re: loading trees...

2016-06-12 Thread Michael Selik
On Sun, Jun 12, 2016 at 3:01 PM Fillmore wrote: > What's my best way to achieve this? > What are your criteria for "best"? > The idea is that I'll receive a bit of data, determine which tree is > suitable for handling it, and dispatch the data to the right tree for > further processing. > How

Re: for / while else doesn't make sense

2016-06-12 Thread Michael Selik
On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > - run the for block > - THEN unconditionally run the "else" block > Saying "unconditionally" is a bit misleading here. As you say, it's conditioned on completing the loop without break/return/raise. -

Re: which library has map reduce and how to use it for this case

2016-06-11 Thread Michael Selik
> > On Friday, June 10, 2016 at 10:04:09 PM UTC+8, Michael Selik wrote: > > You'll need to explain the problem in more detail. Instead of talking > about operators and columns, what is the actual, real-world problem? On Sat, Jun 11, 2016 at 2:21 AM meInvent bbird wro

Re: which library has map reduce and how to use it for this case

2016-06-10 Thread Michael Selik
On Thu, Jun 9, 2016, 9:11 PM Ho Yeung Lee wrote: > input are these six operators, output is finding full column of 27 > elements add together is 54 > > i got memory error when searching this, > > i have difficulty in understanding map reduce and transforming my program > into map reduce problem >

Re: UserList - which methods needs to be overriden?

2016-06-10 Thread Michael Selik
On Fri, Jun 10, 2016, 4:05 AM Nagy László Zsolt wrote: > 2016.06.10. 0:38 keltezéssel, Michael Selik írta: > > On Thu, Jun 9, 2016 at 5:07 AM Nagy László Zsolt > wrote: > >> I would like to create a collections.UserList subclass that can notify >> others when the list

Re: UserList - which methods needs to be overriden?

2016-06-10 Thread Michael Selik
On Fri, Jun 10, 2016 at 9:18 AM Michael Selik wrote: > > > On Fri, Jun 10, 2016, 4:05 AM Nagy László Zsolt > wrote: > >> 2016.06.10. 0:38 keltezéssel, Michael Selik írta: >> >> On Thu, Jun 9, 2016 at 5:07 AM Nagy László Zsolt >> wrote: >> >

Re: which library has map reduce and how to use it for this case

2016-06-09 Thread Michael Selik
I like using Yelp's mrjob module (https://github.com/Yelp/mrjob) to run Python on Hadoop. On Thu, Jun 9, 2016 at 2:56 AM Ho Yeung Lee wrote: > [... a bunch of code ...] If you want to describe a map-reduce problem, start with the data. What does a record of your input data look like? Then thi

Re: Tie dictionary to database table?

2016-06-09 Thread Michael Selik
On Thu, Jun 9, 2016 at 9:10 AM justin walters wrote: > It looks like you might be looking for an ORM. Have you checked out > sqlalchemy? > An ORM might be overkill. If you just want a persistent dictionary, just use the shelve module. https://docs.python.org/3/library/shelve.html -- https://mai

Re: UserList - which methods needs to be overriden?

2016-06-09 Thread Michael Selik
On Thu, Jun 9, 2016 at 5:07 AM Nagy László Zsolt wrote: > I would like to create a collections.UserList subclass that can notify > others when the list is mutated. > Why not subclass MutableSequence instead? The ABC will tell you which methods to override (the abstract ones). The mixin methods r

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

2016-06-08 Thread Michael Selik
By the way, why choose to write, import, and delete modules? I'd think exec'ing code would be sufficient. On Wed, Jun 8, 2016, 5:52 AM Makoto Kuwata wrote: > On Tue, Jun 7, 2016 at 7:28 AM, Michael Selik > wrote: > >> On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwat

Re: reshape and keep x,y,z ordering

2016-06-07 Thread Michael Selik
On Tue, Jun 7, 2016 at 7:31 AM Heli wrote: > Hello, > I have a question regarding reshaping numpy array. > > I either have a 1D array that I need to reshape to a 3D array or a 3D > array to reshape to a 1d numpy array. > > In both of these cases it is assumed that data follows x,y,z ordering. > a

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

2016-06-06 Thread Michael Selik
On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata wrote: > I have a trouble around __import__(). > The docs for __import__ strongly recommend that you use importlib instead https://docs.python.org/3.5/library/importlib.html#importlib.import_module The docs for ``importlib.import_module`` suggest th

Re: Taking two and more data frames and extracting data on unique keys in python

2016-06-06 Thread Michael Selik
On Sun, Jun 5, 2016 at 7:05 AM Danish Hussain wrote: > Please me know if clarification is needed. > Could you clarify what your question is? Did you encounter an error while coding the solution? -- https://mail.python.org/mailman/listinfo/python-list

Re: Anyone know a donation app codebase?

2016-06-06 Thread Michael Selik
On Sun, Jun 5, 2016 at 3:26 PM Ben Finney wrote: > Albert writes: > > > Thank you for your answer Ben, > > You're welcome. Please note that top-posting is poor etiquette for > discussions; instead, interleave your response like a written dialogue. > See https://en.wikipedia.org/wiki/Posting_styl

Re: Would like to see python script output

2016-06-06 Thread Michael Selik
On Mon, Jun 6, 2016 at 3:12 AM Archana Sonavane wrote: > I have ganglia python script, i would like to see output of each code > block. > > Could you please guide. I don't have any idea about python. > Do you know how to run a Python script? Have you read through the Python tutorial? https://do

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 12:01 PM Nagy László Zsolt wrote: > > Is the problem that the attribute or parameter has the same name in > both base classes, but has different meanings in each? > If they had different meanings, a simple rename would solve the problem. > Sometimes finding a good name ain

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 11:58 AM Sayth Renshaw wrote: > That totally makes sense I was just double checking, had hoped I could > create a variable assign it to a list and append in one stroke. > In fact you can! It's called a "list comprehension" pyqFiles = [pq(my_dir + filename) for filenam

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Michael Selik
On Fri, Jun 3, 2016 at 10:41 AM Ian Kelly wrote: > On Fri, Jun 3, 2016 at 8:06 AM, Nagy László Zsolt > wrote: > > There is still something I don't get: how to create cooperative classes > > when some base classes share some of the parameters? > > Why do they need to share the same parameter? >

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 *

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: [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: 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: 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: 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: 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: 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: 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 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: 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 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: 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
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-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-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
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
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: 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

  1   2   >