descriptor Questions
3
Solved
I'm aware that a property is a descriptor, but are there specific examples of when using a descriptor class might be more advantageous, pythonic, or provide some benefit over using @property on a m...
Rustproof asked 30/4, 2011 at 15:3
1
I am using descriptors to define the registers of an interface class:
class Register(object):
def __init__(self, address, docstring="instance docstring"):
self.address = address
self.__doc__ =...
Papilloma asked 16/5, 2016 at 13:28
7
Solved
How to call a property of the base class if this property is being overwritten in the derived class?
I'm changing some classes of mine from an extensive use of getters and setters to a more pythonic use of properties.
But now I'm stuck because some of my previous getters or setters would call the...
Gilpin asked 20/6, 2009 at 11:37
3
Solved
This article describes how Python looks up an attribute on an object when it executes o.a. The priority order is interesting - it looks for:
A class attribute that is a data-descriptor (most comm...
Individually asked 16/12, 2018 at 10:36
3
Solved
I can write a descriptor returning a future which could be awaited on.
class AsyncDescriptor:
def __get__(self, obj, cls=None):
# generate some async future here
return future
def __set__(sel...
Cellophane asked 11/9, 2016 at 16:18
2
Solved
Currently I have a generalized function where you can pass in an attribute name and a class (it would also work with specific object instances, but I am using classes), and the function will look u...
Vasquez asked 26/7, 2013 at 20:48
3
Solved
To the question:
Why can't descriptors be instance attributes?
it has been answered that:
descriptor objects needs to live in the class, not in the instance
because that is the way that t...
Awed asked 26/9, 2012 at 10:45
1
Solved
Let's say I load inception, and I need to extract the final descriptor just before classification.
So given a simple code like this:
cnn = InceptionV3(weights='imagenet',
include_top='False',
...
Mariselamarish asked 24/2, 2018 at 18:33
4
Solved
I've started to use the python descriptor protocol more extensively in the code I've been writing. Typically, the default python lookup magic is what I want to happen, but sometimes I'm finding I w...
Pentahedron asked 27/10, 2009 at 0:38
4
Solved
I have about 20 methods to redirect to a wrapper method that takes the original method, and the rest of the arguments:
class my_socket(parent):
def _in(self, method, *args, **kwargs):
# do funk...
Skipbomb asked 29/11, 2011 at 8:10
3
Solved
I want to be able use python descriptors in a class which has the slots optimization:
class C(object):
__slots__ = ['a']
a = MyDescriptor('a')
def __init__(self, val):
self.a = val
The prob...
Pummel asked 6/2, 2011 at 9:15
2
My CoreBluetooth application need to enable the "indication bit" in Client Characteristic Configuration descriptors. Here is what I did:
Start to scan
Start to connect to the device
Call discover...
Banded asked 26/11, 2012 at 8:31
2
Solved
Recently I have been learning about managed attributes in Python and a common theme with properties and descriptors is, that they have to be assigned as class attributes. But nowhere can I find an ...
Gourmont asked 31/3, 2017 at 18:56
1
I'm reading up on responsive images in HTML5 and have a question.
When would you use the x-descriptor? If for example you have different resolution versions of the same image why would you ever no...
Rosalinarosalind asked 8/6, 2016 at 17:39
4
Solved
I need to concurrently read from a file in different offsets using C.
dup unforunately creates a file descriptor that shares offset and flags with the original.
Is there a function like dup that d...
Dragonet asked 23/2, 2017 at 20:53
1
Solved
In the Python 2.7 documentation on Descriptors in the Introduction the phrase binding behavior is used.
In general, a descriptor is an object attribute with “binding behavior”, one whose attrib...
Erechtheum asked 8/3, 2016 at 22:32
2
Solved
The descriptor protocol works fine but I still have one issue I would like to resolve.
I have a descriptor:
class Field(object):
def __init__(self, type_, name, value=None, required=False):
sel...
Vamp asked 3/2, 2017 at 12:2
7
Solved
We have a Java Spring MVC based project using Eclipse (Juno - the latest build), using the latest JVM 1.7 and Tomcat 7. Eclipse is pretty fast, and everything is set to default settings. Once it is...
Boreal asked 2/8, 2012 at 9:5
4
I created a class String() with __get__(), __set__(), and a method to_db(); however, when I do name = String(), I can't do self.name.to_db() because it's calling to_db() on the value returned by __...
Heeler asked 16/5, 2011 at 21:20
2
Solved
I´m developing an BLE app, based on the Gatt sample project provided by google: https://developer.android.com/samples/BluetoothLeGatt/index.html.
So, I can send data writing in a characteristic suc...
Steinke asked 21/11, 2014 at 19:16
4
Solved
I have the problem that I get a set of pictures and need to classify those.
The thing is, i do not really have any knowledge of these images. So i plan on using as many descriptors as I can find ...
Ambrosane asked 30/4, 2013 at 14:16
5
I am reading the explanation of how descriptors work from the link: http://users.rcn.com/python/download/Descriptor.htm#properties.
But, here, under the class Property's __get__ method, I have a d...
Degrade asked 30/9, 2012 at 11:25
1
Solved
I am learning about descriptors in python. I want to write a non-data descriptor but the class having the descriptor as its classmethod doesn't call the __get__ special method when I call the class...
Gregory asked 10/9, 2016 at 11:38
1
Solved
I was reading a presentation on Pythons' Object model when, in one slide (number 9), the author asserts that Pythons' functions are descriptors. The example he presents to illustrate is similar to ...
Chopping asked 30/8, 2016 at 13:22
3
I'm trying my hand at making an Object-Oriented text-based game in Python, and attempting to implement my first properties and decorators. Using the chapter 5 in the book 'Python 3 Object Oriented ...
Leif asked 27/5, 2014 at 1:52
1 Next >
© 2022 - 2024 — McMap. All rights reserved.