Append gives a empty string error

345
6
09-07-2018 07:32 AM
DougBrowning
MVP Notable Contributor

had to delete

0 Kudos
6 Replies
JoshuaBixby
MVP Esteemed Contributor

Did your code get cut off?  For one, I don't see a try statement anywhere in what you posted.  Also, there is no text below "Error is".

0 Kudos
DougBrowning
MVP Notable Contributor

yea just a part of the code - its 300 lines...

Yes the error is blank - that was the whole point of my post.  It works yet fails with error text of ''.

thanks

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You state the "tool trips the try statement," but I don't see any try statement in what you posted.  If the code you posted is the working code, then I suggest you post the code that generates the error if it is the error you are trying to get feedback on.

DougBrowning
MVP Notable Contributor

Umm ok I added a try.  Not sure why that matters.  I cant post all 300 lines.

Really just asking if anyone has gotten a blank error on Append.

thanks

0 Kudos
DarrenWiens2
MVP Honored Contributor

Unless you specifically ask for the exception, the error message won't be displayed - that's the point of try/except:

foo = 'a'
bar = 1
try:
    concat = foo + bar
except Exception as e:
    print(e)‍‍‍‍‍‍

must be str, not int‍‍‍‍‍‍‍‍

Of course, you may have this, but we can't see your try/except statement.

DanPatterson_Retired
MVP Esteemed Contributor

Of course, skipping the try except block reveals the same message.

Only use them if you know you are going to get an error message that would be thrown that isn't a python error or you want to do something else if there is an error.

foo = 'a'
bar = 1


concat = foo + bar
Traceback (most recent call last):

  File "<ipython-input-56-ef8dcb5742bb>", line 1, in <module>
    concat = foo + bar

TypeError: must be str, not int

a better non-fail

try:
    concat = foo + bar
except:
    concat = "{}{}".format(foo, bar)
    

concat
'a1'
0 Kudos