I have a problem with encoding urls using build-in django urlencode filter. When I use it on default django server everything is fine. But on apache2 it doesn`t work, ie. i have a tag called C#. On localhost my url is encoded to ...tags/C%23/ but on apache2 it is tags/C/
What should I do?
...
I have a web site where there are links like <a href="http://www.example.com?read.php=123"> Can anybody show me how to get all the numbers (123, in this case) in such links using python? I don't know how to construct a regex. Thanks in advance.
...
I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie.
__init__.py
myapp.py
one.py
subdir\
__init__.py
two.py
Inside two.py I have import one and this works fine at runtime, because the top-level directory (from which m...
Hello
I have some algorithms to do that are very similar in very aspects but are all different.
I'll try to give an example of what I mean.
Let's assume I have a Robot class. This class should be the "base" of all classes. It provides basic mechanisms to make the robot work in its environment. It might or not have to work by itself (...
I'm trying to fetch some urls via urllib and mechanize through my proxy.
With mechanize I try the following:
from mechanize import Browser
import re
br = Browser()
br.set_proxies({"http": "MYUSERNAME:*******@itmalsproxy.italy.local:8080"})
br.open("http://www.example.com/")
I get the following error:
httperror_seek_wrapper: HTTP Er...
I want to do something like this:
try:
pid = int(file(lock_file, "r").read())
print "%s exists with pid: %s" % (lock_file, pid)
if not check_pid(pid):
print "%s not running. Phantom lock file? Continuing anyways" % pid
elif wall_time(pid) > 60 * 5:
print "%s has been running for more than 5 minutes. Killi...
Possible Duplicate:
Python decorator makes function forget that it belongs to a class
Is there a way to know that wrapped method belongs to particular class?
In code below:
def guessname(func):
def this(*args, **kwargs):
print "myname = %s" % func.__name__
return func(*args, **kwargs)
return this
class...
I'm trying to use association proxy for tags, in a very similar scenario to the example in the docs. Here is a subset of my schema (it's a blog), using declarative:
class Tag(Base):
__tablename__ = 'tags'
id = Column(Integer, primary_key=True)
tag = Column(Unicode(255), unique=True, nullable=False)
clas...
Hi,
Coming from PHP world, I used to create select box like this:
<select>
<?php foreach($arrField as $idx=>$val){?>
<option <?php echo ($fieldVal == $idx ? "selected='selected'" : ''); ?>><?php echo $val; ?></option>
<?php } ?>
</select>
However, I can't do that in python. Here's my snippet:
<select name='type'>
<option value...
How can a built-in module (say math) be accessed when a file prog.py is placed in the same directory as a local module with the same name (math.py)?
I'm asking this question because I would like to create a package uncertainties that one can use as
import uncertainties
from uncertainties.math import *
Thus, there is a local math modu...
for row, instrument in enumerate(instruments):
for col, value in enumerate(instrument):
self.table.SetValue(row, col, value)
...
I want to turn C:\abc.bmp into abc.bmp, or even better, if possible, in abc. That is easy to do with .NET as there are functions for both goals. Is there anything similar in python?
...
I have a string (authenticated, trusted, etc.) containing source code intended to run within a Ruby loop, quickly. In Python, I would compile the string into an abstract syntax tree and eval() or exec() it later:
# Python 3 example
given_code = 'n % 2 == 1'
pred = compile(given_code, '<given>', 'eval')
print("Passed:", [n for n in rang...
This http://stackoverflow.com/questions/1033897/python-package-install-using-pip-or-easyinstall-from-repos points out a very interesting features of pip.
However, sometimes you just want it to install the source distribution; this is particularly true when
you are running in a virtualenv (so you don't care about messing up the python ...
We have a mature Windows desktop application written in C++. The application's GUI sits on top of a windows DLL that does most of the work for the GUI (it's kind of the engine). It, too, is written in C++. We are considering transitioning the Windows app to be a web-based app for various reasons.
What I would like to avoid is having...
Let's say I have the following dictionary in a small application.
dict = {'one': 1, 'two': 2}
What if I would like to write the exact code line, with the dict name and all, to a file. Is there a function in python that let me do it? Or do I have to convert it to a string first? Not a problem to convert it, but maybe there is an easie...
I need to find a right way to prevent two running instances of my (Python) program.
I am currently using the following method.
On Windows,
os.popen('wmic process get caption,processid | findstr `programname.exe`')
On Linux,
os.popen('ps x | grep `programname`')
It seems to work fine for now. Is this method correct?
Can someone sug...
Is there a simple way to call Python libraries from JavaScript? Especially from the inside of a Firefox extension.
A good option to compile a pure Python library would also be great. I looked at Pyjamas, but it seems to offer only partial support for Python.
...
I would like to install Plone with buildout and gp.recipe.pip. Is this a good idea? How should I convert my "standard" Plone buildout to use pip?
...
Hi everyone!
I'm using Python and its MySQLdb module,
is it possible to do a "selectmany"-like from a tuple/dictionary/list in the condition
something like this:
cursor.executemany("""SELECT * FROM customers WHERE name= %(name)s""",[d.__dict__ for d in data])
selected_rows = cursor.fecthall()
doing a delete/update/insert works fin...