On 4/21/22 15:00, Greg Ewing wrote:
On 20/04/22 10:57 pm, Sam Ezeh wrote:
Has anyone here used or attempted to use a nested class inside an enum?
If so, how did you find it? (what did you expect to happen and did
your expectations align with resulting behaviour etc.)
That's a pretty open-ende
On 20/04/22 10:57 pm, Sam Ezeh wrote:
Has anyone here used or attempted to use a nested class inside an enum?
If so, how did you find it? (what did you expect to happen and did
your expectations align with resulting behaviour etc.)
That's a pretty open-ended question. Is there something about
Hello everyone,
Has anyone here used or attempted to use a nested class inside an enum?
If so, how did you find it? (what did you expect to happen and did
your expectations align with resulting behaviour etc.)
Here are two examples describing the situation I'm talking about
```
class Outer(Enum
Ethan Furman writes:
> I'm asking because in doing some work on Enum it became apparent to me
> that having nested classes was not a smooth, satisfying experience,
> and I'm considering treating them the same way as methods (they will
> no longer be converted into members
Greetings!
So the stdlib Enum has been around for a few years now. Has anyone
written an enum that either had types as members:
class Types(Enum):
Int = int
Str = str
or that had nested classes:
class Types(Enum):
class Contained(Enum):
circle = 1
On 06/29/2018 05:51 PM, Steven D'Aprano wrote:
So not especially complimentary (sorry Ethan, but that was my first
impression) but not *necessarily* a bad thing either.
No worries! :)
The Jargon File adjective that comes closest is probably gnarly:
Wow, I haven't heard that word in a long
On Fri, 29 Jun 2018 10:36:45 -0700, Ethan Furman wrote:
>> What makes them enums? Under what circumstances would you be comparing
>> something to MartinLutherKingJr (Day) without caring about a *specific*
>> Martin Luther King Jr Day?
>
> Enums are also useful when the underlying value is relevan
On Sat, Jun 30, 2018 at 10:51 AM, Steven D'Aprano
wrote:
> ["Baroque"] should not mean "weird or bizarre", although I've seen a couple of
> lesser-quality dictionaries give that as a meaning. Which is itself weird
> and bizarre :-)
>
I guess those dictionaries are baroque. Or maybe just broke.
C
On Sat, 30 Jun 2018 09:02:37 +1000, Cameron Simpson wrote:
> On 29Jun2018 10:36, Ethan Furman wrote:
>>On 06/28/2018 10:52 PM, Steven D'Aprano wrote:
>>>It isn't clear to me why FederalHoliday is an Enum, especially as the
>>>API seems extremely baraque.
>>
>>Huh. I had to look that word up, an
Cameron Simpson wrote:
It tends to mean "weird", but perhaps a more nuanced phrasing might be
unusual and strange, and usually connotes some degree of over complication.
When used in a derogatory way it means "excessively elaborate".
The Baroque period was characterised by extremely ornate
arch
Ethan Furman wrote:
They are the list of dates in which US banks are closed for electronic
business (funds transfers and things).
That sems like something that would be better specified in
a configuration file than hard-wired into the code, in case
the rules change.
--
Greg
--
https://mail.pyt
On 06/29/18 16:02, Cameron Simpson wrote:
On 29Jun2018 10:36, Ethan Furman wrote:
On 06/28/2018 10:52 PM, Steven D'Aprano wrote:
On Thu, 28 Jun 2018 18:33:31 -0700, Ethan Furman wrote:
Perhaps I am using Enum incorrectly, but here is my FederalHoliday
Enum.
Note that date(), next_business_
On 29Jun2018 10:36, Ethan Furman wrote:
On 06/28/2018 10:52 PM, Steven D'Aprano wrote:
On Thu, 28 Jun 2018 18:33:31 -0700, Ethan Furman wrote:
Perhaps I am using Enum incorrectly, but here is my FederalHoliday Enum.
Note that date(), next_business_day, and year() are all callables. The
AutoE
On 06/28/2018 10:52 PM, Steven D'Aprano wrote:
On Thu, 28 Jun 2018 18:33:31 -0700, Ethan Furman wrote:
Perhaps I am using Enum incorrectly, but here is my FederalHoliday Enum.
Note that date(), next_business_day, and year() are all callables. The
AutoEnum parent assigns values from 1 to n f
On 29/06/2018 09:01, Ian Kelly wrote:
On Thu, Jun 28, 2018 at 10:06 PM Ben Finney wrote:
@total_ordering
class ChessPiece(Enum):
PAWN = 1, 'P'
KNIGHT = 2, 'N'
BISHOP = 3, 'B'
ROOK = 4, 'R'
# ...
@property
def label(self):
return self.value[1]
On Thu, Jun 28, 2018 at 10:06 PM Ben Finney wrote:
>
> Ethan Furman writes:
>
> > On 06/28/2018 05:58 PM, Ben Finney wrote:
> >
> > > So I remain dumbfounded as to why anyone would want a class to *both* be
> > > an enumerated type, *and* have callable attributes in its API.
> >
> > Perhaps I am
On Thu, Jun 28, 2018 at 7:01 PM Ben Finney wrote:
>
> Ian Kelly writes:
>
> > On Thu, Jun 28, 2018 at 4:38 AM Ben Finney
> > wrote:
> > >
> > > Ethan Furman writes:
> > >
> > > Specifically, I can't make sense of why someone would want to have a
> > > class that is simultaneously behaving as a
On Thu, 28 Jun 2018 18:33:31 -0700, Ethan Furman wrote:
> On 06/28/2018 05:58 PM, Ben Finney wrote:
>
>> So I remain dumbfounded as to why anyone would want a class to *both*
>> be an enumerated type, *and* have callable attributes in its API.
>
> Perhaps I am using Enum incorrectly, but here is
Ethan Furman writes:
> On 06/28/2018 05:58 PM, Ben Finney wrote:
>
> > So I remain dumbfounded as to why anyone would want a class to *both* be
> > an enumerated type, *and* have callable attributes in its API.
>
> Perhaps I am using Enum incorrectly, but here is my FederalHoliday
> Enum. […]
Th
On 06/28/2018 05:58 PM, Ben Finney wrote:
So I remain dumbfounded as to why anyone would want a class to *both* be
an enumerated type, *and* have callable attributes in its API.
Perhaps I am using Enum incorrectly, but here is my FederalHoliday Enum. Note that date(), next_business_day, and
On Thu, 28 Jun 2018 20:34:58 +1000, Ben Finney wrote:
> Ethan Furman writes:
>
>> Consider the following Enum definition:
>>
>> class Color(Enum):
>> RED = 1
>> GREEN = 2
>> BLUE = 3
>> @property
>> def lower(self):
>> return self.name.lower()
>> d
On Thu, 28 Jun 2018 08:36:47 -0700, Ethan Furman wrote:
>>> Answer:
>>>
>>> - RED, GREEN, and BLUE are members
>>> - lower and spam() are not
>>> - SomeClass /is/ a member (but not its instances)
>>
>> Is that by accident or by design?
>
> By design. It is entirely possible to want a
Ian Kelly writes:
> On Thu, Jun 28, 2018 at 4:38 AM Ben Finney wrote:
> >
> > Ethan Furman writes:
> >
> > Specifically, I can't make sense of why someone would want to have a
> > class that is simultaneously behaving as an enumerated type, *and*
> > has an API of custom callable attributes.
>
On Thu, Jun 28, 2018 at 4:38 AM Ben Finney wrote:
>
> Ethan Furman writes:
>
> > Consider the following Enum definition:
> >
> > class Color(Enum):
> > RED = 1
> > GREEN = 2
> > BLUE = 3
> > @property
> > def lower(self):
> > return self.name.lower()
> >
is really seems to be the sticking point -- what should an Enum of Enums look
like? For example, should the above do
--> list(Colour)
[Colour.PrimaryColour <...>, Colour.SecondaryColour <...>]
or something else?
The only example I have seen so far of nested classes in an Enum is
Ethan Furman writes:
> Consider the following Enum definition:
>
> class Color(Enum):
> RED = 1
> GREEN = 2
> BLUE = 3
> @property
> def lower(self):
> return self.name.lower()
> def spam(self):
> return "I like %s eggs and spam!" % self.l
erit from Enum:
class Colour(Enum):
class PrimaryColour(Enum):
RED = 1
GREEN = 2
BLUE = 3
OCTARINE = 8
class SecondaryColour(Enum):
PUCE = 101
MAUVE = 102
BEIGE = 103
TEAL = 104
> The only example I have seen so far of nested clas
t its instances)
Question:
Should `SomeClass` be an enum member? When would it be useful to have an
embedded class in an Enum be an enum member?
The only example I have seen so far of nested classes in an Enum is when folks want to make an Enum of Enums, and the
nested Enum should not it
Serge WEINSTOCK, 16.05.2013 10:55:
> I'm currently writing a C extension module for python using the "raw" C-API.
> I would like to be able to define "nested classes" like in the following
> python code
>
> =
Serge WEINSTOCK於 2013年5月16日星期四UTC+8下午4時55分07秒寫道:
> Hi,
>
>
>
> I'm currently writing a C extension module for python using the "raw" C-API.
> I would like to be able to define "nested classes
Hi,
I'm currently writing a C extension module for python using the "raw" C-API. I
would like to be able to define "nested classes" like in the following python
code
class A:
class B:
class attributes because the statements bb=... and cc=...
are inside the class definition). It works, but perhaps that's not what
you want. If you want instance attributes instead, create them in
AA.__init__ by using self.bb=something
Nested classes provide no benefit here an
I have class structure as below. How can I create the following nested class
and its properties dynamically.
class AA(object):
class BB(object):
def setBB1(self, value):
##some code
def getBB1(self):
bb1 = #somecode
return bb1
On Fri, 2009-07-10 at 19:00 +0200, Manuel Graune wrote:
> Hello,
>
> as an example of what I would like to achieve, think of a street
> where each house has a door and a sign with a unique (per house)
> number on it. I tried to model this like this:
>
> class House(object):
> class Door(objec
Manuel Graune wrote:
> as an example of what I would like to achieve, think of a street
> where each house has a door and a sign with a unique (per house)
> number on it. I tried to model this like this:
>
> class House(object):
> class Door(object):
> def __init__(self,color):
>
Hello,
as an example of what I would like to achieve, think of a street
where each house has a door and a sign with a unique (per house)
number on it. I tried to model this like this:
class House(object):
class Door(object):
def __init__(self,color):
self.color=color
> Yes. It's the same convention used to indicate that a method is
> "private" in Python, since the language itself has no privacy
> mechanisms.
Great - got it!
Thanks again,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Mar 20, 2009 at 1:24 PM, Esmail wrote:
> On Mar 20, 2:41 pm, Chris Rebert wrote:
>> 2009/3/20 Benjamin Kaplan :
>> > On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote:
>>
>> >> Hello all,
>>
>> >> I am curious why nested classes don
On Mar 20, 2:35 pm, Steve Holden wrote:
> Benjamin Kaplan wrote:
>
> > On Fri, Mar 20, 2009 at 10:06 AM, Esmail > <mailto:ebo...@gmail.com>> wrote:
>
> > Hello all,
>
> > I am curious why nested classes don't seem to be used much
On Mar 20, 2:41 pm, Chris Rebert wrote:
> 2009/3/20 Benjamin Kaplan :
>
>
>
>
>
> > On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote:
>
> >> Hello all,
>
> >> I am curious why nested classes don't seem to be used much in Python.
> >>
2009/3/20 Benjamin Kaplan :
>
>
> On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote:
>>
>> Hello all,
>>
>> I am curious why nested classes don't seem to be used much in Python.
>> I see them as a great way to encapsulate related information, which i
Benjamin Kaplan wrote:
>
>
> On Fri, Mar 20, 2009 at 10:06 AM, Esmail <mailto:ebo...@gmail.com>> wrote:
>
> Hello all,
>
> I am curious why nested classes don't seem to be used much in Python.
> I see them as a great way to encapsulate
On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote:
> Hello all,
>
> I am curious why nested classes don't seem to be used much in Python.
> I see them as a great way to encapsulate related information, which is
> a
> good thing.
>
> In my other post "improve th
Hello all,
I am curious why nested classes don't seem to be used much in Python.
I see them as a great way to encapsulate related information, which is
a
good thing.
In my other post "improve this newbie code/nested functions in
Python?"
(I accidentally referred to nested function
"I'm using the Active Server Pages integration in the win32 extensions,
does anyone have good/bad experiences using this interface?"
What is it you are trying to do?
I'm using python2.4 with win32 and IIS/python ASP and find it ok. There
were at some point some session overlappings but I'm not su
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> But I hope you are aware that nested classes aren't quite the same as
> they are in java, are you?
Actually they are more like java's static inner classes. If you want to
simulate non-static inner classes in pytho
Martin Skou wrote:
> I'm experimenting with using Python for a small web interface, using
> Mark Hammond's nice win32 extensions.
>
> I use a small class hierarchy which uses inheritance and nested classes.
>
> Here are a small extract of the code:
>
> class p
I'm experimenting with using Python for a small web interface, using
Mark Hammond's nice win32 extensions.
I use a small class hierarchy which uses inheritance and nested classes.
Here are a small extract of the code:
class page:
def __init__(self):
Hello Nick,
thank you, your answer really helped me..
--
Greg
Nick Coghlan wrote:
Gregor Horvath wrote:
Hello,
class A(self):
def A1():
pass
class B(self):
def B1():
#
#*** How can I access A1 here ***
#***
Gregor Horvath wrote:
Hello,
class A(self):
def A1():
pass
class B(self):
def B1():
#
#*** How can I access A1 here ***
#
self.A1() # doesnet work because self references to B
self.
Hello,
class A(self):
def A1():
pass
class B(self):
def B1():
#
#*** How can I access A1 here ***
#
self.A1() # doesnet work because self references to B
self.self.A
51 matches
Mail list logo