Hacker News new | ask | show | jobs
by syrrim 1992 days ago

  for x, y in zip(a,b):
      area = to_area(x, y)
      if area > 10:
          print(f"Area {area}")
>in python where you don't often use a namespace to store these intermediary variables

Hm? Most python code is within a function, in my experience.

1 comments

You can abstract it out to a function but I think its overkill, even if you generalize to something like print_area_filter(heights, widths, value, cmp) or whatever

If its not in a function, your example may (or may not depending on length if either a or b have a length of zero) create a floating variable called area out there.