koranthala wrote:
Hi,
Which is more advisable?
import x
b = x.a
or
from x import a
b = a
If I know I want just one thing from x, I tend to use latter.
I also like 'import xyzlib as x'
I read in Learning Python that it is always better to use the
former - especially since namespace wont be dirtied.
Namespace get cluttered, not dirtied. In any case, either 'x' or 'a'
gets added. One new name either way.
class x:
def y():
try:
if test:
obj.filename = str(os.path.basename
(obj1.find_next_element().\
get_file_path()))
obj.modify_time = obj.filename.find_created_time()
+ \
datetime.timedelta
(seconds=time.find_time())
Use 4 spaces instead of 5 for indents
Almost every line requires the '\'.
As Steven said, usually no
Also, especially since Python also
uses whitespace as indentation, I keep confusing the block indentation
with the indentation that the '\' causes in the next line.
'\' causes no indentation
Beyond that, consider find a style you like. I agree with Stvhen about
using 'thought-sized' expressions.
tjr
--
http://mail.python.org/mailman/listinfo/python-list