fCONV_AUSRICHTG is not defined - Why?

Egon Frerich egon at frerich.eu
Tue Nov 7 12:47:26 EST 2023


I've no idea why this happens. In a module there are lists and definitions:

     Felder = [
         # Name       lg1  lg2 typ   Ausrichtung Holen Prüfen Prüfvorg
         ["Jahr", 4, 5, "u", "", "right", "center"],
         ["Monat", 2, 5, "u", "", "right", "center"],
         ["Tag", 2, 3, "u", "", "right", "center"],
         ["Belegnr", 5, 7, "s", "", "right", "center"],
         ["Bank", 2, 4, "u", "", "center", "center"],
         ["Art", 2, 3, "u", "", "center", "center"],
         ["Aufg", 2, 4, "u", "", "center", "center"],
         ["Text", 25, 25, "s", "-", "left", "left"],
         ["Ergänzung", 12, 12, "s", "-", "left", "left"],
         ["Betrag", 13, 13, "s", "", "right", "right"],
         ["W", 1, 2, "s", "", "center", "center"],
         ["WBetrag", 7, 7, "s", "", "right", "right"],
         ["Kurs", 6, 6, "s", "", "right", "right"],
     ]
     "Reihenfolge in der Dimension 1"
     (
         fJAHR,
         fMONAT,
         fTAG,
         fBELEGNR,
         fBANK,
         fART,
         fAUFGABE,
         fTEXT,
         fTEXTERG,
         fBETRAG,
         fWAEHRUNG,
         fBETRAGinWAEHRUNG,
         fUMRECHNUNGSKURS,
     ) = list(range(13))
     "Reihenfolge in der Dimension 2"
     (
         fNAME,
         fLG1,
         fLG2,
         fTYP,
         fCONV_AUSRICHTG,
         fENTRY_AUSRICHTG,
         fTEXT_AUSRICHTUNG,
         fHOLFUNKT,
         fPRUEFFUNKT,
         fPRUEF_ARG,
     ) = list(range(10))


Two lines with  test statements follow and the statement which produces 
an error:

     print(Felder)
     print(fJAHR, fNAME, fTYP, fCONV_AUSRICHTG)
     akette = "%" + "%".join(
         ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in 
Felder])

The traceback shows:

$ python3 testGeldspurGUI.py
[['Jahr', 4, 5, 'u', '', 'right', 'center'], ['Monat', 2, 5, 'u', '', 
'right', 'center'], ['Tag', 2, 3, 'u', '', 'right', 'center'], 
['Belegnr', 5, 7, 's', '', 'right', 'center'], ['Bank', 2, 4, 'u', '', 
'center', 'center'], ['Art', 2, 3, 'u', '', 'center', 'center'], 
['Aufg', 2, 4, 'u', '', 'center', 'center'], ['Text', 25, 25, 's', '-', 
'left', 'left'], ['Ergänzung', 12, 12, 's', '-', 'left', 'left'], 
['Betrag', 13, 13, 's', '', 'right', 'right'], ['W', 1, 2, 's', '', 
'center', 'center'], ['WBetrag', 7, 7, 's', '', 'right', 'right'], 
['Kurs', 6, 6, 's', '', 'right', 'right']]
0 0 3 4
Traceback (most recent call last):
   File "/home/egon/Entw/Geldspur/geldspur/testGeldspurGUI.py", line 15, 
in <module>
     from tests.testU2 import testU2
   File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 
<module>
     from gui.GUI_Konfig import GUIcfg
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, 
in <module>
     class GUIcfg:
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 90, 
in GUIcfg
     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 90, 
in <listcomp>
     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])
NameError: name 'fCONV_AUSRICHTG' is not defined

You see "Felder" and with "0 0 3 4" the correct value 4 for 
fCONV_AUSRICHTG. But there is the NameError.

What does <listcomp> mean? Is there a change from python2 to python3?

Egon





More information about the Python-list mailing list