Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 25/01/2015 00:28, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 11:18 AM, Brian Gladman wrote: >> Is there a way of doing delegation rather than sub-classing? >> >> That is, can I create a class (say RF) that passes some of its methods >> to Fraction for implementation but always returns an R

Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 25/01/2015 01:31, Terry Reedy wrote: > On 1/24/2015 5:57 PM, Brian Gladman wrote: >> I would appreciate advice on how to set up delgation in Python. >> >> I am continuously implementing a function to test whether a Python >> Fraction is an integer > > Since Fractions are reduced to lowest terms

Re: Hello World in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 6:14 PM, Rustom Mody wrote: > On Sunday, January 25, 2015 at 5:36:02 AM UTC+5:30, Chris Angelico wrote: > >> One thing that I really like doing with my Python students (full >> disclosure: I'm a mentor with www.thinkful.com and am thus at times >> paid to help people learn

Re: Hello World in Python

2015-01-24 Thread Rustom Mody
On Sunday, January 25, 2015 at 5:36:02 AM UTC+5:30, Chris Angelico wrote: > One thing that I really like doing with my Python students (full > disclosure: I'm a mentor with www.thinkful.com and am thus at times > paid to help people learn Python) is some form of screen-sharing, so I > can watch hi

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread ravas
I copied the GUI creation from my personal text editor. The scrollbar and stretchability could have been left out, for sure. You're only seeing a portion of a more complex GUI. After writing several Tkinter applications, I decided that subclassing without a clear reason only had the effect of

Re: Hello World in Python

2015-01-24 Thread Christopher J. Pisz
On 1/24/2015 7:12 PM, Terry Reedy wrote: On 1/24/2015 6:53 PM, Christopher J. Pisz wrote: I am trying to help a buddy out. I am a C++ on Windows guy. This buddy of mine is learning Python at work on a Mac. I figured I could contribute with non language specific questions and such. When learning

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Devin Jeanpierre
On Sat, Jan 24, 2015 at 5:58 PM, Ethan Furman wrote: > On 01/24/2015 11:55 AM, Chris Angelico wrote: >> On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman wrote: >>> If the non-generic is what you're concerned about: >>> >>> # not tested >>> dispatch_table_a = {} >>> dispatch_table_b = {} >>> dispatch

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Steven D'Aprano
Yawar Amin wrote: > Hi Ethan, > > On Saturday, January 24, 2015 at 9:00:12 PM UTC-5, Ethan Furman wrote: >> [...] >> __name__ being one of them. One of the reasons lambda >> is not encouraged is because its name is always '', which just >> ain't helpful when the smelly becomes air borne! ;) >

Re: Benchmarking some modules - strange result

2015-01-24 Thread Steven D'Aprano
Dan Stromberg wrote: > Hi folks. > > I've been benchmarking some python modules that are mostly variations > on the same theme. > > For simplicity, let's say I've been running the suite of performance > tests within a single interpreter - so I test one module thoroughly, > then move on to the ne

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread Rick Johnson
On Saturday, January 24, 2015 at 9:17:57 PM UTC-6, ravas wrote: > We resolved it over at the comp.lang.tcl group. It turns > out what Christian suggested affects what is selected when > you double click a word. He later discovered a different > method for producing what I want. Below is my test cod

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:37 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:36 PM, Dan Stromberg wrote: >> On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: >>> On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: For simplicity, let's say I've been running the suite of perfor

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread ravas
We resolved it over at the comp.lang.tcl group. It turns out what Christian suggested affects what is selected when you double click a word. He later discovered a different method for producing what I want. Below is my test code that implements both of these things (tested with Python 3.4 and PyCh

Re: __bases__ misleading error message

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > But that begs the OT question: How does Python maps names to memory > addresses in the interpreter? It doesn't. You are thinking of an execution model like C or Pascal, where variables are best thought of as fixed memory addresses. But Python, like many modern languages

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread Rick Johnson
On Thursday, January 22, 2015 at 4:26:29 PM UTC-6, Christian Gollwitzer wrote: > Well, it turns out you actually can. We don't have Guido's > time machine, but still there is a configuration option in > Tk, albeit a very obscure one: you have to set the global > Tcl variables tcl_wordchars and tcl

Re: Benchmarking some modules - strange result

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 1:36 PM, Dan Stromberg wrote: > On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: >> On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >>> For simplicity, let's say I've been running the suite of performance >>> tests within a single interpreter - so I test one m

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >> For simplicity, let's say I've been running the suite of performance >> tests within a single interpreter - so I test one module thoroughly, >> then move on to the next without exitin

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Yawar Amin
Hi Ethan, On Saturday, January 24, 2015 at 9:00:12 PM UTC-5, Ethan Furman wrote: > [...] > __name__ being one of them. One of the reasons lambda > is not encouraged is because its name is always '', which just > ain't helpful when the smelly becomes air borne! ;) Doesn't the traceback tell us e

Re: Python is DOOMED! Again!

2015-01-24 Thread Mark Lawrence
On 25/01/2015 01:00, Rick Johnson wrote: On Saturday, January 24, 2015 at 5:56:02 PM UTC-6, Mark Lawrence wrote: For at least the third time the PEP was written by three people, one of whom was the BDFL. Why do you keep insisting that "he" is wrong, surely it should be "they" ? TWO REASONS:

Re: Python is DOOMED! Again!

2015-01-24 Thread Steven D'Aprano
Tim Chase wrote: > On 2015-01-25 04:31, Steven D'Aprano wrote: >> Of course we don't have $1/3 dollar coins, but I do have a pair of >> tin-snips and can easily cut a $1 coin into three equal pieces. > > I'm impressed that you can use tin-snips to cut it into exactly three > equal pieces with gre

Re: Benchmarking some modules - strange result

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: > For simplicity, let's say I've been running the suite of performance > tests within a single interpreter - so I test one module thoroughly, > then move on to the next without exiting the interpreter. > [chomp more details] Do the modules imp

Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
Hi folks. I've been benchmarking some python modules that are mostly variations on the same theme. For simplicity, let's say I've been running the suite of performance tests within a single interpreter - so I test one module thoroughly, then move on to the next without exiting the interpreter. I

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Ethan Furman
On 01/24/2015 11:55 AM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman wrote: >> If the non-generic is what you're concerned about: >> >> # not tested >> dispatch_table_a = {} >> dispatch_table_b = {} >> dispatch_table_c = {} >> >> class dispatch: >> def __init__(self, dis

Re: Delegation in Python

2015-01-24 Thread Terry Reedy
On 1/24/2015 5:57 PM, Brian Gladman wrote: I would appreciate advice on how to set up delgation in Python. I am continuously implementing a function to test whether a Python Fraction is an integer Since Fractions are reduced to lowest terms, >>> from fractions import Fraction as F >>> F(4, 2)

Re: Python simple Code

2015-01-24 Thread Terry Reedy
On 1/24/2015 7:16 PM, Salem Alqahtani wrote: Hi Guys, I just joined the group and I hope that I can help and be active. I have a question about python. I wrote a code on python 2.7 and I want to choose from the list of names that I provide n!. I execute the code but the result or output is th

Re: Hello World in Python

2015-01-24 Thread Terry Reedy
On 1/24/2015 6:53 PM, Christopher J. Pisz wrote: I am trying to help a buddy out. I am a C++ on Windows guy. This buddy of mine is learning Python at work on a Mac. I figured I could contribute with non language specific questions and such. When learning any new language, I said, the first step

Re: Python is DOOMED! Again!

2015-01-24 Thread Rick Johnson
On Saturday, January 24, 2015 at 5:56:02 PM UTC-6, Mark Lawrence wrote: > For at least the third time the PEP was written by three > people, one of whom was the BDFL. Why do you keep > insisting that "he" is wrong, surely it should be "they" ? TWO REASONS: (1) I don't know either of those peop

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:51 PM, Marco Buttu wrote: On 24/01/2015 20:24, Terry Reedy wrote: On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last

Re: Python simple Code

2015-01-24 Thread Denis McMahon
On Sat, 24 Jan 2015 16:16:16 -0800, Salem Alqahtani wrote: > import sys > import array > a=['salem','Ali','sultan'] > m = len(a) > def Factorials(m): > if m == 0: > return 1 > else: > print m > return m * Factorials(m-1) > def output(): > print a > def main(

Re: Delegation in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 11:18 AM, Brian Gladman wrote: > Is there a way of doing delegation rather than sub-classing? > > That is, can I create a class (say RF) that passes some of its methods > to Fraction for implementation but always returns an RF? Hmm. The key here is that you want more than

Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 24/01/2015 23:43, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 10:38 AM, Brian Gladman wrote: >> On 24/01/2015 23:22, Chris Angelico wrote: >>> class RF(Fraction): >>> def is_integer(self): >>>return self.numerator % self.denominator == 0 >> >> Thanks for your help on this. I mu

Python simple Code

2015-01-24 Thread Salem Alqahtani
Hi Guys, I just joined the group and I hope that I can help and be active. I have a question about python. I wrote a code on python 2.7 and I want to choose from the list of names that I provide n!. I execute the code but the result or output is the numbers. I want the people names are the resu

Re: Delegation in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 10:59 AM, Mark Lawrence wrote: >> You can always "monkey-path" the Fraction class on the fly to add a new >> method to it. I think most would consider this a bad idea, but it does >> work. > > As regards this being a bad idea I'd suggest the latest score is > Practicality

Re: Hello World in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 10:53 AM, Christopher J. Pisz wrote: > So my buddy creates opens the IDE they gave at the workplace, creates a new > project, adds a demo.py file, writes one line : print "Hello World", hits > Run in the IDE and indeed the display is shown at the bottom when it > executes.

Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 24/01/2015 23:47, Gary Herron wrote: > On 01/24/2015 03:38 PM, Brian Gladman wrote: >> On 24/01/2015 23:22, Chris Angelico wrote: >>> class RF(Fraction): >>> def is_integer(self): >>> return self.numerator % self.denominator == 0 >> Thanks for your help on this. I must admit that n

Re: Delegation in Python

2015-01-24 Thread Mark Lawrence
On 24/01/2015 23:41, Gary Herron wrote: On 01/24/2015 03:22 PM, Chris Angelico wrote: On Sun, Jan 25, 2015 at 9:57 AM, Brian Gladman wrote: But I am not clear on how to delegate from my new class to the existing Fraction class. This is what I have: -- class RF(Fractio

Hello World in Python

2015-01-24 Thread Christopher J. Pisz
I am trying to help a buddy out. I am a C++ on Windows guy. This buddy of mine is learning Python at work on a Mac. I figured I could contribute with non language specific questions and such. When learning any new language, I said, the first step would be a Hello World program. Let's see if we

Re: Python is DOOMED! Again!

2015-01-24 Thread Mark Lawrence
On 24/01/2015 23:20, Rick Johnson wrote: On Saturday, January 24, 2015 at 1:49:08 AM UTC-6, Steven D'Aprano wrote: Rick Johnson wrote: [... snip absurdities...] Duh! Do you think i just pulled stub files out my arse without giving all the other alternatives due consideration? Actually, yes.

Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 24/01/2015 23:41, Gary Herron wrote: [snip]> > You can always "monkey-path" the Fraction class on the fly to add a new > method to it. I think most would consider this a bad idea, but it does > work. > Try this: > from fractions import Fraction def is_integer(self): > ... return

Re: Delegation in Python

2015-01-24 Thread Gary Herron
On 01/24/2015 03:38 PM, Brian Gladman wrote: On 24/01/2015 23:22, Chris Angelico wrote: class RF(Fraction): def is_integer(self): return self.numerator % self.denominator == 0 Thanks for your help on this. I must admit that nowhere in a lot of searching did I find that delegation

Re: Python is DOOMED! Again!

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 10:39 AM, Mario Figueiredo wrote: > In article , > ros...@gmail.com says... >> >> On Sun, Jan 25, 2015 at 10:20 AM, Rick Johnson >> wrote: >> > Besides, why does he need *ME* to lick his boots when he >> > already has plenty of fan-boys over at python-ideas and >> > python

Re: Delegation in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 10:38 AM, Brian Gladman wrote: > On 24/01/2015 23:22, Chris Angelico wrote: >> class RF(Fraction): >> def is_integer(self): >>return self.numerator % self.denominator == 0 > > Thanks for your help on this. I must admit that nowhere in a lot of > searching did I

Re: Python is DOOMED! Again!

2015-01-24 Thread Mario Figueiredo
In article , ros...@gmail.com says... > > On Sun, Jan 25, 2015 at 10:20 AM, Rick Johnson > wrote: > > Besides, why does he need *ME* to lick his boots when he > > already has plenty of fan-boys over at python-ideas and > > python-dev lining up. This community is *NOT*, and should > > never be, a

Re: Delegation in Python

2015-01-24 Thread Gary Herron
On 01/24/2015 03:22 PM, Chris Angelico wrote: On Sun, Jan 25, 2015 at 9:57 AM, Brian Gladman wrote: But I am not clear on how to delegate from my new class to the existing Fraction class. This is what I have: -- class RF(Fraction): def __new__(self, x, y): sup

Re: Delegation in Python

2015-01-24 Thread Brian Gladman
On 24/01/2015 23:22, Chris Angelico wrote: > class RF(Fraction): > def is_integer(self): >return self.numerator % self.denominator == 0 Thanks for your help on this. I must admit that nowhere in a lot of searching did I find that delegation is achieved by doing nothing! Brian -

Re: Python is DOOMED! Again!

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 10:20 AM, Rick Johnson wrote: > Besides, why does he need *ME* to lick his boots when he > already has plenty of fan-boys over at python-ideas and > python-dev lining up. This community is *NOT*, and should > never be, a homogeneous block -- for we would be doing > ourselve

Re: Python is DOOMED! Again!

2015-01-24 Thread Rick Johnson
On Saturday, January 24, 2015 at 1:49:08 AM UTC-6, Steven D'Aprano wrote: > Rick Johnson wrote: > > [... snip absurdities...] > > > Duh! Do you think i just pulled stub files out my arse > > without giving all the other alternatives due consideration? > > Actually, yes. I think that had Guido pr

Re: Delegation in Python

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 9:57 AM, Brian Gladman wrote: > But I am not clear on how to delegate from my new class to the existing > Fraction class. This is what I have: > > -- > class RF(Fraction): > > def __new__(self, x, y): > super().__new__(self, x, y) > > def is

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Yawar Amin
Hi, On Saturday, January 24, 2015 at 3:36:04 PM UTC-5, Devin Jeanpierre wrote: > [...] > Obviously, nobody will be happy until you can do: > > def call(*a, **kw): return lambda f: f(*a, **kw) > > @call() > def x, y (): > yield 1 > yield 2 > > Actually, maybe not even then. You're proba

Delegation in Python

2015-01-24 Thread Brian Gladman
I would appreciate advice on how to set up delgation in Python. I am continuously implementing a function to test whether a Python Fraction is an integer so I wanted to define a new class, based on Fraction, that includes this new method. But I am not clear on how to delegate from my new class to

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ros...@gmail.com says... > Awesome! I'm always a bit wary of analogies... sometimes they're > really helpful, other times they're unhelpful and confusing. Yeah. Your's was all it took :) The thing with analogies is to never take them literally. They are analogies, after all. But th

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ian.g.ke...@gmail.com says... > > No, you're being told that the *object* doesn't know the names of the > variables that it's bound to. In the context above, the variable is > right there under that name in the globals dict, as can be seen in the > disassembly: [snipped] Yes. I got

Re: __bases__ misleading error message

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 9:33 AM, Mario Figueiredo wrote: > In article , > ros...@gmail.com says... >> >> Let me explain by way of analogy. > [snipped] > > Gotcha! Thanks for the explanation :) Awesome! I'm always a bit wary of analogies... sometimes they're really helpful, other times they're unh

Re: Python is DOOMED! Again!

2015-01-24 Thread Mario Figueiredo
In article <54c2299d$0$13005$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > I don't think that a raise of 0.10001 (10%), > 0.035003 (3.5%) or 0.070007 (7%) is quite what > people intended. > > (Don't use binary floating p

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ros...@gmail.com says... > > Let me explain by way of analogy. [snipped] Gotcha! Thanks for the explanation :) -- https://mail.python.org/mailman/listinfo/python-list

Re: __bases__ misleading error message

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 9:09 AM, Mario Figueiredo wrote: > Meaning the interpreter knows a variable's name. Which would allow it to > produce an error message such as: > > AttributeError: 'foo' object has no attribute '__bases__' > > For the following code: > > class Sub: > pass >

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 3:02 PM, Mario Figueiredo wrote: > In article , > tjre...@udel.edu says... >> >> > "__main__" >> > from module import a_name >> >> A module is a namespace associating names with objects. This statememt >> says to import the a_name to object association from modul

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ian.g.ke...@gmail.com says... > > On Sat, Jan 24, 2015 at 2:14 PM, Mario Figueiredo wrote: > > But that begs the OT question: > > No, it doesnt. http://en.wikipedia.org/wiki/Begging_the_question Cute. > I'm not sure I'm understanding what you're asking, but the import > statement

Re: __bases__ misleading error message

2015-01-24 Thread Marco Buttu
On 24/01/2015 13:43, Steven D'Aprano wrote: Mario Figueiredo wrote: > class Sub: > pass > > foo = Sub() > > Sub.__bases__ > foo.__bases__ > >The last statement originates the following error: > > AttributeError: 'Sub' object has no attribute

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , tjre...@udel.edu says... > > > "__main__" > > from module import a_name > > A module is a namespace associating names with objects. This statememt > says to import the a_name to object association from module and add it > to __main__ > > > y = a_name + 1 > > This

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:14 PM, Mario Figueiredo wrote: In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... AttributeError: 'Sub' instance has no attribute '__bases__', AttributeError: 'foo' object has no attribute '__bases__'

Re: Python is DOOMED! Again!

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 2:14 PM, alister wrote: >> >> Either that, or make up change with 20¢, 10¢ and 5¢ (we practice >> round-to-nearest-5-cents here). > > I suppose if you all pay 35¢ it at least gives the waitress a tip. """ In the Pacific States they have made a bolder push for complexity,

Re: __bases__ misleading error message

2015-01-24 Thread Marco Buttu
On 24/01/2015 20:24, Terry Reedy wrote: On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error:

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 2:14 PM, Mario Figueiredo wrote: > In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> > AttributeError: 'Sub' instance has no attribute '__bases__', >> > AttributeError: 'foo' object has no att

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Christian Gollwitzer
Am 23.01.15 um 20:23 schrieb Rick Johnson: > On Thursday, January 22, 2015 at 9:22:40 PM UTC-6, Terry Reedy wrote: >> that it is already an option in mypy and is part of the new >> type-hint proposal. > > An *OPTION*? If it is not mandatory then why bother? If > authors have a choice between writi

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > AttributeError: 'Sub' instance has no attribute '__bases__', > > AttributeError: 'foo' object has no attribute '__bases__' > > The first would be nice. The second is

Re: Python is DOOMED! Again!

2015-01-24 Thread alister
> > Of course we don't have $1/3 dollar coins, but I do have a pair of > tin-snips and can easily cut a $1 coin into three equal pieces. wow you have just given a physical demonstration of integer Maths $1 /3 =$0 as the coin is now worthless ;-) > > Either that, or make up change with 20¢, 10¢ a

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , tjre...@udel.edu says... > > AttributeError: 'Sub' object has no attribute '__bases__' > > In this message, 'Sub' is an adjective, modifying 'object, not naming > it. If you attend to the last line of the traceback > My first reaction is to look at 'Sub' as a noun, not an

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Fetchinson .
On 1/24/15, Steven D'Aprano wrote: > Fetchinson . wrote: > >> On 1/23/15, Steven D'Aprano wrote: > [...] >>> Cobra is especially close to Python-like syntax, and supports unit tests >>> as well: >>> >>> >>> def sqroot(i as int) as float >>> require >>>i > 0 >>> ens

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread MRAB
On 2015-01-24 19:55, Chris Angelico wrote: On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman wrote: If the non-generic is what you're concerned about: # not tested dispatch_table_a = {} dispatch_table_b = {} dispatch_table_c = {} class dispatch: def __init__(self, dispatch_table): self.disp

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Devin Jeanpierre
On Sat, Jan 24, 2015 at 11:55 AM, Chris Angelico wrote: > That's still only able to assign to a key of a dictionary, using the > function name. There's no way to represent fully arbitrary assignment > in Python - normally, you can assign to a name, an attribute, a > subscripted item, etc. (Augment

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 4:37 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> versus any other decorator, but the STRING: >> "@typehint(...)" >> being used where a decorator would normally be expected. > > I didn't catch that either. I think if hints are to go in decorators, > then it's best t

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman wrote: > If the non-generic is what you're concerned about: > > # not tested > dispatch_table_a = {} > dispatch_table_b = {} > dispatch_table_c = {} > > class dispatch: > def __init__(self, dispatch_table): > self.dispatch = dispatch_table > de

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error: This is an anomalous situation. Normall

Re: Python is DOOMED! Again!

2015-01-24 Thread Rustom Mody
On Sunday, January 25, 2015 at 12:15:28 AM UTC+5:30, Tim Chase wrote: > On 2015-01-25 04:31, Steven D'Aprano wrote: > > Of course we don't have $1/3 dollar coins, but I do have a pair of > > tin-snips and can easily cut a $1 coin into three equal pieces. > > I'm impressed that you can use tin-snip

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Ethan Furman
On 01/23/2015 10:28 PM, Chris Angelico wrote: > > cmd = {} > def command(func): > cmd[func.__name__] = func > return func > > @command > def foo(*args): > print("You asked to foo.") > > but this is hardly generic. There's no convenient way to give an > argument to a decorator that sa

Re: Python is DOOMED! Again!

2015-01-24 Thread Tim Chase
On 2015-01-25 04:31, Steven D'Aprano wrote: > Of course we don't have $1/3 dollar coins, but I do have a pair of > tin-snips and can easily cut a $1 coin into three equal pieces. I'm impressed that you can use tin-snips to cut it into exactly three equal pieces with greater precision than the floa

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Paul Rubin
Steven D'Aprano writes: > versus any other decorator, but the STRING: > "@typehint(...)" > being used where a decorator would normally be expected. I didn't catch that either. I think if hints are to go in decorators, then it's best to extend the decorator mechanism to allow arbitrary syntax, e.

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Mark Lawrence
On 24/01/2015 17:26, Steven D'Aprano wrote: Rick Johnson wrote: On Saturday, January 24, 2015 at 7:30:02 AM UTC-6, Steven D'Aprano wrote: [...] It requires extra complexity to the parser, so that decorators may be separated from the function by a hint: @decorate "@typehint: (str, int) -> bool

Re: Python is DOOMED! Again!

2015-01-24 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Jan 25, 2015 at 3:00 AM, Steven D'Aprano > wrote: >> Mark Lawrence wrote: >> >>> On 24/01/2015 06:35, Steven D'Aprano wrote: Obviously I'm not a fanatic. If I'm working out my share of a $37 meal split three ways, I just do 37/3 the same as anyone else :-

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Steven D'Aprano
Rick Johnson wrote: > On Saturday, January 24, 2015 at 7:30:02 AM UTC-6, Steven D'Aprano wrote: >> [...] It requires extra complexity to the parser, so that >> decorators may be separated from the function by a hint: >> >> @decorate >> "@typehint: (str, int) -> bool" >> def myfunction(arg1, arg2)

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Rick Johnson
On Saturday, January 24, 2015 at 7:30:02 AM UTC-6, Steven D'Aprano wrote: > [...] It requires extra complexity to the parser, so that > decorators may be separated from the function by a hint: > > @decorate > "@typehint: (str, int) -> bool" > def myfunction(arg1, arg2): > > No doubt some people w

pysftp connection not sending files, hanging on 'put'

2015-01-24 Thread Jules Stevenson
Hi List, I'm trying to send some files via pysftp, authentication seems fine, but actually putting the file results in it hanging, doing nothing. The files are small (<200kb) so I don't believe it's an upload issue (internet access is fine). Eventually the connection times out. Code: if os.listd

Re: Python is DOOMED! Again!

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 3:00 AM, Steven D'Aprano wrote: > Mark Lawrence wrote: > >> On 24/01/2015 06:35, Steven D'Aprano wrote: >>> Obviously I'm not a fanatic. If I'm working out my share of a $37 meal >>> split three ways, I just do 37/3 the same as anyone else :-) >>> >> >> Always rounding down

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article <54c39e48$0$12996$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> I'm not sure if you're making a general observation or one which is >> specific >> to Python. Plenty of languages have static analysis as a language >>

Re: Python is DOOMED! Again!

2015-01-24 Thread Steven D'Aprano
Mark Lawrence wrote: > On 24/01/2015 06:35, Steven D'Aprano wrote: >> Obviously I'm not a fanatic. If I'm working out my share of a $37 meal >> split three ways, I just do 37/3 the same as anyone else :-) >> > > Always rounding down I take it? :) I'm hurt. I have a maths degree, I know how to do

ANN: Version 0.1.4 of sarge (a subprocess wrapper library) has been released.

2015-01-24 Thread Vinay Sajip
Version 0.1.4 of Sarge, a cross-platform library which wraps the subprocess module in the standard library, has been released. What changed? - - Fixed issue #20: Now runs a pipeline in a separate thread if async. - Fixed issue #21: The command line isn't parsed if shell=True is speci

Re: Python is DOOMED! Again!

2015-01-24 Thread Mark Lawrence
On 24/01/2015 06:35, Steven D'Aprano wrote: Obviously I'm not a fanatic. If I'm working out my share of a $37 meal split three ways, I just do 37/3 the same as anyone else :-) Always rounding down I take it? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you c

Re: Python is DOOMED! Again!

2015-01-24 Thread Mark Lawrence
On 24/01/2015 01:15, Chris Angelico wrote: On Sat, Jan 24, 2015 at 12:00 PM, Sturla Molden wrote: But without a thriving community, Python has no value to me. If we add type hinting, then that community will go away, because other languages are better options. Who will win? Julia? Ruby? They

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Mario Figueiredo
In article , mar...@gmail.com says... > > In article <54c39e48$0$12996$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... > > > > def myfunction(arg1, arg2): > > """ > > Normal docstring. > > @typehint: (str, int) -> bool""" > > return True > >

Re: What killed Smalltalk could kill Python

2015-01-24 Thread Bob Martin
in 734949 20150124 113420 Gene Heskett wrote: >On Saturday 24 January 2015 03:09:51 Bob Martin did opine >And Gene did reply: >> in 734904 20150123 225104 Tim Daneliuk wrote: >> >On 01/21/2015 05:55 PM, Chris Angelico wrote: >> >> On Thu, Jan 22, 2015 at 10:37 A

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Mario Figueiredo
In article <54c39e48$0$12996$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > I'm not sure if you're making a general observation or one which is > specific > to Python. Plenty of languages have static analysis as a language feature. > Are you arguing they are

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Roy Smith
In article <54c3a0c1$0$13013$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Tim Chase wrote: > > > On 2015-01-24 17:21, Steven D'Aprano wrote: > >> # Cobra > >> def sqroot(i as int) as float > >> > >> # Python > >> def sqroot(i:int)->float: > >> > >> > >> Cobra's use of "as" c

Re: What killed Smalltalk could kill Python

2015-01-24 Thread Bob Martin
in 734937 20150124 081658 Chris Angelico wrote: >On Sat, Jan 24, 2015 at 7:09 PM, Bob Martin wrote: >> http://www.oorexx.org/ >> >> I use ooRexx every day, on Linux mostly, but also available on Windows. > >So the question really is: Why that, as opposed to some other

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Steven D'Aprano
Tim Chase wrote: > On 2015-01-24 17:21, Steven D'Aprano wrote: >> # Cobra >> def sqroot(i as int) as float >> >> # Python >> def sqroot(i:int)->float: >> >> >> Cobra's use of "as" clashes with Python. In Python, "as" is used for >> name-binding: >> >> import module as name >> with open('file')

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article <4b3b498a-c9b0-443d-8514-87ccd8e98...@googlegroups.com>, > rantingrickjohn...@gmail.com says... >> >> (Example modified for PEP8 compliance ;-) >> >> @typehint(arg1:str, arg2:int, returns:bool) >> def myfunction(arg1, arg2): >> return True

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Tim Chase
On 2015-01-24 17:21, Steven D'Aprano wrote: > # Cobra > def sqroot(i as int) as float > > # Python > def sqroot(i:int)->float: > > > Cobra's use of "as" clashes with Python. In Python, "as" is used for > name-binding: > > import module as name > with open('file') as f > except Exception as e >

Re: __bases__ misleading error message

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > > Consider the following code at your REPL of choice > > class Super: > pass Super is irrelevant here, since it isn't used. > class Sub: > pass > > foo = Sub() > > Sub.__bases__ > foo.__bases__ > > The

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Tim Chase
On 2015-01-24 17:28, Chris Angelico wrote: > but this is hardly generic. There's no convenient way to give an > argument to a decorator that says "please assign this here", short > of using some stupid eval hack... is there? > > (Incidentally, for a non-generic dispatch table, a callable dict > su

Re: What killed Smalltalk could kill Python

2015-01-24 Thread Gene Heskett
On Saturday 24 January 2015 03:09:51 Bob Martin did opine And Gene did reply: > in 734904 20150123 225104 Tim Daneliuk wrote: > >On 01/21/2015 05:55 PM, Chris Angelico wrote: > >> On Thu, Jan 22, 2015 at 10:37 AM, Tim Daneliuk wrote: > >>> I find these kinds of discussions sort of silly. Once t

OpenCv: different behavior of cv2.imread and cv2.imdecode

2015-01-24 Thread maurog
The starting point is an invalid jpg file, grabbed from a site showing pictures from a webcam while the site is updating the picture itself. So the upper part of the picture is ok, the lower part no. If I execute this code flags = cv2.CV_LOAD_IMAGE_COLOR img = cv2.imread('bad.jpg', flags) this

  1   2   >