Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4MENRA81013 for ; Tue, 22 May 2001 10:23:27 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4LKvdA63202 for ; Mon, 21 May 2001 16:57:39 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f4LKuLM71860 for pgsql-interfaces@postgresql.org; Mon, 21 May 2001 16:56:21 -0400 (EDT) (envelope-from news) From: "Erny" X-Newsgroups: comp.databases.postgresql.interfaces References: <20010404211534.A13150@corvus.biomed.brown.edu> Subject: RE: Python as a procedural language Date: Mon, 21 May 2001 22:27:49 +0200 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Original-NNTP-Posting-Host: 212.166.170.72 Message-ID: <3b0980f3@news> To: pgsql-interfaces@postgresql.org X-Archive-Number: 200105/92 X-Sequence-Number: 1619 Hi, i compiled and installed this. I wonder how you would write a recursive function such as: CREATE FUNCTION factx(int4) RETURNS int4 AS ' def f(n): if n==0: return 1 else: return n*f(n-1) return f(args[0]) ' LANGUAGE 'plpython'; When called, it crashes in the return n*f(n-1) line, not knowing what f is. I could fix that using SD like this: CREATE FUNCTION factx(int4) RETURNS int4 AS ' def f(n): if n==0: return 1 else: return n*SD["f"](n-1) SD["f"]=f return f(args[0]) ' LANGUAGE 'plpython'; Or putting the function as attribute of pgpy. What happens to the namespace? Erny Spain