Hello,
I'd like to be able to "up-arrow" to commands that I input in a previous Python interpreter. I have found the readline module which offers functions like: read_history_file, write_history_file, and set_startup_hook. I'm not quite savvy enough to put this into practice though, so could someone please help? My thoughts on the so...
I often use the python interpreter for doing quick numerical calculations and would like all numerical results to be automatically printed using, e.g., exponential notation. Is there a way to set this for the entire session?
For example, I want:
>>> 1.e12
1.0e+12
not:
>>> 1.e12
1000000000000.0
...
I would like to write a function in Python (2.6) that can determine if it is being called from exception handling code somewhere up the stack.
This is for a specialized logging use. In python's logging module, the caller has to explicitly specify that exception information should be logged (either by calling logger.exception() or by usi...
Maybe, it is a stupid question but I can't use python eggs with IronPython.
I would like to test with IronPython 2.0.2 one module that I've developped. This modules is pure python. It works ok with python 2.6 and is installed as a python egg thanks to setuptools.
I thought that the process for installing my module under IronPython was ...
I have one function in python which should start running when some process (eg. proc.exe) showed up in tasks manager.
How can I monitor processes running in tasks manager with python?
...
When rasterizing svg file, I would like to be able to set width and height for the resulting png file. With the following code, only the canvas is set to the desired width and height, the actual image content with the original svg file dimension is rendered in the top left corner on the (500, 600) canvas.
import cairo
import rsvg
WIDT...
I'm writing an IRC bot in Python, due to the alpha nature of it, it will likely get unexpected errors and exit.
What's the techniques that I can use to make the program run again?
...
I need to set up the following env variables such that I can a database program which use PostgreSQL
export PGDATA="/home/masi/postgres/var"
export PGPORT="12428"
I know that the problem may be solved by adding the files to .zshrc.
However, I am not sure whether it is the right way to go.
How can you add env variables?
...
I'm puzzled by minidom parser handling of empty element, as shown in following code section.
import xml.dom.minidom
doc = xml.dom.minidom.parseString('<value></value>')
print doc.firstChild.nodeValue.__repr__()
# Out: None
print doc.firstChild.toxml()
# Out: <value/>
doc = xml.dom.minidom.Document()
v = doc.appendChild(doc.createEleme...
I would like to know how to I exit from python without having an traceback dump on the output.
I still want want to be able to return an error code but I do not want to display the traceback log.
I want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.
...
In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessary, and then have it fu...
Stumbled upon some seemingly random character mangling in eclipse-pydev console:
specific characters are read from stdout as '\xd0?' (first byte correct, second "?")
Is there some solution to this?
(PyDEV 1.4.6, Python 2.6, console encoding - inherited UTF-8, Eclipse 3.5, WinXP with UK locale)
Code:
import sys
if __name__ == "__main_...
As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?
-- Added --
The network configuration is here.
I'm connecting to the machine via 14...
Hello,
I want to read a line in a file and insert the new line ("\n") character in the n position on a line, so that a 9-character line, for instance, gets converted into three 3-character lines, like this:
"123456789" (before)
"123\n456\n789" (after)
I've tried with this:
f = open(file, "r+")
f.write("123456789")
f.seek(3, 0)
f.wri...
I have a web service that returns following type:
<xsd:complexType name="TaggerResponse">
<xsd:sequence>
<xsd:element name="msg" type="xsd:string"></xsd:element>
</xsd:sequence>
<xsd:attribute name="status" type="tns:Status"></xsd:attribute>
</xsd:complexType>
The type contains one element (msg) and one attribute (sta...
I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module?
...
Suppose I have a relatively long module, but need an external module or method only once.
Is it considered ok to import that method or module in the middle of the module?
Or should imports only be in the first part of the module.
Example:
import string, pythis, pythat
...
...
...
...
def func():
blah
blah
blah
fr...
I have a web service that accepts passed in params using http POST but in a specific order, eg (name,password,data). I have tried to use httplib but all the Python http POST libraries seem to take a dictionary, which is an unordered data structure. Any thoughts on how to http POST params in order for Python?
Thanks!
...
Hi,
I'm installing an egg with easy_install which requires ruledispatch. It isn't available in PyPI, and when I use PEAK's version it FTBFS. There is, however, a python-dispatch package which provides the same functionality as ruledispatch. How can I get easy_install to stop trying to install ruledispatch, and to allow it to recognize t...
Hi,
this question is about the last example on Custom managers and model inheritance.
I want to be able to do something similar to the following:
class ExtraManagerModel(models.Model):
# OtherManager class supplied by argument shall be set as manager here
class Meta:
abstract = True
class ChildC(AbstractBase, ExtraManage...