From the IPreference documentation, it's unclear to me whether I should use preferences.clear(key) or preferences.remove(key) to un-set a preference.
However, it looks as though neither works.
Is it possible to remove a preference altogether? And if so, should one of these two methods work to that end?
Expected
For preferences that are stored to file, if there is a preference at some key (namespace.key), it should be possible to remove that preference altogether.
Consider this initial situation:
>>> def cat(fname):
... with open(fname, "r") as f:
... print(f.read())
...
>>> preferences = Preferences(filename="example.ini")
>>> preferences.set("namespace.field", "value")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value
I would expect that
preferences.remove("namespace.field")
preferences.flush()
would result in a empty example.ini file.
Observed
Neither approach works:
>>> preferences.remove("namespace.field")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value
>>> preferences.clear("namespace.field")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value
From the
IPreferencedocumentation, it's unclear to me whether I should usepreferences.clear(key)orpreferences.remove(key)to un-set a preference.However, it looks as though neither works.
Is it possible to remove a preference altogether? And if so, should one of these two methods work to that end?
Expected
For preferences that are stored to file, if there is a preference at some key (namespace.key), it should be possible to remove that preference altogether.
Consider this initial situation:
I would expect that
would result in a empty
example.inifile.Observed
Neither approach works: