Re: [Python] Pickling in P3.

2017-06-12 Per discussione Gollum1
Il 12 giugno 2017 22:41:00 CEST, Strap Lab  ha scritto:
>Il 12/giu/2017 10:13 PM, "Gabriele Battaglia"  ha
>scritto:
>
>Sera.
>Io torno alle origini del topic.
>Chiedevo come mai non riesco ad usare il modulo pickling con Python 3,
>come
>faccio col 2.
>
>Parto dall’errore:
>
>Traceback (most recent call last):
>  File "collezioni.py", line 84, in 
>
>l=pickle.load(f)
>File
>"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py",
>line 321, in decode
>(result, consumed) = self._buffer_decode(data, self.errors, final)
>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:
>invalid start byte
>
>
>Il file che tento di aprire è un file di testo e f contiene
>semplicemente
>questo:
>
>try:
>f=open(clz+".gbd","U")
>print ("\n\n- Caricamento di "+clz+".gbd"+"  in corso...")
>l=pickle.load(f)
>f.close()
>
>
>A che cosa potrebbe essere dovuto quell’errore?
>
>
>Può essere dovuta a questo:
>https://stackoverflow.com/questions/28218466/unpickling-a-python-2-object-with-python-3
>
>Sani
>Strap

mi sono imbattuto bello stesso errore tempo fa, è dovuta all'interpretazione 
errata del codice 0x80, che in Unicode dovrebbe essere un carattere di 
controllo (se ricordo bene è il decimale 128)... però non mi ricordo come avevo 
risolto la cosa... su stackoverflow dovresti trovare delle info.
-- 
Gollum1
Teoro, dov'è il mio teoro...

Inviato dal mio dispositivo Android con K-9 Mail. Perdonate la brevità e gli 
errori (maledetto correttore ortografico).
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Strap Lab
Il 12/giu/2017 10:13 PM, "Gabriele Battaglia"  ha scritto:

Sera.
Io torno alle origini del topic.
Chiedevo come mai non riesco ad usare il modulo pickling con Python 3, come
faccio col 2.

Parto dall’errore:

Traceback (most recent call last):
  File "collezioni.py", line 84, in 

l=pickle.load(f)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py",
line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:
invalid start byte


Il file che tento di aprire è un file di testo e f contiene semplicemente
questo:

try:
f=open(clz+".gbd","U")
print ("\n\n- Caricamento di "+clz+".gbd"+"  in corso...")
l=pickle.load(f)
f.close()


A che cosa potrebbe essere dovuto quell’errore?


Può essere dovuta a questo:
https://stackoverflow.com/questions/28218466/unpickling-a-python-2-object-with-python-3

Sani
Strap
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


[Python] R: Re: Pickling in P3.

2017-06-12 Per discussione Paolo Di Ieso
>Messaggio originale
>Da: "Carlo Miron" 
>Data: 12/06/2017 11.35
>A: "Discussioni generali sul linguaggio Python"
>Ogg: Re: [Python] Pickling in P3.
>
>2017-06-12 11:31 GMT+02:00 Raffaele Salmaso :
>> 2017-06-12 11:21 GMT+02:00 Daniele Zambelli :
>>>
>>> Il 9 giugno 2017 12:09, Davide Olianas  ha
>>> scritto:
>>> > with open('pippo', 'rb') as f:
>>> > oggetto = pickle.load(f)
>>> Perché usare with e non semplicemente:
>>> f = open('pippo', 'rb')
>>> oggetto = pickle.load(f)
>>> ?
>>
>> Così ti rimane aperto il file inutilmente, col with invece lo chiudi appena
>> hai finito di usarlo.
>> Per uno script usa e getta potrebbe non essere un problema, ma in generale
>> meglio liberare le risorse usate appena possibile.
>
>Inoltre se non chiudi esplicitamente il file, Windows™ non lo scrive
>su disco, abbiamo scoperto.

