Joel Hedlund wrote:
Scott David Daniels wrote:
Perhaps your hash function could be something like:
I'm not sure I understand what you're suggesting.
/Joel
Sorry, a half-thought out idea based on the fact that you wanted a
consistent hash for a varying dictionary. The given dictionary subcl
Joel Hedlund wrote:
First off, please note that I consider my problem to be solved, many
thanks to c.l.p and especially Duncan Booth. But of course continued
discussion on this topic can be both enlightening and entertaining as
long as people are interested. So here goes:
heh, nothing like a
Steven D'Aprano wrote:
On Tue, 16 Dec 2008 14:32:39 +0100, Joel Hedlund wrote:
Duncan Booth wrote:
Alternatively give up on defining hash and __eq__ for FragmentInfo and
rely on object identity instead.
Object identity wouldn't work so well for caching. Objects would always
be drawn as they ap
On Wed, 17 Dec 2008 02:10:31 +0100, Joel Hedlund wrote:
> Scott David Daniels wrote:
>> Perhaps your hash function could be something like:
>
> I'm not sure I understand what you're suggesting.
Neither am I, since you've removed the hash function which might have
given readers a clue.
*wink*
On Tue, 16 Dec 2008 14:32:39 +0100, Joel Hedlund wrote:
> Duncan Booth wrote:
>> I think you probably are correct. The only thing I can think that might
>> help is if you can catch all the situations where changes to the
>> dependent values might change the hash and wrap them up: before
>> changin
Scott David Daniels wrote:
Perhaps your hash function could be something like:
I'm not sure I understand what you're suggesting.
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
Joel Hedlund wrote:
Duncan Booth wrote:
I think you probably are correct. The only thing I can think that
might help is if you can catch all the situations where changes to the
dependent values might change the hash and wrap them up: before
changing the hash pop the item out of the dict, then
Duncan Booth wrote:
I think you probably are correct. The only thing I can think that might
help is if you can catch all the situations where changes to the dependent
values might change the hash and wrap them up: before changing the hash pop
the item out of the dict, then reinsert it after the
Joel Hedlund wrote:
> I should probably do this with lists instead because I can't really
> think of a way of salvaging this. Am i right?
>
I think you probably are correct. The only thing I can think that might
help is if you can catch all the situations where changes to the dependent
value
Joel Hedlund writes:
> I'm having a very hard time explaining why this snippet *sometimes*
> raises KeyError:
>
> snippet:
>> print type(self.pool)
>> for frag in self.pool.keys():
>> if frag is fragment_info:
>> print "the fragment_info *is* in the pool", hash(frag),
>> hash(fragmen
Duncan Booth wrote:
It could happen quite easily if the hash value of the object has changed
since it was put in the dictionary. what does the definition of your
core.gui.FragmentInfo object look like?
Dunno if it'll help much, but:
class FragmentInfo(object):
def __init__(self, renderer,
Joel Hedlund wrote:
> I would very much like an explanation to this that does not involve
> threads, because I haven't made any that I'm aware of. I can't even
> understand how this could happen. How do I even debug this?
>
It could happen quite easily if the hash value of the object has chang
I'm having a very hard time explaining why this snippet *sometimes*
raises KeyError:
snippet:
print type(self.pool)
for frag in self.pool.keys():
if frag is fragment_info:
print "the fragment_info *is* in the pool", hash(frag),
hash(fragment_info), hash(frag) == hash(fragment_info)
Alistair King <[EMAIL PROTECTED]> writes:
> heavy = raw_input("\n\n@@\n\nPlease enter the heaviest
> atom for which you obtained percentage values for, but not Oxygen, eg,
> 'C', 'N', 'S', 'Br'...: ")
>
> print DSvalues
>
> def updateDS1v(Fxas, x):
> if Fxas != 0:
> value = DSvalue
Peter Otten wrote:
> Alistair King wrote:
>
>
>> the code works great now. I know these things are quite simple to learn
>> from books etc.. but i would be lost without this mailinglist, from lack
>> of time. Hopefully soon i can give something more complicated.
>> I ended up doing the dictionar
Alistair King wrote:
> the code works great now. I know these things are quite simple to learn
> from books etc.. but i would be lost without this mailinglist, from lack
> of time. Hopefully soon i can give something more complicated.
> I ended up doing the dictionary formatting properly and the n
Fredrik Lundh wrote:
> Alistair King wrote:
>
>
>> Is there any other way of removing double and single quotes from a
>> number, as a string, to give the float value again?
>>
>
> help(str) describes what you can do with a string (an object of type
> 'str', that is). among the methods lis
Alistair King wrote:
> Is there any other way of removing double and single quotes from a
> number, as a string, to give the float value again?
help(str) describes what you can do with a string (an object of type
'str', that is). among the methods listed, you'll find:
> | strip(...)
> |
Ben Finney wrote:
> Alistair King <[EMAIL PROTECTED]> writes:
>
>
>> Ben Finney wrote:
>>
>>> Even better, work on a minimal program to do nothing but reproduce
>>> the unexpected behaviour. If you get to such a program and still
>>> don't understand, then post it here so others can run it
Alistair King <[EMAIL PROTECTED]> writes:
> Ben Finney wrote:
> > Even better, work on a minimal program to do nothing but reproduce
> > the unexpected behaviour. If you get to such a program and still
> > don't understand, then post it here so others can run it
> > themselves and explain.
> ive c
Ben Finney wrote:
> "Jon Clements" <[EMAIL PROTECTED]> writes:
>
>
>> We're still in the dark as to what you're trying to do, try
>> describing something like: "for each element there is an associated
>> 'F' value. For each element in an existing molecule I wish to change
>> the number of 'whate
"Jon Clements" <[EMAIL PROTECTED]> writes:
> We're still in the dark as to what you're trying to do, try
> describing something like: "for each element there is an associated
> 'F' value. For each element in an existing molecule I wish to change
> the number of 'whatever' to be 'whatever' + my 'F'
Alistair King wrote:
> Jon Clements wrote:
>
> > > Alistair King wrote:
> > >
> > >
> >
> >> >> Hi,
> >> >>
> >> >> ive been trying to update a dictionary containing a molecular formula,
> >> >> but seem to be getting this error:
> >> >>
> >> >>
> >> >> Traceback (most recent call last):
> >> >>
Jon Clements wrote:
> > Alistair King wrote:
> >
> >
>
>> >> Hi,
>> >>
>> >> ive been trying to update a dictionary containing a molecular formula,
>> >> but seem to be getting this error:
>> >>
>> >>
>> >> Traceback (most recent call last):
>> >> File "DS1excessH2O.py", line 242, in ?
>>
Alistair King wrote:
> Hi,
>
> ive been trying to update a dictionary containing a molecular formula, but
> seem to be getting this error:
>
>
> Traceback (most recent call last):
> File "DS1excessH2O.py", line 242, in ?
> updateDS1v(FCas, C, XDS)
> NameError: name 'C' is not defined
>
> d
Alistair King wrote:
> Hi,
>
> ive been trying to update a dictionary containing a molecular formula, but
> seem to be getting this error:
>
>
> Traceback (most recent call last):
> File "DS1excessH2O.py", line 242, in ?
> updateDS1v(FCas, C, XDS)
> NameError: name 'C' is not defined
>
>
Roberto Bonvallet wrote:
> Alistair King wrote:
>> DS1v = {'C': 6, 'H': 10, 'O': 5}
>
> Try DS1v['C'] instead of DS1v[C].
> updateDS1v(FCas, C, XDS)
> updateDS1v(FHas, H, XDS)
> updateDS1v(FOas, O, XDS)
> updateDS1v(FNas, N, XDS)
> updateDS1v(FSas, S, XDS)
> updateDS1v(FClas, Cl, XDS)
> updateDS1
Alistair King wrote:
> Hi,
>
> ive been trying to update a dictionary containing a molecular formula, but
> seem to be getting this error:
>
>
> Traceback (most recent call last):
> File "DS1excessH2O.py", line 242, in ?
>updateDS1v(FCas, C, XDS)
> NameError: name 'C' is not defined
>
> d
Hi,
ive been trying to update a dictionary containing a molecular formula, but seem
to be getting this error:
Traceback (most recent call last):
File "DS1excessH2O.py", line 242, in ?
updateDS1v(FCas, C, XDS)
NameError: name 'C' is not defined
dictionary is:
DS1v = {'C': 6, 'H': 10, 'O
Michael Spencer wrote:
> Alternatively, you could edit visitName to allow 'True' and any other
> identifiers you specify e.g. (untested):
>
> allowed = {"True": True, "False": False}
> def visitName(self,node, **kw):
> try:
> return self.allowed[node.name]
> e
Em Sex, 2006-04-21 às 18:40 -0700, Clodoaldo Pinto escreveu:
> Only a small problem when I try to evaluate this:
>
> safe_eval('True')
Change
def visitName(self,node, **kw):
raise Unsafe_Source_Error("Strings must be quoted",
node.name, node)
To
Clodoaldo Pinto wrote:
> Michael Spencer wrote:
>
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
>
> Very nice work. It will be very useful. Thanks.
>
> Only a small problem when I try to evaluate this:
>
> safe_eval('True')
>
> I get:
>
> Traceback (most recent call last):
Michael Spencer wrote:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
Very nice work. It will be very useful. Thanks.
Only a small problem when I try to evaluate this:
safe_eval('True')
I get:
Traceback (most recent call last):
File "safe_eval.py", line 63, in ?
safe_e
> def default(self, node, **kw):
> for child in node.getChildNodes():
> return self.visit(child, **kw)
>
> visitExpression = default
I'm not sure I grok this part. It leads to unexpected results:
>>> safe_dict("""gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS'
Ah, finally, that's exactly what I need! Thanks bunches. I was
attempting to modify your first code to fit my needs, but mine was much
longer, and not yet working, a sure clue that yours is a better
solution. :-D
--
http://mail.python.org/mailman/listinfo/python-list
Kamilche wrote:
> Thanks! It's interesting, and nearly what I want, but not quite there.
>
> When I run my sample code through it, I get a syntax error because it's
> not a valid expression. If I were to put a 'dict(' in front and a ')'
> at the end, THEN it nearly works - but it gives me an
> 'Un
Thanks! It's interesting, and nearly what I want, but not quite there.
When I run my sample code through it, I get a syntax error because it's
not a valid expression. If I were to put a 'dict(' in front and a ')'
at the end, THEN it nearly works - but it gives me an
'Unsafe_Source_Error: Line 1.
Kamilche wrote:
> Hi everyone. I'm trying to convert a string that looks like this:
>
> gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS', text2 = 'more
> text without quotes', fmtline = "@VALUE @SIGNAL", signals = [('FPS',
> None), ('FPS2', 'something')]
>
> to a dict that looks like this
Hi everyone. I'm trying to convert a string that looks like this:
gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS', text2 = 'more
text without quotes', fmtline = "@VALUE @SIGNAL", signals = [('FPS',
None), ('FPS2', 'something')]
to a dict that looks like this:
{'signals': [('FPS', None),
Benji York wrote:
> I'll extrapolate from your message that you want to get the values of
> the dict in sorted order. If so, here's how:
>
> >>> d = {'a': 1, 'b': 2, 'c':3}
> >>> d
> {'a': 1, 'c': 3, 'b': 2}
> >>> v = d.values()
> >>> v
> [1, 3, 2]
> >>> v.sort()
> >>> v
> [1, 2, 3]
Or in
cheng wrote:
> hi all..it a problem about dict:
>
> print target, dict[target]
>
> get output:
>
> keyword
> {page3.html, page2.html, page1.html}
>
> is it some ways to change it to:
>
> keyword
> {page1.html, page2.html, page3.html}
First, I would recommend you always post actual cod
hi all..it a problem about dict:
print target, dict[target]
get output:
keyword
{page3.html, page2.html, page1.html}
is it some ways to change it to:
keyword
{page1.html, page2.html, page3.html}
--
http://mail.python.org/mailman/listinfo/python-list
42 matches
Mail list logo