Advertisement
mbazs

Mysterious in-place function call

Oct 15th, 2017
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. import numpy
  2.  
  3. def main():
  4.     xs0 = [1, 2, 3]
  5.     xs1 = numpy.array([1, 2, 3, 4, 5])
  6.     f = lambda x: x**2
  7.     #print(f(xs0))  # invalid of course
  8.     print(f(xs1))  # why does it work?
  9.  
  10. if __name__ == '__main__':
  11.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement