Re: Python refactoring question and create dynamic attributes

2019-06-23 Thread DL Neil
readability concern(s):- 1 If it seems complex, first write a comment (in plain English). 2 Is the most basic refactoring improvement is any possible improvement in attribute/variable names? A mid-point between these two: if you find the intricate coding of specific concepts awkward to read

Re: Python refactoring question and create dynamic attributes

2019-06-23 Thread MRAB
On 2019-06-23 10:44, Arup Rakshit wrote: On 23-Jun-2019, at 2:31 PM, Cameron Simpson wrote: On 23Jun2019 13:26, Arup Rakshit wrote: In the below code: @classmethod def find(self, id): if isinstance(id, list): rows = self.__table__().get_all(*id).run(self.__db__().conn)

Re: Python refactoring question and create dynamic attributes

2019-06-23 Thread Arup Rakshit
> On 23-Jun-2019, at 2:31 PM, Cameron Simpson wrote: > > On 23Jun2019 13:26, Arup Rakshit wrote: >> In the below code: >> >> @classmethod >> def find(self, id): >> if isinstance(id, list): >> rows = self.__table__().get_all(*id).run(self.__db__().conn) >> result =

Re: Python refactoring question and create dynamic attributes

2019-06-23 Thread Cameron Simpson
On 23Jun2019 13:26, Arup Rakshit wrote: In the below code: @classmethod def find(self, id): if isinstance(id, list): rows = self.__table__().get_all(*id).run(self.__db__().conn) result = [] for row in rows: acategory = Category()

Python refactoring question and create dynamic attributes

2019-06-23 Thread Arup Rakshit
In the below code: @classmethod def find(self, id): if isinstance(id, list): rows = self.__table__().get_all(*id).run(self.__db__().conn) result = [] for row in rows: acategory = Category() acategory.__dict__.updat

Re: Refactoring

2017-09-29 Thread Bill
Stefan Ram wrote: The customer pays for the solution. The software manufacturer does the refactoring for it's own sake, because when it's a longer running project, the refactorings will pay for themself. The customer owns the source code (at least where I was). YMM

Re: Refactoring (was: Spacing conventions)

2017-09-29 Thread Chris Angelico
On Sat, Sep 30, 2017 at 12:45 AM, Stefan Ram wrote: > Chris Angelico writes: >>If the behaviour remains *exactly* the same, then it's a code >>improvement (aka a refactoring), not a bug fix. > > Usually, one cannot observe whether behavior stays the same, > beca

Refactoring tool to create Python functions

2017-05-08 Thread beliavsky--- via Python-list
Googling "refactoring python code to create functions" I came to https://wingware.com/doc/intro/tutorial-refactoring where the "Extract Function/Method" does what I want. Is there a free Python tool that does this? -- https://mail.python.org/mailman/listinfo/python-list

Re: WANT: bad code in python (for refactoring example)

2017-02-19 Thread Dotan Cohen
t; > > Year, this is a good example code for me to do refactoring. > > I created a pull request. This will be shown to my students. > > https://github.com/dotancohen/burton/pull/20/files > > I hope you favor this PR. > > -- > regards, > makoto kuwata > -- &

Re: WANT: bad code in python (for refactoring example)

2017-02-17 Thread Makoto Kuwata
On Thu, Feb 16, 2017 at 6:34 AM, Dotan Cohen wrote: > I think that we can help each other! This is my own code, back when I > was writing Python like PHP: > https://github.com/dotancohen/burton Year, this is a good example code for me to do refactoring. I created a pull request. Thi

Re: WANT: bad code in python (for refactoring example)

