I always wanted to know if there a way to find out how many cpu’s does the machine have. For example to run n number of processes based on number of cores, recently i was exploring multiprocessing module and i found that there is a method that show up number of cpu’s / cores that the machine have.
import multiprocessing
multiprocessing.cpu_count()
# this shows up 2 for my core2duo e9300
#so now if we iterate this like that
for i in xrange(multiprocessing.cpu_count()):
print 'core',i+1
#this prints
#core 1
#core 2