View Issue Details

IDProjectCategoryView StatusLast Update
0004798FEMFeaturepublic2021-12-07 20:16
Reportermac_the_bike Assigned To 
PrioritynoneSeveritytrivialReproducibilityN/A
Status closedResolutionno change required 
OSubuntu 18.04 
Product Version0.20 
Summary0004798: this is not a bug - but a query about the code
Descriptionhttps://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Fem/femtools/ccxtools.py

lines: 829->835
for m in self.analysis.Group:
                if m.isDerivedFrom("Fem::FemResultObject"):
                    self.results_present = True
                    break
else:
                if self.solver.AnalysisType == "check":
                    for m in self.analysis.Group:
                       ...

i can't see where the 'if' statement is for the 'else'
i have written a small simpler program which has the same form as above:
l = [1,2,3,4]
for i in l:
   if(i==2):
      print("hello", i)
else:
    print("world", i)

and it works, in the sense that it executes the 'else' statement after it has completed the 'for' loop.

mac
TagsFEM
FreeCAD InformationOS: Ubuntu 18.04.6 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4.
Build type: Release
Python version: 2.7.15+
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)

Activities

jnxd

2021-12-07 20:15

developer   ~0016066

The `else` is for the `for` statement. Please educate yourself about the `for... else..` expression in Python, e.g. https://book.pythontips.com/en/latest/for_-_else.html

Additionally, the forum is a better place for such questions. Please begin a forum post for future doubts about the code, and only use the tracker if it is established to be a problem there.

Issue History

Date Modified Username Field Change
2021-12-06 11:56 mac_the_bike New Issue
2021-12-06 11:56 mac_the_bike Tag Attached: FEM
2021-12-07 20:15 jnxd Note Added: 0016066
2021-12-07 20:16 jnxd Status new => closed
2021-12-07 20:16 jnxd Resolution open => no change required