<div class="gmail_quote">On 27 September 2012 18:20, Prasad, Ramit <span dir="ltr"><<a href="mailto:ramit.prasad@jpmorgan.com" target="_blank">ramit.prasad@jpmorgan.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dennis Lee Bieber wrote:<br>
> Sent: Sunday, September 23, 2012 11:53 AM<br>
> To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>
> Subject: Re: Capitalization for variable that holds a class<br>
<div class="im">><br>
> On Sun, 23 Sep 2012 16:48:38 +0100, Joshua Landau<br>
> <<a href="mailto:joshua.landau.ws@gmail.com">joshua.landau.ws@gmail.com</a>> declaimed the following in<br>
> gmane.comp.python.general:<br>
><br>
> > Simple question:<br>
> ><br>
> > [myClass() for myClass in myClasses]<br>
> > vs<br>
> > [MyClass() for MyClass in myClasses]<br>
> ><br>
><br>
> The recommended naming scheme for Python is that class DEFINITIONS<br>
> begin capitalized. Instances, methods/attributes, functions begin<br>
> lowercase.<br>
><br>
> I abstain from the argument about camel-case vs _ (Ada "pretty<br>
> printers" automatically capitalize at _, so _ is common in Ada)<br>
><br>
> class MyClass(object):<br>
> def myMethod(self):<br>
<br>
</div>Are you (the OP) using Python 2 or 3? In python 2 list<br>
comprehensions leak; if you use MyClass as the list<br>
comprehension variable name it will overwrite the<br>
MyClass class definition (if it exists).<br>
<br>
>>> class MyClass(object):<br>
... pass<br>
...<br>
>>> print MyClass<br>
<class '__pieshell__.MyClass'><br>
>>> _ = [ MyClass for MyClass in xrange( 5 ) ]<br>
>>> print MyClass<br>
4<br></blockquote><div><br></div><div>Don't worry, not only am I using Python 3 but I would be certain to use GenericUnusedClassName anyway ;)</div></div>