Tagged Questions
3
votes
0answers
24 views
In which order multiple abstract models are processed in Django [duplicate]
So I have this structure where I have multiple abstract Django models and all my models inherit one or more of these abstract models, for instance
class BaseProblem(Base, Slugged, Ownable, Tagged)
...
3
votes
5answers
420 views
Python abstract classes - how to discourage instantiation?
I come from a C# background where the language has some built in "protect the developer" features. I understand that Python takes the "we're all adults here" approach and puts responsibility on the ...
0
votes
2answers
90 views
Django subclassing a class that is subclassing an abstract base class
I tried to do the following in Django 1.4.3:
class The_Image_Abstract(models.Model):
create_time = models.DateTimeField()
class Meta:
abstract = True
class ...
4
votes
3answers
180 views
Determine if a Python class is an Abstract Base Class or Concrete
My Python application contains many abstract classes and implementations. For example:
import abc
import datetime
class MessageDisplay(object):
__metaclass__ = abc.ABCMeta
...
3
votes
1answer
63 views
Creating dynamic ABC class based on user defined class
I'm writing an plugin framework and I want to be able to write a decorator interface, which will convert user class to ABC class and substitute all methods with abstractmethods. I cannot get it ...
3
votes
3answers
128 views
Is it possible to make abstract classes in python?
I tried redefining __new__() like so:
class F:
def __new__(cls):
raise Exception("Unable to create an instance of abstract class %s" %cls)
And it works, I can not define any instances ...
2
votes
1answer
78 views
In Python, how do I determine if an iterable has stable iteration order?
In Python, how do I determine if an iterable has stable iteration order?
There's collections.Iterable abstract base class but there's no stable counterpart.
The reason I'm asking is to be able to ...
0
votes
2answers
56 views
Constrain method access to an interface?
I have a Python system consisting of around 9-10 classes all implementing most of a fat duck-typed interface and used interchangeably by a large collection of modules. I'm trying to refactor the ...
2
votes
1answer
66 views
Make model reference abstract model in one-to-many
I'm pretty new to Django and right now I'm trying to understand the use of abstract models. Let's say you're writing a blogging service and you want both authenticated and anonymous users to be able ...
1
vote
1answer
383 views
Class factories and abstract base classes
I am trying to define a number of classes based on an abstract base class. Each of these classes basically defines a cell shape for a visualisation package. The cell is comprised of a number of ...
2
votes
1answer
51 views
issubclass(C, Mapping) not behaving as expected
from collections import *
class C(object):
def __iter__(self): pass
def __contains__(self, i): pass
def __len__(self): pass
def __getitem__(self, i): pass
issubclass(C, Mapping) => ...
0
votes
1answer
170 views
Python ABC seems to allow incomplete implementation
I'm trying to create base class and force all subclasses to implement it's interface. I'm using the abc module for this purpose.
Here is the base class:
class PluginBase:
__metaclass = ...
1
vote
0answers
75 views
Applying metaclass rules to all descendants rather than direct metaclassed class
Let me start by defining the goals I have:
Enabling definition of abstract class members (not properties, methods, or instance members) with no default values (not None or some other magic value, ...
2
votes
1answer
396 views
Abstraction in Python?
I'm trying to pick up Python for a project, and I'm a bit confused about how to use abstraction and classes. (I'm not a very experienced programmer, so apologies for the basic level of this question.) ...
1
vote
2answers
109 views
Python: how to define __new__ for MutableSequence derived class?
I'm trying to inherit from collections.MutableSequence:
class myList(MutableSequence):
def __new__(cls,*kwargs):
obj=MutableSequence.__new__(cls,*kwargs)
return obj
I get the error:
...