[Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
[Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
@mods: se l'argomento è OT ... cancellate pure, pazienza! Se, invece decidete, come mi auguro, di lasciarlo per qualche giorno, chiedo che il 3D rimanga qui e non venga spostato al Bar, dove avrebbe poca evidenza.
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
http://mpmath.org/BlueEyes [url=http://forum.ubuntu-it.org/viewtopic.php?p=4953230#p4953230][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Non so da dove prelevarla, riesco a trovare solo .exe a 32bit. Qualcuno mi può aiutare? Grazie anticipate
@mods: se l'argomento è OT ... cancellate pure, pazienza! Se, invece decidete, come mi auguro, di lasciarlo per qualche giorno, chiedo che il 3D rimanga qui e non venga spostato al Bar, dove avrebbe poca evidenza.
mpmath-0.19.tar.gz
scompatti e metti nel path dei moduli python
http://stackoverflow.com/questions/3701 ... -windows-7
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Domani testerò le indicazioni che mi hai dato e poi riferirò. Incrocio le dita di non trovare conflitto con la mia CPU a 64bit. Ciao
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
conflitti de che?BlueEyes [url=http://forum.ubuntu-it.org/viewtopic.php?p=4953246#p4953246][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Grazie dell'info, telperion!
Domani testerò le indicazioni che mi hai dato e poi riferirò. Incrocio le dita di non trovare conflitto con la mia CPU a 64bit. Ciao
solo il python è un programma compilato (exe),
le librerie sono semplice codice sorgente compilato al volo da python.
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Quelli dello screenshot, intendevo dire, dove vengono presentate due librerie mpmath distinte a seconda della CPU del sistemaconflitti de che?
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Purtroppo non va, come descritto all'interno della figura. Ringrazio il mio interlocutore, che mi ha permesso di capire il motivo per cui ... devo ancora aspettare: la libreria mpmath _non_ è ancora supportata sui sistemi Windows per Python 3, come evidenzia la figura del mio precedente post. Grazie anche ai mods, per avermi permesso questo ... fuori pista! Ciaompmath-0.19.tar.gz
scompatti e metti nel path dei moduli python
- crap0101
- Rampante Reduce
- Messaggi: 8242
- Iscrizione: martedì 30 ottobre 2007, 6:33
- Desktop: LXDE
- Distribuzione: Ubuntu 18.04.1 LTS
- Sesso: Maschile
- Località: TO
- Contatti:
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Se invece non è compatibile con python3 è un altro discorso, però sul sito scrivono
mpmath runs on Python 2.5 or higher (including Python 3.x), with no other required dependencies.
- Ricorda le ultime parole di suo padre: «Sta' alla larga dalle chiese, figlio. La sola cosa per cui hanno la chiave è il merdaio. E giurami che non porterai mai un distintivo della legge» - W.S. Burroughs
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Questa non la sapevo, domani la provo. Vediamo se ho capito. Vado sul terminale di Windows, il noto Prompt dei Comandi, mi trasferisco nella cartella di setup.py (quella che si vede in figura) e da lì digito:btw, non è un file bash... è un file python, in teoria (e pure in pratica) lo puoi eseguire anche da Win, basta usare l'opzione -x ;
Codice: Seleziona tutto
python setup.py -x (invio)
Edit. Per maggior chiarezza allego l'help (+version) del mio Python:
Codice: Seleziona tutto
python --help
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-b : issue warnings about str(bytes_instance), str(bytearray_instance)
and comparing bytes/bytearray with str. (-bb: issue errors)
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser; also PYTHONDEBUG=x
-E : ignore PYTHON* environment variables (such as PYTHONPATH)
-h : print this help message and exit (also --help)
-i : inspect interactively after running script; forces a prompt even
if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I : isolate Python from the user's environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO : remove doc-strings in addition to the -O optimizations
-q : don't print version and copyright messages on interactive startup
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S : don't imply 'import site' on initialization
-u : unbuffered binary stdout and stderr, stdin always buffered;
also PYTHONUNBUFFERED=x
see man page for details on internal buffering relating to '-u'
-v : verbose (trace import statements); also PYTHONVERBOSE=x
can be supplied multiple times to increase verbosity
-V : print the Python version number and exit (also --version)
-W arg : warning control; arg is action:message:category:module:lineno
also PYTHONWARNINGS=arg
-x : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option
file : program read from script file
- : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH : ';'-separated list of directories prefixed to the
default module search path. The result is sys.path.
PYTHONHOME : alternate <prefix> directory (or <prefix>;<exec_prefix>).
The default module search path uses <prefix>\lib.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.
PYTHONHASHSEED: if this variable is set to 'random', a random value is used
to seed the hashes of str, bytes and datetime objects. It can also be
set to an integer in the range [0,4294967295] to get hash values with a
predictable seed.
python -V
Python 3.5.1
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
BlueEyes [url=http://forum.ubuntu-it.org/viewtopic.php?p=4953396#p4953396][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Purtroppo non va, come descritto all'interno della figura. Ringrazio il mio interlocutore, che mi ha permesso di capire il motivo per cui ... devo ancora aspettare: la libreria mpmath _non_ è ancora supportata sui sistemi Windows per Python 3, come evidenzia la figura del mio precedente post. Grazie anche ai mods, per avermi permesso questo ... fuori pista! Ciaompmath-0.19.tar.gz
scompatti e metti nel path dei moduli python
ma quella roba serve solo per copiare da qualche parte la lib.
Puoi metterla a mano nel path di python (PYTHONPATH) o dove ti pare.
http://stackoverflow.com/questions/3701 ... -windows-7
Esempio ho solo scompattato l'archivio vedi immagine:
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Ed è proprio quello che voglio fare io, metterla da qualche parte in modo che possa richiamare qualsiasi script da terminale per es. questo:ma quella roba serve solo per copiare da qualche parte la lib
Codice: Seleziona tutto
# ---- FI-aureo.py -------- FI= [1+sqrt(5)]/2 = 1.6180339....
# Avvio: python FI-aureo.py > output.txt (enter) --------
from mpmath import *
mp.dps = 10000; mp.pretty= True
fi= (sqrt(5)+1.0)/2
print fi
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
BlueEyes [url=http://forum.ubuntu-it.org/viewtopic.php?p=4953565#p4953565][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Ed è proprio quello che voglio fare io, metterla da qualche parte in modo che possa richiamare qualsiasi script da terminale per es. questo:ma quella roba serve solo per copiare da qualche parte la libche gira se la libreria è installata ed è la prelevabile da Windows, non la devo richiamare. Su Ubuntu 16.04.01 non ho alcun problema perché mpmath è installata correttamente da repo: supo apt-get install mpmath. ThxSpoilerMostraCodice: Seleziona tutto
# ---- FI-aureo.py -------- FI= [1+sqrt(5)]/2 = 1.6180339.... # Avvio: python FI-aureo.py > output.txt (enter) -------- from mpmath import * mp.dps = 10000; mp.pretty= True fi= (sqrt(5)+1.0)/2 print fi
Codice: Seleziona tutto
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH : ';'-separated list of directories prefixed to the
default module search path. The result is sys.path.
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Sull'help di Python 3.5.1 (Windows OS) trovo:
Codice: Seleziona tutto
-x : skip first line of source, allowing use of non-Unix forms of #!cmd
Codice: Seleziona tutto
Microsoft Windows [Versione 10.0.14393]
C:\Users\Alfabeta>cd\tr*\mp*
C:\Training\mpmath-0.19>dir
Il volume nell'unità C è Windows
Numero di serie del volume: 480B-D91C
Directory di C:\Training\mpmath-0.19
26/01/2017 16:16 <DIR> .
26/01/2017 16:16 <DIR> ..
10/06/2014 15:21 38.737 CHANGES
26/12/2013 17:39 1.524 LICENSE
26/01/2017 16:16 <DIR> mpmath
10/06/2014 15:41 331 PKG-INFO
10/06/2014 15:11 599 setup.py
4 File 41.191 byte
3 Directory 799.520.047.104 byte disponibili
1.. Primo tentativo
C:\Training\mpmath-0.19>setup.py -x
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option -x not recognized
2.. Secondo tentativo
C:\Training\mpmath-0.19>python setup.py -x
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option -x not recognized
- crap0101
- Rampante Reduce
- Messaggi: 8242
- Iscrizione: martedì 30 ottobre 2007, 6:33
- Desktop: LXDE
- Distribuzione: Ubuntu 18.04.1 LTS
- Sesso: Maschile
- Località: TO
- Contatti:
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Codice: Seleziona tutto
python -x setup.py comandi_e_opzioni_per_il_setup
- Ricorda le ultime parole di suo padre: «Sta' alla larga dalle chiese, figlio. La sola cosa per cui hanno la chiave è il merdaio. E giurami che non porterai mai un distintivo della legge» - W.S. Burroughs
Re: Python 3.5.1 (Win10-64bit): libreria mpmath
Codice: Seleziona tutto
Microsoft Windows [Versione 10.0.14393]
(c) 2016 Microsoft Corporation. Tutti i diritti sono riservati.
C:\Users\Alfabeta>cd\tr*\mp*
C:\Training\mpmath-0.19>python -x setup.py install
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\mpmath
copying mpmath\conftest.py -> build\lib\mpmath
copying mpmath\ctx_base.py -> build\lib\mpmath
copying mpmath\ctx_fp.py -> build\lib\mpmath
copying mpmath\ctx_iv.py -> build\lib\mpmath
copying mpmath\ctx_mp.py -> build\lib\mpmath
copying mpmath\ctx_mp_python.py -> build\lib\mpmath
........
........
byte-compiling C:\Users\AlfaBeta\AppData\Local\Programs\Python\Python35\Lib\site-packages\mpmath\
__init__.py to __init__.cpython-35.pyc
running install_egg_info
Writing C:\Users\AlfaBeta\AppData\Local\Programs\Python\Python35\Lib\site-packages\mpmath-0.19-py
3.5.egg-info
// fine dell'nstallazione
// file fi.py (che gira su python 2.7)
# ---- FI-aureo.py -------- FI= [1+sqrt(5)]/2 = 1.6180339....
# Avvio: python FI-aureo.py > output.txt (enter) --------
from mpmath import *
mp.dps = 10000; mp.pretty= True
fi= (sqrt(5)+1.0)/2
print fi
Microsoft Windows [Versione 10.0.14393]
(c) 2016 Microsoft Corporation. Tutti i diritti sono riservati.
C:\Users\Alfabeta>cd\tr*
C:\Training>python fi.py
File "fi.py", line 6
print fi
^
SyntaxError: Missing parentheses in call to 'print'
// inserisco le parentesi tonde ed avvio .... voilà les yeux sont faits!
C:\Training>python fi.py
1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939
1137484754088075386891752126633862223536931793180060766726354433389086595939582905638322661319928
2902678806752087668925017116962070322210432162695486262963136144381497587012203408058879544547492
......
...... ultimi decimali del numero aureo
4882723856345156390526577104264594760405569509598408889037620799566388017861855915944111725092313
279771138
-----------
Re: [Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
La libreria mpmath installata da repo viene letta dal comando python filename.py ed avvia lo script, mentre python3 (che è installato di default) ... non la vede! Non vorrei si creassero conflitti, ripetendo la stessa 'manovra' di sopra.
Codice: Seleziona tutto
alfabeta@ubuntu:~$ whereis python
python: /usr/bin/python3.5 /usr/bin/python3.5m /usr/bin/python2.7 /usr/bin/python /usr/lib/python3.5 /usr/lib/python2.7 /etc/python3.5 /etc/python2.7 /etc/python /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/include/python3.5m /usr/share/python /usr/share/man/man1/python.1.gz
alfabeta@ubuntu:~/Scrivania/Python-2.7.12$ python3 FI-aureo.py
Traceback (most recent call last):
File "FI-aureo.py", line 3, in <module>
from mpmath import *
ImportError: No module named 'mpmath'
- crap0101
- Rampante Reduce
- Messaggi: 8242
- Iscrizione: martedì 30 ottobre 2007, 6:33
- Desktop: LXDE
- Distribuzione: Ubuntu 18.04.1 LTS
- Sesso: Maschile
- Località: TO
- Contatti:
Re: [Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
Codice: Seleziona tutto
pip3 install mpmath
- Ricorda le ultime parole di suo padre: «Sta' alla larga dalle chiese, figlio. La sola cosa per cui hanno la chiave è il merdaio. E giurami che non porterai mai un distintivo della legge» - W.S. Burroughs
Re: [Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
Et voilà ... anche questa è andata, caricando la libreria pacchettizzata. Grazie mille, crap0101, Ecco un test:guardando sembra che nei repo ci sia la versione già pacchettizzata, python3-mpmath
Codice: Seleziona tutto
# ---- Neper -------- e= base dei logaritmi neperiani = 2.718281828....
# Avvio: python Neper.py > output.txt (enter) --------
from mpmath import *
mp.dps = 50000; mp.pretty= True
e= exp(1.0)
print (e)
#alfabeta@ubuntu:~/Scrivania/Python-2.7.12$ python3 Neper.py
#2.718281828459045235360287471352662497757247093699959574966967627724076
#63035354759457138217852516642742746639193200305992181741359662904357290
#03342952605956307381323286279434907632338298807531952510190115738341879
#30702154089149934884167509244761460668082264800168477411853742345442437
#1075390777449920695517027618386062613313845830007520449338 ... e così via fino a 50mila
Codice: Seleziona tutto
alfabeta@ubuntu:~/Scrivania/Python-2.7.12$ python3 separoo.py
Traceback (most recent call last):
File "separoo.py", line 16, in <module>
print (pretty(k,8,8))
File "separoo.py", line 12, in pretty
return '\n'.join(lines)
File "separoo.py", line 11, in <genexpr>
lines = (' '.join(''.join(group) for group in line) for line in groups)
File "separoo.py", line 6, in split_columns
for k, g in itertools.groupby(iterable, lambda item: c.next() // size):
File "separoo.py", line 6, in split_columns
for k, g in itertools.groupby(iterable, lambda item: c.next() // size):
File "separoo.py", line 6, in <lambda>
for k, g in itertools.groupby(iterable, lambda item: c.next() // size):
AttributeError: 'itertools.count' object has no attribute 'next'
# -------- separoo.py ------------
import itertools
def split_columns(iterable, size):
c = itertools.count()
for k, g in itertools.groupby(iterable, lambda item: c.next() // size):
yield list(g)
def pretty(number, size=8, per_line=8):
groups = split_columns(split_columns(str(number), size), per_line)
lines = (' '.join(''.join(group) for group in line) for line in groups)
return '\n'.join(lines)
k = 14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759
print (pretty(k,8,8))
# ------------ EOF: separoo.py -----------
Output di separoo.py con Python 2.7, usando print pretty(k,8,8)
-----------------------------------
14159265 35897932 38462643 38327950 28841971 69399375 10582097 49445923
07816406 28620899 86280348 25342117 06798214 80865132 82306647 09384460
95505822 31725359 40812848 11174502 84102701 93852110 55596446 22948954
93038196 44288109 75665933 44612847 56482337 86783165 27120190 91456485
..........
48960841 28488626 94560424 19652850 22210661 18630674 42786220 39194945
04712371 37869609 56364371 91728746 77646575 73962413 89086583 26459958
13390478 02759
Re: [Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
- crap0101
- Rampante Reduce
- Messaggi: 8242
- Iscrizione: martedì 30 ottobre 2007, 6:33
- Desktop: LXDE
- Distribuzione: Ubuntu 18.04.1 LTS
- Sesso: Maschile
- Località: TO
- Contatti:
Re: [Risolto] Python 3.5.1 (Win10-64bit): libreria mpmath
il problema è che in python3 itertools.count non ha più il metodo next, ma __next__ (che funziona iterandoci su normalmente)... per adattarlo alla tua funzione (così che funzioni sia su py2 che py3) dovresti scrivereBlueEyes [url=http://forum.ubuntu-it.org/viewtopic.php?p=4954220#p4954220][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Et voilà ... anche questa è andata, caricando la libreria pacchettizzata. Grazie mille, crap0101, Ecco un test:guardando sembra che nei repo ci sia la versione già pacchettizzata, python3-mpmathMa Python3 mi ha riservato un'altra sorpresa, su quest'esempio. Il comando print pretty(k,8,8) va bene su Python2.7, e mi sarei aspettato che, racchiudendolo tra le tonde come ho fatto sopra con la variabile 'e', ovvero print (pretty(k,8,8)), l'output della matrice funzionasse lo stesso, invece ...SpoilerMostraCodice: Seleziona tutto
# ---- Neper -------- e= base dei logaritmi neperiani = 2.718281828.... # Avvio: python Neper.py > output.txt (enter) -------- from mpmath import * mp.dps = 50000; mp.pretty= True e= exp(1.0) print (e) #alfabeta@ubuntu:~/Scrivania/Python-2.7.12$ python3 Neper.py #2.718281828459045235360287471352662497757247093699959574966967627724076 #63035354759457138217852516642742746639193200305992181741359662904357290 #03342952605956307381323286279434907632338298807531952510190115738341879 #30702154089149934884167509244761460668082264800168477411853742345442437 #1075390777449920695517027618386062613313845830007520449338 ... e così via fino a 50mila
SpoilerMostraCodice: Seleziona tutto
alfabeta@ubuntu:~/Scrivania/Python-2.7.12$ python3 separoo.py Traceback (most recent call last): File "separoo.py", line 16, in <module> print (pretty(k,8,8)) File "separoo.py", line 12, in pretty return '\n'.join(lines) File "separoo.py", line 11, in <genexpr> lines = (' '.join(''.join(group) for group in line) for line in groups) File "separoo.py", line 6, in split_columns for k, g in itertools.groupby(iterable, lambda item: c.next() // size): File "separoo.py", line 6, in split_columns for k, g in itertools.groupby(iterable, lambda item: c.next() // size): File "separoo.py", line 6, in <lambda> for k, g in itertools.groupby(iterable, lambda item: c.next() // size): AttributeError: 'itertools.count' object has no attribute 'next' # -------- separoo.py ------------ import itertools def split_columns(iterable, size): c = itertools.count() for k, g in itertools.groupby(iterable, lambda item: c.next() // size): yield list(g) def pretty(number, size=8, per_line=8): groups = split_columns(split_columns(str(number), size), per_line) lines = (' '.join(''.join(group) for group in line) for line in groups) return '\n'.join(lines) k = 14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759 print (pretty(k,8,8)) # ------------ EOF: separoo.py ----------- Output di separoo.py con Python 2.7, usando print pretty(k,8,8) ----------------------------------- 14159265 35897932 38462643 38327950 28841971 69399375 10582097 49445923 07816406 28620899 86280348 25342117 06798214 80865132 82306647 09384460 95505822 31725359 40812848 11174502 84102701 93852110 55596446 22948954 93038196 44288109 75665933 44612847 56482337 86783165 27120190 91456485 .......... 48960841 28488626 94560424 19652850 22210661 18630674 42786220 39194945 04712371 37869609 56364371 91728746 77646575 73962413 89086583 26459958 13390478 02759
Codice: Seleziona tutto
next(c)
Codice: Seleziona tutto
c.next()
Però... non so se è quello che vuoi fare perchè non mi sembra così utile: per come l'hai scritto è identico a restituire *tutti* gli elementi di `iterable`, dato che la keyfunc che utilizzi restituisce numeri progressivi e tu ritorni solo `g`; in pratica è identico a scrivere
Codice: Seleziona tutto
for item in iterable:
yield [item]
- Ricorda le ultime parole di suo padre: «Sta' alla larga dalle chiese, figlio. La sola cosa per cui hanno la chiave è il merdaio. E giurami che non porterai mai un distintivo della legge» - W.S. Burroughs
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 17 ospiti