Is it possible to create C-style "main" function in Python? (for teaching purposes)

Chris Angelico rosuav at gmail.com
Mon Oct 3 20:07:24 EDT 2011


On Tue, Oct 4, 2011 at 9:41 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> def add_from_input(num_lines):
>    total = global.sum(global.int(global.input()) for i in
> global.range(num_lines))
>    global.print("The total is", total)

That's pretty unfair to the globals.

def add_from_input(param.num_lines):
   local.total = global.sum(global.int(global.input()) for tinyscope.i
in global.range(param.num_lines))
   global.print("The total is", local.total)

FTFY.

ChrisA



More information about the Python-list mailing list