What would be the best way to do this.
The input string is
<133_3><135_3><116_2>The other system worked for about 1 month</116_2> got some good images <137_3>on it then it started doing the same thing as the first one</137_3> so then I quit using either camera now they are just sitting and collecting dust.</135_3></133_3>
the expect...
I'm writing a reasonably complex web application. The Python backend runs an algorithm whose state depends on data stored in several interrelated database tables which does not change often, plus user specific data which does change often. The algorithm's per-user state undergoes many small changes as a user works with the application. T...
Given a string as below, I need to convert:
1 Dec 2008 06:43:00 +0100
to
MM/DD/YYYY HH:MM:SSAM
using jython what is the best way to do this?
...
For quite a long time I've wanted to start a pet project that will aim in
time to become a web hosting control panel, but mainly focused on Python hosting --
meaning I would like to make a way for users to generate/start Django/
other frameworks projects right from the panel. I seemed to have
found the perfect tool to build my app with i...
If I want to split a list of words separated by a delimiter character, I can use
>>> 'abc,foo,bar'.split(',')
['abc', 'foo', 'bar']
But how to easily and quickly do the same thing if I also want to handle quoted-strings which can contain the delimiter character ?
In: 'abc,"a string, with a comma","another, one"'
Out: ['abc', 'a strin...
How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible and also not to conflict with different lib/version that is already on my system.
L.E.: Sorry i forgot to specify. I will be doing this on linux. And I'm not referring in making my app a installable file like deb/rpm, etc but ...
Simple beginner question:
I've created a small python script to toggle between two files I'm using for testing.
My question is, what is a good python format style for the following code:
import filecmp
import shutil
local = "local.txt"
remote = "remote.txt"
config_file = "C:\some\path\file.txt"
shutil.copyfile( remote if( filecmp.cm...
Hi,
I need to check whether a page is being redirected or not without actually downloading the content. I just need the final URL. What's the best way of doing this is Python?
Thanks!
...
I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images.
PIL does not work, as it can't read PDFs. The two options I've found are using either GhostScript or Im...
I know class foo(object) is an old school way of defining a class. But I would like to understand in more details of the difference between these two. Thanks.
...
How do you change the size of figure drawn with matplotlib?
...
I've written some C code that I would like to port to python, as I feel python is a better 'concept' language.
In my C code, I use memory reinterpretation to achieve my goals, for example:
sizeof(int) is 4 byte
sizeof(char) is 1 byte
char c[4]={0x01,0x30,0x00,0x80};
int* i=(int*)c;
*i has the value 0x80003001
similarly if i have:
...
I've made this decorator, which results in an infinite redirect loop.
The problem is this:
args[0].redirect(users.create_login_url(args[0].request.path))
It appears to be a perfectly valid URL. So why wouldn't it properly redirect?
def admin_only(handler, *args):
def redirect_to_login(*args, **kwargs):
return args[0].r...
Hi,
There is one thing that I do not understand...
Imagine you have a text = "hello world" and you want to split it.
In some places I see people that want to split the text doing:
string.split(text)
In other places I see people just doing:
text.split()
What’s the difference? Why you do in one way or in the other way? Can you g...
Is there a simple way to detect, within Python code, that this code is being executed through the Python debugger?
I have a small Python application that uses Java code (thanks to JPype). When I'm debugging the Python part, I'd like the embedded JVM to be given debug options too.
...
I'd like to call a function in python using a dictionary.
Here is some pseudo-code:
d = dict(param='test')
def f(param):
print param
f(d)
This prints {'param': 'test'} but I'd like it to just print test.
I'd like it to work similarly for more parameters:
d = dict(p1=1, p2=2)
def f2(p1,p2):
print p1, p2
f2(d)
Is this pos...
I am currently looking at developing a mobile apps for the S60 platform and is specifically looking at PyS60. It seems to suggest that the it can be compiled into native .sis files without the need for an embedded python interpreter. Reading through the documentations I could not find any statements where this is explicitly mentioned. Wh...
I would like to do the equivalent off this (ruby code) in python for a Django project I am working on. I want to make a filmstrip image of X number of images in a folder.
...
I'd like to be able to print the definition code of a lambda function.
Example if I define this function through the lambda syntax:
>>>myfunction = lambda x: x==2
>>>print_code(myfunction)
I'd like to get this output:
x==2
...
I'm trying to make some types in Django that map to standard Django types. The custom model field documentation goes into complicated cases; I just want to store a basic Django type from a class with a bunch of handy methods.
For example, if I were storing playing cards, I want something like:
class Card(object):
""" A playing car...