On Sat, 15 Sep 2007 02:45:10 -0700, James Stroud wrote:
> Steven D'Aprano wrote:
>> On Fri, 14 Sep 2007 18:19:45 -0700, James Stroud wrote:
>>
How do I subclass int and/or long so that my class also auto-converts
only when needed?
>>> Use __new__.
>>
>> The disadvantage of that is
On 9/15/07, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Fri, 14 Sep 2007 22:59:13 -0300, Eduardo O. Padoan wrote:
>
> > On 14 Sep 2007 18:08:00 -0700, Paul Rubin
> > <"http://phr.cx"@nospam.invalid> wrote:
> >> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
> >> > Not totally unrelated, but in Py3k
Steven D'Aprano wrote:
> On Fri, 14 Sep 2007 18:19:45 -0700, James Stroud wrote:
>
>>> How do I subclass int and/or long so that my class also auto-converts
>>> only when needed?
>>>
>> Use __new__.
>
> The disadvantage of that is that your example code requires me to
> duplicate my methods in t
On Fri, 14 Sep 2007 18:19:45 -0700, James Stroud wrote:
>> How do I subclass int and/or long so that my class also auto-converts
>> only when needed?
>>
>>
>>
>>
> Use __new__.
The disadvantage of that is that your example code requires me to
duplicate my methods in the long version and the
On Fri, 14 Sep 2007 21:43:38 -0300, Eduardo O. Padoan wrote:
>> How do I subclass int and/or long so that my class also auto-converts
>> only when needed?
>
> What about just subclassing long - is this not an option?
Of course it's an option. As it turned out, that was the easiest way for
me to
On Fri, 14 Sep 2007 22:59:13 -0300, Eduardo O. Padoan wrote:
> On 14 Sep 2007 18:08:00 -0700, Paul Rubin
> <"http://phr.cx"@nospam.invalid> wrote:
>> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
>> > Not totally unrelated, but in Py3k, as it seems, overflows are really
>> > things of the past:
On 14 Sep 2007 18:08:00 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
> > Not totally unrelated, but in Py3k, as it seems, overflows are really
> > things of the past:
> >
> >
> > Python 3.0a1 (py3k:58061, Sep 9 2007, 13:18:37)
> > [GCC
Steven D'Aprano wrote:
> I thought that overflow errors would be a thing of the past now that
> Python automatically converts ints to longs as needed. Unfortunately,
> that is not the case.
>
class MyInt(int):
> ... pass
> ...
MyInt(sys.maxint)
> 2147483647
MyInt(sys.maxint+1)
"Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
> Not totally unrelated, but in Py3k, as it seems, overflows are really
> things of the past:
>
>
> Python 3.0a1 (py3k:58061, Sep 9 2007, 13:18:37)
> [GCC 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2
> Type "help", "copyright", "
On 9/14/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> I thought that overflow errors would be a thing of the past now that
> Python automatically converts ints to longs as needed. Unfortunately,
> that is not the case.
>
> >>> class MyInt(int):
> ... pass
> ...
> >>> MyInt(sys.maxint)
> 2147
10 matches
Mail list logo