Re: [Python-ideas] AtributeError inside __get__

2016-12-27 Thread Zahari
> So here's a two-part proposal that would solve Zaheri's problem: > > 1) Enhance AttributeError to include arguments for the parts in > quotes, for i18n independence. > 2) Provide, in the docs, a hasattr replacement that checks the exception's > args. > > The new hasattr would look like thi

Re: [Python-ideas] AtributeError inside __get__

2016-12-27 Thread Chris Angelico
On Tue, Dec 27, 2016 at 9:11 PM, Zahari wrote: > This looks like a good idea. Note that there is also getattr(X(), 'y', > 'default') that would have to behave like this. > Forgot about that. Feel free to enhance the hasattr replacement. I still think the parameterization of AttributeError would b

[Python-ideas] Function arguments in tracebacks

2016-12-27 Thread Ammar Askar
Consider the following similar C and Python code and their tracebacks: C --- int divide(int x, int y, char* some_string) { return x / y; } int main(...) { divide(2, 0, "Hello World"); } --- Program received signal SIGFPE, Arithmetic exception. (gdb) bt #0 0x0

[Python-ideas] incremental hashing in __hash__

2016-12-27 Thread jab
Suppose you have implemented an immutable Position type to represent the state of a game played on an MxN board, where the board size can grow quite large. Or suppose you have implemented an immutable, ordered collection type. For example, the collections-extended package provides a frozensetlist[

Re: [Python-ideas] incremental hashing in __hash__

2016-12-27 Thread Ryan Gonzalez
You could always try to make a Python version of the C tuple hashing function[1] (requires the total # of elements) or PyPy's[2] (seems like it would allow true incremental hashing). API idea: hasher = IncrementalHasher() hasher.add(one_item_to_hash) # updates hasher.hash property with result #