I am reading .c file to look out for functions defined in it and count number of lines in each function.
My problem is that I am unable to look for function name/signature spanned across multiple ines.
I have the list of function names of .c file and i am matching the function names of this list with functions in .c file to process fur...
What would you use to alter an XML-file while preserving as much as possible of layout, including indentation and comments?
My problem is that I have a couple of massive hand-edited XML-files describing a user interface, and now I need to translate several attributes to another language.
I've tried doing this using Python + ElementTree...
I need to get the system locale to do a number of things, ultimately I want to translate my app using gettext. I am going to distribute it on both Linux and OSX, but I ran into problems on OSX Snow Leopard:
$ python
Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" f...
I'm just starting with programming. I have a list of a few strings and now I need to print the biggest (in length) one.
So I first want to just print the lengths of elements. I was trying things like this:
l = ("xxxxxxxxx", "yyyy","zz")
for i in range(len(l):
So how do I do it?
...
How do you make the following code work?
example = "%%(test)%" % {'test':'name',}
print example
Where the desired output is "%name%"
Thanks
...
I need to develop an app that runs side by side with a django-app.
This will be the first time i develop a multithreaded app that runs next to a django-app so are there any 'gotchas' and 'traps' i should be aware of?
...
I have a website I am looking to stay updated with and scrape some content from there every day. I know the site is updated manually at a certain time, and I've set cron schedules to reflect this, but since it is updated manually it could be 10 or even 20 minutes later.
Right now I have a hack-ish cron update every 5 minutes, but I'd li...
I'd like to know the best way (more compact and "pythonic" way) to do a special treatment for the last element in a for loop. There is a piece of code that should be called only between elements, being suppressed in the last one. Here is how I currently do it:
for i, data in enumerate(data_list):
code_that_is_done_for_every_element
...
I have few uploads in this app, uploading csv files is working fine.
I have a model that has zip upload in it. Zip file is uploaded, can be viewed, but having issues extracting it.
class Message(models.Model):
uploadFile = models.FileField(_('images file (.zip)'),
upload_to='message/',
...
Hi,
In general, let's say you have a method like the below.
def intersect_two_lists(self, list1, list2):
if not list1:
self.trap_error("union_two_lists: list1 must not be empty.")
return False
if not list2:
self.trap_error("union_two_lists: list2 must not be empty.")
return False
#http://byt...
I installed Python 3.1 yesterday on my Windows Vista PC, and was surprised to find that the version of IDLE is 2.6.4, for "Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32"
I was hoping to use IDLE to investigate some of the new features of Python 3...
I guess I'm stuck with the command line...
Any...
I'm writing a Game Website, where the draw is a series of four digits. e.g 1234
I"m trying to write a query in django that will select all winners based on the four digits entered. winners are any combination of the same numbers or the same combination, 1 2 3 4, 2 3 1 4, 4 1 3 2 are all winners.
how is the most efficient way to write ...
If you have a QImage wrapped inside a QLabel, is it possible to scale it up or down when you resize the window and maintain the aspect ratio (so the image doesn't become distorted)? I figured out that it can scale using setScaledContents(), and you can set a minimum and maximum size, but the image still loses its aspect.
It would be gr...
I'm working on a new Django project, and the client wants to "feature" content on the homepage and a few other sections of the website. Content in this case could be a blog post, an event, a news story, etc. Each item would have a "start featuring" datetime and an "stop featuring" datetime.
I've done this a few different ways in the pa...
I have the LDAP python module installed to authorise logins via active directory, but if I change the password, the new and the old one work together. Does anyone know how to resolve this issue?
...
I have DLL, interface on C++ for work with he. In bcb, msvc it works fine. I want to use Python-scripts to access function in this library.
Generate python-package using Swig.
File setup.py
import distutils
from distutils.core import setup, Extension
setup(name = "DCM",
version = "1.3.2",
ext_modules = [Extension("_dcm", ...
Hi,
I have been writing Python code for only a couple of weeks, so I'm still figuring out the lay of the land. But let's say I have a method that MAY be called on by a 'user' on occasion as well as used HEAVILY internally (ie, the arguments have already been checked before the call). Here is what I am currently doing:
#The method the '...
Is there a one-liner to read all the lines of a file in Python, rather than the standard:
f = open('x.txt')
cts = f.read()
f.close()
Seems like this is done so often that there's got to be a one-liner. Any ideas?
...
In my view I create a formset of photos belonging to a specific article, this works brilliantly, and I am able to render and process the forms. However for the image field I would like to display the already uploaded image. Normally I would access the path through the instance form.instance.image.get_thumbnail_url however that doesn't wo...
What I am trying to achieve is something like this:
class object:
def __init__(self):
WidthVariable(self)
print self.width
#Imagine I did this 60frames/1second later
print self.width
#output:
>>0
>>25
What I want happening (as above): When WidthVariable - a class - is created it adds the variable ...