Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread jfong
Sibylle Koczian於 2019年10月20日星期日 UTC+8上午2時04分54秒寫道: > Am 19.10.2019 um 13:11 schrieb jf...@ms4.hinet.net: > > For the two examples below: > > (1) > class A: > > ... def foo(self): > > ... self.goo() > > ... > class B(A): > > ... def goo(self): > > ... print(1) > > .

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread Ian Hobson
Hi Jach, On 20/10/2019 09:34, jf...@ms4.hinet.net wrote: What puzzles me is how a parent's method foo() can find its child's method goo(), no matter it was overwrote or not? MRO won't explain this and I can't find document about it also:-( This is a generalised description - Python may be sl

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread Chris Angelico
On Sun, Oct 20, 2019 at 9:06 PM Ian Hobson wrote: > > Hi Jach, > > On 20/10/2019 09:34, jf...@ms4.hinet.net wrote: > > What puzzles me is how a parent's method foo() can find its child's method > > goo(), no matter it was overwrote or not? MRO won't explain this and I > > can't find document abo

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread Richard Damon
On 10/20/19 4:34 AM, jf...@ms4.hinet.net wrote: > Yes, there will be an attribute error if no goo() was defined. > > What puzzles me is how a parent's method foo() can find its child's method > goo(), no matter it was overwrote or not? MRO won't explain this and I can't > find document about it

Re: keying by identity in dict and set

2019-10-20 Thread Steve White
Hi Chris, Yes, I am aware of the hash of small integers. But I am not keying with small integers here: I am keying with id() values of class instances. Precisely what my example shows is that the dict/set algorithms in fact *never* call __eq__, when the id() of a class instance is returned by __

Re: keying by identity in dict and set

2019-10-20 Thread Peter Otten
Steve White wrote: > Hi Chris, > > Yes, I am aware of the hash of small integers. But I am not keying > with small integers here: I am keying with id() values of class > instances. The id() values /are/ smallish integers though. (I would guess that this is baked into the CPython source, but di

tri.token compared to Enum

2019-10-20 Thread Ethan Furman
On 10/20/2019 04:16 AM, Anders Hovmöller wrote: On 20 Oct 2019, at 12:41, Steve Jorgensen wrote: Anders Hovmöller wrote: We try to do the same thing in various libraries. We've settled on using existing python and end up with syntax like: class MyForm(Form): field = Field() or in your

Re: keying by identity in dict and set

2019-10-20 Thread Steve White
Hi Peter, Yes you are right. In fact, I shouldn't even have mentioned the hash() function... it came from a line of reasoning about what an implementation might do if very large integers were returned by __hash__(), and some remarks about the value returned by id() applied to small integers. The

Re: keying by identity in dict and set

2019-10-20 Thread Peter Otten
Steve White wrote: > Hi Peter, > > Yes you are right. In fact, I shouldn't even have mentioned the > hash() function... it came from a line of reasoning about what an > implementation might do if very large integers were returned by > __hash__(), and some remarks about the value returned by id()

Re: keying by identity in dict and set

2019-10-20 Thread Steve White
On Sun, Oct 20, 2019 at 7:57 PM Peter Otten <__pete...@web.de> wrote: > > Steve White wrote: > > > > The point is, I don't think __eq__() is ever called in a situation as > > described in my post, yet the Python documentation states that if > > instances are to be used as keys, it must not be used

Re: keying by identity in dict and set

2019-10-20 Thread Chris Angelico
On Mon, Oct 21, 2019 at 4:33 AM Steve White wrote: > The options for following the documentation in this situation are: > either subject users to unfamiliar, custom-made container classes, or > give up the semantics of the "==" operator. > > It seems so unnecessary, given (my understanding of) how

Re: keying by identity in dict and set

2019-10-20 Thread Peter Otten
Steve White wrote: > On Sun, Oct 20, 2019 at 7:57 PM Peter Otten <__pete...@web.de> wrote: >> >> Steve White wrote: >> > >> > The point is, I don't think __eq__() is ever called in a situation as >> > described in my post, yet the Python documentation states that if >> > instances are to be used a

Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-20 Thread Piet van Oostrum
doganad...@gmail.com writes: > > In the meanwhile I have checked Scala , and it's more limited then Python. > As an example: > 0.0001 > 1.0E-4: Double > Why do you think this means Scala is more limited than Python? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4]

Fwd: keying by identity in dict and set

2019-10-20 Thread Steve White
-- Forwarded message - From: Steve White Date: Sun, Oct 20, 2019 at 11:38 PM Subject: Re: keying by identity in dict and set To: Peter Otten <__pete...@web.de> Hi Peter, Thanks, that does seem to indicate something. (But there was no need to define a class... you're basically sa

[ANN] Austin -- CPython frame stack sampler v1.0.0 is now available

2019-10-20 Thread Gabriele
I am delighted to announce the release 1.0.0 of Austin. If you haven't heard of Austin before, it is a frame stack sampler for CPython. It can be used to obtain statistical profiling data out of a running Python application without a single line of instrumentation. This means that you can start

Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-20 Thread doganadres
my statement may seem unlogical while evaluating and comparing the languages as a whole.. I thought when I give a small number into the programme , the more decimals I can see after the dot as an output, the more human readable it is. when I see a bunch of numbers with 'e' s I know the number

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread jfong
Ian Hobson於 2019年10月20日星期日 UTC+8下午6時05分11秒寫道: > Hi Jach, > > On 20/10/2019 09:34, jf...@ms4.hinet.net wrote: > > What puzzles me is how a parent's method foo() can find its child's method > > goo(), no matter it was overwrote or not? MRO won't explain this and I > > can't find document about it

Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-20 Thread Joel Goldstick
On Sun, Oct 20, 2019 at 6:06 PM wrote: > > > my statement may seem unlogical while evaluating and comparing the languages > as a whole.. > > I thought when I give a small number into the programme , the more decimals I > can see after the dot as an output, the more human readable it is. > > when

In praise of triple-quoted strings

2019-10-20 Thread Chris Angelico
Python's triple-quoted multiline string is a wonderful feature. It vastly simplifies the writing of polyglot scripts (where the same file contains multiple different languages of code in it), hiding any non-Python code inside a triple quoted string. Had need of a Makefile+Python setup today... (No