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


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

Re: Python bloqué

Path csiph.com!aioe.org!news.gegeweb.eu!gegeweb.org!news.ortolo.eu!news.izac.org!reader
From Benoit Izac <use.reply.to@INVALID.ADDRESS>
Newsgroups fr.comp.lang.python
Subject Re: Python bloqué
Date Tue, 03 Dec 2019 23:16:33 +0100
Message-ID <87zhg95a2m.fsf@izac.org> (permalink)
References <-ZKdnfFwIp08TnvAnZ2dnUU798zNnZ2d@giganews.com>
Reply-To benoit.izac@free.fr
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Injection-Info keg.izac.org; logging-data="26562"; mail-complaints-to="usenet@izac.org"
Xref csiph.com fr.comp.lang.python:3261

Show key headers only | 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