Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'friday,': 0.07; 'enum': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'python': 0.11; 'language,': 0.11; 'considers': 0.16; 'driscoll': 0.16; 'length:': 0.16; 'metaclass': 0.16; 'metaclasses': 0.16; 'metaclasses.': 0.16; 'wrote:': 0.16; 'intermediate': 0.18; '(in': 0.18; 'changes': 0.20; 'am,': 0.23; '2015': 0.23; "i've": 0.24; 'header:In-Reply- To:1': 0.24; 'mike': 0.24; 'developers': 0.24; 'second': 0.24; 'wondering': 0.25; 'header:User-Agent:1': 0.26; 'asked': 0.28; '~ethan~': 0.29; "we're": 0.30; 'topics': 0.31; 'skip:[ 10': 0.32; 'realize': 0.32; 'class': 0.33; 'third': 0.33; 'curious': 0.33; 'instances': 0.33; 'subject:?': 0.34; 'growing': 0.35; 'to:addr :python-list': 0.35; 'but': 0.36; 'subject:" ': 0.36; 'received:10': 0.37; 'subject:: ': 0.37; 'community': 0.38; 'to:addr:python.org': 0.39; 'why': 0.40; 'behavior': 0.61; 'email addr:gmail.com': 0.64; 'our': 0.64; 'gain': 0.81; 'received:10.1.10': 0.84; 'utc-7,': 0.84 Date: Fri, 29 May 2015 10:17:30 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: What is considered an "advanced" topic in Python? References: <33b7ab62-8cc2-4a27-b229-64c94bce16b6@googlegroups.com> In-Reply-To: <33b7ab62-8cc2-4a27-b229-64c94bce16b6@googlegroups.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432919880 news.xs4all.nl 2858 [2001:888:2000:d::a6]:49855 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91486 On 05/29/2015 10:03 AM, sohcahtoa82@gmail.com wrote: > On Friday, May 29, 2015 at 9:02:06 AM UTC-7, Mike Driscoll wrote: >> I've been asked on several occasions to write about intermediate or advanced topics >> in Python and I was wondering what the community considers to be "intermediate" or >> "advanced". I realize we're all growing in our abilities with the language, so this >> is going to be very subjective, but I am still curious what my fellow Python >> developers think about this topic. > > Metaclasses. > > I've read about them. I still don't understand them, why you would want them, and what you gain from them. Metaclasses change the way a class behaves. For example, the new (in 3.4) Enum class uses a metaclass. class SomeEnum(Enum): first = 1 second = 2 third = 3 The metaclass changes normal class behavior to: - support iterating: list(SomeEnum) --> [SomeEnum.first, SomeEnum.second, SomeEnum.third] - support a length: len(SomeEnum) --> 3 - not allow new instances to be created: --> SomeEnum(1) is SomeEnum(1) # True -- ~Ethan~