Hi,

there seems to be a sematic difference between cython and native python
in the use of defaults and class variables. Consider the following example:

>>> class Bar(object):
...     CONST = 25
...     def foo(self, value=CONST):
...         print value
...
>>> b = Bar()
>>> b.foo()
25

Compiling the same code in cython results in this exception:

Error converting Pyrex file to C:
------------------------------------------------------------

class Bar(object):
    CONST = 25
    def foo(self, value=CONST):
                            ^
------------------------------------------------------------

test.pyx:6:29: undeclared name not builtin: CONST


Cython will compile the code like this:

class Bar(object):
    CONST = 25
    def foo(self, value=Bar.CONST):
        print value

But importing the a module compiled like this results in:

>>> import test
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "test.pyx", line 3, in test
NameError: Bar

So how to solve this? Is this a bug or a so called feature? ;)

Johannes

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to