Às 05:20 de 09-05-2016, Paulo da Silva escreveu:
Thank you Yann and Peter.
I really didn't know anything about those "things".
So far I have worked a lot with classes but they are written by me.
Now I needed to derive pandas.Series (for example) and it has some
methods that return pandas.Series o
Paulo da Silva wrote:
> Hi!
>
> Suppose I have a class A whose implementation I don't know about.
> That class A has a method f that returns a A object.
>
> class A:
> ...
> def f(self, <...>):
> ...
>
> Now I want to write B derived from A with method f1. I want f1 to return
> a B object:
>
>
If you can't change A to use something like "type(self)(...)" to create its
return value, you could use the dark side and swap res's __class__:
res.__class__ = B
Or:
res.__class__ = type(self)
Do note that B.__init__ will not be run when you do this, so it is up to
you to execute any ad
Hi!
Suppose I have a class A whose implementation I don't know about.
That class A has a method f that returns a A object.
class A:
...
def f(self, <...>):
...
Now I want to write B derived from A with method f1. I want f1 to return
a B object:
class B(A):
cfgauss wrote:
> I am having a strange problem with classes. I'm fairly sure the
> problem is with classes, anyway, because when I re-write the program
> without them, it works like I'd expect it to.
>
> When I run this program, at first, L[0].z[1] is 0, because z=[0,0
I am having a strange problem with classes. I'm fairly sure the
problem is with classes, anyway, because when I re-write the program
without them, it works like I'd expect it to.
When I run this program, at first, L[0].z[1] is 0, because z=[0,0].
But after I run that loop to assign