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(,
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
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
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
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