Fredrik Lundh wrote: > > skip wrote: > > > mal> pickle and marshal would also be a good to have wrapped as codecs. > > > > Why? They operate on much more than strings. Of course. Still their basic task is to take an object and encode in some way for dumps() and do the reverse for loads(). That's pretty much what codecs normally do ;-) I wasn't referring to the use of pickle and marshal with string.encode() and .decode(); even though you could then decode a pickle using "pickledata".decode("pickle") and get back the object. These two are very useful though when it comes to using codecs for file wrappers: f = codecs.open('mypicklfile', mode='wb', encoding='pickle') f.write((123, 'abc', 456.789)) f.close() f = codecs.open('mypicklfile', mode='rb', encoding='pickle') t = f.read() f.close() > hypergeneralization, of course. > > more candidates: > > "10".decode("int") > "10.0".decode("float") > "[1, 2, 3]".decode("list") > "readme.txt".decode("file") > "SyntaxError".decode("raise") > (etc) You forgot the most important one ;-) ... "print 'My first Python program'".decode("python").run() -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4