[Pyrex] variable scope : is that  the waited behaviour ?
    Cyril Giraudon 
    cyril.giraudon at free.fr
       
    Sun Apr 23 18:51:27 CEST 2006
    
    
  
Hello,
Take these lines of code :
###############################
cdef struct variable:
  int a
  int b
cdef variable var1
cdef variable var2
def oups():
  var1.a = 1
  var1.b = 2
  var2 = var1
  print var2.a, var2.b
Compilation :
/usr/local/bin/pyrexc ./test.pyx
/home/cyril/outils/ng-spice-rework-17/src/./test.pyx:11:9: Cannot
convert 'variable' to Python object
##############################
cdef struct variable:
  int a
  int b
cdef variable var1
cdef variable var2
def oups():
  global var2
  var1.a = 1
  var1.b = 2
  var2 = var1
  print var2.a, var2.b
The compilation succeeds and the module works fine.
################################
Is there another way to not use the global statement ?
Where am I wrong ?
Thanks a lot,
Cyril.
    
    
More information about the Pyrex
mailing list