User Profile

Collapse

Profile Sidebar

Collapse
MisterPete
MisterPete
Last Activity: Dec 10 '07, 10:55 PM
Joined: May 10 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • MisterPete
    replied to unable to inherit
    Here is an improvement to fix compatibility with objects that use the deprecated __methods__ and __members__ attributes.
    Now it will show the expected result for dir(objectWrapp erInstance), similar to what you would get if you had inherited from the wrapped object.

    Code:
    class ObjectWrapper(object):
        """ObjectWrapper class redirects unhandled calls to wrapped object.
        
        Intended
    ...
    See more | Go to post

    Leave a comment:


  • MisterPete
    replied to unable to inherit
    Thanks for the reply.
    The __setattr__ is necessary to set wrapped object attributes on the wrapped object rather than the object wrapper (when assigning an attr directly and not calling a set method). This probably wasn't a concern for your DBConnectionWra pper. Consider the following example:

    Code:
    class Foo(object):
        def __init__(self, bar='default'):
            self.bar = bar
        def getUpperCaseBar(self):
    ...
    See more | Go to post

    Leave a comment:


  • MisterPete
    started a topic unable to inherit

    unable to inherit

    I've run into this issue a couple of times. I want to inherit from a class in order to extend it's functionality. The problem is that the class is defined in c in a shared library and doesn't seem to be designed so that it will allow inheritance (no __class__ defined, etc).
    For example the Client object from pysvn.

    [CODE=python]
    import pysvn
    class MyClient(pysvn. _pysvn._Client) :
    pass
    [/CO...
    See more | Go to post
    Last edited by bartonc; Oct 19 '07, 04:04 PM.

  • MisterPete
    replied to Function Names on a function call
    Is there a way to determine the calling module name as well? Ie, I want to print "called by MyModule.SubMod ule.Foo()" not just "called by Foo()"
    I think I saw the file path for the module in there but I don't want to have to try to determine the submodules from the path if possible.

    Cheers,
    Pete
    See more | Go to post

    Leave a comment:


  • MisterPete
    started a topic inherit from file and create stdout instance?

    inherit from file and create stdout instance?

    How can I inherit from file but stil create an instance that writes to stdout?
    -----------
    I'm writing a file-like object that has verbosity options (among some other things). I know I could just set self.file to a file object rather than inheriting from file. I started with something like this (simplified for clarity):
    Code:
    class Output(object):
        def __init__(self, file=sys.stdout, verbosity=1):
    ...
    See more | Go to post
    Last edited by bartonc; May 11 '07, 07:05 PM. Reason: Added [CODE] [/CODE] tags
No activity results to display
Show More
Working...