Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-08 Thread Egon Frerich via Python-list


Am 07.11.23 um 20:10 schrieb MRAB via Python-list:

On 2023-11-07 18:30, dn via Python-list wrote:

On 08/11/2023 06.47, Egon Frerich via Python-list wrote:
I've no idea why this happens. In a module there are lists and 
definitions:

...

 ["%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 
 ["%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  mean? Is there a change from python2 to python3?


Works for me (Python 3.11 on Fedora-Linux 37)
- both as a script, and simple/single import.

What happens when you extract the second dimension's definitions into a
module of their own, and import that (with/out less-sophisticated join)?


The missing detail is this line from the traceback:

   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11,
in 
 class GUIcfg:

You are right. The list comprehension has to be outside the class. The 
scope rules have been changed python2 and python3.


Egon




Here's a small example that shows the problem:

8<
#!python3.11
# -*- encoding: utf-8 -*-

class Test:
    hello = "hello"
    print(hello)
    print([[zero] for _ in range(4)])
8<

and its traceback:

8<
hello
Traceback (most recent call last):
  File "C:\Projects\regex3\test_clipboard.py", line 4, in 
    class Test:
  File "C:\Projects\regex3\test_clipboard.py", line 7, in Test
    print([zero for _ in range(4)])
 ^^
  File "C:\Projects\regex3\test_clipboard.py", line 7, in 
    print([zero for _ in range(4)])
   
NameError: name 'zero' is not defined
8<

'zero' is visible in:

    print(hello)

but not in:

    print([zero for _ in range(4)])

Something to do with how scoping is implemented in comprehensions?



--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Greg Ewing via Python-list

On 8/11/23 8:10 am, MRAB wrote:

Something to do with how scoping is implemented in comprehensions?


Yes, together with the way class scopes work during class construction.

Behind the scenes, the body of a listcomp happens to be implemented
as a nested function.

Usually you don't notice this, but while a class is being built,
its scope doesn't count as an enlosing scope for functions defined
within the class.

This is necessary, otherwise all of a class's attributes would be 
visible inside its methods, which isn't what we want. However, it

leads to some odd corner cases, such as this one.

There are various ways you could work around this. I would suggest
moving the offending code outside the class and qualifying the
constants it uses with the class name.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list

On 2023-11-07 20:56, Thomas Passin via Python-list wrote:

On 11/7/2023 3:29 PM, MRAB via Python-list wrote:

On 2023-11-07 19:20, Jim Schwartz via Python-list wrote:
Where do you define fCONV_AUSRICHTG? It must be initialized or defined 
somewhere. Did you leave out a statement from the python 2 version?



It's given its value here:

     (
     fNAME,
     fLG1,
     fLG2,
     fTYP,
     fCONV_AUSRICHTG,
     fENTRY_AUSRICHTG,
     fTEXT_AUSRICHTUNG,
     fHOLFUNKT,
     fPRUEFFUNKT,
     fPRUEF_ARG,
     ) = list(range(10))



This construction is a sneaky way to assign index numbers to list
entries.  A simplified example:

  >>> S1 = 'string 1'
  >>> S2 = 'string 2'
  >>> (fS1, fS2) = list(range(2))
  >>> fS1
0
  >>>
  >>> fS2
1


You don't need the 'list', though: range(...) will work on its own.

[snip]

--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Thomas Passin via Python-list

On 11/7/2023 3:29 PM, MRAB via Python-list wrote:

On 2023-11-07 19:20, Jim Schwartz via Python-list wrote:
Where do you define fCONV_AUSRICHTG? It must be initialized or defined 
somewhere. Did you leave out a statement from the python 2 version?



It's given its value here:

     (
     fNAME,
     fLG1,
     fLG2,
     fTYP,
     fCONV_AUSRICHTG,
     fENTRY_AUSRICHTG,
     fTEXT_AUSRICHTUNG,
     fHOLFUNKT,
     fPRUEFFUNKT,
     fPRUEF_ARG,
     ) = list(range(10))



This construction is a sneaky way to assign index numbers to list 
entries.  A simplified example:


>>> S1 = 'string 1'
>>> S2 = 'string 2'
>>> (fS1, fS2) = list(range(2))
>>> fS1
0
>>>
>>> fS2
1





On Nov 7, 2023, at 1:06 PM, Thomas Passin via Python-list 
 wrote:


On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:
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 

    from tests.testU2 import testU2
  File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, 
in 

    from gui.GUI_Konfig import GUIcfg
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 
11, in 

    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 
    ["%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  mean? Is there a change from python2 to python3?


You are using a syntax that I don't understand, but "listcomp" means 
a list comprehenson.






--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list

On 2023-11-07 19:20, Jim Schwartz via Python-list wrote:

Where do you define fCONV_AUSRICHTG? It must be initialized or defined 
somewhere. Did you leave out a statement from the python 2 version?


It's given its value here:

(
fNAME,
fLG1,
fLG2,
fTYP,
fCONV_AUSRICHTG,
fENTRY_AUSRICHTG,
fTEXT_AUSRICHTUNG,
fHOLFUNKT,
fPRUEFFUNKT,
fPRUEF_ARG,
) = list(range(10))




On Nov 7, 2023, at 1:06 PM, Thomas Passin via Python-list 
 wrote:

On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:

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 

from tests.testU2 import testU2
  File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 
from gui.GUI_Konfig import GUIcfg
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, in 

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 

["%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  mean? Is there a change from python2 to python3?


You are using a syntax that I don't understand, but "listcomp" means a list 
comprehenson.



--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Jim Schwartz via Python-list
Where do you define fCONV_AUSRICHTG? It must be initialized or defined 
somewhere. Did you leave out a statement from the python 2 version?  

Sent from my iPhone

> On Nov 7, 2023, at 1:06 PM, Thomas Passin via Python-list 
>  wrote:
> 
> On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:
>> 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 
>> 
>> from tests.testU2 import testU2
>>   File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 
>> 
>> from gui.GUI_Konfig import GUIcfg
>>   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, in 
>> 
>> 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 
>> 
>> ["%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  mean? Is there a change from python2 to python3?
> 
> You are using a syntax that I don't understand, but "listcomp" means a list 
> comprehenson.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list

On 2023-11-07 18:30, dn via Python-list wrote:

On 08/11/2023 06.47, Egon Frerich via Python-list wrote:

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

...


     ["%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 

     ["%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  mean? Is there a change from python2 to python3?


Works for me (Python 3.11 on Fedora-Linux 37)
- both as a script, and simple/single import.

What happens when you extract the second dimension's definitions into a
module of their own, and import that (with/out less-sophisticated join)?


The missing detail is this line from the traceback:

   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11,
in 
 class GUIcfg:

Here's a small example that shows the problem:

8<
#!python3.11
# -*- encoding: utf-8 -*-

class Test:
hello = "hello"
print(hello)
print([[zero] for _ in range(4)])
8<

and its traceback:

8<
hello
Traceback (most recent call last):
  File "C:\Projects\regex3\test_clipboard.py", line 4, in 
class Test:
  File "C:\Projects\regex3\test_clipboard.py", line 7, in Test
print([zero for _ in range(4)])
 ^^
  File "C:\Projects\regex3\test_clipboard.py", line 7, in 
print([zero for _ in range(4)])
   
NameError: name 'zero' is not defined
8<

'zero' is visible in:

print(hello)

but not in:

print([zero for _ in range(4)])

Something to do with how scoping is implemented in comprehensions?

--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Thomas Passin via Python-list

On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:

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 

     from tests.testU2 import testU2
   File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 


     from gui.GUI_Konfig import GUIcfg
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, 
in 

     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 

     ["%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  mean? Is there a change from python2 to python3?


You are using a syntax that I don't understand, but "listcomp" means a 
list comprehenson.


--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread dn via Python-list

On 08/11/2023 06.47, Egon Frerich via Python-list wrote:

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

...


     ["%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 

     ["%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  mean? Is there a change from python2 to python3?


Works for me (Python 3.11 on Fedora-Linux 37)
- both as a script, and simple/single import.

What happens when you extract the second dimension's definitions into a 
module of their own, and import that (with/out less-sophisticated join)?


--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Egon Frerich via Python-list

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 

    from tests.testU2 import testU2
  File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 


    from gui.GUI_Konfig import GUIcfg
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, 
in 

    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 

    ["%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  mean? Is there a change from python2 to python3?

Egon



--
https://mail.python.org/mailman/listinfo/python-list