[Chicago] What to do about File Like Object methods I don't need...

Brantley Harris deadwisdom at gmail.com
Sun Dec 21 21:48:23 CET 2008


It's what NotImplimentedError is for!

On Sun, Dec 21, 2008 at 12:56 PM, Ian Bicking <ianb at colorstudy.com> wrote:
> Steven Githens wrote:
>>
>> My question is, when I see methods in the docs like these two:
>>
>> fileno(      )
>>   Return the integer ``file descriptor'' that is used by the underlying
>> implementation to request I/O operations from the operating system. This can
>> be useful for other, lower level interfaces that use file descriptors, such
>> as the fcntl module or os.read() and friends. Note: File-like objects which
>> do not have a real file descriptor should not provide this method!
>>
>> isatty(     )
>>   Return True if the file is connected to a tty(-like) device, else False.
>> Note: If a file-like object is not associated with a real file, this method
>> should not be implemented.
>>
>>
>>
>> Should I...
>>
>> - really just flat out not implement them
>> - or should I stub them in and throw a standard Python not implemented
>> sort of exception
>> - or stub them in and just 'pass'
>> - or something else?
>
> Just don't implement them.  Almost all code when it uses these methods
> either would be flat-out unusable with your interface (for instance, it's
> doing fancy locking and other file manipulations using the fileno), or it
> expects that these methods might not defined.  Most code just doesn't use
> these methods.
>
> --
> Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>


More information about the Chicago mailing list