SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, code samples and tools and downloads for ASP.Net, SQL Server, R Script, Windows, Windows Phone, AWS, SAP HANA and ABAP, like SAP UI5, Screen Personas, etc.

Software Development

Python TypeError: 'str' object is not callable

Hello Python developers or programmers trying to learn Python

I'ld like to share an error that confused me a lot on IDLE when I executed a simple Python code while I was following Python 101

Traceback (most recent call last):
File "test-python.py", line 14, in
numc = str(myNum)
TypeError: 'str' object is not callable

When I checked the mentioned Python code like, all seemed very logical.
I was converting a numeric variable using STR() function and storing into an other variable as follows

myNum = 26
numc = str(myNum)

That is interesting that the IDLE points to line 14 where the STR() convert function is used, actually the cause of the error is beforehand.

I realized that I created a string variable named "str" which was causing all those troubles.

str = "hello world!"
myNum = 26
numc = str(myNum)

Changing the name of the variable from "str" to another non-keyword name helped me to solve the issue

Published Monday, June 04, 2018 7:36 PM
Filed Under:


No Comments
Anonymous comments are disabled

About eralper

SQL Server administrator and T-SQL developer including BI components Web programming with HTML, HTML5 and ASP, ASP.NET and .NET Framework developer SAP ABAP and SAPUI5 development, Web Dynpro and Smart Form Siemens HiPath Center CTI development
Copyright © 2004 - 2020 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems