You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In fact, I added my own debugging, and the .append() does not even trigger the __setitem__ function of the PickleShareDB class.
>>> from pickleshare import *
>>> db = PickleShareDB('test')
This is the debugged version.
>>> db['testvalue'] = 1234567
Set item called with key:testvalue and value:1234567
>>> db['stack'] = []
Set item called with key:stack and value:[]
>>> db['stack'].append("Hello")
Fix
Since the __setitem__ magic method only triggers when the value of a key is set, or updated, it does not trigger when you .append() something.
Also, there is no magic method that triggers when an .append() happens
So I suggest adding an .append() function:
It would be nice if you could overwrite the default .append() function, like db['stack'].append(0) but since every db['key'] is not an instance of the class PickleShareDB but a list, I don't want to mess with it :D
The text was updated successfully, but these errors were encountered:
Hello,
I've noticed that using
.append()
on a PickleShare Key does not represent the changes that were made.Example
Command Line 1:
Command Line 2:
Command Line 1:
Command Line 2:
In fact, I added my own debugging, and the
.append()
does not even trigger the__setitem__
function of thePickleShareDB
class.Fix
Since the
__setitem__
magic method only triggers when the value of a key is set, or updated, it does not trigger when you.append()
something.Also, there is no magic method that triggers when an
.append()
happensSo I suggest adding an
.append()
function:Test
Command Line 1:
Command Line 2:
Command Line 1:
Command Line 2:
It would be nice if you could overwrite the default
.append()
function, likedb['stack'].append(0)
but since everydb['key']
is not an instance of the class PickleShareDB but a list, I don't want to mess with it :DThe text was updated successfully, but these errors were encountered: