Tagged Questions
4
votes
3answers
336 views
Space between negative sign and variable name
I tried doing a Google search, as well as searching this Stack Exchange site but could not find a question relating directly to this.
The PEP 8 -- Style Guide for Python Code has lots of good style ...
5
votes
1answer
319 views
Is using '{}' within format strings considered Pythonic?
I just learned you can write
'{}{}'.format(string_a, string_b)
instead of
'{0}{1}'.format(string_a, string_b)
in Python, i.e. you can omit the numerals for the string format parameters when you ...
2
votes
1answer
170 views
call sub function based on variable value
I have a function containing other functions. These function are called based on value of variable action.
These sub functions are logically grouped - i.e., they all deal with file manipulation.
...
4
votes
1answer
342 views
Pythonic use of the isinstance function?
Whenever I find myself wanting to use the isinstance() function I usually know that I'm doing something wrong and end up changing my ways. However, in this case I think I have a valid use for it. I ...
12
votes
2answers
2k views
What's wrong with relative imports in Python?
I recently upgraded versions of pylint, a popular Python style-checker.
It has gone ballistic throughout my code, pointing out places where I import modules in the same package, without specifying ...
2
votes
6answers
2k views
Single quotes vs double quotes [closed]
I just started a job where I'm writing Python after coming from a Java background, and I'm noticing that other developers tend to quote strings using single quotes ('') instead of double quotes (""). ...
5
votes
3answers
281 views
Should I return iterators or more sophisticated objects?
Say I have a function that creates a list of objects. If I want to return an iterator, I'll have to return iter(a_list). Should I do this, or just return the list as it is? My motivation for returning ...
7
votes
5answers
575 views
Which style to use for unused return parameters in a Python function call
Is there any recommended/generally accepted coding style for handling situations where a function returns a tuple of values but only one of those values is used afterwards (note that this is mostly ...
28
votes
8answers
3k views
How can I learn to effectively write Pythonic code?
Doing a google search for "pythonic" reveals a wide range of interpretations. The wikipedia page says:
A common neologism in the Python community is pythonic, which can have a wide range of ...