I've seen a few questions on this topic, but I haven't been able to find a definitive answer.
I would like to know the proper way to use old-style classes in a new Python code base. Let's say for example that I have two fixed classes, A and B. If I want to subclass A and B, and convert to new-style classes (A2 and B2), this works. Howe...
I have a content of strings and I have to reverse the order using python.
the content is
Python
Java
microsoft
...
Hi,
Actually I am stuck in my work. I want to import a txt file into my python program which should have two lists of intergers.
The following program is working fine but I need to import the list 'a' and 'b' with the help of configparser.
It will be so nice if some one help me with it!
I am a begineer in python so please try to ans...
Please consult me with your opinions on the following topic:
I have a model - a structure of the objects. Such as:
Event, containing participants
Current task
Assignee of each task
The model is going to be pickled on the server and transferred over the network to the client GUI application. Because of the pickle I'd want to keep the...
I am looking for a basic open source http proxy server for Google App Engine.
Preferably written in Python. Any suggestions?
...
I need to run a server side script like Python "forever" (or as long as possible without loosing state), so they can keep sockets open and asynchronously react to events like data received. For example if I use Twisted for socket communication.
How would I manage something like this?
Am I confused? or are there are better ways to impl...
This is a follow up to http://stackoverflow.com/questions/1417473/call-python-from-c
At the startup of the programm I call the following function to initialize the interpreter:
void initPython(){
PyEval_InitThreads();
Py_Initialize();
PyEval_ReleaseLock();
}
Every thread creates it's own data structure and acquires the lo...
Project euler problem #255 is quite mathematical. I figured out how it is done for given example. Since I am a newbie in Python, I am not sure how to handle long range values. Below is the solution I have. But how does it work for 10^13 and 10^14?
def ceil(a, b):
return (a + b - 1) / b;
def func(a, b):
return (b + ceil(a, b)) / 2;
d...
I'm looking for a Python caching library but can't find anything so far. I need a simple dict-like interface where I can set keys and their expiration and get them back cached. Sort of something like:
cache.get(myfunction, duration=300)
which will give me the item from the cache if it exists or call the function and store it if it doe...
Greetings lords and ladies,
I am given a method that returns instances of mpl_toolkits.basemap.Basemap and matplotlib.collections.PolyCollection and I need to construct a matplotlib.figure.Figure out of them. Calling matplotlib.pyplot.gcf() did not help.
Can you advise me or point into the right direction?
Thank you.
...
I want to be able to create and unknown number of objects. I'm not sure if there is a better way to manage and reference them.
Lets use a standard OOP example... say every time a user enters a name for a pet in a text field and clicks a button a new pet object is created via the petFactory function.
function pet(name)
{
this.nam...
[Closing NOTE]
Thank you everyone that trying to help me.
I've found the problem and it have nothing to do with python understanding of mine (which is little). :p
The problem is that I edit the wrong branch of the same project, Main.py in one branch and XWinInfos.py in another branch.
Thanks anyway.
[Original Question]
I am a Java/PH...
I'm using python 2.6.2's xml.etree.cElementTree to create an xml document:
import xml.etree.cElementTree as etree
elem = etree.Element('tag')
elem.text = (u"Würth Elektronik Midcom").encode('utf-8')
xml = etree.tostring(elem,encoding='UTF-8')
At the end of the day, xml looks like:
<?xml version='1.0' encoding='UTF-8'?>
<tag>WÃ&#...
this is a complete n00b question and i understand i may get voted down for asking this but i am totally confused over python's html integration.
as i understand one way to integrate python with html code is by using mod_python.
now, is there any other way or method that is more effective for using python with html?
please advise me on t...
I am a newbie and seeking for the Zen of Python :) Today's koan was finding the most Pythonesq way to solve the following problem:
Permute the letters of a string pairwise, e.g.
input: 'abcdefgh'
output: 'badcfehg'
...
Disclaimer: I'm not a regex expert.
I'm using Python re module to perform regex matching on many htm files. One of the patterns is something like this:
<bla><blabla>87765.*</blabla><bla>
The problem I've encountered is that instead of finding all (say) five occurrences of the pattern, it will find only one. Because it welds all the o...
I would like to get some feedback on these tools on :
features;
adaptability;
ease of use and learning curve.
...
Suppose you're running Django on Linux, and you've got a view, and you want that view to return the data from a subprocess called cmd that operates on a file that the view creates, for example likeso:
def call_subprocess(request):
response = HttpResponse()
with tempfile.NamedTemporaryFile("W") as f:
f.write(request....
I'm having a problem emailing unicode characters using smtplib in Python 3. This fails in 3.1.1, but works in 2.5.4:
import smtplib
from email.mime.text import MIMEText
sender = to = '[email protected]'
server = 'smtp.DEF.com'
msg = MIMEText('€10')
msg['Subject'] = 'Hello'
msg['From'] = sender
msg['To'] = to
s = smtplib.SM...
I am trying to use GetExtendedTcpTable via a Python program. Basically I am trying to convert "ActiveState Code Recipe 392572: Using the Win32 IPHelper API" to "Getting the active TCP/UDP connections using the GetExtendedTcpTable function".
My problem is that I cannot seem to get the Python script to recognize TCP_TABLE_CLASS.TCP_TAB...