using extended built-in types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rim

    using extended built-in types

    Hi,

    When I extend a built-in type, how do I cause the extended type to
    be used by default, without having to specify it? For instance, say I
    extend the int type:

    class myint(int):
    def foo(self): print 'foo'

    How do I make all future integers use myint instead of int without explicitely
    say a = myint(value)?

    Thanks
    - Rim
  • Martin v. Löwis

    #2
    Re: using extended built-in types

    rimbalaya@yahoo .com (Rim) writes:
    [color=blue]
    > How do I make all future integers use myint instead of int without
    > explicitely say a = myint(value)?[/color]

    That is not possible.

    Martin

    Comment

    • Andrew Bennetts

      #3
      Re: using extended built-in types

      On Mon, Jun 30, 2003 at 05:40:06AM +0200, Martin v. L?wis wrote:[color=blue]
      > rimbalaya@yahoo .com (Rim) writes:
      >[color=green]
      > > How do I make all future integers use myint instead of int without
      > > explicitely say a = myint(value)?[/color]
      >
      > That is not possible.[/color]

      If only ;)

      If your tolerance for evil is sufficiently high, you could use intrinisics,
      a hack by Jp Calderone...

      PyCon lightning talk:


      Source:


      -Andrew.


      Comment

      • Rim

        #4
        Re: using extended built-in types

        > If only ;)[color=blue]
        >
        > If your tolerance for evil is sufficiently high, you could use intrinisics,
        > a hack by Jp Calderone...
        >
        > PyCon lightning talk:
        > http://www.intarweb.us:8080/PyCon/in...htning-0.xhtml
        >
        > Source:
        > http://www.intarweb.us:8080/evil/intrinsics.c[/color]

        The links do not work.

        Thanks,
        -Rim

        Comment

        Working...