Tra l'altro nel caso di un'eccezione lanciata prima di arrivare a un ipotetico 
f.close() il file rimarrebbe comunque aperto, mentre "with" chiude sempre il 
file, Puoi sempre utilizzare try/finally per chiudere il file qualunque cosa 
vada storto, ma with è lì che lo fa per te, perché non usarlo...

Paolo
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Gabriele Battaglia
Sera.
Io torno alle origini del topic.
Chiedevo come mai non riesco ad usare il modulo pickling con Python 3, come 
faccio col 2.

Parto dall’errore:

Traceback (most recent call last):
  File "collezioni.py", line 84, in 

l=pickle.load(f)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py", 
line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid 
start byte


Il file che tento di aprire è un file di testo e f contiene semplicemente 
questo:

try:
f=open(clz+".gbd","U")
print ("\n\n- Caricamento di "+clz+".gbd"+"  in corso...")
l=pickle.load(f)
f.close()


A che cosa potrebbe essere dovuto quell’errore?

Grazie.
Gabriele.
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Daniele Zambelli
Il 12 giugno 2017 11:31, Raffaele Salmaso  ha scritto:
> Così ti rimane aperto il file inutilmente, col with invece lo chiudi appena
> hai finito di usarlo.

[...]

Grazie, molto interessante.

-- 

Daniele

www.fugamatematica.blogspot.com

giusto!
nel verso
forse è perché non guardiamo le cose
Quando non ci capiamo,
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


[Python] EuroScipy 2017: CfP now Open

2017-06-12 Per discussione Valerio Maggio
*(Apologies if you receive multiple copies of this message)*

*10th European Conference on Python in Science*

*August 28 - September 1, 2017 in Erlangen, Germany*

*Description: *

The *EuroSciPy* meeting is a cross-disciplinary gathering focused on the
use and development of the Python language in scientific research. This
event strives to bring together both users and developers of scientific
tools, as well as academic research and state of the art industry.

Erlangen is one of Germany’s major science hubs and located north of Munich
(90 minutes by train).

*Topics of Interest*

Presentations of scientific tools and libraries using the Python language,
including but not limited to:

   - Vector and array manipulation
   - Parallel computing
   - Scientific visualization
   - Scientific data flow and persistence
   - Algorithms implemented or exposed in Python
   - Web applications and portals for science and engineering-
   - Reports on the use of Python in scientific achievements or ongoing
   projects.
   - General-purpose Python tools that can be of special interest to the
   scientific community.

*Submission Details:*

You can send your proposal by submitting your application here:
https://www.papercall.io/euroscipy-2017

The Call for Papers closes on *June 25, 2017 00:00 CEST*

Please feel free to forward this message to anyone who may be interested.

Cheers,
Valerio

-- 
# valerio
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Paolo Di Ieso


Il 12/06/2017 11:35, Carlo Miron ha scritto:

2017-06-12 11:31 GMT+02:00 Raffaele Salmaso :

2017-06-12 11:21 GMT+02:00 Daniele Zambelli :

Il 9 giugno 2017 12:09, Davide Olianas  ha
scritto:

with open('pippo', 'rb') as f:
 oggetto = pickle.load(f)

Perché usare with e non semplicemente:
f = open('pippo', 'rb')
oggetto = pickle.load(f)
?

Così ti rimane aperto il file inutilmente, col with invece lo chiudi appena
hai finito di usarlo.
Per uno script usa e getta potrebbe non essere un problema, ma in generale
meglio liberare le risorse usate appena possibile.

Inoltre se non chiudi esplicitamente il file, Windows™ non lo scrive
su disco, abbiamo scoperto.


Aggiungo: e mentre "with" ti chiude automaticamente il file anche in 
caso di eccezione, nel caso di un'eccezione lanciata prima di arrivare a 
un ipotetico f.close() il file rimarrebbe comunque aperto. Puoi sempre 
utilizzare try/finally per chiudere il file qualunque cosa vada storto, 
ma with è lì che lo fa per te, perché non usarlo...


Paolo
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Paolo Di Ieso


Il 12/06/2017 11:31, Raffaele Salmaso ha scritto:
2017-06-12 11:21 GMT+02:00 Daniele Zambelli 
mailto:daniele.zambe...@gmail.com>>:


Il 9 giugno 2017 12:09, Davide Olianas mailto:dav...@davideolianas.com>> ha scritto:
> with open('pippo', 'rb') as f:
> oggetto = pickle.load(f)
Perché usare with e non semplicemente:
f = open('pippo', 'rb')
oggetto = pickle.load(f)
?

Così ti rimane aperto il file inutilmente, col with invece lo chiudi 
appena hai finito di usarlo.
Per uno script usa e getta potrebbe non essere un problema, ma in 
generale meglio liberare le risorse usate appena possibile.




Aggiungo: e mentre "with" ti chiude automaticamente il file anche in 
caso di eccezione, nel caso di un'eccezione lanciata prima di arrivare a 
un ipotetico f.close() il file rimarrebbe comunque aperto. Puoi sempre 
utilizzare try/finally per chiudere comunque il file qualunque cosa vada 
storto, ma with è lì che lo fa per te, perché non usarlo...


Paolo
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Carlo Miron
2017-06-12 11:31 GMT+02:00 Raffaele Salmaso :
> 2017-06-12 11:21 GMT+02:00 Daniele Zambelli :
>>
>> Il 9 giugno 2017 12:09, Davide Olianas  ha
>> scritto:
>> > with open('pippo', 'rb') as f:
>> > oggetto = pickle.load(f)
>> Perché usare with e non semplicemente:
>> f = open('pippo', 'rb')
>> oggetto = pickle.load(f)
>> ?
>
> Così ti rimane aperto il file inutilmente, col with invece lo chiudi appena
> hai finito di usarlo.
> Per uno script usa e getta potrebbe non essere un problema, ma in generale
> meglio liberare le risorse usate appena possibile.

Inoltre se non chiudi esplicitamente il file, Windows™ non lo scrive
su disco, abbiamo scoperto.

㎝

-- 
|:**THE 🍺-WARE LICENSE** *(Revision ㊷)*:
|  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 🍺 in return. —㎝
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Raffaele Salmaso
2017-06-12 11:21 GMT+02:00 Daniele Zambelli :

> Il 9 giugno 2017 12:09, Davide Olianas  ha
> scritto:
> > with open('pippo', 'rb') as f:
> > oggetto = pickle.load(f)
> Perché usare with e non semplicemente:
> f = open('pippo', 'rb')
> oggetto = pickle.load(f)
> ?
>
Così ti rimane aperto il file inutilmente, col with invece lo chiudi appena
hai finito di usarlo.
Per uno script usa e getta potrebbe non essere un problema, ma in generale
meglio liberare le risorse usate appena possibile.

-- 
| Raffaele Salmaso
| https://salmaso.org
| https://bitbucket.org/rsalmaso
| https://github.com/rsalmaso
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python


Re: [Python] Pickling in P3.

2017-06-12 Per discussione Daniele Zambelli
Il 9 giugno 2017 12:09, Davide Olianas  ha scritto:
>
> with open('pippo', 'rb') as f:
> oggetto = pickle.load(f)

Scusate se allargo la discussione, ma forse la risposta è abbastanza
semplice e non occorre aprire un nuovo thread.

Perché usare with e non semplicemente:

f = open('pippo', 'rb')
oggetto = pickle.load(f)

oppure:

oggetto = pickle.load(open('pippo', 'rb'))

?

Grazie

-- 

Daniele

www.fugamatematica.blogspot.com

giusto!
nel verso
forse è perché non guardiamo le cose
Quando non ci capiamo,
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python