On 09/23/12 11:12, Chris Angelico wrote: > On Mon, Sep 24, 2012 at 1:48 AM, Joshua Landau > <joshua.landau...@gmail.com> wrote: >> Simple question: >> >> [myClass() for myClass in myClasses] >> vs >> [MyClass() for MyClass in myClasses] > > Since there's no difference between a "class" and a "variable > containing a class" or a "pointer to a class" or any other such > concept, it makes sense to capitalize MyClass in your example, if you > are guaranteeing that they're all classes.
Having just written code very much like this in the last 24hr, my own code reads something like my_list_of_classes = [ MyClassA, MyClassB, MyClassC, ] instances = [my_cls(args) for my_cls in my_list_of_classes] I do come down on it being a variable (and thus lowercase-with-underscores, according to PEP-8) because, well, it's varying. A class *definition* is generally expected to be non-varying (or if it does, it's often a code smell) so it gets the CapCamelCase. So while ChrisA correctly claims that at the interpreter-level "there's no difference between a 'class' and a 'variable containing a class'", I'd say that at a programmer-level, there's a conceptual difference between "expect this to vary" and "expect this to be the same". And I try to write my code for other programmers first, and the interpreter second. -tkc -- http://mail.python.org/mailman/listinfo/python-list