Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.python > #3261

Re: Python bloqué

From Benoit Izac <use.reply.to@INVALID.ADDRESS>
Newsgroups fr.comp.lang.python
Subject Re: Python bloqué
Date 2019-12-03 23:16 +0100
Message-ID <87zhg95a2m.fsf@izac.org> (permalink)
References <-ZKdnfFwIp08TnvAnZ2dnUU798zNnZ2d@giganews.com>

Show all headers | View raw


Bonjour,

Le 03/12/2019 à 22:29, Jonathannnn a écrit dans le message
<-ZKdnfFwIp08TnvAnZ2dnUU798zNnZ2d@giganews.com> :

> Depuis peu je suis sur Python et je reçois le même message d'erreur qui est
> "TypeError: 'module' object is not callable". Je suis allé sur d'autre forum
> mais je ne comprends pas mon erreur. Voici mon programme :
>
> from random import randint
> import random

random représente le module que tu as importé (de type class 'module').

> def parcoursfourmisurtriangle(n):
>         a=0
>         b=0
>         c=0
>         randint=random(1,3)

Et là tu l'appelles avec des arguments ; ça n'a pas de sens puisque
c'est un module. J'imagine que ce que tu veux c'est random.randint(1, 3)
et c'est ce que tu fais très bien juste en dessous vu que tu as importé
randint (de type class 'method'). Tu noteras également que tu "écrases"
randint (la fonction du module random) lorsque tu fais « randint = … ».

>         p=randint(1,3)
>         for deplacement in range(n):
>                 alea=random()

Même problème ici.

   alea = random.random() # la fonction random du module random

-- 
Benoit Izac

Back to fr.comp.lang.python | Previous | NextPrevious in thread | Find similar


Thread

Python bloqué Jonathannnn <nospam_enzo.mostachetti@gmail.com.invalid> - 2019-12-03 15:29 -0600
  Re: Python bloqué Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2019-12-03 23:16 +0100

csiph-web