Il 13 aprile 2015 11:33, Gabriele Battaglia <iz4...@libero.it> ha scritto:
> Potrei io chiamare la funzione assegnando a _int un tipo diverso: > random.randrange(1, 101, _int='float') > ed ottenere un valore casuale fra 1 e 100 ma in virgola mobile? Dipende. Se stai usando ancora Python 2, sì. In [2]: random.randrange(1, 10, 1, float) Out[2]: 5.600622736511129 Python 3.1 aggiunge il supporto al metodo `int.bit_length()`, e lo utilizza in `randrange`. Quindi non è più possibile inizializzarlo con `float`. >>> random.randrange(1, 10, 1, float) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.4/random.py", line 194, in randrange return istart + self._randbelow(width) File "/usr/lib/python3.4/random.py", line 229, in _randbelow k = n.bit_length() # don't use (n-1) here because n can be 1 AttributeError: 'float' object has no attribute 'bit_length' © -- |:**THE BEER-WARE LICENSE** (Revision 42): | <mi...@python.it> wrote this mail. As long as you retain | this notice you can do whatever you want with this stuff. | If we meet some day, and you think this stuff is worth it, | you can buy me a beer in return. | --Carlo Miron : _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python