[Zope] How can I "from __future__ import nested_scopes" in python scripts?

jelle jellej@pacbell.net
Tue, 26 Jun 2001 09:25:56 -0700 (PDT)


Hi Shane,

I had hoped that to be true but the following code snippet fails in
Python 2.1 unless I add the "__future__" import and always fails in Zope
2.4beta.  By removing one of the "echoAlpha()" calls from either
"echoBeta()" or "echoDelta()" and the Zope python script works.

---start Zope python script---

def echoAlpha():
	return 'alpha.'

def echoBeta():
	return 'beta.' + echoAlpha()


def echoDelta():
	return 'delta.' + echoAlpha()

print echoAlpha()
print echoBeta()
print echoDelta()
return printed

---end Zope python script---

A similar "pure" python script follows:

---start python 2.1 code---

def checknestedscope():
    def echoAlpha():
            return 'alpha.'

    def echoBeta():
            return 'beta.' + echoAlpha()


    def echoDelta():
            return 'delta.' + echoAlpha()

    print echoAlpha()
    print echoBeta()
    print echoDelta()

checknestedscope()

---end python 2.1 code---


I can get the "pure" python script to work by added the "__future__"
import.


Any ideas?

Jelle

On Tue, 26 Jun 2001, Shane Hathaway wrote:

> jelle wrote:
> > I'm using Zope2.4 beta with Python 2.1 and I want to use the nest_scope
> > functionality. However when I add the prerequisite statement:
> >
> > from __future__ import nested_scopes
> >
> > at the top of my python script it gives me an "ImportError" and
> > "unauthorized" message.
>
> You don't have to.  Starting in Zope 2.4.0a1, Nested scopes are always
> turned on.
>
> Shane
>

--