First, I apologize for the poor post. Your corrections were exactly
correct: This is only relevant in the context of properties/descriptors,
and the property swallows the error message and it isn't printed to
screen. I should not be typing without testing.
> So... what precisely should be passed
On Tue, Jun 20, 2017 at 12:26 PM, Steven D'Aprano wrote:
> On Tue, Jun 20, 2017 at 11:31:34AM +1000, Chris Angelico wrote:
>
>> Why not just write cross-version-compatible code as
>>
>> def __getattr__(self, name, error=None):
>>
>> ? Is there something special about getattr?
On 06/19/2017 07:26 PM, Steven D'Aprano wrote:
Or maybe we decide that it's actually a feature, not a problem, for an
AttributeError inside self.attr.__get__ to look like self.attr is
missing.
It's a feature. It's why Enum classes can have members named 'value' and
'name'.
--
~Ethan~
On Tue, Jun 20, 2017 at 11:31:34AM +1000, Chris Angelico wrote:
> Why not just write cross-version-compatible code as
>
> def __getattr__(self, name, error=None):
>
> ? Is there something special about getattr?
You've still got to write it in the first place. That's a pain,
especially since
On 06/19/2017 06:31 PM, Chris Angelico wrote:
On Tue, Jun 20, 2017 at 10:18 AM, Steven D'Aprano wrote:
Having said that, there's another problem: adding this feature (whatever
it actually is) to __getattr__ will break every existing class that uses
__getattr__. The problem
Namedtuple in Python make startup time slow.
So I'm very conservative to convert tuple to namedtuple in Python.
INADA Naoki
On Tue, Jun 20, 2017 at 7:27 AM, Victor Stinner
wrote:
> Oh, about the cost of writing C code, we started to enhance
On Tue, Jun 20, 2017 at 10:18 AM, Steven D'Aprano wrote:
> Apparently you heavily use properties, and __getattr__, and find that
> the two don't interact well together when the property getters and
> setters themselves raise AttributeError. I think that's relevant
>
On Mon, Jun 19, 2017 at 04:06:56PM -0500, Jason Maldonis wrote:
> Hi everyone,
>
> A while back I had a conversation with some folks over on python-list. I
> was having issues implementing error handling of `AttributeError`s using
> `__getattr__`.
[...]
> For example, we cannot tell the
On 19/06/17 02:47, David Mertz wrote:
As an only semi-joke, I have created a module on GH that meets the needs
of this discussion (using the spelling I think are most elegant):
https://github.com/DavidMertz/RLE
It's a shame you have to build that list when encoding. I tried to work
out a
Oh, about the cost of writing C code, we started to enhance the socket
module in socket.py but keep the C code unchanged. I am thinking to the
support of enums. Some C functions are wrapped in Python.
Victor
Le 19 juin 2017 11:59 PM, "Guido van Rossum" a écrit :
> There are
There are examples in timemodule.c which went through a similar conversion
from plain tuples to (sort-of) named tuples. I agree that upgrading the
tuples returned by the socket module to named tuples would be nice, but
it's a low priority project. Maybe someone interested can create a PR?
(First
Hi,
2017-06-13 22:13 GMT+02:00 Thomas Güttler :
> AFAIK the socket module returns plain tuples in Python3:
>
> https://docs.python.org/3/library/socket.html
>
> Why not use named tuples?
For technical reasons: the socket module is mostly implemented in the
C
+1 ;-)
for example to get IP address of all interfaces we have to use the third
(indexed as 2) member of "something" it is much more beatiful to get
ip_address:
*import *socket
*for *ip *in *socket.gethostbyname_ex(socket.gethostname())[2]:
print(ip)
BR,
George
2017-06-13 22:13 GMT+02:00
Hi everyone,
A while back I had a conversation with some folks over on python-list. I
was having issues implementing error handling of `AttributeError`s using
`__getattr__`.
My problem is that it is currently impossible for a `__getattr__` in Python
to know which method raised the
On 19 June 2017 at 04:10, Barry Scott wrote:
> The code does this:
>
> Py::Object getattro( const Py::String _ )
> {
> std::string name( name_.as_std_string( "utf-8" ) );
>
> if( name == "value" )
> {
> return m_value;
>
On 19 June 2017 at 04:47, Mahmoud Hashemi wrote:
> Barry, that kind of circular import is actually fine in many (if not most)
> cases. Modules are immediately created and importable, thenincrementally
> populated. The problem arises when you try to do something with contents
On 2017-06-18 20:10, Barry Scott wrote:
> What is the way to tell python about 'value' in the python3 world?
Implement a __dir__ method. This should call the superclass' (e.g.
object's) __dir__ and add whatever it is you want to add to the list.
In general I'd recommend using properties for
17 matches
Mail list logo