C
castironpi
I'd like a persistent deque, such that the instance operations all
commit atomicly to file system.
commit atomicly to file system.
castironpi said:I'd like a persistent deque, such that the instance operations all
commit atomicly to file system.
Larry Bates said:Defaulting initial to empty list this way is asking for trouble. Youinhahe said:def __init__(self, filename, initial):
should be
def __init__(self, filename, initial=[]):
(that was the whole reason i put the filename first.)
sorry.
should
default it to None and check for None and reset to empty list.
-Larry
i don't know how i would get around the problem, though, because i'd have
to know how to access the deque object that my class stores when i do
deque.__init__ in my constructor, so that i could pickle it and my class
variables separately.
inhahe said:4. can someone tell me if the way i'm using the decorator is sane? i've
never used decorators before. it just seems ridiculous to a) define a
lambda that just throws away the parameter, and b) define a meaningless
function to pass to that lambda.
I thought about the fact that a decorator is merely syntactic sugar, so it
shouldn't have any closure magic that I can't make myself, and I realized
that I could have done it the following way:
def makefunc(func):
def func2(instance, *args):
result = func(instance, *args)
instance.save()
return result
return func2
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.