2017-02-17 Thread Jussi Piitulainen
(steps): positions = move(positions) yield positions def draw(positions): print(*('-' * pos for pos in positions), sep = '\n') if __name__ == '__main__': for step, positions in enumerate(race([1,1,1], 5)): step and print()

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread Makoto Kuwata
Thanks Erik, On Thu, Feb 16, 2017 at 6:53 AM, Erik wrote: > (which is what I think you mean by "proper size") > As I explained at my first post, I'm teaching Python to novice programmers. Therefore refactoring example code should be in the size what they can understand. I

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread alister
On Thu, 16 Feb 2017 12:00:36 +0100, Cecil Westerhof wrote: > On Thursday 16 Feb 2017 10:43 CET, alister wrote: > >> On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: >> >>> Antoon Pardon writes: On reason to use this is for some easy "logging" >>> >>> I think it's better to use the actu

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread Cecil Westerhof
On Thursday 16 Feb 2017 10:43 CET, alister wrote: > On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: > >> Antoon Pardon writes: >>> On reason to use this is for some easy "logging" >> >> I think it's better to use the actual logging module. I generally >> start a new program with print state

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread alister
On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: > Antoon Pardon writes: >> On reason to use this is for some easy "logging" > > I think it's better to use the actual logging module. I generally start > a new program with print statements but convert them to logging after > there's enough

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Paul Rubin
Antoon Pardon writes: > On reason to use this is for some easy "logging" I think it's better to use the actual logging module. I generally start a new program with print statements but convert them to logging after there's enough code to want to be more organized about it. -- https://mail.pytho

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Erik
On 15/02/17 21:53, Erik wrote: process(data) Before I get jumped on by a pack of rabid wolves, I of course meant: process(d) E. -- https://mail.python.org/mailman/listinfo/python-list

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Erik
Hi, On 15/02/17 09:36, Makoto Kuwata wrote: I'm sorry that my explanation is not enough. I'm looking for bad python code, not refactoring examples. I think you need to explain what you mean by "bad". Do you mean something like: i = 0 data = ["bad", "exam

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Dotan Cohen
wrote: > Hi, > > Is there any *just right* python code to refactor? > In other words, I'm finding bad code example in python. > > (background) > I'm teaching Python to some novice programmer, and > want to show refactoring example to them. > > (required) &g

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread jladasky
On Wednesday, February 15, 2017 at 2:52:55 AM UTC-8, Antoon Pardon wrote: > Op 15-02-17 om 07:28 schreef Steven D'Aprano: > > E.g. http://code.activestate.com/recipes/580750 > > > > does nothing more that define > > > > echo = sys.stdout.write > > > > Why not use sys.stdout.write directly? Or prin

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Chris Angelico
On Thu, Feb 16, 2017 at 12:37 AM, Antoon Pardon wrote: >> But a better way, in my opinion, is to >> use your editor to search for: >> >> print( >> >> and replace with: >> >> #print( > > You don't seem to understand, I don't want to disable all printing, only the > diagnostics. That is easier to do

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Antoon Pardon
Op 15-02-17 om 13:24 schreef Steve D'Aprano: > On Wed, 15 Feb 2017 09:49 pm, Antoon Pardon wrote: > >> Op 15-02-17 om 07:28 schreef Steven D'Aprano: > [...] >>> Why not use sys.stdout.write directly? Or print? If I saw somebody using >>> this recipe in production code, in the way shown, I'd refacto

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Steve D'Aprano
On Wed, 15 Feb 2017 09:49 pm, Antoon Pardon wrote: > Op 15-02-17 om 07:28 schreef Steven D'Aprano: [...] >> Why not use sys.stdout.write directly? Or print? If I saw somebody using >> this recipe in production code, in the way shown, I'd refactor it to just >> use print. There's no advantage to re

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread David Palao
2017-02-15 10:36 GMT+01:00 Makoto Kuwata : > Thanks Irmen and Steven, > > I'm sorry that my explanation is not enough. > I'm looking for bad python code, not refactoring examples. > I can do (and want to do) refactor bad code by myself. > > Is there any bad pytho

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Antoon Pardon
Op 15-02-17 om 07:28 schreef Steven D'Aprano: > On Wed, 15 Feb 2017 07:44:03 +0900, Makoto Kuwata wrote: > >> Hi, >> >> Is there any *just right* python code to refactor? >> In other words, I'm finding bad code example in python. > > Try looking at the ActiveState website for recipes in Python. Esp

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Makoto Kuwata
Thanks Irmen and Steven, I'm sorry that my explanation is not enough. I'm looking for bad python code, not refactoring examples. I can do (and want to do) refactor bad code by myself. Is there any bad python code (or project) with proper size? # I found a lot of bad PHP code in g

Re: WANT: bad code in python (for refactoring example)

2017-02-14 Thread Steven D'Aprano
On Wed, 15 Feb 2017 07:44:03 +0900, Makoto Kuwata wrote: > Hi, > > Is there any *just right* python code to refactor? > In other words, I'm finding bad code example in python. Try looking at the ActiveState website for recipes in Python. Especially look at the ones with negative ratings, but e

Re: WANT: bad code in python (for refactoring example)

2017-02-14 Thread Irmen de Jong
On 14-2-2017 23:44, Makoto Kuwata wrote: > Hi, > > Is there any *just right* python code to refactor? > In other words, I'm finding bad code example in python. > > (background) > I'm teaching Python to some novice programmer, and > want to show refactori

WANT: bad code in python (for refactoring example)

2017-02-14 Thread Makoto Kuwata
Hi, Is there any *just right* python code to refactor? In other words, I'm finding bad code example in python. (background) I'm teaching Python to some novice programmer, and want to show refactoring example to them. (required) * not good code * not too large (for novice programmer)

Automated refactoring tools (was: How to import all things defined the files in a module directory in __init__.py?)

2016-09-22 Thread Ben Finney
Peng Yu writes: > Is there such a good automated tool for python refactoring? This sounds like a job for — Bicycle Repair Man! Watch him extract jumbled code into well ordered classes. Gasp, as he renames all occurrences of a method. Thank You Bicycle Repair Man! h

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Sat, Jan 23, 2016 at 12:48 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> Okay. Start persuading "management" (presumably the PSU) that CPython >> needs to be more modular, with different release cycles for different >> components. Your first step is to figure out the boundaries between >> t

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Sat, Jan 23, 2016 at 12:30 AM, Rustom Mody wrote: > You just gave a graphic vivid description... > of the same thing Marko is describing: ;-) viz. > A full-size language parser is something that you - an experienced developer - > make a point of avoiding. It's worth noting that "experienced de

Re: Refactoring in a large code base

2016-01-22 Thread Rustom Mody
On Friday, January 22, 2016 at 7:13:49 PM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody : > > > IOW anyone who thinks that *arbitrary* complexity can *always* be > > tamed either has a visa to utopia or needs to re-evaluate (or get) a > > CS degree > > Not all complexity can be tamed, but what yo

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Chris Angelico : > Okay. Start persuading "management" (presumably the PSU) that CPython > needs to be more modular, with different release cycles for different > components. Your first step is to figure out the boundaries between > those components. Get started. Gladly, I don't need to do anythi

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Rustom Mody : > IOW anyone who thinks that *arbitrary* complexity can *always* be > tamed either has a visa to utopia or needs to re-evaluate (or get) a > CS degree Not all complexity can be tamed, but what you can't tame you shouldn't release, either. Marko -- https://mail.python.org/mailman/

Re: Refactoring in a large code base

2016-01-22 Thread Rustom Mody
On Friday, January 22, 2016 at 6:05:02 PM UTC+5:30, Chris Angelico wrote: > On Fri, Jan 22, 2016 at 11:04 PM, Rustom Mody wrote: > > 2. My students trying to work inside the lexer made a mess because the > > extant lexer is a mess. > > I.e. while python(3) *claims* to accept Unicode input, the ac

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Sat, Jan 23, 2016 at 12:00 AM, Marko Rauhamaa wrote: > However, as a matter of rule, older code bases have been bloated till > they can barely be maintained. That's when the management starts to > listen to new ideas. Better late than never. Okay. Start persuading "management" (presumably the

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Chris Angelico : > Alright. Can you rewrite all of those modules in three months? The point is not to rewrite modules except as a fallback for a hopelessly badly written module. > And then there's the language itself. The cpython/Python directory has > 58 .c files, many of which are closely tied

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Fri, Jan 22, 2016 at 11:04 PM, Rustom Mody wrote: > On Friday, January 22, 2016 at 4:49:19 PM UTC+5:30, Chris Angelico wrote: >> On Fri, Jan 22, 2016 at 9:19 PM, Marko Rauhamaa wrote: >> > The knowhow, vision and skill is apparently very rare. On the product >> > management side, we have the f

Re: Refactoring in a large code base

2016-01-22 Thread Thomas Mellman
On Fri, 22 Jan 2016 04:04:44 -0800, Rustom Mody wrote: > These are just specific examples that I am familiar with Chris' general > point still stands, viz take the large and complex program that is > cpython and clean up these messinesses: You will still have a large and > complex program I'm not

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Fri, Jan 22, 2016 at 10:54 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jan 22, 2016 at 9:19 PM, Marko Rauhamaa wrote: >> So what do you do with a huge program? > > Modularize. Treat each module as a separate product with its own release > cycle, documentation, apis, ownership etc

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
he ugly parts are compartmentalized, you have a better chance at refactoring them -- or replacing them altogether. Modularization is an obvious, but under-practiced, method of managing complexity. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Refactoring in a large code base

2016-01-22 Thread Rustom Mody
On Friday, January 22, 2016 at 4:49:19 PM UTC+5:30, Chris Angelico wrote: > On Fri, Jan 22, 2016 at 9:19 PM, Marko Rauhamaa wrote: > > The knowhow, vision and skill is apparently very rare. On the product > > management side, we have the famous case of Steve Jobs, who simply told > > the engineers

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jan 22, 2016 at 9:19 PM, Marko Rauhamaa wrote: > So what do you do with a huge program? Modularize. Treat each module as a separate product with its own release cycle, documentation, apis, ownership etc. What is a reasonable size of a module? It is something you would

Re: Refactoring in a large code base

2016-01-22 Thread Charles T. Smith
On Fri, 22 Jan 2016 12:19:50 +0200, Marko Rauhamaa wrote: > We need similar code sanity management. Developers are given much too > much power to mess up the source code. That's why "legacy" is considered > a four-letter word among developers. When I started in this business, in the mid-70s, ther

Re: Refactoring in a large code base

2016-01-22 Thread Chris Angelico
On Fri, Jan 22, 2016 at 9:19 PM, Marko Rauhamaa wrote: > The knowhow, vision and skill is apparently very rare. On the product > management side, we have the famous case of Steve Jobs, who simply told > the engineers to go back to the drawing boards when he didn't like the > user experience. Most

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Rustom Mody : > On Friday, January 22, 2016 at 1:59:15 PM UTC+5:30, Marko Rauhamaa wrote: >> I've been there. I think the root problem is to have a code base >> that's so large and complex. > > Bizarre comment... Are you saying large and complex code-bases should > non-exist? Why, yes, I am. >>

Re: Refactoring in a large code base

2016-01-22 Thread Rustom Mody
On Friday, January 22, 2016 at 1:59:15 PM UTC+5:30, Marko Rauhamaa wrote: > Ben Finney : > > > The author points out there are times when a code base is large and > > complex enough that refactoring puts the programmer in a state of not > > knowing whether they're m

Re: Refactoring in a large code base

2016-01-22 Thread Marko Rauhamaa
Ben Finney : > The author points out there are times when a code base is large and > complex enough that refactoring puts the programmer in a state of not > knowing whether they're making progress, because until the whole > refactoring is complete the errors just cascade and

Refactoring in a large code base (was: importing: what does "from" do?)

2016-01-21 Thread Ben Finney
Rustom Mody writes: > You may find this strategy useful: > https://pchiusano.github.io/2015-04-23/unison-update7.html > > particularly the section "Limitations of refactoring via modifying > text files in place, and what to do instead" A direct link

Re: PyCharm refactoring tool?

2014-09-15 Thread Stefan Behnel
George Silva schrieb am 15.09.2014 um 21:49: > It's pretty useful. I use it for some time now and I very much like it. > [...] > The most powerful for me are the rename refactor and extract. Works like > charm (no pun intended). Dito. > On Mon, Sep 15, 2014 at 4:44 PM, Skip Montanaro wrote: >>

Re: PyCharm refactoring tool?

2014-09-15 Thread George Silva
7;t need the VCS menu. Most > everything else looks fairly genertic. > > Except the Refactor menu. Before I try to do much/anything with it, I > thought I would solicit feedback on its capability. Does it work as > intended? I read through the PyCharm help sections on refactoring. It

PyCharm refactoring tool?

2014-09-15 Thread Skip Montanaro
its capability. Does it work as intended? I read through the PyCharm help sections on refactoring. It seems to describe a number of code refactorings which aren't available for Python code. For example, I don't see an "invert boolean" refactoring. How useful is PyCharm's

Re: Tools for refactoring/obfuscation

2012-04-02 Thread Javier
Well, a .pyc file would be a too blatant obfuscation, and people at my job would get angry. I need something more subtle. So I need a refactoring tool, preferably with which I can do scripting. These is what I found up to now in the CheeseShop: http://pypi.python.org/pypi/bicyclerepair/0.7.1

Re: Tools for refactoring/obfuscation

2012-03-30 Thread Lie Ryan
On 03/29/2012 03:04 AM, Javier wrote: Yes, in general I follow clear guidelines for writing code. I just use modules with functions in the same directory and clear use of name spaces. I almost never use classes. I wonder if you use some tool for refactoring. I am mainly intersted in scripting

Re: Tools for refactoring/obfuscation

2012-03-28 Thread Javier
Yes, in general I follow clear guidelines for writing code. I just use modules with functions in the same directory and clear use of name spaces. I almost never use classes. I wonder if you use some tool for refactoring. I am mainly intersted in scripting tools, no eclipse-style guis. Just let

Re: Tools for refactoring/obfuscation

2012-03-27 Thread Stefan Behnel
Javier, 07.03.2012 04:29: > I am looking for an automated tool for refactoring/obfuscation. Sadly, there really is one thing that these two have in common: they modify code while retaining its exact functionality. Apart from that, they are diametric opposites. Refactoring aims at making the c

Re: Tools for refactoring/obfuscation

2012-03-26 Thread Vladimir Ignatov
Hi, (sorry for replying to the old topic) On Tue, Mar 6, 2012 at 10:29 PM, Javier wrote: > I am looking for an automated tool for refactoring/obfuscation. > Something that changes names of functions, variables, or which would > merge all the functions of various modules in a sing

Tools for refactoring/obfuscation

2012-03-06 Thread Javier
I am looking for an automated tool for refactoring/obfuscation. Something that changes names of functions, variables, or which would merge all the functions of various modules in a single module. The closest I have seen is http://bicyclerepair.sourceforge.net/ Does somebody know of something that

Re: Python LOC, .exe size, and refactoring

2012-02-24 Thread CM
Tkinter, etc., but now wonder how much I could size I could reduce by > > refactoring--and therefore shortening--my code. > > Well that will depend on how much you refactor it, but frankly, unless > your code is truly awful, this will be a micro-optimization. py2exe > bundles a P

Re: Python LOC, .exe size, and refactoring

2012-02-22 Thread Chris Angelico
On Wed, Feb 22, 2012 at 4:29 PM, Steven D'Aprano wrote: > While I think 60MB for a basic calculator app is taking the piss, this is > 2011 not 1987 and we don't have to support floppy disks any more. 11MB > for a GUI app is nothing to be worried about. That takes, what, 3 minutes > to download eve

Re: Python LOC, .exe size, and refactoring

2012-02-21 Thread Steven D'Aprano
On Tue, 21 Feb 2012 19:51:07 -0800, CM wrote: > I have an application that I was hoping to reduce a bit the size of its > .exe when "packaged" with py2exe. I'm removing some Python modules such > as Tkinter, etc., but now wonder how much I could size I could redu

Python LOC, .exe size, and refactoring

2012-02-21 Thread CM
I have an application that I was hoping to reduce a bit the size of its .exe when "packaged" with py2exe. I'm removing some Python modules such as Tkinter, etc., but now wonder how much I could size I could reduce by refactoring--and therefore shortening--my code. Is there a rul

Re: Lisp refactoring puzzle

2011-07-13 Thread Gregory Ewing
Teemu Likonen wrote: Please don't forget that the whole point of Lisps' (f x) syntax is that code is also Lisp data. It's possible to design other syntaxes that have a similar property. Prolog, for example -- a Prolog program is expressed in terms of Prolog data structures, yet it manages to h

Re: Lisp refactoring puzzle

2011-07-13 Thread William Clifford
Neil Cerutti writes: > On 2011-07-12, Petter Gustad wrote: >> Xah Lee writes: >> >>> it's funny, in all these supposedly modern high-level langs, they >>> don't provide even simple list manipulation functions such as union, >>> intersection, and the like. Not in perl, not in python, not in lisp

Re: Lisp refactoring puzzle

2011-07-13 Thread Teemu Likonen
* 2011-07-13T10:34:41-04:00 * Terry Reedy wrote: > On 7/13/2011 4:29 AM, Teemu Likonen wrote: >> Please don't forget that the whole point of Lisps' (f x) syntax is >> that code is also Lisp data. > > Thank you for clarifying that. Some Lispers appear to promote the > simple, uniform syntax' as a e

Re: Lisp refactoring puzzle

2011-07-13 Thread Terry Reedy
On 7/13/2011 4:29 AM, Teemu Likonen wrote: * 2001-01-01T14:11:11-05:00 * Terry Reedy wrote: As a side note, the same principle of expressions matching operations in symmetry suggest that majority of up are quite sensible and not dumb idiots for preferring 'f(x)' to the '(f x)' of Lisp. In a fun

Re: Lisp refactoring puzzle

2011-07-13 Thread gene heskett
On Wednesday, July 13, 2011 05:34:23 AM Terry Reedy did opine: > On 7/12/2011 2:23 PM, gene heskett wrote: > > Now, I hate to mention it Terry, but your clock seems to be about 126 > > months behind the rest of the world. > > Please do not hate to be helpful. It was a bad malfunction perhaps due

Re: Lisp refactoring puzzle

2011-07-13 Thread Teemu Likonen
* 2001-01-01T14:11:11-05:00 * Terry Reedy wrote: > As a side note, the same principle of expressions matching operations > in symmetry suggest that majority of up are quite sensible and not > dumb idiots for preferring 'f(x)' to the '(f x)' of Lisp. In a > function call, the function has a differe

Re: Lisp refactoring puzzle

2011-07-12 Thread rusi
On Jul 13, 9:39 am, Terry Reedy wrote: > On 7/12/2011 2:23 PM, gene heskett wrote: > > > Now, I hate to mention it Terry, but your clock seems to be about 126 > > months behind the rest of the world. > > Please do not hate to be helpful. Ha Ha. Cute one. Thanks -- http://mail.python.org/mailman/

Re: Lisp refactoring puzzle

2011-07-12 Thread Terry Reedy
On 7/12/2011 2:23 PM, gene heskett wrote: Now, I hate to mention it Terry, but your clock seems to be about 126 months behind the rest of the world. Please do not hate to be helpful. It was a bad malfunction perhaps due to a run-down battery on a machine turned off for two weeks. I will keep

Re: Lisp refactoring puzzle

2011-07-12 Thread Roy Smith
In article <4e1cf936.4050...@canterbury.ac.nz>, Gregory Ewing wrote: > Xah Lee wrote: > > they > > don't provide even simple list manipulation functions such as union, > > intersection, and the like. Not in perl, not in python, not in lisps. > > Since 2.5 or so, Python has a built-in set type t

Re: Lisp refactoring puzzle

2011-07-12 Thread Gregory Ewing
Xah Lee wrote: they don't provide even simple list manipulation functions such as union, intersection, and the like. Not in perl, not in python, not in lisps. Since 2.5 or so, Python has a built-in set type that provides these (which is arguably a better place for them than lists). -- Greg --

Re: Lisp refactoring puzzle

2011-07-12 Thread Pascal J. Bourguignon
Neil Cerutti writes: > What's the rationale for providing them? Are the definitions > obvious for collections that a not sets? The rational is to prove that Xah is dumb. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.

Re: Lisp refactoring puzzle

2011-07-12 Thread WJ
Petter Gustad wrote: > Xah Lee writes: > > > it's funny, in all these supposedly modern high-level langs, they > > don't provide even simple list manipulation functions such as union, > > intersection, and the like. Not in perl, not in python, not in lisps. > > In Common Lisp you have: > > CL-

Re: Lisp refactoring puzzle

2011-07-12 Thread Neil Cerutti
On 2011-07-12, Petter Gustad wrote: > Xah Lee writes: > >> it's funny, in all these supposedly modern high-level langs, they >> don't provide even simple list manipulation functions such as union, >> intersection, and the like. Not in perl, not in python, not in lisps. > > In Common Lisp you have

Re: Lisp refactoring puzzle

2011-07-12 Thread Petter Gustad
Xah Lee writes: > it's funny, in all these supposedly modern high-level langs, they > don't provide even simple list manipulation functions such as union, > intersection, and the like. Not in perl, not in python, not in lisps. In Common Lisp you have: CL-USER> (union '(a b c) '(b c d)) (A B C D

Re: Lisp refactoring puzzle

2011-07-12 Thread gene heskett
On Tuesday, July 12, 2011 02:08:02 PM Terry Reedy did opine: > On 7/11/2011 11:37 PM, Xah Lee wrote: > > watch the first episode of Douglas Crockford's talk here: > > http://developer.yahoo.com/yui/theater/video.php?v=crockonjs-1 > > The link includes a transcript of the talk, which I read > >

Re: Lisp refactoring puzzle

2011-07-12 Thread Terry Reedy
On 7/11/2011 11:37 PM, Xah Lee wrote: watch the first episode of Douglas Crockford's talk here: http://developer.yahoo.com/yui/theater/video.php?v=crockonjs-1 The link includes a transcript of the talk, which I read I suspect Lee likes Crockford because they both think they are smarter than

Re: Lisp refactoring puzzle

2011-07-12 Thread fortunatus
I think the problem with so-called "forward looking" or "highest level" languages is that they tend to become domain specific. What Lispers are always saying is construct your own high level language out of your favorite Lisp. Of course no one else will use it then, or even discuss it, unless you

Re: Lisp refactoring puzzle

2011-07-12 Thread Chris Kaynor
On Mon, Jul 11, 2011 at 8:37 PM, Xah Lee wrote: > > it's funny, in all these supposedly modern high-level langs, they > don't provide even simple list manipulation functions such as union, > intersection, and the like. Not in perl, not in python, not in lisps. > (sure, lib exists, but it's a ride

Re: Lisp refactoring puzzle

2011-07-12 Thread WJ
Xah Lee wrote: > it's funny, in all these supposedly modern high-level langs, they > don't provide even simple list manipulation functions such as union, > intersection, and the like. Not in perl, not in python, not in lisps. Ruby has them. Intersection: [2,3,5,8] & [0,2,4,6,8] ==>[2, 8] U

Re: Lisp refactoring puzzle

2011-07-12 Thread jvt
I might argue that it isn't quite right (or politic) to call those who resist technological changes "idiots" so much as to observe they often have goals which cannot wait for the ideal expressive system. People love python not because Python is the platonic programming language, but because it doe

Re: Lisp refactoring puzzle

2011-07-12 Thread Terry Reedy
On 7/11/2011 11:37 PM, Xah Lee wrote: it's funny, in all these supposedly modern high-level langs, they don't provide even simple list manipulation functions such as union, intersection, and the like. Not in perl, not in python, Union and intersection are set operations, not list operations. Py

Re: Lisp refactoring puzzle

2011-07-11 Thread Xah Lee
2011-07-11 On Jul 11, 6:51 am, jvt wrote: > I might as well toss my two cents in here.  Xah, I don't believe that > the functional programming idiom demands that we construct our entire > program out of compositions and other combinators without ever naming > anything.  That is much more the pro

Re: Refactoring similar subclasses

2010-09-13 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : I have some code that currently takes four different classes, A, B, C and D, and subclasses each of them in the same way: class MyA(A): def method(self, x): result = super(MyA, self).method(x) if result == "spam": return "spam spam spam"

Re: Refactoring similar subclasses

2010-09-11 Thread Steven D'Aprano
On Sat, 11 Sep 2010 08:53:38 +0200, Peter Otten wrote: > Steven D'Aprano wrote: > >> I have some code that currently takes four different classes, A, B, C >> and D, and subclasses each of them in the same way: [...] >> Any suggestions or guidelines? > > You could use a mixin: Nice! I'll give it

Re: Refactoring similar subclasses

2010-09-11 Thread Peter Otten
Steven D'Aprano wrote: > I have some code that currently takes four different classes, A, B, C and > D, and subclasses each of them in the same way: > > class MyA(A): > def method(self, x): > result = super(MyA, self).method(x) > if result == "spam": > return "spam

Refactoring similar subclasses

2010-09-10 Thread Steven D'Aprano
I have some code that currently takes four different classes, A, B, C and D, and subclasses each of them in the same way: class MyA(A): def method(self, x): result = super(MyA, self).method(x) if result == "spam": return "spam spam spam" return result #

Re: refactoring a group of import statements

2010-06-29 Thread Aahz
In article , Thomas Jollans wrote: > >(3) Why not > >try: >import x >import y >import z >except ImportError as exc: >display_error_properly(exc) >raise exc Why not? Because that destroys the original traceback. Inside an except clause, you should almost always use a bare ra

Re: refactoring a group of import statements

2010-06-28 Thread Steven W. Orr
On 06/27/10 23:20, quoth GrayShark: > Thanks for the help > That was what I was looking for. All the rest, the arguments were > unhelpful. > > Question: If you can't answer the question, why are you talking? > > I'm American Indian. That's what I was taught. We don't talk that much. > But you

Re: refactoring a group of import statements

2010-06-28 Thread Stephen Hansen
On 6/28/10 12:54 PM, rantingrick wrote: On Jun 27, 10:20 pm, GrayShark wrote: Question: If you can't answer the question, why are you talking? Q: If you can't take advice without complaining, then why are you asking? I'm American Indian. That's what I was taught. We don't talk that much. Bu

Re: refactoring a group of import statements

2010-06-28 Thread rantingrick
On Jun 27, 10:20 pm, GrayShark wrote: > Question: If you can't answer the question, why are you talking? Q: If you can't take advice without complaining, then why are you asking? > I'm American Indian. That's what I was taught. We don't talk that much. > But you get an answer when we do talk. Ma

Re: refactoring a group of import statements

2010-06-27 Thread GrayShark
Thanks for the help Thomas Jollans. Just what I needed. I was wondering what the: __import__(name, globals={}, locals={}, fromlist=[], level=-1) globals was (that was from the docstring on __import__. Odd, the doc on www.python.org has globals as a list, not a dictionary). In any case, I

Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 6:09 pm, Thomas Jollans wrote: > > import Tkinter as tk > > try: > >     import Image #from PIL > >     print 'Using high quality images :)' > > except ImportError: > >     print 'Using low quality images :(' > > As such, that still appears rather useless - the following code doesn't >

Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:48 AM, rantingrick wrote: > On Jun 27, 5:18 pm, Thomas Jollans wrote: >> On 06/28/2010 12:06 AM, GrayShark wrote: >>> I have a large list of package files to import. I'm using a try/except >>> test to verify the import. Looks like: > > > >> (1) Don't. If you need the module, th

Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 5:18 pm, Thomas Jollans wrote: > On 06/28/2010 12:06 AM, GrayShark wrote: > > I have a large list of package files to import. I'm using a try/except > > test to verify the import. Looks like: > (1) Don't. If you need the module, there's no reason to check for > exceptions. Just let t

Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:06 AM, GrayShark wrote: > I have a large list of package files to import. I'm using a try/except > test to verify the import. Looks like: > > try: > import abc > except ImportError: > print( "Error importing abc" ) > > I've got many of those segments. I want to try a

refactoring a group of import statements

2010-06-27 Thread GrayShark
I have a large list of package files to import. I'm using a try/except test to verify the import. Looks like: try: import abc except ImportError: print( "Error importing abc" ) I've got many of those segments. I want to try and refactor this part of the code. Trying: f

Re: Need help in refactoring my python script

2009-08-08 Thread MRAB
n179911 wrote: I have a python script which process a file line by line, if the line matches a regex, it calls a function to handle it. My question is is there a better write to refactor my script. The script works, but as it is, i need to keep indent to the right of the editor as I add more and

  1   2   >