Phantom Errors - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Phantom Errors (/thread-22084.html) |
Phantom Errors - prospero - Oct-29-2019 Can anyone see anything wrong with the syntax in this code? def CheckClearInv(self, EntityName): me=Bladex.GetEntity(EntityName) inv = me.GetInventory() for id in range(inv.nObjects): for ob in Actions.GetListOfObjectsAt(inv,id): try: ent = Bladex.GetEntity(ob) if ent.Kind in ("Pocima100", "Pocima200", "PocimaTodo"): Actions.RemoveFromInventory (me, ent, "") print "Stuck potion removed" except: # this is line 1164 in the file passThere isn't. It works perfectly well in a game level and has done for years. I have used UltraEdit for about 20 years. Recently I got a new PC and upgraded to the latest version. I copied that code into another game map and now it gives this error..... File "..\..\Maps\DwarfWarsII\NUFiles\AllyNPCTypes.py", line 1164 except: ^ SyntaxError: invalid syntaxThis is totally baffling me. I make enough real errors with getting phantom ones. This isn't the first time it has happened. NEVER with the old version of UltraEdit. Not really asking for magic answers, but has anyone encountered this weird phenomenon??? RE: Phantom Errors - buran - Oct-29-2019 Lines 6-12 block must be indented one level, but this should raise IndentationError, so I guess glitch is when posting here. Then if you updated to latest python3 version (3.8?) print is a function, not statement like in python2. I guess that is what you worked with.
RE: Phantom Errors - prospero - Oct-29-2019 So Sorry.... This is what it looks like. def CheckClearInv(self, EntityName): me=Bladex.GetEntity(EntityName) inv = me.GetInventory() for id in range(inv.nObjects): for ob in Actions.GetListOfObjectsAt(inv,id): try: ent = Bladex.GetEntity(ob) if ent.Kind in ("Pocima100", "Pocima200", "PocimaTodo"): Actions.RemoveFromInventory (me, ent, "") print "Stuck potion removed" except: passI can't really update the Python. This game comes with it's own and dates from 1999. It's a case of "If it ain't broke......." I'm now getting instances of functions not being found in classes when they are clearly there. RE: Phantom Errors - buran - Oct-29-2019 (Oct-29-2019, 12:59 AM)prospero Wrote: Recently I got a new PC and upgraded to the latest version (Oct-29-2019, 04:02 AM)prospero Wrote: I can't really update the Python. This game comes with it's own and dates from 1999.I am confused - what exactly did you upgrade to latest version? RE: Phantom Errors - prospero - Oct-29-2019 (Oct-29-2019, 04:50 AM)buran Wrote:(Oct-29-2019, 12:59 AM)prospero Wrote: Recently I got a new PC and upgraded to the latest version(Oct-29-2019, 04:02 AM)prospero Wrote: I can't really update the Python. This game comes with it's own and dates from 1999.I am confused - what exactly did you upgrade to latest version? The code editor UltraEdit. RE: Phantom Errors - prospero - Oct-30-2019 Just to report that the Attribute Error that occurred when trying to call some functions within a class was solved by my re-typing the entire function manually and deleting the old code. I was scrupulous in copying it exactly. I am still none the wiser, but at least it wasn't my fault. RE: Phantom Errors - snippsat - Oct-30-2019 (Oct-29-2019, 12:59 AM)prospero Wrote: I have used UltraEdit for about 20 years. Recently I got a new PC and upgraded to the latest version.Maybe it's time to test something else,i remember i tired UltraEdit a long time ago. Example VS Code from start it's free open source unlike UltraEdit,and they have put a lot resources to make Python work well in there editor. There is no longer a discussion about 2 or 3,most use Python 3 now, as Python 2 is dead(all most some will of course use for a long time still) in a couple of months. RE: Phantom Errors - nilamo - Oct-30-2019 If there's still an issue, please share the entire error traceback. RE: Phantom Errors - prospero - Oct-31-2019 Caught another..... def CheckNearerOpponent(EntityName): me=Bladex.GetEntity(EntityName) x,y,z = me.Position for i in Bladex.GetEntitiesAt(x,y,z,2200): ent=Bladex.GetEntity(i) if ent and ent.Person: if ent.Life>0: if CheckIfEnemy(ent.Name): if ent.ActiveEnemy and ent.ActiveEnemy==EntityName: me.Data.SwitchOpponent(EntityName, ent.Name) return 1 #me.Data.SwitchOpponent(EntityName, ent.Name) #return 1 return 0In the above function the commented lines cause an error. The live lines(which I typed manually) are OK. Traceback (innermost last): File "Cfg.py", line 98, in ? execfile("DefFuncs.py") File "DefFuncs.py", line 21, in ? import EnemyNPCTypes File "..\..\Maps\DwarfWarsII\NUFiles\EnemyNPCTypes.py", line 332 me.Data.SwitchOpponent(EntityName, ent.Name) ^ SyntaxError: invalid syntax** I'll try a different editor. RE: Phantom Errors - ichabod801 - Oct-31-2019 I get no error with a copy/paste into sublime text. |