« first day (779 days earlier)      last day (1409 days later) » 

3:00 AM
0
Q: Extracting title of table from Word (.docx) using Python

gauthamI have a Word (.docx) document which has title/headings and their corresponding tables below the titles as shown below: 1.1.1.1 Table_Title_001 Name Gautham College Oxford University Cambridge 1.1.1.2 Table_Title_002 Name Krishnan College Harvard University Stanfor...

 
3:25 AM
0
Q: Why is the _replace method of Python namedtuple classes protected?

kuzzoorooIn the section Method Names and Instance Variables, the Python Style Guide (aka PEP 0008) says, "Use one leading underscore only for non-public methods and instance variables." Why then, does the _replace method on namedtuple have a leading underscore? namedtuple classes themselves do not invoke ...

 
 
3 hours later…
6:05 AM
0
Q: Primality check

Wilf-FineI'm learning Python. I want to list the first N numbers that are of the form $$p^{2^n}$$ where p is prime and n is a natural number. My code is as follows. def isprime(n): if n==1: return False if n==2: return True if n%2==0: return False if n<9: return True if n%3==0: ...

 
 
6 hours later…
12:06 PM
0
Q: Solution to the 0/1 knapsack in Python

Huy VoSo I made a version for the 0/1 knapsack problem myself (using matrix dynamic programming algorithm). Given a list of items with name, value, and weight, my function computes correctly the optimal value with total weight <= allowed weight. I don't know if my code is clean and pythonic enough, I ...

 
 
8 hours later…
7:56 PM
0
Q: Dice Game - What am I doing wrong?

Idont ReallywolfThe loop breaks before TURNS is == 0 from random import randint, choice print """ ######################################### # # # # # WELCOME TO DICE GAME # # By: IdontRea...

 
 
2 hours later…
9:54 PM
-1
Q: Comparing performance of different ways of filtering in python

John BachirI'm trying different ways of filtering to see which has the best performance. I'm surprised that list comprehension is by far the fastest. This is under python 2.7: import timeit import random from itertools import ifilter things = [int(100*random.random()) for i in xrange(1000)] def test1(): ...

 

« first day (779 days earlier)      last day (1409 days later) »