Martin Vegter
Martin Vegter

Reputation: 527

ipython macro interfering with variable

In ipython, I have defined a macro called c (this macro clears the screen).

I have noticed, when I type

c = 2 + 2 

my macro c gets executed. I would have expected, that I am not calling a macro, but rather assigning a variable c.

Is there any way to distinguish between the two (macro vs. variable assignment)?

Upvotes: 0

Views: 64

Answers (2)

Padraic Cunningham
Padraic Cunningham

Reputation: 180411

I cannot see any easy way to override or distinguish a macro from a variable but macros can start with characters that are not legal in python variable names:

You could use 1c, $c or any other variation that did not have the potential to clash with a python variable name.

Upvotes: 2

unutbu
unutbu

Reputation: 879591

globals()['c'] = 2 + 2

will reassign the value of c (thus disassociating it from the definition of the macro).

I think your best option is to rename either the macro or the variable.

Upvotes: 1

Related Questions