Serialising an 8x8x8 array of pygame sounds

Peter Otten __peter__ at web.de
Sun Sep 18 11:17:06 EDT 2016


kerbingamer376 wrote:

> On Sunday, September 18, 2016 at 2:59:10 PM UTC+1, Steve D'Aprano wrote:
>> On Sun, 18 Sep 2016 11:20 pm, kerbingamer376 wrote:
>> 
>> > Is it possible to serialise an 8x8x8 array of pygame.mixer.Sound
>> > objects, so they stay at the same places in the array, but in a format
>> > that can be pickled, and then the opposite (read from that back to
>> > pygame.mixer.Sound objects)?
>> 
>> Can you seralise *one* Sound object?
>> 
>> If not, then you can't serialise an array of Sound objects either.
>> 
>> 
>> 
>> --
>> Steve
>> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
>> enough, things got worse.
> 
> That's my problem, the Sound object can't be picked, I was wondering if a
> way existed to convert said object to a serialize-able format.

If the Sound object exposes enough of its state to build an equivalent one 
from that state there's a way to write and register your own serialization 
routine. See

https://docs.python.org/2/library/copy_reg.html




More information about the Python-list mailing list