On Wed, 16 Sep 2009 23:06:18 +, kj wrote:
>>Instead of:
>
>>x.__getattr__('name')
>
>>write this:
>
>>getattr(x, 'name')
>
> This did the trick.
For the record, it's fairly unusual to call double-underscore special
methods directly. Any time you think you need to, it's worth a rethink.
kj wrote:
I'm trying to get the hang of Python's OO model, so I set up this
conceptually simple problem of creating a new file-like class to
read a certain type of file. The data in this type of file consists
of multiline "chunks" separated by lines consisting of a single
".".
My first crack a
In Steven D'Aprano
writes:
>On Wed, 16 Sep 2009 21:56:09 +, kj wrote:
>...
>> I thought at first that I could achieve this by overriding __getattr__:
>>
>> def __getattr__(self, attribute):
>> return self.fh.__getattr__(attribute)
>>
>> But to my surprise this did not work to
On Wed, 16 Sep 2009 21:56:09 +, kj wrote:
...
> I thought at first that I could achieve this by overriding __getattr__:
>
> def __getattr__(self, attribute):
> return self.fh.__getattr__(attribute)
>
> But to my surprise this did not work too well. For example, if I use a
> Gzip