p.s. Is Python seeing a lot of use at Ubisoft or is this just for personal
interest (or
perhaps both)?
We do use Python a fair bit, mostly for build systems and data mining, but also
because it's the built-in script language for Motionbuilder.
--
On Sat, May 12, 2012 at 9:10 AM, Ethan Furman et...@stoneleaf.us wrote:
Firstly, __slots__ is a tuple.
I object: conceptually, the slots of a class are set in stone, but
the `__slots__` attribute of a class object is just an attribute, and
any iterable (as long as it yields valid identifier
On Thu, May 10, 2012 at 9:33 AM, Andreas Tawn andreas.t...@ubisoft.com wrote:
And there's also something like...
return \n.join((: .join((str(k), str(self.__dict__[k]))) for k in
self.__dict__))
which is a nice length, but I lose control of the order of the attributes and
the formatting
Karl Knechtel wrote:
On Thu, May 10, 2012 at 9:33 AM, Andreas Tawn andreas.t...@ubisoft.com wrote:
And there's also something like...
return \n.join((: .join((str(k), str(self.__dict__[k]))) for k in
self.__dict__))
which is a nice length, but I lose control of the order of the attributes
This issue bit me once too often a few months ago, and now I have a class
called
O from which I often subclass instead of from object.
Its main purpose is a friendly __str__ method, though it also has a friendly
__init__.
Code:
class O(object):
''' A bare object subclass to
On 05/11/2012 07:16 AM, Andreas Tawn wrote:
SNIP
This is a very interesting solution.
I think it might be better suited (for my purpose) to __repr__ rather than
__str__, mostly because I still lose control of the order the attributes
appear.
I have no idea why using __repr__ versus
I have no idea why using __repr__ versus __str__ would make any difference in
the
order of the attributes. They're going to come out in the order you specify,
regardless of what you name your method. If you don't like the arbitrary
order you
get from the dictionary, then either sort it,
On 11/05/2012 15:32, Andreas Tawn wrote:
It's also helpful to not have to display every attribute, of which there may be
dozens.
Do I detect a code smell here?
--
Cheers.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list
Mark Lawrence wrote:
On 11/05/2012 15:32, Andreas Tawn wrote:
It's also helpful to not have to display every attribute, of which
there may be dozens.
Do I detect a code smell here?
I think so, Murphy's law dictates that the attribute you're interested
in will not be displayed anyway.
JM
It's also helpful to not have to display every attribute, of which there
may be
dozens.
Do I detect a code smell here?
Possibly. I'll often try to subdivide into several simpler types, but sometimes
that makes the code more complex than it needs to be.
--
It's also helpful to not have to display every attribute, of which
there may be dozens.
Do I detect a code smell here?
I think so, Murphy's law dictates that the attribute you're interested in
will not be
displayed anyway.
That's what __repr__'s for.
--
On 11May2012 15:40, Mark Lawrence breamore...@yahoo.co.uk wrote:
| On 11/05/2012 15:32, Andreas Tawn wrote:
| It's also helpful to not have to display every attribute, of which there
may be dozens.
|
| Do I detect a code smell here?
Not necessarily. (Well, yeah, dozens may indicate time to
On Thu, May 10, 2012 at 11:33 PM, Andreas Tawn andreas.t...@ubisoft.com wrote:
Say I've got a class...
class test(object):
def __init__(self):
self.foo = 1
self.bar = 2
self.baz = 3
I can say...
def __str__(self):
return foo: {0}\nbar: {1}\nbaz:
On Thu, May 10, 2012 at 11:33 PM, Andreas Tawn andreas.t...@ubisoft.com
wrote:
Say I've got a class...
class test(object):
def __init__(self):
self.foo = 1
self.bar = 2
self.baz = 3
I can say...
def __str__(self):
return foo: {0}\nbar: {1}\nbaz:
On Fri, May 11, 2012 at 1:15 AM, Andreas Tawn andreas.t...@ubisoft.com wrote:
I considered the triple quote string one, but it's not very PEP 8 compatible
in a real class because it includes the indentation in the formatted string.
Yeah, that is an annoying side effect. My personal view is
On 10May2012 15:33, Andreas Tawn andreas.t...@ubisoft.com wrote:
| Say I've got a class...
|
| class test(object):
| def __init__(self):
| self.foo = 1
| self.bar = 2
| self.baz = 3
|
| I can say...
|
| def __str__(self):
|return foo: {0}\nbar: {1}\nbaz:
16 matches
Mail list logo