[Python-Dev] file(file)

Jack Jansen Jack.Jansen at cwi.nl
Sat Jan 13 00:54:26 CET 2007


On  12-Jan-2007, at 19:01 , Guido van Rossum wrote:

> On 1/12/07, A.M. Kuchling <amk at amk.ca> wrote:
>> Many types in Python are idempotent, so that int(1) works
>> as expected, float(2.34)==2.34, ''.join('hello')=='hello'
>> et cetera.
>
> I'm not sure I understand the use case; I don't believe I've ever felt
> the need for this.

I have oodles of routines of the form
def foo(thefile):
	if type(thefile) == str: thefile = open(thefile)
or
	if not hasattr(thefile, 'read'): thefile = open(thefile)
or something similar.

> We should also consider the semantics in more detail. Should the seek
> position be shared between the two objects? What about buffering?

That's definitely the hard part. But it's somewhat similar to  
"normal" mutable objects which are (I think always, right?) shallow  
copied when used in a constructor.
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma  
Goldman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070113/beebb5c5/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2255 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20070113/beebb5c5/attachment.bin 


More information about the Python-Dev mailing list