Greg Ewing wrote:
> Talin wrote:
>
>> r = Rectangle( x, y, w, h )
>> r = Rectangle( minpos, maxpos )
>> r = Rectangle( position, size )
>
> This sort of thing is better done in Python using
> keyword arguments:
>
>Rectangle(left = x, top = y, width = w, height = h)
>Rectan
Le dimanche 14 mai 2006 à 11:01 +1000, Nick Coghlan a écrit :
> Fredrik Johansson wrote:
> > For example, square roots are known as math.sqrt(x) for floats,
> > cmath.sqrt(x) for complex numbers, x.sqrt() for decimals, and
> > gmpy.sqrt(x)/gmpy.fsqrt(x) for gmpy's types. Oh, and SciPy has its own
>
Martin v. Löwis <[EMAIL PROTECTED]> wrote:
>> @overloaded
>> def sqrt(value):
>> raise TypeError("Cannot take square root of %s" %
>> type(value).__name__)
>>
>> @sqrt.overload
>> def sqrt_float(value : float):
>> return math.sqrt(value)
>>
>> @sqrt.overload
>> def sqrt_complex(value : com
Nick Coghlan <[EMAIL PROTECTED]> wrote:
>> For example, square roots are known as math.sqrt(x) for floats,
>> cmath.sqrt(x) for complex numbers, x.sqrt() for decimals, and
>> gmpy.sqrt(x)/gmpy.fsqrt(x) for gmpy's types. Oh, and SciPy has its
>> own sqrt function that works on arrays (but not Decim
Giovanni Bajo wrote:
>>> @overloaded
>>> def sqrt(value):
>>> raise TypeError("Cannot take square root of %s" %
>>> type(value).__name__)
>>>
>>> @sqrt.overload
>>> def sqrt_float(value : float):
>>> return math.sqrt(value)
>>>
>> So where would that sqrt function live?
>
> "math" would be
On 5/14/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote:
> So, are we totally dropping the "special-cased __ method" that worked so fine
> till now? I can "overload" abs() for my point type (to return its modulus)
> just
> by defining a __abs__, and it works fine. In such a world (called Python 2.x),
Paul Moore wrote:
> (FWIW, I like function overloading, and I'd love to see language or
> stdlib support. I can see the arguments for using it in place of
> existing special methods, but I'm nervous of the extent of that
> change. If I had to decide *right now*, I'd go for adding overloading,
> but
Nick Coghlan <[EMAIL PROTECTED]> wrote:
>> (FWIW, I like function overloading, and I'd love to see language or
>> stdlib support. I can see the arguments for using it in place of
>> existing special methods, but I'm nervous of the extent of that
>> change. If I had to decide *right now*, I'd go fo
Martin v. Löwis wrote:
> Giovanni Bajo wrote:
@overloaded
def sqrt(value):
raise TypeError("Cannot take square root of %s" %
type(value).__name__)
@sqrt.overload
def sqrt_float(value : float):
return math.sqrt(value)
>>> So where would that sqrt
Edward Loper wrote:
> For this use case, I don't think that a direct translation of the
> overloaded-constructor design for C++ carries over into Python as a good
> design. In particular, I think this would be better coded in Python
> using either keyword arguments, or factory methods. I.e., I'd
10 matches
Mail list logo