Re: [Tutor] decomposing a problem

2018-12-25 Thread Avi Gross
Steven showed a more abstract solution than the one I tried but Cameron is making some good points on whether it might not be a great idea to chain some side-effect operations. I have seen languages where everything seems to be immutable. Python does this in places like with tuples. The idea is th

Re: [Tutor] decomposing a problem

2018-12-25 Thread Steven D'Aprano
On Tue, Dec 25, 2018 at 11:56:21PM -0500, Avi Gross wrote: > I find that many people are fairly uncomfortable with abstraction and > tend to resist a pure top down approach by diving to any solutions > they may envision. https://blog.codinghorror.com/it-came-from-planet-architecture/ > As some

Re: [Tutor] decomposing a problem

2018-12-25 Thread Avi Gross
[REAL SUBJECT: What's this?] Steven, I am afraid you are right. I was not selfish enough about this. I have done object-oriented programming in many other languages and I am afraid today it showed. Think C++ or Java. Part of me continues to think in every language I ever used, including human lan

Re: [Tutor] decomposing a problem

2018-12-25 Thread Avi Gross
Mike, Excellent advice. I find that many people are fairly uncomfortable with abstraction and tend to resist a pure top down approach by diving to any solutions they may envision. For example, if you say things like create a data structure that can hold as many kinds of information as will be

Re: [Tutor] decomposing a problem

2018-12-25 Thread Steven D'Aprano
On Tue, Dec 25, 2018 at 10:25:50PM -0500, Avi Gross wrote: > class chainable_list(list): > """Same as list but sort() can now be chained""" > def chainsort(this, *args, **kwargs): > this.sort(*args, **kwargs) > return this In Python, it is traditional to use "self" rather

Re: [Tutor] decomposing a problem

2018-12-25 Thread Avi Gross
Alan, Your thoughts were helpful and gave me a hint. Just an idea. What if you sub-classed an object type like list with a name like chainable_list? For most things it would be left alone. But if you isolated specific named methods like sort() and reverse() you could over-ride them with the same

Re: [Tutor] decomposing a problem

2018-12-25 Thread Cameron Simpson
On 26Dec2018 01:06, Alan Gauld wrote: On 26/12/2018 00:00, Avi Gross wrote: great. Many things in python can be made to fit and some need work. Dumb example is that sorting something internally returns None and not the object itself. This is one of my few complaints about Python. In Smalltal

Re: [Tutor] decomposing a problem

2018-12-25 Thread Steven D'Aprano
On Wed, Dec 26, 2018 at 01:06:04AM +, Alan Gauld via Tutor wrote: > In Smalltalk the default return value from > any method is self. In Python it is None. > > self allows chaining of methods, None does not. You might be interested in this simple recipe for retrofitting method chaining onto

Re: [Tutor] decomposing a problem

2018-12-25 Thread Alan Gauld via Tutor
On 26/12/2018 00:00, Avi Gross wrote: > great. Many things in python can be made to fit and some need work. Dumb > example is that sorting something internally returns None and not the object > itself. This is one of my few complaints about Python. In Smalltalk the default return value from any

[Tutor] decomposing a problem

2018-12-25 Thread Avi Gross
[Long enough that some should neither read nor comment on.] Mats raised an issue that I think does relate to how to tutor people in python. The issue is learning how to take a PROBLEM to solve that looks massive and find ways to look at it as a series of steps where each step can be easily solved

Re: [Tutor] look back comprehensively

2018-12-25 Thread Mats Wichmann
On 12/24/18 5:45 PM, Avi Gross wrote: > As for the UNIX tools, one nice thing about them was using them in a > pipeline where each step made some modification and often that merely > allowed the next step to modify that. The solution did not depend on one > tool doing everything. I know we're wo