Can't detect EOF from stdin on windows console

2006-04-03 Thread Dmitry Anikin
I want to read stdin in chunks of fixed size until EOF I want to be able (also) to supply data interactively in console window and then to hit Ctrl+Z when finished So what I do is: while True: s = sys.stdin.read(chunk_size) if not s: break # do something with s if stdin is standar

cmp() on integers - is there guarantee of returning only +-1 or 0?

2006-03-19 Thread Dmitry Anikin
doc says that it must be > 0, or < 0, but it seems that it returns +1 or -1. Can it be reliably used to get the sign of x: cmp(x, 0) like pascal Sign() function does? I mean, I'm pretty sure that it can be used, but is it mentioned somewhere in language spec, or it may be implementation defined? If

Re: Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-10 Thread Dmitry Anikin
Some example (from real life). def ChooseItems(StartDate, EndDate, Filter): #function returns a set of some items in chronological order #from required interval possibly using filter ChooseItems() #get everything ChooseItems('01.01.2000', ,SomeFilter) #get everything after a date using filter Choo

Re: Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-10 Thread Dmitry Anikin
Some example (from real life). def ChooseItems(StartDate, EndDate, Filter): #function returns a set of some items in chronological order #from required interval possibly using filter ChooseItems() #get everything ChooseItems('01.01.2000', ,SomeFilter) #get everything after a date using filter Choo

Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-10 Thread Dmitry Anikin
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload resolution, isn't it?) and when calling, just omit parameter when you want to use defaults: a_func(,