Stefan i spent sooooo long on this thank you!

I got another quick question, how do i define the class in the global namespace but still refer to it in functions? I want to do something like this but keep getting compile errors.

//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////

import GEUtil
import GEGameMode

charlieTemp = 0

class Charlie(GEGameMode.CGEPYGameMode):
   def __init__(self):
       super(Alpha, self).__init__()
def FunctionCall(self):
       GEUtil.Msg("This is function test Charlie!")

   def StringReturn(self):
       return "This is return test Charlie!"

def Ident():
   return "Charlie"
def NewGamePlay():
   return "NewCharlie"
def NewCharlie():
   global charlieTemp
charlieTemp = Charlie()
   return charlieTemp


//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////


Loading Script: Charlie
Traceback (most recent call last):
 File "test_c.py", line 25, in NewCharlie
   charlieTemp = Charlie()
NameError: global name 'Charlie' is not defined






Stefan Seefeld wrote:
On 08/31/2009 07:51 AM, Mark Chandler wrote:
Im toying around with the idea to use python as an embedded scripting language for a project im working on and have got most things working. However i cant seem to be able to convert a python extended object back into a native c++ pointer.


[...]

   import GEGameMode
      def Ident():
       return "Alpha"
          def NewGamePlay():
       return "NewAlpha"
         def NewAlpha():
       import GEGameMode
       import GEUtil
          class Alpha(GEGameMode.CGEPYGameMode):
           def __init__(self):
               print "Made new Alpha!"

             super(Alpha, self).__init__()

is missing here.



              def FunctionCall(self):
               GEUtil.Msg("This is function test Alpha!")
              def StringReturn(self):
               return "This is return test Alpha!"
                      return Alpha()

Without explicit initialization of the base class, your Alpha instance is in fact not a CGEPYGameMode instance.

HTH,
        Stefan


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to