Kent Johnson wrote:
> My understanding of the OP is that he wants an exception if there are items
> in errdict. Also this solution will change self.somedict even in the error
> case which may not be desirable.
I understood what the OP said but think he expressed himself incorrectly or
the alg
Really I was just wondering if this was a bad practice or if there was
some way to get the same result.
So if the list comprehension isn't a bad way to to it then I will
stick with it.
I am at the point where I have used python for simple stuff for a few
years and I am attempting to get past a n
Javier Ruere wrote:
> I should also add the most simple and obvious implementation which is also
> the fastest:
>
>
> class Test:
> def __init__(self, dict):
> self.somedict = dict
>
> def updateit(self, **mydict):
> errdict = {}
> for k, v in mydict.iteritems():
David Driver wrote:
> I have a function
>
> def updateit(self,**mydict):
>
> which is intended to update a dictionary self.somedict.
>
> If there are keys in mydict that are not in self.somedict I want them
> returned in a new dict.
>
> here is what i am doing now:
>
> errdict = dict([(a,b) f
I should also add the most simple and obvious implementation which is also the
fastest:
class Test:
def __init__(self, dict):
self.somedict = dict
def updateit(self, **mydict):
errdict = {}
for k, v in mydict.iteritems():
if k not in self.somedict:
David Driver wrote:
> I have a function
>
> def updateit(self,**mydict):
>
> which is intended to update a dictionary self.somedict.
>
> If there are keys in mydict that are not in self.somedict I want them
> returned in a new dict.
>
> here is what i am doing now:
>
> errdict = dict([(a,b) f
I have a function
def updateit(self,**mydict):
which is intended to update a dictionary self.somedict.
If there are keys in mydict that are not in self.somedict I want them
returned in a new dict.
here is what i am doing now:
errdict = dict([(a,b) for a,b in mydict.items() if not a in self.so