matplotlib: Tkagg - resizing window

- if self._edgecolors == 'None':
    + if self._edgecolors is 'None': self._edgecolors = self._facecolors

You need to be careful when using 'is' for comparisons. This tests to
see if two objects actually share the same pointer in memory. This is
appropriate for the object None, but not the string 'None'

x = 'None'
y = x.capitalize()
x

'None'

y

'None'

x==y

True

x is y

False

matplotlib uses the string 'None' in some cases because the object
None is already used to mean "do the default thing using rc"

JDH

John Hunter wrote:

"Eric" == Eric Firing <efiring@...202...> writes:

    - if self._edgecolors == 'None': + if self._edgecolors is 'None': self._edgecolors = self._facecolors

You need to be careful when using 'is' for comparisons. This tests to
see if two objects actually share the same pointer in memory. This is
appropriate for the object None, but not the string 'None'

John,

I thought that python was keeping track of string objects so as not to duplicate them, as the simple test I did seemed to confirm. Your counterexample is more subtle. Lesson learned!

It looks like I will have to use

if isinstance(x, str) and x == 'None':

to get around the problem that the comparison will fail if x is a numarray array (but not Numeric or numpy).

Eric

···

x = 'None'
y = x.capitalize()
x

'None'

y

'None'

x==y

True

x is y

False

matplotlib uses the string 'None' in some cases because the object
None is already used to mean "do the default thing using rc"

JDH