Re: Very Strange Problem

2009-07-29 Thread Omer Khalid
Hi Dave,

Thanks for your reply. I actually didn't cut and paste my code as it was
dispersed in different places, i typed the logic behind my code in the email
(and obiviously made some typos, indentations is some thing else) but my
real code does not have these problems as my application runs fine with out
errors...

Except that the line where i want to update the value doesn't get updated
and no exception is thrown. What's surprising for me is that i am doing the
same thing in hundreds of places in my 3k+ line code but by some reason this
part doesn't work...

As far as the global variables are concerned, i am using them in other
places too and didn't see any problems.

I think some thing else is going on here as the statement above and below my
modified lines get executed.

Is there a way in Python to debug memory address or to see where in memory
this object is stored, and is there a lock on it or else?

Thanks,
Omer


**


On Wed, Jul 29, 2009 at 8:56 PM, Dave Angel da...@ieee.org wrote:

 Omer Khalid wrote:

 Hi,

 I am having a very strange problem with modifying a variable in a list in
 my
 program. Here is the code:

 # a list that contains dictionary objects
 jobs = []

 index=5
 for each in range(index):
 jobs.append({'v':0})

 some_function(index):
   if jobs[index]['v'] == 0:
   # set it to 1
   jobs[index]['v'] = 1
   print Set to 1
  else:
   print Already set to 1

 loop():
index=0
for each in range(len(jobs)):
 some_function(index)
 index +=1


 Apparently, the jobs[index]['v'] never get updated in the some_function
 but
 the print statement afterwards get printed...

 What's really surprising is that there are no errors or exceptions and my
 my
 program runs in a single thread...so i have been unable to explain this
 behavior.

 Any insight would be much appreciated!

 Cheers
 Omer



 There are four things to fix before the program does anything much at all.
  Two places you're missing the def, indentation is inconsistent, and you
 never actually call either of the functions.   The first three are syntax
 errors, so presumably your cut/paste in your computer is broken.

 Once I make those four corrections, I get the following output:

 Set to 1
 Set to 1
 Set to 1
 Set to 1
 Set to 1

 But you never said what you got, nor what you expected.  That's certainly
 what I'd expect.  And if you make a second call to loop() in your outer
 code, you get five copies of Already set to 1

 BTW, there are a number of things that could be done better.  The main one
 I'll point out is that you shouldn't re-use a global variable 'index' as a
 local with different meaning.  As someone else pointed out, since the global
 is a constant, making it all uppercase is the convention.

 DaveA


-- 
http://mail.python.org/mailman/listinfo/python-list


How to do CPU/Memory benchmarking in Python?

2008-08-05 Thread Omer Khalid
Hi,
I have few long running python based scripts which does lots of number
crunching; I would like to bench mark the CPU/Memory/IO for that script. I
am wondering if there is a python benchmarking suite available?

There is pybench but it more or less test the executing script it self from
Python's performance perspective rather than the performance of the system
it self.

Thanks in advance!
Omer
--
http://mail.python.org/mailman/listinfo/python-list

Re: What was that web interaction library called again?

2007-06-26 Thread Omer Khalid

On the RESTFul web service, I would like to piggy pack my own question two
is there a way to make the connection secure between two Restful service
running on GNU/linux?

Thanks,
Omer

On 6/26/07, Kathryn Van Stone [EMAIL PROTECTED] wrote:




So does anyone know of any equivalent library for testing RESTful web
services.

In particular it needs to be able to handle more than 'GET' or POST
http calls.

-Kathy Van Stone
[EMAIL PROTECTED]

--
http://mail.python.org/mailman/listinfo/python-list





--
--
CERN – European Organization for Nuclear
Research, IT Department,  CH-1211
Geneva 23, Switzerland

Phone: +41 (0) 22 767 2224
Fax: +41 (0) 22 766 8683
E-mail : [EMAIL PROTECTED]
Homepage: http://cern.ch/Omer.Khalid
-- 
http://mail.python.org/mailman/listinfo/python-list