Re: Safely move an element into a heap

2008-09-04 Thread Alexandru Palade
I'm not sure what you expect as an answer, but if you mean the heap as in the data structure, you can not just arbitrarily move one key where you want as it will destroy the heap property. Giampaolo Rodola' wrote: Hi, I wanted to know if does exist a safe way to, given a heap, move an

Re: how to find position of dictionary values

2008-09-01 Thread Alexandru Palade
lookfor = 'dfsdf' for item, value in kev.items(): if lookfor in value: print item print value.index(lookfor) break # assuming you only want one result You can also skip the 'if' verification in which case you need to catch ValueError

Setting urllib2 what IP to use

2008-08-18 Thread Alexandru Palade
Hi, I have an interface (let's say eth0) which has more than one IP. Is there any way I can choose - from a parameter or something - what ip to use? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Using trace module from command line

2008-08-13 Thread Alexandru Palade
python -m trace -r -f blah.blah But nothing is displayed... What am I doing wrong? Thanks in advance, Alexandru Palade -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking out a module for Subversion

2008-08-12 Thread Alexandru Palade
As for the open source IDE you can always try Eclipse with PyDev extension. Dudeja, Rajat wrote: Hi, I'm new to Python. I only have read Byte of Python by Swaroop C H just to be familiar with sytax of python. I've installed Python 2.5 from Active State and using its PythonWin Editor /

Re: very rare python expression

2008-08-12 Thread Alexandru Palade
Nothing strange about that syntax (though some spaces might helped you out). The '' operator is a bit-wise operator (http://docs.python.org/ref/bitwise.html). 甜瓜 wrote: Howdy everyone, I saw a strange python code in pygame project. What does while not(x528or x in l): mean? Below code works in

Re: How to troubleshoot hanging script?

2008-08-06 Thread Alexandru Palade
Hi, Just a thought, I'm not sure it's the best way. You can start an alarm just before the line you *think* it's wrong and cancel it after that. If it's activated then you probably have pinpointed the location. Have a look at the signals module http://docs.python.org/lib/module-signal.html, the

Re: Odd math related issue.

2008-07-21 Thread Alexandru Palade
However, you should be carefully because using an %i modifier for a what-should-be a float value truncates the value in a way you may not expect. What I mean is that if you have sent 2 out of 3 bytes, the math will be 200/3 which with the %i modifier will print 66, rather than 66.6 (or at least

String flags - redundant?

2008-07-15 Thread Alexandru Palade
Hi to everyone, I'm rather a Python newbie, so I've put myself a question. Are these two statements (performance-wise) equal? r Text and Text I mean using the raw flag speeds up things because the interpreter doesn't need to look after escape sequences? Or it's rather optimized? I'm