Hi,
I have a string like this:
String A: [ 12234_1_Hello'World_34433_22acb_4554344_accCC44 ]
I would like to encrypt String A to be used in a clean URL. something like this:
String B: [ cYdfkeYss4543423sdfHsaaZ ]
Is there a encode API in python, given String A, it returns String B?
Is there a decode API in python, given String B,...
I'm a beginner with both Python and RegEx, and I would like to know how to make a string that takes symbols and replaces them with spaces. Any help is great.
For example:
how much for the maple syrup? $20.99? That's ricidulous!!!
into:
how much for the maple syrup 20 99 That s ridiculous
...
I want to know is there any python 3.0 supported library for encryption. To encrypt files of 128 bits of data??
...
I want to generate a list of color specifications in the form of (r, g, b) tuples, that span the entire color spectrum with as many entries as I want. So for 5 entries I would want something like:
(0, 0, 1)
(0, 1, 0)
(1, 0, 0)
(1, 0.5, 1)
(0, 0, 0.5)
Of course, if there are more entries than combination of 0 and 1 it should turn to u...
I am looking to implement "like" functionallity a bit similar as they do in friendfeed. Is there a django reusable app that already does this?
Thanks!
Nick.
...
I'm looking to use a local webserver to run a series of python scripts for the user. For various unavoidable reasons, the python script must run locally, not on a server. As a result, I'll be using HTML+browser as the UI, which I'm comfortable with, for the front end.
I've been looking, therefore, for a lightweight web server that can e...
I have two lists:
A = [0,0,0,1,0,1]
B = [0,0,1,1,1,1]
I want to find the number of 1s in the same position in both lists.
The answer for these arrays would be 2.
...
Hi guys,
I'm playing around with a Python application on CentOS 5.2.
It uses the Boto module to communicate with Amazon Web Services, which requires communication through a HTTPS connection.
When I try running my application I get an error regarding HTTPSConnection being missing:
"AttributeError: 'module' object has no attribute 'HTTPS...
Developing a web browser in Python - is it possible?
...
Matlab has this great tool called publish. This tool converts a regular matlab script with minimal formatting stuff into structured, nice looking reports (HTML, LateX, RTF). It is capable of handling graphics, mathematical formulae etc.
Is there a similar tool for Python?
...
The problem:
>>> a = dict(a=1,b=2 )
>>> b = dict( b=3,c=2)
>>> c = ???
c = {'a': 1, 'b': 5, 'c': 2}
So, the idea is two add to dictionaries by int/float values in the shortest form.
Here's one solution that I've devised, but I don't like it, cause it's long:
c = dict([(i,a.get(i,0) + b.get(i,0)) for i in set(a.keys()+b.keys()...
I'd like to avoid writting errorCount += 1 in more than one place.
I'm looking for a better way than
success = False
try:
...
else:
success = True
finally:
if success:
storage.store.commit()
else:
storage.store.rollback()
I'm trying to avoid store.rollback() i...
I have a 2d array that looks like this:
XX
xx
What's the most efficient way to add an extra row and column:
xxy
xxy
yyy
For bonus points, I'd like to also be able to knock out single rows and columns, so for example in the matrix below I'd like to be able to knock out all of the a's leaving only the x's - specifically I'm trying to...
I'm interested in converting a numpy array into a sparse dictionary as quickly as possible. Let me elaborate:
Given the array:
numpy.array([12,0,0,0,3,0,0,1])
I wish to produce the dictionary:
{0:12, 4:3, 7:1}
As you can see, we are simply converting the sequence type into an explicit mapping from indices that are nonzero to their...
Is there a better way than using globals to get interesting values from a context manager?
@contextmanager
def transaction():
global successCount
global errorCount
try:
yield
except:
storage.store.rollback()
errorCount += 1
else:
storage.store.commit()
successCount += 1
Other...
I am in the design phase of a file upload service that allows users to upload very large zip files to our server as well as updates our database with the data. Since the files are large (About 300mb) we want to allow the user to limit the amount of bandwidth they want to use for uploading. They should also be able to pause and resume t...
I've tried to replace
PyRun_SimpleString("import Pootle");
with
PyObject *obj = PyString_FromString("Pootle");
PyImport_Import(obj);
Py_DECREF(obj);
after initialising the module Pootle in some C code. The first seems to make the name Pootle available to subsequent PyRun_SimpleString calls, but the second doesn't.
Could someone p...
What is the Python equivalent to DatabaseMetaData
...
I just found out python has a singleton called NotImplemented.
Why would someone want to ever return it instead of raising the NotImplementedError exception? Won't it just make it harder to find bugs, such as code that executes invalid methods?
Just wondering here...
...
First I chage Windows CMD encoding to utf-8 and run Python interpreter:
chcp 65001
python
Then I try to print a unicode sting inside it and when i do this Python crashes in a peculiar way (I just get a cmd prompt in the same window).
>>> import sys
>>> print u'ëèæîð'.encode(sys.stdin.encoding)
Any ideas why it happ...