From 141c2ca04f479a877b8b9318818295c206cf1173 Mon Sep 17 00:00:00 2001 From: Lukas Merten Date: Tue, 30 Jan 2018 10:11:00 +0100 Subject: [PATCH] Solution for: Issue - Segfault extending by inheritance in python #165 --- Extending-CRPropa.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Extending-CRPropa.md b/Extending-CRPropa.md index 1dd2eb370..2866b4467 100644 --- a/Extending-CRPropa.md +++ b/Extending-CRPropa.md @@ -56,8 +56,11 @@ class MySourceFeature(SourceFeature): def prepareCandidate(self, candidate): candidate.setRedshift(0.6) +# The source feature has to be created outside of the class attribute +# s.add(MySourceFeature()) wil NOT work! +srcFtr = MySourceFeature() s = Source() -s.add(MySourceFeature()) +s.add(srcFtr) c = s.getCandidate() print c.getRedshift() ```