Hi,
I would like to know what naming conventions we can follow for the following types of variables/sequences :
Variables :
-------------
Integer
Float
Boolean
Sequences :
--------------
Strings
List
Dictionary
Tuples
File
I understand that Python variables are "Dynamically Typed" ,that is one of the feature of it.But how the developer differentiate with different sequences or variables he is working with.
Thanks in advance
PSB
18 3256
Hi,
I would like to know what naming conventions we can follow for the following types of variables/sequences :
Variables :
-------------
Integer
Float
Boolean
Sequences :
--------------
Strings
List
Dictionary
Tuples
File
I understand that Python variables are "Dynamically Typed" ,that is one of the feature of it.But how the developer differentiate with different sequences or variables he is working with.
Thanks in advance
PSB
As I was reading your post, the words "Dynamically Typed" were running through my mind. I'm glad that you have that understanding. Because a function don't care about the type of it's arguments, I've settled on a nameType (sometimes long_nameType) naming "convention" for myself. But that mostly applies to instances of class objects. I don't differentiate between mutibles and non-mutibles the way that you have. As a rule, I use:
class: ThisClassName
def: ThisFuncName
useofThisClass = ThisClassName()
thisType = ThisFuncName()
Integer
Float
I just use descriptive names like
loopCount, distance, etc. Just wait 'til you meet Decimal and others that are not built in, but are very commonly used.
Boolean
conditionFlag
Strings
whateverStr
List
listofList
Dictionary
describeDict
Tuples
samehereTuple
File
alwaysFile
I hope that is useful to you. Thanks for posting. Keep it up.
As I was reading your post, the words "Dynamically Typed" were running through my mind. I'm glad that you have that understanding. Because a function don't care about the type of it's arguments, I've settled on a nameType (sometimes long_nameType) naming "convention" for myself. But that mostly applies to instances of class objects. I don't differentiate between mutibles and non-mutibles the way that you have. As a rule, I use:
class: ThisClassName
def: ThisFuncName
useofThisClass = ThisClassName()
thisType = ThisFuncName()
Integer
Float
I just use descriptive names like
loopCount, distance, etc. Just wait 'til you meet Decimal and others that are not built in, but are very commonly used.
Boolean
conditionFlag
Strings
whateverStr
List
listofList
Dictionary
describeDict
Tuples
samehereTuple
File
alwaysFile
I hope that is useful to you. Thanks for posting. Keep it up.
Also, for short loops where the whole life of a counter can be seen in just a few line, i, j, k, do just fine. And for long life instance variablea shared by many methods, I use_very_descriptive_names which may not need the Type at the end. This is all just personal style and I have seen "conventions" change over the years. If you look at the style that Tkinter was written in, you'll see what I think is a very common "pythonic" way of naming things. On the other hand, wxPython ToolKit uses C naming conventions because of the underlieing implementation and is the style that I prefer.
bvdet 2,851
Expert Mod 2GB
Hi,
I would like to know what naming conventions we can follow for the following types of variables/sequences :
Variables :
-------------
Integer
Float
Boolean
Sequences :
--------------
Strings
List
Dictionary
Tuples
File
I understand that Python variables are "Dynamically Typed" ,that is one of the feature of it.But how the developer differentiate with different sequences or variables he is working with.
Thanks in advance
PSB
Take a look at this: http://www.python.org/doc/essays/styleguide/
Following are some guidelines I use: single letter names for class instances ('a', 'b', 'c')
single letter name ('f') for an open file if contained in a small block of code
'i' (integer) when executing a range iteration
LineLineIntersect3D, Plane3D - class definitions
clip_hole, add_weld, radius_cut, data_Defaults_path, import_data, trueAngleBetweenMembers, formatDict, formatPtList - descriptive names for functions
PointRotate3D - descriptive names for functions with major functionality
pt_list or ptList - a list of points
bm_list or bmList - a list of beams
dd1, dd2, memDict, conn_dict - dictionaries
rot_arg - tuple (I mostly use lists)
ptWP, pt1, p1 - point objects
mem1 - the first selected member object
m, bm, col, mem, key - iteration on a list of:
material
beams
columns
members
dictionary keys
A descriptive name similar to lists - strings, integers, and floats
no_spa (number of spaces), left_dist (the distance from the left end)
I am still in 2.3 - not using sets yet
Take a look at this: http://www.python.org/doc/essays/styleguide/
Thanks BV. I hadn't read that before. I am amazed how much of THE MAN's style I have picked up over the years just by reading library modules. My whitespace thinking exactly matches his. Great link (I bookmarked it).
Hi,
What naming conventions has to be followed for the Class Variables and Methods?.How to differentiate the Private ,Protected and Public Class Variables and Methods?Is there any conventions has to be followed.
Thankls & REgards
PSB
Hi,
What naming conventions has to be followed for the Class Variables and Methods?.How to differentiate the Private ,Protected and Public Class Variables and Methods?Is there any conventions has to be followed.
Thankls & REgards
PSB
Guess you haven't found this yet.
Hi ,
I am not able to decide the Naming conventions for the following.
Variables :
--------------
Float
Integer
String
List
Dictionary
Tuples
File
Class Names
Private,Protected and Public
Class Variables
Class Methods
Functions
I have looked for various material in Internet .I am not able to get the consistency naming conventions.
Each one is following thier own naming conventions.
Thanks in advacne
PSB
Hi ,
I am not able to decide the Naming conventions for the following.
Variables :
--------------
Float
Integer
String
List
Dictionary
Tuples
File
Class Names
Private,Protected and Public
Class Variables
Class Methods
Functions
I have looked for various material in Internet .I am not able to get the consistency naming conventions.
Each one is following thier own naming conventions.
Thanks in advacne
PSB
It really comes down to a matter of personal style.
BV gave a great link. I gave suggestions. Please try to keep one post per topic so that all info ends up in one place. Thanks.
Hi ,
The naming conventions for UI in Python are similar to that of Application.
UI Variables and Methods
- Handlers
- Control Variables ( ID's,EDIT Box,Combo Box)
- Class Variables
- Call back names
- Event Handlers
- Other
Thanks in Advacne
PSB
Hi,
I am confused which naming conventions to be followed for Variables ,Classes and Functions.In www.Python.org ,the naming conventions looks fine.When I refer the .py files of the Python4.2.I am confused with different mixture of naming conventions used in different (.py) files for the variables,Classes,Methods,function etc.
Could anybody help me in better understanding of which naming has to be used and when it has to be used.
Thanks in advacne
PSB
Hi ,
The naming conventions for UI in Python are similar to that of Application.
UI Variables and Methods
- Handlers
- Control Variables ( ID's,EDIT Box,Combo Box)
- Class Variables
- Call back names
- Event Handlers
- Other
Thanks in Advacne
PSB
Let's try to keep a topic in a single thread, please.
Hi,
I am confused which naming conventions to be followed for Variables ,Classes and Functions.In www.Python.org ,the naming conventions looks fine.When I refer the .py files of the Python4.2.I am confused with different mixture of naming conventions used in different (.py) files for the variables,Classes,Methods,function etc.
Could anybody help me in better understanding of which naming has to be used and when it has to be used.
Thanks in advacne
PSB
The Father of Python clearly states:
"Naming Conventions
The naming conventions of Python's library are a bit of a mess, so we'll never get this completely consistent -- nevertheless, here are some guidelines."
Let's try to keep a topic in a single thread, please.
Thanks for the reply
Still I need the clarification for the UI variables as mentioned in the discusiion.
Could you please clarifyit in more elaborately,so that I Can start working on my applications using the standard conventions.
-PSB
Thanks for the reply
Still I need the clarification for the UI variables as mentioned in the discusiion.
Could you please clarifyit in more elaborately,so that I Can start working on my applications using the standard conventions.
-PSB
I use mixedCaseWords for all class instances, like GUI elements. The prefixed word is the name followed by TheClassOfTheElement. BTW, You shouldn't (although Tkinter allows it) do things like: - myClass[attribute] = value
. Always call the setters of GUI objects (or any class for that matter).
How to differentiate the Class variables/Methods?.Whether we have to use the same variable names as ordinary variable names.
Private:
Protected:
Public:
Thanks in advance
PSB
Quoting from http://www.python.org/doc/essays/styleguide/#names
Method Names
Hmm, the story is largely the same as for functions. When using ILU, here's a good convention: use CapWords for methods published via an ILU interface. Use lowercase for methods accessed by other classes or functions that are part of the implementation of an object type. Use one leading underscore for "internal" methods and instance variables when there is no chance of a conflict with subclass or superclass attributes or when a subclass might actually need access to them. Use two leading underscores (class-private names, enforced by Python 1.4) in those cases where it is important that only the current class accesses an attribute. (But realize that Python contains enough loopholes so that an insistent user could gain access nevertheless, e.g. via the __dict__ attribute. Only ILU or Python's restricted mode will XXX
Quoting from http://www.python.org/doc/essays/styleguide/#names
Method Names
Hmm, the story is largely the same as for functions. When using ILU, here's a good convention: use CapWords for methods published via an ILU interface. Use lowercase for methods accessed by other classes or functions that are part of the implementation of an object type. Use one leading underscore for "internal" methods and instance variables when there is no chance of a conflict with subclass or superclass attributes or when a subclass might actually need access to them. Use two leading underscores (class-private names, enforced by Python 1.4) in those cases where it is important that only the current class accesses an attribute. (But realize that Python contains enough loopholes so that an insistent user could gain access nevertheless, e.g. via the __dict__ attribute. Only ILU or Python's restricted mode will XXX
What is this ILU stands for ?
What is this ILU stands for ?
Check it out here.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Cristof Falk |
last post by:
I wanted to get a feel. The documentation gives naming conventions for
public/protected members. Is this truly widely adopted?
And what about using the same conventions for private members and...
|
by: cmiddlebrook |
last post by:
Hi there,
I keep finding myself getting inconsistent with naming conventions for
things like member variables, class names etc and I just want to find
something that suits me and stick to it. I...
|
by: clintonG |
last post by:
Does the use of DTD, XML Schema and similar constructs adopt
the use of C# naming conventions? If so how do I make the distinction
of how to apply C# conventions with XML elements, attributes and...
|
by: Mark Broadbent |
last post by:
stupid question time again to most of you experts but this is something that
continually bothers me.
I am trying to get into the habit of naming variables and controls in an
assembly as per...
|
by: clintonG |
last post by:
Does the use of DTD, XML Schema and similar constructs adopt
the use of C# naming conventions? If so how do I make the distinction
of how to apply C# conventions with XML elements, attributes and...
|
by: rastaman |
last post by:
Hi all,
I know of the existence of Object Naming Conventions for Visual Basic 6.
Now I'm reading some books about VB .NET, but the names used for the
objects are button1, picturebox1, etc.
I...
|
by: Patrick |
last post by:
what are the general naming conventions for vb.net controls.
esp txtUserName, lblPassword, btnSubmit
What are the prefixes for the controls????
I've tried to search hi and low on the net, but...
|
by: kevininstructor |
last post by:
Greetings,
I am in the process of creating naming conventions for VB.NET controls i.e.
CheckBox -> chkShowThisOnStartup
ListBoxt -> lstSomeList
What I am looking for other developers...
|
by: Smithers |
last post by:
Is it common practise to begin the name of form classes with "frm" (e.g.,
frmOneForm, frmAnotherForm).
Or is that generally considered an outdated convention?
If not "frm" what is a common or...
|
by: Philipp Post |
last post by:
Marcello,
Not a big surprise as naming conventions have a lot to do with
personal prefernces. There are a lot of threads in comp.databases and
the other database groups. Just do a search for...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |