Hello,
I am using Eclipse and PyDev with Iron Python on a Windows XP machine. I have a class definition that takes an object as an argument which is itself an instantiation of another class like this:
myObject1 = MyClass1()
myObject2 = MyClass2(myObject1)
The two class definitions are in different modules, myclass1.py and myclass2....
It seems that IDLE (part of the standard Python Windows install) will not execute multithreaded programs correctly without nasty hangs or bugout crashes. Does anyone know of a way to fix this?
The following program will always hang in IDLE but complete normally when executed with the Python interpreter directly:
import threading, time...
I am trying to write some code that will function like google calendars quick add feature . You know the One where you can input any of the following :
1) 24th sep 2010 , Johns Birthday
2) John's Birthday , 24/9/10
3) 24 September 2010 , Birthday of John Doe
4) 24-9-2010 : John Does Birthday
5) John Does Birthday 24th of September 2010 ...
Hey again all,
I have the following script so far:
from mechanize import Browser
from BeautifulSoup import BeautifulSoup
import re
import urllib2
br = Browser()
br.open("http://www.foo.com")
html = br.response().read();
soup = BeautifulSoup(html)
items = soup.findAll(id="info")
and it runs perfectly, and results in the following ...
Is it possible to use Python (specifically Pygments) with PHP? Currently, I have a phpBB forum that I'm developing for and JS Syntax Highlighters just haven't been working for me. There's already a GeSHI mod, but I want to develop something myself just for experience.
Also, would there be performance issues?
...
Given the array a = [1,1,12,3,5,8,13,21] I can slice off the first 3 elements like a[:3] giving [1,1,2]. What I want is to slice off up to the element of vlaue i (e.g. if i=8 I want [1,1,12,3,5,8] or [1,1,12,3,5] (I can work with either)).
This works:
return a[:a.index(i)]
but only if I give it a value that's in the array.
Is ther...
Here's my problem. I have a mac with 2.5 installed & was using django 1.1 with it. I had no problems until I decided to upgrade python & django. I uninstalled django from my mac as per the djangoproject.com website recommends. I left python 2.5 on my mac as not to interfere with pre-installed mac programs. I put python 2.6 & 3.1 on my ma...
Using the Python bindings for CGAL, I can't work out how create a hexahedron, nor how to calculate its intersection with another hexahedron.
I have 8 input points, which are the corners of the hexahedron:
My code does this:
P = Polyhedron_3()
bottom = P.make_tetrahedron(p[0],p[1],p[2],p[3])
top = P.make_tetrahedron(p[4],p[5],p[6],p[...
I am enormously impressed with the ease of use of XLWT, but there is one thing I have not figured out how to do. I am trying to adjust certain rows to the minimum width they would need to display all characters (in other words, what excel would do if you double clicked on the divider between cells).
I know how to adjust the column wi...
I guess it's an academic question, but the second result does not make sense to me. Shouldn't it be as thoroughly empty as the first? What is the rationale for this behavior?
from itertools import product
one_empty = [ [1,2], [] ]
all_empty = []
print [ t for t in product(*one_empty) ] # []
print [ t for t in product(*all_empty) ] #...
i have a LogEntry in django admin for superadministrator users, but, now i need a LogEntry for the other "staff" users, it's this possible?
Thanks folks!
...
Hi all -
Using a Python array, I can initialize a 32,487,834 integer array (found in a file HR.DAT) using the following (not perfectly Pythonic, of course) commands:
F = open('HR.DAT','rb')
HR = array('I',F.read())
F.close()
I need to do the same in ctypes. So far the best I have is:
HR = c_int * 32487834
I'm not sure how to initi...
I have a python program with a global function that is painful to test (it needs a large dataset to work properly). What is the best way to get around this while testing functions that call it?
I've found that the following works (but it make me feel dirty to use it).
module foo:
def PainLiesHere():
return 4; #guaranteed to be rando...
is there a python library that would make numbers such as this more human readable
$187,280,840,422,780
edited: for example iw ant the output of this to be 187 Trillion not just comma separated. So I want output to be trillions, millions, billions etc
...
I was challenged how to break or end execution of a parent function without modifying the code of the parent, using PHP
I cannot figure out any solution, other than die(); in the child, which would end all execution, and so anything after the parent function call would end. Any ideas?
code example:
function victim() {
echo "I shou...
Let's say I have a form for adding/editing products (with field 'user' being a foreign key to my User) triggered from two separate view functions - add/edit :
def product_add(request):
userprofile = UserProfile.objects.get(user=request.user)
if request.method == 'POST':
form = ProductAddForm(request.POST, request.FILES,)...
Hi,
Please suggest me the solution to the following problem
consider a function
function recurse(a):
for child in a.childs:
recurse(child)
Now I want to execute some code lets say
print "Program ends here"
when the program is done with recursion,so how can I know when the recursion will end?
Thank you
...
I have to parse an input string in python and extract certain parts from it.
the format of the string is
(xx,yyy,(aa,bb,...)) // Inner parenthesis can hold one or more characters in it
I want a function to return xx, yyyy and a list containing aa, bb ... etc
I can ofcourse do it by trying to split of the parenthesis and stuff but I...
Instead of encapsulating my entire code in a try{} except{} block, is there someway of catching exceptions globally?
Basically I am looking for a way to have a global exception handler which will handle all unhandled exceptions in the my python application written for google app engine
...
I'm really interested in learning Python for web development. Can anyone point me in the right direction? I've been looking at stuff on Google, but haven't really found anything that shows proper documentation and how to get started. Any recommended frameworks? Tutorials?
I've been doing PHP for 5 years now, so I just want to try someth...