How to determine if printing is being a bottleneck in my code?

2012-12-04 Thread SherjilOzair
Hello list, When it comes to printing things while some computation is being done, there are 2 extremes. 1. printing speed is slower than data-to-print generation speed. In this case, printing is a bottleneck. Examples: for i in xrange(2**30): print i. Without the print, this code would be

Scoping Issues

2012-05-24 Thread SherjilOzair
def adder(): s = 0 def a(x): s += x return sum return a pos, neg = adder(), adder() for i in range(10): print pos(i), neg(-2*i) This should work, right? Why does it not? Checkout slide no. 37 of a Tour of Go to know inspiration. Just

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-19 Thread SherjilOzair
Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-19 Thread SherjilOzair
Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is

Python as a default shell, replacement of bash, sh, cmd ?

2012-02-18 Thread SherjilOzair
Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. I'm sure everyone would agree that doing this would make the terminal very powerful. What are your views on this? --

Best way to insert sorted in a list

2011-06-17 Thread SherjilOzair
There are basically two ways to go about this. One is, to append the new value, and then sort the list. Another is to traverse the list, and insert the new value at the appropriate position. The second one's complexity is O(N), while the first one's is O(N * log N). Still, the second one works

Re: I want this to work. [[]] * n

2011-06-14 Thread SherjilOzair
Thanks. This works. :) Regards, Sherjil Ozair -- http://mail.python.org/mailman/listinfo/python-list

I want this to work. [[]] * n

2011-06-13 Thread SherjilOzair
I want a list which contains n lists, which are all different. I had read a page which was about the mutability of lists, and how the * operator on lists just does a shallow copy. But I can't find it now. Does anyone know of that page ? Either way, How to get a list of list, with all original