[EMAIL PROTECTED] wrote:
> On Oct 17, 4:05 am, Ken Schutte <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>> Does anyone know of an approximation to raising a negative base to a
>>> fractional exponent? For example, (-3)^-4.1 since this cannot be
>
[EMAIL PROTECTED] wrote:
> Does anyone know of an approximation to raising a negative base to a
> fractional exponent? For example, (-3)^-4.1 since this cannot be
> computed without using imaginary numbers. Any help is appreciated.
As others have said, you can use Python's complex numbers (jus
Lets say I want an integer class that lets you attach arbitrary
attributes. I can simply do:
class foo(int): pass
x = foo(5)
x.text = "okay"
print x, x.text # prints "5 okay"
So, that's good. But, how can I change the value of x from 5 to
something else, without creating a new instance?
I
Steven Bethard wrote:
> So even though your __new__ method returns the object you want, the
> __init__ method is clearing out all the items you've added and then
> re-adding them as it normally would. To prove this to yourself, take a
> look at what happens when we override __init__::
>
Okay,
Steven Bethard wrote:
>
> The __new__ method is for immutable types. So things like str and int
> do their initialization in __new__. But for regular mutable types, you
> should do your initialization in __init__::
>
I see... So, is there a use for __new__ in mutable types? From my
list-d
Hi,
I'm been trying to create some custom classes derived from some of
python's built-in types, like int and list, etc. I've run into some
trouble, which I could explain with a couple simple examples. Lets say
I want an int-derived class that is initilized to one greater than what
it's const