Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Capitalization for variable that holds a class

Thread Tools

RE: Capitalization for variable that holds a class

Prasad, Ramit
Posts: n/a
Dennis Lee Bieber wrote:

> Sent: Sunday, September 23, 2012 11:53 AM
> To: Removed)
> Subject: Re: Capitalization forvariable that holds a class
> On Sun, 23 Sep 2012 16:48:38 +0100, Joshua Landau
> <(E-Mail Removed)> declaimed the following in
> gmane.comp.python.general:

> > Simple question:
> >
> > [myClass() for myClass in myClasses]
> >vs
> > [MyClass() for MyClass in myClasses]
> >

> The recommended naming scheme for Python is that class DEFINITIONS
> begin capitalized. Instances, methods/attributes, functions begin
> lowercase.
> I abstain from the argument about camel-case vs_ (Ada "pretty
> printers" automatically capitalize at _, so _ is common in Ada)
> class MyClass(object):
> def myMethod(self):

Are you (the OP) using Python 2 or 3? In python 2 list
comprehensions leak; if you use MyClass as the list
comprehension variable name it will overwrite the
MyClass class definition (if it exists).

>>> class MyClass(object):

... pass

>>> print MyClass

<class '__pieshell__.MyClass'>

>>> _ = [ MyClass for MyClass in xrange( 5 ) ]
>>> print MyClass



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness ofinformation, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Re: Capitalization for variable that holds a class Chris Angelico Python 1 09-23-2012 09:42 PM
Re: Capitalization for variable that holds a class Tim Chase Python 0 09-23-2012 06:36 PM
Re: Capitalization for variable that holds a class Dennis Lee Bieber Python 0 09-23-2012 04:53 PM
Instance variable capitalization Jim Freeze Ruby 7 02-23-2004 08:26 AM