On 12/06/13 19:32, Khalid Al-Ghamdi wrote:
Hi,
Why doesn't this work? And is there way to have an
object immediately return a value or object once it is instantiated with
using a method call?
It does return a value. It returns the object that was just instantiated.
Supposed you could do what
Khalid Al-Ghamdi wrote:
>1. >>> class k:
>2. def __init__(self,n):
>3. return n*n
>4.
>5.
>6. >>> khalid=k(3)
>7. Traceback (most recent call last):
>8. File "", line 1, in
>9. khalid=k(3)
>10. TypeError: __init__() should retu
On Wed, Jun 12, 2013 at 3:02 PM, Khalid Al-Ghamdi wrote:
> Hi,
>
> Why doesn't this work? And is there way to have an
> object immediately return a value or object once it is instantiated with
> using a method call?
>
__init__ returns the newly created object. You cannot (or at least
shouldn't) r
Hi,
Why doesn't this work? And is there way to have an
object immediately return a value or object once it is instantiated with
using a method call?
1. >>> class k:
2. def __init__(self,n):
3. return n*n
4.
5.
6. >>> khalid=k(3)
7. Traceback (most rec