Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using own Python classes with the runtime type and range checking feature of the library Pyadaaah

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 351
    Answer it

    I am currently trying out pyadaaah - which works quite fine - until I try to use own classes in a vardef line. I then get the error message:

    Fatal error in VarDef.__init__: Fatal error in VarDef.__processTypeSection: evaluating type section 'class:Club' failed (name 'Club' is not defined)!

    Which is annoying, as I think, I have done everything alike in the example vardef line belonging to "ConstrExampleL" of the "SemanticTestClass" in "pyadaaah.py" itself.

    Can anyone help with that? The example code I programmed, leading to said error, is:

    from pyadaaah import *
    
    
    #soccer club
    class Club(DocTypes):
          """
              ----------
              Interface:
              ----------
    
              vardef str   name        = ""               in [*]          with rw, check                                                         #club name
              vardef str   league      = "Premier League" in ["La Liga",  "Premier League", "Bundesliga", "Serie A", "Ligue 1"] with rw, check   #soccer league in which this club is playing
              vardef int   foundYear   = 2000             in [1843..2020] with rw, check(strict)                                                 #year of foundation
              vardef float marketValue = 0.0              in [0.0..*]     with rw, check                                                         #market value in EUR
      
    
              ----------
              Internals:
              ----------
    
              #No internals yet  
          """
         
          exec(DocTypesApi.execStr("Club", __doc__))
    
    
          #constructor
          @logExceptions
          def __init__(self):
              """ """
    
              self.Club__init__()
    
    
    #soccer player
    class Player(DocTypes):
          """
              ----------
              Interface:
              ----------
    
              vardef str        name      = ""               in [*]                              with rw, check            #name of the player
              vardef float      height    = 1.80             in [1.50..2.30]                     with rw, check            #height of the player - in meters
              vardef str        position  = "offense"        in ["defense", "center", "offense"] with rw, check            #position on which the player is playing  
              vardef int        birthYear = 2000             in [1975..2005]                     with rw, check(strict)    #year of birth of the player
              vardef class:Club club      = *                in [*]                              with rw, check            #soccer club the player is playing for 
      
              ----------
              Internals:
              ----------
    
              #No internals yet  
          """
         
          exec(DocTypesApi.execStr("Player", __doc__))
    
    
          #constructor
          @logExceptions
          def __init__(self):
              """ """
    
              self.Player__init__()
    
    
    

     

     

     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: