Wednesday, August 28, 2013

Python: One More Example of How PyCharm is Psychic

I had the following line in my Python code:

if self._lookup_unallocated(current_allocation_state, key) > 0:

I wanted to change it to:

unallocated = self._lookup_unallocated(current_allocation_state, key)
if unallocated > 0:

Hence, I highlighted the expression, right clicked, refactor, extract, variable. It did the refactoring and automatically guessed that I wanted to name the variable "unallocated"! Presumably, it guessed based on the name of the method I was calling. Nonetheless, it's like it read my mind!

No comments: