I would like to write good code, it is so east to start writing crap. Is the following bad.
lets say I have the following code

testvar = 5
def test(testvar):
    print testvar
test(testvar)

is it a bad practice to use the name of a variable or function in the definition of function, in particular for naming the parameter. This would seem useful to help document what is happening in your code(helps me remember). It does not seem to cause any problems

maybe this would be a better solution. It would allow you to rember what parameter the function needs, but use a slighty different name

testvar = 5
def test(_testvar):
  print _testvar
test(testvar)

Either example is okay. If I would have to show somebody how Python works, the second example using a different variable name would be less confusing.

Make your function names "action verb" descriptive like printNumber(num1) or printValue(val1). I started using a number with a variable name after I used str for a string variable and later in the program used the str() function. Try it, it is a bitch! So now the common string variable is str1 and so on for me!

Underlines drive me nuts, because I don't always notice if there is just _one or __two of them. Python uses too many of those things already.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.