Builtin function not working with Spyder
This is a bit of an iPython headshot that comes with Spyder. I've fallen foul of this when copy/pasting random bits of code from SO to test only to find really odd behaviour several days later - variables defined in the iPython console will also be in the script's global namespace indefinitely.
There's two things you can do:
- A hard restart of the Kernel (
ctrl
+.
) - Follow up on this feature request thread where it's now possible to clear the namespace automatically every time you run a script.
Python Str object is not callable in Spyder
You have overwritten the built-in str
somewhere in your code.
>>> str = 'foo' # overwriting the builtin `str`
>>> x = 5
>>> print str(x) # equivalent to 'foo'(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
Simple input function gives spyder an internal problem
This bug has been reported on Github and is supposedly fixed. See https://github.com/spyder-ide/spyder/issues/17616
Instructions there are to upgrade to 5.3.0.
Spyder console not displaying function output
(Spyder maintainer here) You need to use a print
if you want to see something printed in the console. In the example shown above, you need to change your code like this
print(type(13.4))
to see the result displayed in the console.
Strange module reload behavior in spyder or IPython
This is a feature in Spyder that is built on purpose to allow you to continue running from stop points, especially when considering longer run times to generate specific results, and also powers the variable explorer function.
There is a way around it though following the instructions in this answer to Clear all variables before each run or by restarting.
However, as pointed out by roganjosh, clearing the namespace is not necessarily better.
You can run a function that takes 10 mins to process data and return it to a global name, then just hash that function call out for every subsequent run and never have to incur the processing time again (until you wipe the namespace, that is).
If you want to only reset one or a group of variables, you can use reset_selective
%reset_selective [-f] regex
Related Topics
How to Bind the Enter Key to a Function in Tkinter
Intersection of Two Lists Including Duplicates
How to Write Tests for the Argparse Portion of a Python Module
Installing Scipy in Python 3.5 on 32-Bit Windows 7 MAChine
Using Multiple Python Engines (32Bit/64Bit and 2.7/3.5)
List' Object Has No Attribute 'Get_Attribute' While Iterating Through Webelements
How to Use Win32 API with Python
Numpy: Get Random Set of Rows from 2D Array
Parsing .Properties File in Python
Pandas Filling Missing Dates and Values Within Group
How to Tell If a String Repeats Itself in Python
Python Equivalent of Filter() Getting Two Output Lists (I.E. Partition of a List)
Differencebetween I = I + 1 and I += 1 in a 'For' Loop