0
votes

I am using emacs (GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)) as a text editor and interface with python. So far its been fairly straightforward to do everything I want to do with the script I'm working on, but I just came across a weird result using the set function.

The python docs give the following example for the set function:

>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)               # create a set without duplicates
>>> fruit
set(['orange', 'pear', 'apple', 'banana'])

However, when I run these commands in emacs I get the following error:

>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable

Can anyone explain to me why this is happening and what I should do to recover the functionality of the command? Also, are there other functions that will also fail to work as they normally do?

Thanks.

1

1 Answers

3
votes

You named a variable set, hiding the built-in. Don't name it that. If you want to recover the built-in, restart the interpreter or use

del set

to unassign the variable you made.