From reinout at vanrees.org Fri May 4 12:21:29 2012 From: reinout at vanrees.org (Reinout van Rees) Date: Fri, 04 May 2012 12:21:29 +0200 Subject: [python-nl] django/python meeting split? In-Reply-To: <4F9E638C.6000403@wiggy.net> References: <4F9E638C.6000403@wiggy.net> Message-ID: On 30-04-12 12:03, Wichert Akkerman wrote: > Utrecht is prima voor mij! Zolang het niet op 7 of 14 september is - die > data zijn al bezet. 21 september zou het dan worden. Remco, heb je al een datum voor de django bijeenkomst rond oktober? Als het maar niet gelijk 28 sept ofzo is :-) Reinout -- Reinout van Rees http://reinout.vanrees.org/ reinout at vanrees.org http://www.nelen-schuurmans.nl/ "If you're not sure what to do, make something. -- Paul Graham" From roland at micite.net Mon May 7 14:36:21 2012 From: roland at micite.net (Roland van Laar) Date: Mon, 07 May 2012 14:36:21 +0200 Subject: [python-nl] PyGrunn uitverkocht :-) Message-ID: <4FA7C1C5.2090307@micite.net> Hallo, (Helaas) is PyGrunn uitverkocht. Mijn felicitaties aan de organisatie. Is er iemand die een ticket overheeft of een ticket kwijt wil omdat hij/zij niet gaat? Groeten, Roland From j.braas at ogd.nl Tue May 8 10:28:56 2012 From: j.braas at ogd.nl (=?windows-1252?Q?Josien_Braas?=) Date: Tue, 8 May 2012 10:28:56 +0200 Subject: [python-nl] Ticket voor PyGrunn 2012 over Message-ID: Hallo, Door een communicatiefoutje met de HR-afdeling van mijn werkgever heb ik een ticket voor PyGrunn over. Zonde als er geen gebruik van wordt gemaakt nu PyGrunn uitverkocht is! De aanschafprijs is 27,62. Vriendelijke groet, Josien From remco at maykinmedia.nl Thu May 10 14:09:01 2012 From: remco at maykinmedia.nl (Remco Wendt) Date: Thu, 10 May 2012 14:09:01 +0200 Subject: [python-nl] PyGrunn Message-ID: Hello all, Everybody stop, PyGrunn time! If anyone of you are taking the train to Groningen tomorrow morning. I'll be taking the 06:56 train from Amsterdam Central. I'll be seated in the frontmost wagon. Would be fun to socialize a bit during the trip north. Cheers, Remco -- Maykin Media Herengracht 416, 1017 BZ Amsterdam tel.: +31 (0)20 753 05 23 mob.: +31 (0)6 187 967 06 http://www.maykinmedia.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From maarten at fourdigits.nl Thu May 10 14:20:25 2012 From: maarten at fourdigits.nl (Maarten Kling) Date: Thu, 10 May 2012 14:20:25 +0200 Subject: [python-nl] PyGrunn In-Reply-To: References: Message-ID: <4FABB289.4040109@fourdigits.nl> We are leaving at 8.10 from Arnhem CS. I have one ticket left, anyone interested? Regards, Maarten On 5/10/12 2:09 PM, Remco Wendt wrote: > Hello all, > > Everybody stop, PyGrunn time! If anyone of you are taking the train to > Groningen tomorrow morning. I'll be taking the 06:56 train from > Amsterdam Central. I'll be seated in the frontmost wagon. Would be fun > to socialize a bit during the trip north. > > Cheers, > Remco > -- > Maykin Media > Herengracht 416, 1017 BZ Amsterdam > tel.: +31 (0)20 753 05 23 > mob.: +31 (0)6 187 967 06 > http://www.maykinmedia.nl > > > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl -- Maarten Kling http://fourdigits.nl/mensen/maarten-kling Four Digits BV http://www.fourdigits.nl Willemsplein 44, 6811 KD, Arnhem tel: +31 (0)26 4422700 fax: +31 (0)84 2206117 KVK 091621370000 BTW 8161.22.234.B01 -------------- next part -------------- An HTML attachment was scrubbed... URL: From roland at micite.net Thu May 10 14:40:33 2012 From: roland at micite.net (Roland van Laar) Date: Thu, 10 May 2012 14:40:33 +0200 Subject: [python-nl] PyGrunn In-Reply-To: <4FABB289.4040109@fourdigits.nl> References: <4FABB289.4040109@fourdigits.nl> Message-ID: <4FABB741.80602@micite.net> Hoi Maarten, I'm interested. Roland On 05/10/2012 02:20 PM, Maarten Kling wrote: > We are leaving at 8.10 from Arnhem CS. > I have one ticket left, anyone interested? > > Regards, > Maarten > > > On 5/10/12 2:09 PM, Remco Wendt wrote: >> Hello all, >> >> Everybody stop, PyGrunn time! If anyone of you are taking the train >> to Groningen tomorrow morning. I'll be taking the 06:56 train from >> Amsterdam Central. I'll be seated in the frontmost wagon. Would be >> fun to socialize a bit during the trip north. >> >> Cheers, >> Remco >> -- >> Maykin Media >> Herengracht 416, 1017 BZ Amsterdam >> tel.: +31 (0)20 753 05 23 >> mob.: +31 (0)6 187 967 06 >> http://www.maykinmedia.nl >> >> >> >> >> _______________________________________________ >> Python-nl mailing list >> Python-nl at python.org >> http://mail.python.org/mailman/listinfo/python-nl > > -- > Maarten Kling > http://fourdigits.nl/mensen/maarten-kling > > Four Digits BV > http://www.fourdigits.nl > Willemsplein 44, 6811 KD, Arnhem > tel: +31 (0)26 4422700 fax: +31 (0)84 2206117 > KVK 091621370000 BTW 8161.22.234.B01 > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From remco at gerlich.nl Thu May 10 15:26:01 2012 From: remco at gerlich.nl (Remco Gerlich) Date: Thu, 10 May 2012 15:26:01 +0200 Subject: [python-nl] PyGrunn In-Reply-To: <4FABB289.4040109@fourdigits.nl> References: <4FABB289.4040109@fourdigits.nl> Message-ID: I'm leaving from Arnhem as well, at 7:10. Don't want to miss the coffee :-) I'll take the frontmost wagon in Zwolle. Remco Gerlich On Thu, May 10, 2012 at 2:20 PM, Maarten Kling wrote: > We are leaving at 8.10 from Arnhem CS. > I have one ticket left, anyone interested? > > Regards, > Maarten > > > > On 5/10/12 2:09 PM, Remco Wendt wrote: > > Hello all, > > Everybody stop, PyGrunn time! If anyone of you are taking the train to > Groningen tomorrow morning. I'll be taking the 06:56 train from Amsterdam > Central. I'll be seated in the frontmost wagon. Would be fun to socialize a > bit during the trip north. > > Cheers, > Remco > -- > Maykin Media > Herengracht 416, 1017 BZ Amsterdam > tel.: +31 (0)20 753 05 23 > mob.: +31 (0)6 187 967 06 > http://www.maykinmedia.nl > > > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl > > > -- > Maarten Kling > http://fourdigits.nl/mensen/maarten-kling > > Four Digits BV > http://www.fourdigits.nl > Willemsplein 44, 6811 KD, Arnhem > tel: +31 (0)26 4422700 fax: +31 (0)84 2206117 > KVK 091621370000 BTW 8161.22.234.B01 > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl > From reinout at vanrees.org Thu May 10 23:10:54 2012 From: reinout at vanrees.org (Reinout van Rees) Date: Thu, 10 May 2012 23:10:54 +0200 Subject: [python-nl] PyGrunn In-Reply-To: References: Message-ID: On 10-05-12 14:09, Remco Wendt wrote: > Everybody stop, PyGrunn time! I must say, pygrunn is looking pretty good. Lots of interest and completely sold out! The organizers hit upon a sweet spot (a one-day python conference in the Netherlands) and they're executing very well. Finishing the last tweaks on my presentation right now... I'm taking one train earlier than the rest of the westerners as I've got the first talk and I do want to make completely sure I'm there on time :-) Reinout -- Reinout van Rees http://reinout.vanrees.org/ reinout at vanrees.org http://www.nelen-schuurmans.nl/ "If you're not sure what to do, make something. -- Paul Graham" From f.schneider at de-bleek.demon.nl Mon May 14 11:25:27 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Mon, 14 May 2012 11:25:27 +0200 Subject: [python-nl] Decorator Message-ID: <002501cd31b3$82e6e750$88b4b5f0$@schneider@de-bleek.demon.nl> Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat "pyprint" achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): . zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? Met vriendelijke groet, Frans -------------- next part -------------- An HTML attachment was scrubbed... URL: From tikitu at buzzcapture.com Mon May 14 11:49:03 2012 From: tikitu at buzzcapture.com (Tikitu de Jager) Date: Mon, 14 May 2012 11:49:03 +0200 Subject: [python-nl] Decorator In-Reply-To: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> Message-ID: Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer dan echt nodig is. Ik zou zeggen: def clips_callable(f): clips.RegisterPythonFunction(f, f.__name__) return f Of dat je probleem oplost is een andere vraag... gr, Tikitu 2012/5/14 Schneider > Dames, heren,**** > > ** ** > > Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik > opzoek naar een beetje hulp.**** > > Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) > waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om > Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in > CLIPS worden geregistreerd. **** > > Meest basale vorm zonder decorators.**** > > ** ** > > import clips**** > > import multiprocessing**** > > ** ** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > clips.RegisterPythonFunction(*self*.pyprint, *"pyprint"*)**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > ** ** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > ** ** > > Inhoud van test.clp is:**** > > ** ** > > (defrule MAIN::start-me-up**** > > =>**** > > (python-call *pyprint* "Hello world")**** > > ) ** > > ** ** > > Output is CLIPSProcess-1 2456 Hello world**** > > Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen > registreren via iets als:**** > > ** ** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > ?**** > > ** ** > > zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een > simpele decorator zoals hieronder werkt niet:**** > > ** ** > > import clips**** > > import multiprocessing**** > > ** ** > > def *clips_callable*(f):**** > > from functools import wraps**** > > *@wraps*(f)**** > > def *wf*(*args, **kwargs):**** > > print *'calling {}'*.format(f.__name__)**** > > return f(*args, **kwargs)**** > > clips.RegisterPythonFunction(wf, f.__name__)**** > > return wf**** > > ** ** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > #clips.RegisterPythonFunction(self.pyprint, "*pyprint*")**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > ** ** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > ** ** > > Met als output **** > > ** ** > > calling pyprint**** > > ** ** > > De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een > oplossing?**** > > ** ** > > Met vriendelijke groet,**** > > ** ** > > Frans**** > > > ** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.schneider at de-bleek.demon.nl Mon May 14 12:38:05 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Mon, 14 May 2012 12:38:05 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> Message-ID: <005301cd31bd$a58db540$f0a91fc0$@schneider@de-bleek.demon.nl> Nop, doet het niet. Maar toch dank voor je suggestie. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs=de-bleek.demon.nl at python.org] Namens Tikitu de Jager Verzonden: maandag 14 mei 2012 11:49 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer dan echt nodig is. Ik zou zeggen: def clips_callable(f): clips.RegisterPythonFunction(f, f.__name__) return f Of dat je probleem oplost is een andere vraag... gr, Tikitu 2012/5/14 Schneider Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): ? zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? Met vriendelijke groet, Frans -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.esselink at gmail.com Mon May 14 12:58:47 2012 From: a.esselink at gmail.com (Dexter) Date: Mon, 14 May 2012 12:58:47 +0200 Subject: [python-nl] Decorator In-Reply-To: <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> Message-ID: Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op het moment dat de functie meegegeven wordt aan de decorator. 2012/5/14 Schneider > Nop, doet het niet. Maar toch dank voor je suggestie.**** > > ** ** > > Frans**** > > ** ** > > *Van:* python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto: > python-nl-bounces+fs=de-bleek.demon.nl at python.org] *Namens *Tikitu de > Jager > *Verzonden:* maandag 14 mei 2012 11:49 > *Aan:* Dutch Python developers and users > *Onderwerp:* Re: [python-nl] Decorator**** > > ** ** > > Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer > dan echt nodig is. Ik zou zeggen:**** > > ** ** > > def clips_callable(f):**** > > clips.RegisterPythonFunction(f, f.__name__)**** > > return f**** > > ** ** > > Of dat je probleem oplost is een andere vraag...**** > > ** ** > > gr,**** > > Tikitu**** > > ** ** > > 2012/5/14 Schneider **** > > Dames, heren,**** > > **** > > Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik > opzoek naar een beetje hulp.**** > > Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) > waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om > Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in > CLIPS worden geregistreerd. **** > > Meest basale vorm zonder decorators.**** > > **** > > import clips**** > > import multiprocessing**** > > **** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > clips.RegisterPythonFunction(*self*.pyprint, *"pyprint"*)**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > **** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > **** > > Inhoud van test.clp is:**** > > **** > > (defrule MAIN::start-me-up**** > > =>**** > > (python-call *pyprint* "Hello world")**** > > ) **** > > **** > > Output is CLIPSProcess-1 2456 Hello world**** > > Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen > registreren via iets als:**** > > **** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > ?**** > > **** > > zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een > simpele decorator zoals hieronder werkt niet:**** > > **** > > import clips**** > > import multiprocessing**** > > **** > > def *clips_callable*(f):**** > > from functools import wraps**** > > *@wraps*(f)**** > > def *wf*(*args, **kwargs):**** > > print *'calling {}'*.format(f.__name__)**** > > return f(*args, **kwargs)**** > > clips.RegisterPythonFunction(wf, f.__name__)**** > > return wf**** > > **** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > #clips.RegisterPythonFunction(self.pyprint, "*pyprint*")**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > **** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > **** > > Met als output **** > > **** > > calling pyprint**** > > **** > > De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een > oplossing?**** > > **** > > Met vriendelijke groet,**** > > **** > > Frans**** > > ** ** > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ronaldoussoren at mac.com Mon May 14 11:44:14 2012 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 14 May 2012 11:44:14 +0200 Subject: [python-nl] Decorator In-Reply-To: <002501cd31b3$82e6e750$88b4b5f0$%schneider@de-bleek.demon.nl> References: <002501cd31b3$82e6e750$88b4b5f0$%schneider@de-bleek.demon.nl> Message-ID: On 14 May, 2012, at 11:25, Schneider wrote: > Dames, heren, > > Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. > Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. > Meest basale vorm zonder decorators. > > import clips > import multiprocessing > > class CLIPS(object): > def __init__(self, data): > self.environment = clips.Environment() > self.data = data > clips.RegisterPythonFunction(self.pyprint, "pyprint") > self.environment.Load("test.clp") > self.environment.Reset() > self.environment.Run() > def pyprint(self, value): > print self.data, "".join(map(str, value)) > > class CLIPSProcess(multiprocessing.Process): > def run(self): > p = multiprocessing.current_process() > self.c = CLIPS("%s %s" % (p.name, p.pid)) > pass > > if __name__ == "__main__": > cp = CLIPSProcess() > cp.start() > > Inhoud van test.clp is: > > (defrule MAIN::start-me-up > => > (python-call pyprint "Hello world") > ) > > Output is CLIPSProcess-1 2456 Hello world > Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen registreren via iets als: > > @clips_callable > def pyprint(self, value): > ? > > zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: > > import clips > import multiprocessing > > def clips_callable(f): > from functools import wraps > @wraps(f) > def wf(*args, **kwargs): > print 'calling {}'.format(f.__name__) > return f(*args, **kwargs) > clips.RegisterPythonFunction(wf, f.__name__) > return wf > > class CLIPS(object): > def __init__(self, data): > self.environment = clips.Environment() > self.data = data > #clips.RegisterPythonFunction(self.pyprint, "pyprint") > self.environment.Load("test.clp") > self.environment.Reset() > self.environment.Run() > @clips_callable > def pyprint(self, value): > print self.data, "".join(map(str, value)) > > class CLIPSProcess(multiprocessing.Process): > def run(self): > p = multiprocessing.current_process() > self.c = CLIPS("%s %s" % (p.name, p.pid)) > pass > > if __name__ == "__main__": > cp = CLIPSProcess() > cp.start() > > Met als output > > calling pyprint > > De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? De decorator wordt aangeroepen bij het uitvoeren van de class definitie, dus voordat CLIPS instantie gemaakt wordt. Om met de decorator hetzelfde gedrag te krijgen als zonder decorator moet je de de decorator in twee-en splitsen: de decorator zelf markeert de functies als clips_callable (door ze in een lijstje te plaatsen, of een functie attribuut toe te voegen), en in __init__ kan je daarna RegisterPythonFunction aanroepen voor alle functies die je eerder gemarkeerd hebt. Als alle "pyprint" functies methoden van de CLIPS klasse zijn zou je ook het patroon kunnen gebruiken dat in cmd.Cmd in de stdlib gebruikt wordt: geeft alle CLIPS functies een naam met een specifieke prefix (bijvoorbeeld "def clips_pyprint(self, value): ...") en maak in __init__ een loop over alle methoden van de klasse en registreer de methoden waarvan de naam met deze prefix begint. Ronald -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4788 bytes Desc: not available URL: From f.schneider at de-bleek.demon.nl Mon May 14 13:04:11 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Mon, 14 May 2012 13:04:11 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> Message-ID: <006d01cd31c1$4ab83dd0$e028b970$@schneider@de-bleek.demon.nl> Dat zou best wel eens kunnen. Dat zou betekenen dat iets met @.... helemaal niet gaat? Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs=de-bleek.demon.nl at python.org] Namens Dexter Verzonden: maandag 14 mei 2012 12:59 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op het moment dat de functie meegegeven wordt aan de decorator. 2012/5/14 Schneider Nop, doet het niet. Maar toch dank voor je suggestie. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs =de-bleek.demon.nl at python.org] Namens Tikitu de Jager Verzonden: maandag 14 mei 2012 11:49 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer dan echt nodig is. Ik zou zeggen: def clips_callable(f): clips.RegisterPythonFunction(f, f.__name__) return f Of dat je probleem oplost is een andere vraag... gr, Tikitu 2012/5/14 Schneider Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat "pyprint" achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): . zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? Met vriendelijke groet, Frans _______________________________________________ Python-nl mailing list Python-nl at python.org http://mail.python.org/mailman/listinfo/python-nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.esselink at gmail.com Mon May 14 14:18:26 2012 From: a.esselink at gmail.com (Dexter) Date: Mon, 14 May 2012 14:18:26 +0200 Subject: [python-nl] Decorator In-Reply-To: <4fb0e8ce.09630e0a.78d3.ffffebb4SMTPIN_ADDED@mx.google.com> References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> <4fb0e8ce.09630e0a.78d3.ffffebb4SMTPIN_ADDED@mx.google.com> Message-ID: Jawel class CLIPSClass(object): callables = [] @classmethod class CLIPS(CLIPSClass): @clipsCallable def pyprint(self, value): self.data, "".join(map(str, value)) 2012/5/14 Schneider > Dat zou best wel eens kunnen. Dat zou betekenen dat iets met @.... > helemaal niet gaat?**** > > ** ** > > Frans**** > > ** ** > > *Van:* python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto: > python-nl-bounces+fs=de-bleek.demon.nl at python.org] *Namens *Dexter > *Verzonden:* maandag 14 mei 2012 12:59 > > *Aan:* Dutch Python developers and users > *Onderwerp:* Re: [python-nl] Decorator**** > > ** ** > > Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op > het moment dat de functie meegegeven wordt aan de decorator.**** > > 2012/5/14 Schneider **** > > Nop, doet het niet. Maar toch dank voor je suggestie.**** > > **** > > Frans**** > > **** > > *Van:* python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto: > python-nl-bounces+fs=de-bleek.demon.nl at python.org] *Namens *Tikitu de > Jager > *Verzonden:* maandag 14 mei 2012 11:49 > *Aan:* Dutch Python developers and users > *Onderwerp:* Re: [python-nl] Decorator**** > > **** > > Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer > dan echt nodig is. Ik zou zeggen:**** > > **** > > def clips_callable(f):**** > > clips.RegisterPythonFunction(f, f.__name__)**** > > return f**** > > **** > > Of dat je probleem oplost is een andere vraag...**** > > **** > > gr,**** > > Tikitu**** > > **** > > 2012/5/14 Schneider **** > > Dames, heren,**** > > **** > > Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik > opzoek naar een beetje hulp.**** > > Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) > waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om > Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in > CLIPS worden geregistreerd. **** > > Meest basale vorm zonder decorators.**** > > **** > > import clips**** > > import multiprocessing**** > > **** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > clips.RegisterPythonFunction(*self*.pyprint, *"pyprint"*)**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > **** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > **** > > Inhoud van test.clp is:**** > > **** > > (defrule MAIN::start-me-up**** > > =>**** > > (python-call *pyprint* "Hello world")**** > > ) **** > > **** > > Output is CLIPSProcess-1 2456 Hello world**** > > Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen > registreren via iets als:**** > > **** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > ?**** > > **** > > zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een > simpele decorator zoals hieronder werkt niet:**** > > **** > > import clips**** > > import multiprocessing**** > > **** > > def *clips_callable*(f):**** > > from functools import wraps**** > > *@wraps*(f)**** > > def *wf*(*args, **kwargs):**** > > print *'calling {}'*.format(f.__name__)**** > > return f(*args, **kwargs)**** > > clips.RegisterPythonFunction(wf, f.__name__)**** > > return wf**** > > **** > > class *CLIPS*(object):**** > > def *__init__*(*self*, data):**** > > *self*.environment = clips.Environment()**** > > *self*.data = data**** > > #clips.RegisterPythonFunction(self.pyprint, "*pyprint*")**** > > *self*.environment.Load(*"test.clp"*)**** > > *self*.environment.Reset()**** > > *self*.environment.Run()**** > > *@clips_callable***** > > def *pyprint*(*self*, value):**** > > print *self*.data, *""*.join(map(str, value))**** > > **** > > class *CLIPSProcess*(multiprocessing.Process):**** > > def *run*(*self*):**** > > p = multiprocessing.current_process()**** > > *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** > > pass**** > > **** > > if __name__ == *"__main__"*:**** > > cp = CLIPSProcess()**** > > cp.start()**** > > **** > > Met als output **** > > **** > > calling pyprint**** > > **** > > De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een > oplossing?**** > > **** > > Met vriendelijke groet,**** > > **** > > Frans**** > > **** > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl**** > > ** ** > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.esselink at gmail.com Mon May 14 14:21:05 2012 From: a.esselink at gmail.com (Dexter) Date: Mon, 14 May 2012 14:21:05 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> <4fb0e8ce.09630e0a.78d3.ffffebb4SMTPIN_ADDED@mx.google.com> Message-ID: ow, was nog niet klaar Jawel class CLIPSClass(object): callables = [] def __init__(self): for c in self.callables: clips.RegisterPythonFunction(c, c.__name__) @classmethod def clipsCallable(cls, f): cls.callables.append(f) class CLIPS(CLIPSClass): @CLIPSClass.clipsCallable def pyprint(self, value): self.data, "".join(map(str, value)) zoiets zou moeten werken > 2012/5/14 Schneider > >> Dat zou best wel eens kunnen. Dat zou betekenen dat iets met @.... >> helemaal niet gaat?**** >> >> ** ** >> >> Frans**** >> >> ** ** >> >> *Van:* python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto: >> python-nl-bounces+fs=de-bleek.demon.nl at python.org] *Namens *Dexter >> *Verzonden:* maandag 14 mei 2012 12:59 >> >> *Aan:* Dutch Python developers and users >> *Onderwerp:* Re: [python-nl] Decorator**** >> >> ** ** >> >> Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op >> het moment dat de functie meegegeven wordt aan de decorator.**** >> >> 2012/5/14 Schneider **** >> >> Nop, doet het niet. Maar toch dank voor je suggestie.**** >> >> **** >> >> Frans**** >> >> **** >> >> *Van:* python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto: >> python-nl-bounces+fs=de-bleek.demon.nl at python.org] *Namens *Tikitu de >> Jager >> *Verzonden:* maandag 14 mei 2012 11:49 >> *Aan:* Dutch Python developers and users >> *Onderwerp:* Re: [python-nl] Decorator**** >> >> **** >> >> Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer >> dan echt nodig is. Ik zou zeggen:**** >> >> **** >> >> def clips_callable(f):**** >> >> clips.RegisterPythonFunction(f, f.__name__)**** >> >> return f**** >> >> **** >> >> Of dat je probleem oplost is een andere vraag...**** >> >> **** >> >> gr,**** >> >> Tikitu**** >> >> **** >> >> 2012/5/14 Schneider **** >> >> Dames, heren,**** >> >> **** >> >> Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik >> opzoek naar een beetje hulp.**** >> >> Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) >> waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om >> Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in >> CLIPS worden geregistreerd. **** >> >> Meest basale vorm zonder decorators.**** >> >> **** >> >> import clips**** >> >> import multiprocessing**** >> >> **** >> >> class *CLIPS*(object):**** >> >> def *__init__*(*self*, data):**** >> >> *self*.environment = clips.Environment()**** >> >> *self*.data = data**** >> >> clips.RegisterPythonFunction(*self*.pyprint, *"pyprint"*)**** >> >> *self*.environment.Load(*"test.clp"*)**** >> >> *self*.environment.Reset()**** >> >> *self*.environment.Run()**** >> >> def *pyprint*(*self*, value):**** >> >> print *self*.data, *""*.join(map(str, value))**** >> >> **** >> >> class *CLIPSProcess*(multiprocessing.Process):**** >> >> def *run*(*self*):**** >> >> p = multiprocessing.current_process()**** >> >> *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** >> >> pass**** >> >> **** >> >> if __name__ == *"__main__"*:**** >> >> cp = CLIPSProcess()**** >> >> cp.start()**** >> >> **** >> >> Inhoud van test.clp is:**** >> >> **** >> >> (defrule MAIN::start-me-up**** >> >> =>**** >> >> (python-call *pyprint* "Hello world")**** >> >> ) **** >> >> **** >> >> Output is CLIPSProcess-1 2456 Hello world**** >> >> Werkt goed. Nu wil ik heel wat ?pyprint? achtige functies kunnen >> registreren via iets als:**** >> >> **** >> >> *@clips_callable***** >> >> def *pyprint*(*self*, value):**** >> >> ?**** >> >> **** >> >> zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een >> simpele decorator zoals hieronder werkt niet:**** >> >> **** >> >> import clips**** >> >> import multiprocessing**** >> >> **** >> >> def *clips_callable*(f):**** >> >> from functools import wraps**** >> >> *@wraps*(f)**** >> >> def *wf*(*args, **kwargs):**** >> >> print *'calling {}'*.format(f.__name__)**** >> >> return f(*args, **kwargs)**** >> >> clips.RegisterPythonFunction(wf, f.__name__)**** >> >> return wf**** >> >> **** >> >> class *CLIPS*(object):**** >> >> def *__init__*(*self*, data):**** >> >> *self*.environment = clips.Environment()**** >> >> *self*.data = data**** >> >> #clips.RegisterPythonFunction(self.pyprint, "*pyprint*")**** >> >> *self*.environment.Load(*"test.clp"*)**** >> >> *self*.environment.Reset()**** >> >> *self*.environment.Run()**** >> >> *@clips_callable***** >> >> def *pyprint*(*self*, value):**** >> >> print *self*.data, *""*.join(map(str, value))**** >> >> **** >> >> class *CLIPSProcess*(multiprocessing.Process):**** >> >> def *run*(*self*):**** >> >> p = multiprocessing.current_process()**** >> >> *self*.c = CLIPS(*"%s %s"* % (p.name, p.pid))**** >> >> pass**** >> >> **** >> >> if __name__ == *"__main__"*:**** >> >> cp = CLIPSProcess()**** >> >> cp.start()**** >> >> **** >> >> Met als output **** >> >> **** >> >> calling pyprint**** >> >> **** >> >> De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een >> oplossing?**** >> >> **** >> >> Met vriendelijke groet,**** >> >> **** >> >> Frans**** >> >> **** >> >> >> _______________________________________________ >> Python-nl mailing list >> Python-nl at python.org >> http://mail.python.org/mailman/listinfo/python-nl**** >> >> ** ** >> >> _______________________________________________ >> Python-nl mailing list >> Python-nl at python.org >> http://mail.python.org/mailman/listinfo/python-nl >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.schneider at de-bleek.demon.nl Mon May 14 13:13:48 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Mon, 14 May 2012 13:13:48 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <002501cd31b3$82e6e750$88b4b5f0$%schneider@de-bleek.demon.nl> Message-ID: <009801cd31c2$a5f70c20$f1e52460$@schneider@de-bleek.demon.nl> Ok. Dat klinkt logisch. Kijk ik naar. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs=de-bleek.demon.nl at python.org] Namens Ronald Oussoren Verzonden: maandag 14 mei 2012 11:44 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator On 14 May, 2012, at 11:25, Schneider wrote: Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat "pyprint" achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): . zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? De decorator wordt aangeroepen bij het uitvoeren van de class definitie, dus voordat CLIPS instantie gemaakt wordt. Om met de decorator hetzelfde gedrag te krijgen als zonder decorator moet je de de decorator in twee-en splitsen: de decorator zelf markeert de functies als clips_callable (door ze in een lijstje te plaatsen, of een functie attribuut toe te voegen), en in __init__ kan je daarna RegisterPythonFunction aanroepen voor alle functies die je eerder gemarkeerd hebt. Als alle "pyprint" functies methoden van de CLIPS klasse zijn zou je ook het patroon kunnen gebruiken dat in cmd.Cmd in de stdlib gebruikt wordt: geeft alle CLIPS functies een naam met een specifieke prefix (bijvoorbeeld "def clips_pyprint(self, value): ...") en maak in __init__ een loop over alle methoden van de klasse en registreer de methoden waarvan de naam met deze prefix begint. Ronald -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.schneider at de-bleek.demon.nl Mon May 14 18:49:33 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Mon, 14 May 2012 18:49:33 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> <4fb0e8ce.09630e0a.78d3.ffffebb4SMTPIN_ADDED@mx.google.com> Message-ID: <000001cd31f1$8a496e80$9edc4b80$@schneider@de-bleek.demon.nl> Werkt jammer genoeg ook niet. Er wordt wel wat geregistreerd in CLIPS, maar niet de functie waarom het gaat. Ik kan niet goed nagaan wat er in CLIPS gebeurd omdat zich dit diep ergens in de interface afspeelt. De call crasht in ieder geval als deze gemaakt wordt vanuit CLIPS. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs=de-bleek.demon.nl at python.org] Namens Dexter Verzonden: maandag 14 mei 2012 14:21 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator ow, was nog niet klaar Jawel class CLIPSClass(object): callables = [] def __init__(self): for c in self.callables: clips.RegisterPythonFunction(c, c.__name__) @classmethod def clipsCallable(cls, f): cls.callables.append(f) class CLIPS(CLIPSClass): @CLIPSClass.clipsCallable def pyprint(self, value): self.data, "".join(map(str, value)) zoiets zou moeten werken 2012/5/14 Schneider Dat zou best wel eens kunnen. Dat zou betekenen dat iets met @.... helemaal niet gaat? Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs =de-bleek.demon.nl at python.org] Namens Dexter Verzonden: maandag 14 mei 2012 12:59 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op het moment dat de functie meegegeven wordt aan de decorator. 2012/5/14 Schneider Nop, doet het niet. Maar toch dank voor je suggestie. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs =de-bleek.demon.nl at python.org] Namens Tikitu de Jager Verzonden: maandag 14 mei 2012 11:49 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer dan echt nodig is. Ik zou zeggen: def clips_callable(f): clips.RegisterPythonFunction(f, f.__name__) return f Of dat je probleem oplost is een andere vraag... gr, Tikitu 2012/5/14 Schneider Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat "pyprint" achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): . zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? Met vriendelijke groet, Frans _______________________________________________ Python-nl mailing list Python-nl at python.org http://mail.python.org/mailman/listinfo/python-nl _______________________________________________ Python-nl mailing list Python-nl at python.org http://mail.python.org/mailman/listinfo/python-nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.schneider at de-bleek.demon.nl Tue May 15 11:55:06 2012 From: f.schneider at de-bleek.demon.nl (Schneider) Date: Tue, 15 May 2012 11:55:06 +0200 Subject: [python-nl] Decorator In-Reply-To: References: <4fb0d200.815e0e0a.6a23.0a70SMTPIN_ADDED@mx.google.com> <4fb0e256.8f630e0a.3cde.1955SMTPIN_ADDED@mx.google.com> <4fb0e8ce.09630e0a.78d3.ffffebb4SMTPIN_ADDED@mx.google.com> Message-ID: <000001cd3280$d1ce18c0$756a4a40$@schneider@de-bleek.demon.nl> Geprobeerd, maar werkt ook niet. Verwijzen de callables nu ook niet naar unbound methods? Ik zag iets met een constructie als deze: class clips_callable(object): def __init__(self, func): self.func = func def __get__(self, obj, type=None): f = self.__class__(self.func.__get__(obj, type)) print "__get__", f, self.func.__name__ clips.RegisterPythonFunction(f, self.func.__name__) return self.__class__(self.func.__get__(obj, type)) def __call__(self, *args, **kw): return self.func(*args, **kw) class CLIPS(object): . @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value))de functie pyprint een keer benaderd worden: Om dit te laten werken moet een instance gemaakt worden van CLIPS en de functie pyprint 1 maal benaderd worden. Dit werkt wel: c = CLIPS("%s %s" % (p.name, p.pid)) print c.pyprint Maar dit wekt niet c = CLIPS("%s %s" % (p.name, p.pid)) #print c.pyprint De hele decorator definitie gaat mij boven mijn pet en misschien dat iemand deze kan uitleggen? Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs=de-bleek.demon.nl at python.org] Namens Dexter Verzonden: maandag 14 mei 2012 14:21 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator ow, was nog niet klaar Jawel class CLIPSClass(object): callables = [] def __init__(self): for c in self.callables: clips.RegisterPythonFunction(c, c.__name__) @classmethod def clipsCallable(cls, f): cls.callables.append(f) class CLIPS(CLIPSClass): @CLIPSClass.clipsCallable def pyprint(self, value): self.data, "".join(map(str, value)) zoiets zou moeten werken 2012/5/14 Schneider Dat zou best wel eens kunnen. Dat zou betekenen dat iets met @.... helemaal niet gaat? Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs =de-bleek.demon.nl at python.org] Namens Dexter Verzonden: maandag 14 mei 2012 12:59 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Ik denk dat dat komt omdat er nog geen instantie van de class CLIPS is op het moment dat de functie meegegeven wordt aan de decorator. 2012/5/14 Schneider Nop, doet het niet. Maar toch dank voor je suggestie. Frans Van: python-nl-bounces+fs=de-bleek.demon.nl at python.org [mailto:python-nl-bounces+fs =de-bleek.demon.nl at python.org] Namens Tikitu de Jager Verzonden: maandag 14 mei 2012 11:49 Aan: Dutch Python developers and users Onderwerp: Re: [python-nl] Decorator Met CLIPS heb ik geen ervaring, maar je decorator doet volgens mij meer dan echt nodig is. Ik zou zeggen: def clips_callable(f): clips.RegisterPythonFunction(f, f.__name__) return f Of dat je probleem oplost is een andere vraag... gr, Tikitu 2012/5/14 Schneider Dames, heren, Omdat ik weinig ervaring met decorators en multiprocessing heb, ben ik opzoek naar een beetje hulp. Ik maak gebruik van CLIPS via PyClips (http://pyclips.sourceforge.net/) waarbij CLIPS in een apart proces gestart wordt i.v.m. performance e.d. Om Python aan te kunnen roepen vanuit CLIPS, moeten de Python functies in CLIPS worden geregistreerd. Meest basale vorm zonder decorators. import clips import multiprocessing class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Inhoud van test.clp is: (defrule MAIN::start-me-up => (python-call pyprint "Hello world") ) Output is CLIPSProcess-1 2456 Hello world Werkt goed. Nu wil ik heel wat "pyprint" achtige functies kunnen registreren via iets als: @clips_callable def pyprint(self, value): . zonder dat ik steeds clips.RegisterPythonFunction hoef aan te roepen. Een simpele decorator zoals hieronder werkt niet: import clips import multiprocessing def clips_callable(f): from functools import wraps @wraps(f) def wf(*args, **kwargs): print 'calling {}'.format(f.__name__) return f(*args, **kwargs) clips.RegisterPythonFunction(wf, f.__name__) return wf class CLIPS(object): def __init__(self, data): self.environment = clips.Environment() self.data = data #clips.RegisterPythonFunction(self.pyprint, "pyprint") self.environment.Load("test.clp") self.environment.Reset() self.environment.Run() @clips_callable def pyprint(self, value): print self.data, "".join(map(str, value)) class CLIPSProcess(multiprocessing.Process): def run(self): p = multiprocessing.current_process() self.c = CLIPS("%s %s" % (p.name, p.pid)) pass if __name__ == "__main__": cp = CLIPSProcess() cp.start() Met als output calling pyprint De decorator doet duidelijk niet wat ik wil. Heeft iemand misschien een oplossing? Met vriendelijke groet, Frans _______________________________________________ Python-nl mailing list Python-nl at python.org http://mail.python.org/mailman/listinfo/python-nl _______________________________________________ Python-nl mailing list Python-nl at python.org http://mail.python.org/mailman/listinfo/python-nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From penningmeester at djangovereniging.nl Tue May 29 13:21:33 2012 From: penningmeester at djangovereniging.nl (Joeri Bekker) Date: Tue, 29 May 2012 13:21:33 +0200 Subject: [python-nl] Win a last-minute DjangoCon Europe 2012 ticket Message-ID: Hello all, As some might know already, the Dutch Dango Association is a proud sponsor of DjangoCon Europe 2012. See: http://2012.djangocon.eu/ To thank us, the organizers behind this years DjangoCon Europe gave us a ticket to DjangoCon Europe 2012 that we are happy to give away to a Djangonaut! *Who can win the ticket?* People that signed up for one of the Django Meetings this year (ie. on january 18 or april 18 you were on the list) and members of the Dutch Django Association (ie. everyone who paid contribution last year). *How to participate?* Just reply to this e-mail with your name and address before wednesday 16.00 (Amsterdam time). We'll pick someone in the evening and email the result. I know it's short notice, and everyone who wants to go probably already has a ticket, but this cannot be helped. We didn't know we would get one to give away until recently. Remember, it's just the ticket to the conference, you still need to arrange a place to sleep and transportation. Good luck, Joeri Bekker -- Penningmeester Django Vereniging / Treasurer Dutch Django Association Herengracht 416, 1017 BZ Amsterdam The Netherlands tel.: +31 (0)20 753 05 23 mob.: +31 (0)6 238 410 17 http://www.djangovereniging.nl/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From roel at fourdigits.nl Tue May 29 13:34:30 2012 From: roel at fourdigits.nl (Roel Bruggink) Date: Tue, 29 May 2012 13:34:30 +0200 Subject: [python-nl] Plone conference 2012 - end of early bird getting near Message-ID: Pythonistas, A quick reminder: the early bird period end may 31th [1]. If you'd like to go the Plone conference in Arnhem make sure to order a ticket in the early bird period and save yourself 50 euro! Take a look at http://www.ploneconf.org/the-event/talks/conference-talksfor the talks submitted so far. We expect several non-Plone talks (about Pyramid, ie) also. Perhaps you would like to give a talk about you favorite topic? Hopefully we'll meet in Arnhem soon! [1] http://www.ploneconf.org/news/3-days-left-for-early-bird-registration -- Roel Bruggink http://www.fourdigits.nl/mensen/roel-bruggink Four Digits BV http://www.fourdigits.nl tel: +31(0)26 4422700 -------------- next part -------------- An HTML attachment was scrubbed... URL: From crito at 30loops.net Tue May 29 13:58:29 2012 From: crito at 30loops.net (Christo Buschek) Date: Tue, 29 May 2012 13:58:29 +0200 Subject: [python-nl] Win a last-minute DjangoCon Europe 2012 ticket In-Reply-To: References: Message-ID: Hey, I definitely would love to go to djangocon. I gave a little talk at the django meetup 18th o january. Let me know if i was lucky. Greetinx Christo On May 29, 2012 1:22 PM, "Joeri Bekker" wrote: > Hello all, > > As some might know already, the Dutch Dango Association is a proud sponsor > of DjangoCon Europe 2012. See: http://2012.djangocon.eu/ > > To thank us, the organizers behind this years DjangoCon Europe gave us > a ticket to DjangoCon Europe 2012 that we are happy to give away to a > Djangonaut! > > *Who can win the ticket?* > People that signed up for one of the Django Meetings this year (ie. on > january 18 or april 18 you were on the list) and members of the Dutch > Django Association (ie. everyone who paid contribution last year). > > *How to participate?* > Just reply to this e-mail with your name and address before wednesday > 16.00 (Amsterdam time). We'll pick someone in the evening and email the > result. > > I know it's short notice, and everyone who wants to go probably already > has a ticket, but this cannot be helped. We didn't know we would get one to > give away until recently. > Remember, it's just the ticket to the conference, you still need to > arrange a place to sleep and transportation. > > Good luck, > > Joeri Bekker > > -- > Penningmeester Django Vereniging / Treasurer Dutch Django Association > Herengracht 416, 1017 BZ Amsterdam > The Netherlands > tel.: +31 (0)20 753 05 23 > mob.: +31 (0)6 238 410 17 > http://www.djangovereniging.nl/ > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > http://mail.python.org/mailman/listinfo/python-nl > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roel at fourdigits.nl Thu May 31 16:28:50 2012 From: roel at fourdigits.nl (Roel Bruggink) Date: Thu, 31 May 2012 16:28:50 +0200 Subject: [python-nl] Ploneconf 2012 early bird period is ending soon! Message-ID: Hi! Did everyone get their tickets already? Early bird period is going to end soon! Early bird period end on may 31th on 24:00 CET. -- Roel Bruggink http://www.fourdigits.nl/mensen/roel-bruggink Four Digits BV http://www.fourdigits.nl tel: +31(0)26 4422700 -------------- next part -------------- An HTML attachment was scrubbed... URL: From penningmeester at djangovereniging.nl Thu May 31 17:34:04 2012 From: penningmeester at djangovereniging.nl (Joeri Bekker) Date: Thu, 31 May 2012 17:34:04 +0200 Subject: [python-nl] Win a last-minute DjangoCon Europe 2012 ticket In-Reply-To: References: Message-ID: And the winner is... Tom Kruijsen who visited the last two Django Meetings ( http://wiki.python.org/moin/DjangoMeetingNL). Thanks to all that participated. Maybe next year we can announce it a little earlier so more people can have a chance to win. Tom, have fun on DjangoCon Europe 2012! Best regards, Joeri Bekker 2012/5/29 Joeri Bekker > Hello all, > > As some might know already, the Dutch Dango Association is a proud sponsor > of DjangoCon Europe 2012. See: http://2012.djangocon.eu/ > > To thank us, the organizers behind this years DjangoCon Europe gave us > a ticket to DjangoCon Europe 2012 that we are happy to give away to a > Djangonaut! > > *Who can win the ticket?* > People that signed up for one of the Django Meetings this year (ie. on > january 18 or april 18 you were on the list) and members of the Dutch > Django Association (ie. everyone who paid contribution last year). > > *How to participate?* > Just reply to this e-mail with your name and address before wednesday > 16.00 (Amsterdam time). We'll pick someone in the evening and email the > result. > > I know it's short notice, and everyone who wants to go probably already > has a ticket, but this cannot be helped. We didn't know we would get one to > give away until recently. > Remember, it's just the ticket to the conference, you still need to > arrange a place to sleep and transportation. > > Good luck, > > Joeri Bekker > > -- > Penningmeester Django Vereniging / Treasurer Dutch Django Association > Herengracht 416, 1017 BZ Amsterdam > The Netherlands > tel.: +31 (0)20 753 05 23 > mob.: +31 (0)6 238 410 17 > http://www.djangovereniging.nl/ > > -- Penningmeester Django Vereniging / Treasurer Dutch Django Association Herengracht 416, 1017 BZ Amsterdam The Netherlands tel.: +31 (0)20 753 05 23 mob.: +31 (0)6 238 410 17 http://www.djangovereniging.nl/ -------------- next part -------------- An HTML attachment was scrubbed... URL: