On 07/08/11 17:35, John O'Hagan wrote:
I'm looking for good ways to ensure that attributes are only writable such
that they retain the characteristics the class requires.
My particular case is a class attribute which is initialised as a list of
lists of two integers, the first of which is
I'm looking for good ways to ensure that attributes are only writable such that
they retain the characteristics the class requires.
My particular case is a class attribute which is initialised as a list of lists
of two integers, the first of which is a modulo remainder. I need to be able to
In article mailman.2010.1312731312.1164.python-l...@python.org,
John O'Hagan resea...@johnohagan.com wrote:
I'm looking for good ways to ensure that attributes are only writable such
that they retain the characteristics the class requires.
Sounds like you're trying to do
Roy Smith wrote:
In article mailman.2010.1312731312.1164.python-l...@python.org,
John O'Hagan resea...@johnohagan.com wrote:
I'm looking for good ways to ensure that attributes are only writable
such that they retain the characteristics the class requires.
Sounds like you're trying to
I think you might use a tuple instead of a list for OrderElement, that would
make much easier your code:
class
OrderElement(tuple):
def __new__(cls, x, y):
if not isinstance(x, int) or not isinstance(y, int):
raise TypeError(Order element must receives two
integers)
The assert on Order should be an if ... raise, like OrderElement, sorry for
the mistake and repost
El 7 de agosto de 2011 18:53, Rafael Durán Castañeda
rafadurancastan...@gmail.com escribió:
I think you might use a tuple instead of a list for OrderElement, that
would make much easier your
John O'Hagan wrote:
I'm looking for good ways to ensure that attributes are only writable such
that they retain the characteristics the class requires.
That's what properties are for.
My particular case is a class attribute which is initialised as a list of
lists of two integers, the first
On Sun, Aug 7, 2011 at 6:07 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
class ThingWithTwoIntegers(object):
I'm not a lisp expert, but this might well be called a cons cell. Or a pair.
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 08 Aug 2011 03:07:30 +1000
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
John O'Hagan wrote:
I'm looking for good ways to ensure that attributes are only writable such
that they retain the characteristics the class requires.
That's what properties are for.
My