On May 2, 11:59 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > ... > > > >>> import gmpy > > >>> gmpy.mpz(11) > > mpz(11) > > >>> gmpy.mpz('11',10) > > mpz(11) > > >>> gmpy.mpz(11,10) > > > Traceback (most recent call last): > > File "<pyshell#38>", line 1, in <module> > > gmpy.mpz(11,10) > > TypeError: gmpy.mpz() with numeric argument needs exactly 1 argument > > > The mpz conversion takes two arguments if and only if s is a string, > > else it takes 1 argument. So being non-empty is insufficient. > > Being a string AND being non-empty is insufficient too -- just try > > gmpy.mpz("Hello, I am a string and definitely not empy!", 10) > > on for size. > > Alex
>>> import gmpy >>> gmpy.mpz("Hello, I am a string and definitely not empy!", 10) Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> gmpy.mpz("Hello, I am a string and definitely not empy!", 10) ValueError: invalid digits But you don't get a TypeError, you get a ValueError. And you might scratch your head over >>> gmpy.mpz('zzz',26) Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> gmpy.mpz('zzz',26) ValueError: invalid digits until you remember that base 26 is 0-9a-p, not a-z. -- http://mail.python.org/mailman/listinfo/python-list