On 22 oct, 23:39, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Nope, still doesn't work:
>
> def fact(x):
> return reduce(operator.mul,xrange(1,x+1),1)
>
> fact() should raise an exception if x is negative.
So, where is the problem? if not allowing negative numbers is so
important for
On 22 oct, 20:35, Paul Rudin <[EMAIL PROTECTED]> wrote:
> import operator
> def fact(x):
> return reduce(operator.mul, xrange(1,x))
Maybe:
import operator
def fact(x):
return reduce(operator.mul, xrange(2, x+1), 1)
fact(0)
1
fact(4)
24
--
http://mail.python.org/mailman/listinfo/python
On 29 sep, 21:38, Zentrader <[EMAIL PROTECTED]> wrote:
> ctr_a=0
> ctr_b=0
> while ctr_a < len(generator_a):
> this_el_a = generator_a[ctr_a]
> while ctr_b < len(generator_b):
> this_el_b = generator_b[ctr_ b]
> if something_happen:
> ctr_b = len(generator
On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> for i in generator_a: # the first "for" cycle
> for j in generator_b:
> if something_happen:
> # do something here ..., I want the outer cycle to break
> break
Do you like this?
generator_
On 22 sep, 11:37, Konstantinos Pachopoulos <[EMAIL PROTECTED]>
wrote:
> does any body now any such algorith? to find difference in days from
> MMDD to MMDD?
Once I needed the same and I wrote:
def days_difference(s1, s2):
splitdate = lambda s: time.strptime(s, "%Y%m%d")[:3]
str2d
On 20 sep, 08:31, "Dmitry Teslenko" <[EMAIL PROTECTED]> wrote:
> I'm using os.popen to perform lengthy operation such as building some
> project from source.
> def execute_and_save_output( command, out_file, err_file):
> (i,o,e) = os.popen3( command )
You should consider using the higher
Grant Edwards ha escrito:
> > Or, if you happen to like the itertools modules:
> >
> > from itertools import imap
> > ",".join(imap(str, [1, 2, 3]))
>
> It's nice people have invented so many ways to spell the
> builting "map" ;)
Did you wonder why the Python developers bother to implement "imap"