Steven D'Aprano wrote:
Overkill? Storage of a single attribute holding a (usually short)
string is overkill?
No, but storing the first name a class is bound to in it is a bit
of, IMHO.
When you do that, you wouldn't expect the __name__ of
some.module.function to change to f, and it
On Mar 2, 3:01 pm, Bjoern Schliessmann usenet-
[EMAIL PROTECTED] wrote:
Steven D'Aprano wrote:
Overkill? Storage of a single attribute holding a (usually short)
string is overkill?
No, but storing the first name a class is bound to in it is a bit
of, IMHO.
Don't see it as the first name a
Arnaud Delobelle wrote:
Don't see it as the first name a class is bound to, but rather as
the name a class is defined as.
If class_object.__name__ == 'Foo' it means that somewhere in your
code there is a class definition:
class Foo:
# stuff
Same for function: if
On Mar 2, 8:28 pm, Bjoern Schliessmann usenet-
[EMAIL PROTECTED] wrote:
This is somehow contrary to my understanding of the Python names
concept.
What if I use a loop to define several classes based on data --
they'll all have the same __name__ unless I change it manually.
Well that's not a
On Feb 28, 1:26 pm, Luis M. González [EMAIL PROTECTED] wrote:
I've come across a code snippet in www.rubyclr.com where they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
I posted like 10 minutes ago, but it
On Mar 2, 8:29 pm, MonkeeSage [EMAIL PROTECTED] wrote:
On Feb 28, 1:26 pm, Luis M. González [EMAIL PROTECTED] wrote:
I've come across a code snippet inwww.rubyclr.comwhere they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate
On Mar 2, 5:48 pm, Luis M. González [EMAIL PROTECTED] wrote:
Thanks for your detailed reply!
So after all, the www.rubyclr.com code is not a fair comparison.
Because the c# code shows a class definition, and the ruby code shows
a struct definition, which is not equivalent to a class.
Is that
In [EMAIL PROTECTED], Bjoern Schliessmann wrote:
Bruno Desthuilliers wrote:
class Toto(object):
pass
print Toto.__name__
Okay, I revoke my statement and assert the opposite.
But what's it (__name__) good for?
As objects don't know to which name they are bound, that's a good
On Mar 1, 9:40 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
In [EMAIL PROTECTED], Bjoern Schliessmann wrote:
But what's it (__name__) good for?
As objects don't know to which name they are bound, that's a good way to
give some information in stack traces or when doing
Michele Simionato wrote:
On Mar 1, 9:40 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED]
In [EMAIL PROTECTED], Bjoern Schliessmann
But what's it (__name__) good for?
As objects don't know to which name they are bound, that's a good
way to give some information in stack traces or when doing
In [EMAIL PROTECTED], Bjoern Schliessmann wrote:
Michele Simionato wrote:
On Mar 1, 9:40 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED]
In [EMAIL PROTECTED], Bjoern Schliessmann
But what's it (__name__) good for?
As objects don't know to which name they are bound, that's a good
way to
On 28 Feb 2007 13:53:37 -0800, Luis M. González [EMAIL PROTECTED] wrote:
Hmmm... not really.
The code above is supposed to be a shorter way of writing this:
class Person:
def __init__(self, name, birthday, children):
self.name = name
self.birthday = birthday
On Feb 28, 7:26 pm, Luis M. González [EMAIL PROTECTED] wrote:
I've come across a code snippet inwww.rubyclr.comwhere they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
The code is as follows:
Person =
Arnaud Delobelle wrote:
On Feb 28, 7:26 pm, Luis M. González [EMAIL PROTECTED] wrote:
I've come across a code snippet inwww.rubyclr.comwhere they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
The code is as
On Mar 1, 4:01 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Arnaud Delobelle wrote:
[...]
This does pretty much the same thing as the recipe I posted:
Not at all. My new_struct create returns a new class which is similar
to a C struct (notice the __slots__). The recipe you refer to is
nothing
Arnaud Delobelle wrote:
On Mar 1, 4:01 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Arnaud Delobelle wrote:
[...]
This does pretty much the same thing as the recipe I posted:
Not at all. My new_struct create returns a new class which is similar
to a C struct (notice the __slots__). The
On Mar 1, 7:37 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Arnaud Delobelle wrote:
On Mar 1, 4:01 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Arnaud Delobelle wrote:
[...]
This does pretty much the same thing as the recipe I posted:
Not at all. My new_struct create returns a new class
Arnaud Delobelle wrote:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502237
[snip]
Although I don't see the necessity of a metaclass: you could have
class Record(object):
def __init__(self, *vals):
for slot, val in zip(self.__slots__, vals):
On Mar 1, 3:03 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote:
On Mar 1, 4:01 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Arnaud Delobelle wrote:
[...]
This does pretty much the same thing as the recipe I posted:
Not at all. My new_struct create returns a new class which is similar
to a C
Luis M. González wrote:
This is the closest we got so far to the intended result.
If there was a way to enter attributes without quotes, it would be
almost identical.
Ok, below is the Python code so that the following works::
class Person(Struct): name birthday children
Note that
* The
On Thu, 01 Mar 2007 10:44:48 +0100, Bjoern Schliessmann wrote:
Mh. I suspect there's also more to it than I see now, but this
__name__ seems quite useless to me. What if I rebind the class'
name after definition? Or is it really just for some manual
introspection? If it is, it seems a bit of
Luis M. González a écrit :
I've come across a code snippet in www.rubyclr.com where they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
The code is as follows:
Person = struct.new( :name, :birthday,
Luis M. González wrote:
I've come across a code snippet in www.rubyclr.com where they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
The code is as follows:
Person = struct.new( :name, :birthday, :children)
On Feb 28, 6:21 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Luis M. González wrote:
I've come across a code snippet inwww.rubyclr.comwhere they show how
easy it is to declare a class compared to equivalent code in c#.
I wonder if there is any way to emulate this in Python.
The code is as
Luis M. González wrote:
On Feb 28, 6:21 pm, Steven Bethard [EMAIL PROTECTED] wrote:
How about something like::
class Person(Record):
__slots__ = 'name', 'birthday', 'children'
You can then use the class like::
person = Person('Steve', 'April 25', [])
assert
Luis M. González wrote:
I've come across a code snippet in www.rubyclr.com where they show
how easy it is to declare a class compared to equivalent code in
c#. I wonder if there is any way to emulate this in Python.
The code is as follows:
Person = struct.new( :name, :birthday,
Bjoern Schliessmann a écrit :
(snip)
In Python, classes have no name.
class Toto(object):
pass
print Toto.__name__
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
class Toto(object):
pass
print Toto.__name__
Okay, I revoke my statement and assert the opposite.
But what's it (__name__) good for?
Regards,
Björn
--
BOFH excuse #179:
multicasts on broken packets
--
28 matches
Mail list logo