Python style, Python Programming

Python  Style

Software  engineering courses  often  provide very  rigid  guidelines on the style of programming, generally the appropriate value of indentation, or what  to use, or whether to capitalize  underscores in variable characters.   Those things may be useful  for uniformity and  readability of program, especially when  a lot of engineers are working on a software.  But they are mostly  arbitrary: a style is chosen for consistency and according to some person's aesthetic preferences.

There  are other  method of style that look, to us, to be more  fundamental, because  they  directly affect the readability or ef?ciency  of the code.

  • Avoid recalculation of the similar value.

You should compute it once and  assign  it to a variable instead; otherwise, if you have  a bug in the calculation (or you  want  to change  the program), you  will have  to modify  it multiple ways.  It is also not efficient.

  • Avoid repetition of a structure of computation.

 

You should use a method instead, again  to avoid  having to change  or debug the same basic code multiple times.

 

  • Avoid numeric indexing.

 

You should need destructuring if possible, since it is much  easier to read the code and therefore easier to get right and to modify later.

 

  • Avoid excessive numeric constants.

 

You should name  the constants, since it is much  easier to read the code and therefore easier to get right and to modify later.

 

Here  are some  examples of simple  procedures that  exhibit  several ?aws.  We'll talk about  what creates  them  problematic.

 

Posted Date: 8/9/2012 7:23:02 AM | Location : United States







Related Discussions:- Python style, Assignment Help, Ask Question on Python style, Get Answer, Expert's Help, Python style Discussions

Write discussion on Python style
Your posts are moderated
Related Questions
Basics of python-introduction Python is designed for easy interaction between a user and the system. It goes with  an inter­ active function  known as  a shell or listener.  T

Normalize a vector Let's imagine we want  to normalize a vector  of three  variables;  that  is to compute a new  vector  of three values,  such that its size  is 1. Here is o

A program to count how many files are on the file system which displays summary information regarding the total number of bytes used by all files and a breakdown of the number of b

#que Write a program that will take price data for stocks and print it graphically to the screen. Your program should begin by asking the user for the file name. It should then cre

program on damped lcr cicuit


For this assignment, you are to: 1.    Modify the output format of your Python script from Assignment 1 to match the input format of your C program from Assignment 2. 2.    W

Write a program on python to give solution for driven and damped rlc circuit

Procedures as First-class objects In Python, unlike  many  other  languages, methods are behave in much  the same way as num­ bers:  they  can be stored as values  of variable

Procedures in python Procedures are computer program creates that let us capture common patterns of computation by: Grouping together sequences of statements