113
votes
6answers
3k views

What is […] in Python 2.7?

I was playing around in python. I used the following code in IDLE p = [1, 2] p[1:1] = [p] print p The output was [1, [...], 2] What is this […]? Interestingly I could now use this as a list of ...
3
votes
1answer
1k views

Url decode UTF-8 in Python

I have spent plenty of time as far as I am newbie in Python. How could I ever decode such a URL: ...
43
votes
3answers
40k views

How to uninstall Python 2.7 on a Mac OS X 10.6.4?

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH variable by reverting my .bash_profile. But I also want to remove all directories, files, ...
22
votes
4answers
9k views

Why is parenthesis in print voluntary in Python 2.7?

In Python 2.7 both the following will do the same print("Hello, world!") # Prints "Hello, world!" print "Hello, world!" # Prints "Hello, world!" However the following will not print("Hello,", ...
6
votes
4answers
4k views

How to create a TRIE in Python

I am new to Python and trying to learn and advance. I am interested in TRIEs and DAWGs and I have been reading a lot about it but I don't understand what should the output TRIE or DAWG file look like. ...
1
vote
2answers
1k views

board-drawing code to move an oval

I am working on a python checkers game for college. I have the board drawn, using tk, but I can't seem to implement a movement function for the pieces. If anyone see any errors in my code, or can ...
88
votes
1answer
3k views

Why is early return slower than else?

This is a follow-up question to an answer I gave a few days back. Edit: it seems that the OP of that question already used the code I posted to him to ask the same question, but I was unaware of it. ...
8
votes
4answers
7k views

python : scipy install on ubuntu

I'm currently following this tutorial to install scipy on Ubuntu 12.04 (I can't use apt-get install because I need a recent version) : http://www.scipy.org/Installing_SciPy/Linux However I get errors ...
5
votes
2answers
6k views

Python threading.timer - repeat function every 'n' seconds

I'm having difficulties with the python timer and would greatly appreciate some advice or help :D I'm not too knowledgeable of how threads work, but I just want to fire off a function every 0.5 ...
7
votes
4answers
3k views

pydev breakpoints not working

I am working on a project using python 2.7.2, sqlalchemy 0.7, unittest, eclipse 3.7.2 and pydev 2.4. I am setting breakpoints in python files (unit test files), but they are completely ignored ...
7
votes
2answers
163 views

file.tell() inconsistency

Does anybody happen to know why when you iterate over a file this way: Input: f = open('test.txt', 'r') for line in f: print "f.tell(): ",f.tell() Output: f.tell(): 8192 f.tell(): 8192 ...
-4
votes
2answers
198 views

python takes list and returns only if negative value also exists using set

Basically I have a big list: # where (n) is over a couple hundred thousand or is 1 million def big_list(n): return [ randrange(-n//3,n//3) for i in range(n) ] And using a set I must return a ...
5
votes
2answers
294 views

python - memory not being given back to kernel

I have a very simple script that allocates memory, dels the only reference to a sizable object, all the while printing heapy and pidstat reports. After running the script, heapy tells me that there ...
7
votes
6answers
809 views

Is it possible to modify variable in python that is in outer, but not global, scope?

Given following python 2.7 code: def A() : def B() : b = 1 def C() : # I can access 'b' from here. print( b ) # But can i modify 'b' here? 'global' and assignment will not ...
7
votes
4answers
8k views

ImportError: No module named _ssl

Ubuntu Maverick w/Python 2.7: I can't figure out what to do to resolve the following import error: >>> import ssl Traceback (most recent call last): File "<stdin>", line 1, in ...

1 2 3 4 5 21
15 30 50 per page