# Why does the except: statement error

**URL:** <https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [August 30, 2023, 5:41pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569 "2023-08-30T17:41:13Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [August 30, 2023, 6:24pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/21 "2023-08-30T18:24:17Z")

</div>

I am printing TagValuePLC and TagValueNum

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 30, 2023, 6:24pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/22 "2023-08-30T18:24:39Z")

</div>

But then why wouldn't these subsequent print statements show up?

```auto
		print "PLC=" + str(TagValuePLC)
		print "Num=" + str(TagValueNum)
		print "got here"

```

this seems strange

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 30, 2023, 6:30pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/23 "2023-08-30T18:30:14Z")

</div>

I tried this and it still works fine, it never goes past the `if` statement

```auto
# Grab tag values 
tagPaths = 'PLC_NUMBER','OUTPUT_NUMBER'
values = system.tag.readBlocking(tagPaths)
TagValuePLC = values[0].value
TagValueNum = values[1].value
print values
print "PLC=" + str(TagValuePLC)
print "Num=" + str(TagValueNum)
#continue if tag values valid
if TagValuePLC is not None and TagValueNum is not None:
	print "got here"
	
	#if negative add to overflow index to check at end
	if TagValuePLC <0 and TagValueNum <0 and TagValueNum < TagValuePLC:
		overflowIndex.append[index]
    
    #get input Number based on index value (ignore overflow till later)
	if index <= lastFixed:
		Input_Number = index/10
	else:
		Input_Number = 0
    
	updateString = "UPDATE TGMS_InputDBAction SET Output_PLC = ?, Output_Number = ? OUTPUT DELETED.Output_PLC, DELETED.Output_Number WHERE UniqueActionID = ?"
	updateArgs = [TagValuePLC, TagValueNum, UniqueActionID] 
	insertString = "INSERT INTO TGMS_InputDBAction (ActionID, Input_PLC, Input_Number, Output_PLC, Output_Number) Values (?,?,?,?,?)"
	insertArgs = [index, PLC, Input_Number, TagValuePLC, TagValueNum]
	try:
		DBvalues = system.db.runPrepQuery(updateString, updateArgs, DB)
		DBValuePLC = DBvalues.getValueAt(0,0)
		DBValueNum = DBvalues.getValueAt(0,1)
		if DBValuePLC != TagValuePLC or DBValueNum != TagValueNum:
		    updatecount += 1
		    updated = 1
		    #set values to str for audit log
		    OldValue = "PLC-"+str(DBValuePLC)+" Num-"+ str(DBValueNum)
		    NewValue = "PLC-"+str(TagValuePLC)+" Num-"+ str(TagValueNum)
		    ColName = "Output PLC/Number Updated"

	except:
		print "I did get to the except"
		system.db.runPrepUpdate(insertString, insertArgs, DB)
		updatecount += 1
		updated = 1
	    #set values to str for audit log
		OldValue = "inserted row"
		NewValue = "PLC-"+str(TagValuePLC)+" Num-"+ str(TagValueNum)
		ColName = "Output PLC/Number Updated"
    
	if updated == 1: #add entry to audit log		
	    auditQuery = "INSERT INTO TGMS_AuditInputAction (ModifiedUniqueActionID, OldValue, NewValue, ColumnChanged, TagPath) VALUES (?,?,?,?,?)"
	    auditArgs = UniqueActionID, OldValue, NewValue, ColName, basePath
	    system.db.runPrepUpdate(auditQuery, auditArgs, DB)			
	    updated = 0

```

output

```auto
[[null, Bad_NotFound("Path '[default]PLC_NUMBER' not found."), Tue Aug 29 16:51:45 EDT 2023 (1693342305436)], [null, Bad_NotFound("Path '[default]OUTPUT_NUMBER' not found."), Tue Aug 29 16:51:45 EDT 2023 (1693342305436)]]
PLC=None
Num=None

```

---

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [August 30, 2023, 6:31pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/24 "2023-08-30T18:31:35Z")

</div>

> [@rfolkes](#):
>
> `print "got here"`

Undid all my Tab out spacing and redid it. Not sure where it was but something got messed up with indents.

Working now.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 30, 2023, 6:32pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/25 "2023-08-30T18:32:41Z")

</div>

I noticed that when I copied the script into my console, I had to redo the indentation. I'm surprised it would work for you as is, I couldn't even run it without fixing it.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 30, 2023, 6:34pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/26 "2023-08-30T18:34:41Z")

</div>

Ah, yep, there's a mix of tabs and spaces in here...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d296f80802214c5d3876d03594415ec1d319712.png)

---

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [August 30, 2023, 6:36pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/27 "2023-08-30T18:36:14Z")

</div>

which is odd since I NEVER use space. Silicon Valley (show) told me that space was BAD 🙂

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 30, 2023, 6:42pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/28 "2023-08-30T18:42:09Z")

</div>

For posterity, I'll point out that the editor does have a setting to show whitespace:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/22613a91938fa3ca71ffde355db052128cb24107.png)

Admittedly, it was _not_ my first thought for the root cause of the issue until I walked through it with Cody.

What we're preemptively thinking of as a "solution" is to add smarts to the code editor such that it warns on mixed tab and space indentation. It's technically allowed in Python 2, but should pretty much never be used and is even explicitly prevented in Python 3.

---

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [August 30, 2023, 6:48pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/29 "2023-08-30T18:48:03Z")

</div>

> [@paul-griffith](#):
>
> nd spa

When is ignition upgrading python version?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 30, 2023, 6:55pm UTC](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569/30 "2023-08-30T18:55:04Z")

</div>

Well, Jython 3 doesn't exist, so that's a pretty big impediment 🙂

Basically: We'll take on the **enormous** pain of providing (one or more) replacements or alternatives to Jython 2 **once a suitable alternative exists**. There is no alternative that meets all public and private criteria available right now, though we're keeping a close eye on a few possibilities.

[Previous page](https://forum.inductiveautomation.com/t/why-does-the-except-statement-error/78569.md?page=1)
