very strange bug coercing to Unicode: need string or buffer, int found

Max Erickson maxerickson at gmail.com
Wed Jun 21 09:29:40 EDT 2006


"bussiere maillist" <bussieremaillist at gmail.com> wrote:

> ------=_Part_118629_1441854.1150895040355
> i truly didn't understand this error :
> Traceback (most recent call last):
>   File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77,
>   in ? 
>     cabtri = "zz" + chiffrescabtri + clefc
> TypeError: coercing to Unicode: need string or buffer, int found

> 
> def calculclef(nombre):
>     if clef == 10:
>         clef = 0
>     return clef
> 

>             clefb = calculclef(debutplage)
>             clefb = str(clefb)
>             print clefb

>             clefc = calculclef(chiffrescabtri)

>             cabtri = "zz" + chiffrescabtri + clefc


Your calculclef function returns an integer. You explitly convert 
clefb into a string, but you never convert clefc into a string, hence 
the TypeError.

max




More information about the Python-list mailing list