On 09/24/2015 02:50 PM, paul.hermeneu...@gmail.com wrote:
 > A lot of our in base weird python comes from heavily C-wired people:
 >
 > The classic
 > for i in range(len(alist)):
 >   print alist[i]
 >
 > with its twin brother
 >
 > i=0
 > while i < len(alist):
 >   print alist[i]
 >   i += 1
 >
 > And the even more annoying
 >
 > result = Result()
 > getResult(result)
 >
 > JM

Please follow up with good ways to write these. I hear that creating one
really good way is a Python maxim.

for item in alist:
  print item

and

result = getResult()

For the later, the original weird form come from a C habit to allocate returned structures within the caller and provide a pointer to it so the function can fill the data in, otherwise the structure is lost as the stack is popped out and the structure content is garbage. None of this make any sense in python.

JM


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to