is there a difference between one line and many lines
Hello, I'm a newbie. What's the defference between >>>a=-6; b=-6; a is b >>>True and >>>a=-6 >>>b=-6 >>>a is b >>>False ? -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a difference between one line and many lines
Sure, I understand that "is" is not "==", cause "is" just compares id(a)==id(b). I have a win32 CPython and the range of "singletons" is from -5 to 256 on my machine. I am asking about what happens in Python interpreter? Why is there a difference between running one line like "a=1;b=1" and two lines like "a=1 \n b=1"? Does it decide to locate memory in different types depend on a code? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a difference between one line and many lines
Python 2.7.1 (downloaded from python.org a week ago) You see, if I save this to a file and then run from CMD: "python test1.py" the result will be the same: "True" When I use IDLE or IPython or DreamPie or maybe something else then result is not the same. So maybe as Chris Angelico said it is the IDLE(or Ipython) makes some optimization depend on a code style. -- http://mail.python.org/mailman/listinfo/python-list
searching in list
I want to make a function that is called only once per one argument. I mean I want to store data of function calling to prevent calling it again if there is no need. How to make it? For example I can make a global list that just consist of tuples [(arg1, res1), (arg2, res2), ...]. Ok, how to search if an arg135 in that list? Thanks for answering -- http://mail.python.org/mailman/listinfo/python-list
Re: searching in list
Thanks. It seems that dictionary is a sorted list of tuples, so the procedure of searching an element is quite quick. -- http://mail.python.org/mailman/listinfo/python-list