Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Nikunj
Hi All,

Out of curiosity, I wanted to understand the reason behind having different 
memory location for two identical floats . This is unlike ints or strings. 
Tried googling but couldn't find anything concrete. Any links or references 
would be appreciated!

Example:

For FLOATS:
==

>>> l = 1.3
>>> id(l)
140421602788216

>>> k = 1.3
>>> id(k)
140421602788240

>>> k == l
True

>>> k is l
False

For INTS and STRINGS:
=
>>> i = 2
>>> o = 2
>>> id(i), id(o)
(140421602779712, 140421602779712)

>>> i is o
True

>>> a1 = 'hi'
>>> a2 = 'hi'
>>> a1 is a2
True



Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


HELP ! Popen.terminate() - WindowsError: [Error 5] Access is denied

2012-03-01 Thread Nikunj Badjatya
Howdy All,

Py ver - 3.2, Windows-XP . Logged in as user with admin privileges.

>From my main python program, I am running powershell program using
subprocess.Popen().
Now I have created a signal_handler() function in main python script which
will handle CTRL-C ( This works fine ).
Now when I put "proc.terminate()" in my signal_handler() function to
terminate the subprocess created as well,
It is giving me "WindowsError: [Error 5] Access is denied" error.
I have tried with os.kill() also, same error.  Tried with Popen.kill() also
same error. Have googled a bit but couldn't understand them.

In general,  How to kill a subprocesses created from a python program.? If
that subprocess also creates a new process from itself, how can I kill all
child processes from my main python script.?

Any ideas.??


Thanks,
Nikunj
-- 
http://mail.python.org/mailman/listinfo/python-list