From: Martijn F. <fa...@ve...> - 2000-04-19 13:09:24
|
Mark Baker wrote: > On Tue, 18 Apr 2000, Eric Jacobs wrote: > > I have a patch for PySDL 0.0.3 to allow any Python > > file-like object to be loaded or saved as an image. > > It also allows strings to be loaded as data. This > > could be useful for games and other programs that > > might not want to store all of their images in > > individual files. > > I'll need to think about the real need of the introspection, but it seems like > it'd be good to not only support file object, but "file-like" objects, as well. > You mention MetaKit, for instance, which could alleviate hassles of back-end > management. > > Using strings as a source of data, though, seems less useful. Flexible, > perhaps, but it's not worth making the API nasty with an optional argument > indicating whether a string is a filename, or a source of data. I think we shouldn't overload the load function too much. Can't we instead have two functions, one to load from a file object, and another to load through a filename? Or perhaps just don't have the last one at at all; it's not hard to create a file object after all. Generally it's better to have multiple functions instead of one function which can receive an argument that can be fundamentally different types (such as strings or file-like objects). Loading from strings directly doesn't seem necessary to me either; you can easily use StringIO or cStringIO to wrap the string up as a file-like object after all? From what I understood from the example, it seems 'file like' objects are supported already, as I saw StringIO being used, right? Regards, Martijn |