tags:

views:

202

answers:

2

i'd like know about python tricks and tips.

how write a cleaner code when you have an unfortunate situation where you need to fit as much as you can in one expression?

i have some questions:

  • Best way for speed propose
  • Best way for readable code
  • What you should never do
  • What you should avoid
  • Best expert python book
  • Libraries that you should know

i think that every answer will be enough to create a guide for python best pratices.

EDIT you don't need answer all the questions, just give some tips.

+2  A: 

Do stop by to read Dr. Peter Norvig's Python Infrequently Asked Questions. They are not everything you ask for but they are nonetheless very useful.

There is also this nice collection of "hidden features" of Python.

Manoj Govindan
+3  A: 

Python speed tips :

Pythonic way for readable code :

  • Respect PEP 8
  • Use tools such as pylint
  • Do not use list comprehension ^^

Never use exec() or eval() statement on vars that may vary.

Best expert python book... Expert Python Programming is a good start

Librairies that you should know (from standard python modules):

  • collections
  • ConfigParser
  • cPickle
  • ctypes
  • time/datetime
  • distutils
  • httplib
  • inspect
  • itertools
  • json
  • logging
  • optparse
  • os
  • pdb
  • pprint
  • subprocess
  • sys
  • threading
  • unittest
  • urllib
ohe