The use of :

Nick Coghlan ncoghlan at
Sat Nov 27 13:58:56 CET 2004

Dave Anderson wrote:
> this is answered in the python faq:
>> The colon is required primarily to enhance readability

It also allows 'suiteless' versions of some statements:

   if x > 0: print "Greater that 0"
   while x > 0: x -= 1
   def f(): pass
   class c(object): pass
   for x in range(4): print x

Actually using that feature outside sample code is generally bad karma, though ;)


More information about the Python-list mailing list