Why does str(A()) seemingly call A.__repr__() and not dict.__str__() in the example below?
class A(dict):
def __repr__(self):
return 'repr(A)'
def __str__(self):
return dict.__str__(self)
class B(dict):
def __str__(self):
return dict.__str__(self)
print 'call: repr(A) expect: repr(A) get:', repr(A...
First things first, I am a Python beginner, with a typical C++/Java background for object oriented stuff.
I was convinced to try Python for this current endeavor I am working on, and so far I like it. One issue I am having though is finding a good mp3 module.
I have tried TkSnack, which installed and ran fine with no errors(as long as ...
Hi everybody,
I have question regarding the SQLAlchemy. How can I add into my mapped class the dictionary-like attribute, which maps the string keys into string values and which will be stored in the database (in the same or another table as original mapped object). I want this add support for arbitrary tags of my objects.
I found the f...
I've put site directory created by django-admin startproject under version control (Mercurial). Let's say, the site is called frobnicator.
Now I want to make some serious refactoring, so I clone the site using command
hg clone frobnicator frobnicator-refactoring`
but ROOT_URLCONF in settings.py still says frobnicator.urls.
Is there ...
Guys, I need to develop a tool which would meet following requirements:
Input: XHTML document with CSS rules within head section.
Output: XHTML document with CSS rules computed in tag attributes
The best way to illustrate the behavior I want is as follows.
Example input:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
...
Hello,
I am writing an rather simple http web server in python3. The web server needs to be simple - only basic reading from config files, etc. I am using only standard libraries and for now it works rather ok.
There is only one requirement for this project, which I can't implement on my own - virtual hosts. I need to have at least tw...
Problem:
I have a python script that I have running as a service. It's a subclass of the win32 class win32serviceutil.ServiceFramework. I want a simple straightforward way of sending arbitrary commands to it via the command line.
What I've looked at:
It looks like the standard way of controlling the service once it's started is by...
Hi, I just wondered, how to hide special
__.*__
methods in python*? Especially I am using an interactive python interpreter with tab-completion, and I would like to display only the methods my modules expose ...
thanks,
/ myyn /
*(at least from the user, who uses a python shell)
it looks like this now:
h[2] >>> Q.
Q.ALL( ...
I know this topic has been discussed in the past, but I am a tiny bit paranoid about resource usage.
I am looking into writing a daemon for queing jobs to archive files into zip files for a web app i am working on. It would behave something like this:
while True:
while morejobs():
zipfile()
sleep(15seconds)
What sort ...
Hello, i need to create a context menu on right clicking at my window. But i really don't know what should i do. Are there any widgets or i must make it by my hands?
Programming language: Python
Graphical lib: Qt (PyQt).
...
I'm editing some Python code with rather long functions and decided it would be useful to quickly get the function name without scrolling up. I put this bit of code together to do it. Is there something built in to emacs in general, or the standard python mode in particular, which I can use instead?
(defun python-show-function-name()
...
I would like to write a bit of code that calls a function specified by a given argument. EG:
def caller(func):
return func()
However what I would also like to do is specify optional arguments to the 'caller' function so that 'caller' calls 'func' with the arguments specified (if any).
def caller(func, args):
# calls func with th...
I defined an handler for EVT_IDLE that does a certain background task for me. (That task is to take completed work from a few processes and integrate it into some object, making a visible change in the GUI.)
The problem is that when the user is not moving the mouse or doing anything, EVT_IDLE doesn't get called more than once. I would l...
Is there an easy-to-use python module that'd do english or finnish text validation?
It'd be ok if I could just check the words exist in user-defined dictionary and possibly checking that the grammar is somewhat okay.
I am planning to implement a fancy validation for a directory contents I did while ago back. This involves some simple s...
I seem to be blind at the moment, so I need to ask here. I want to sort a list of tuples which look like that
(id, parent_id, value)
So that it is a representation of the tree as a flattend list of list of tree nodes.
For example the input
(1, None, '...')
(3, 2', '...')
(2, 1, '...')
(4, 1, '...')
(5, 2, '...')
(6, None, '...')
S...
I have the following code
print "Starting stage 1<br>"
# Something that takes about 5 seconds
time.sleep(5)
print "Stage 1 complete"
I view the script with my browser as it's part of a web-app, the problem is that it's displaying all of it together, I want it to display first the starting message before it starts and then add the co...
We're embarking on a project for a client. They plan on having about 50k users by the end of the year. We're pushing to use Pylons w/ Mako and SQLAlchemy, and our contact there is excited about it, but some of his colleagues are wary because it's not .NET or J2ee (they're used to enterprisey stuff).
Their web app will have some data an...
Hi, I have a script which checking something on my pc every 5 min and I dont want python to show on my tasktray
is there any way to make python run in the background and force him not to show in my task tray ?
thanks
im using windows by the way
...
compact() and extract() are functions in PHP I find tremendously handy. compact() takes a list of names in the symbol table and creates a hashtable with just their values. extract does the opposite. e.g.,
$foo = 'what';
$bar = 'ever';
$a = compact('foo', 'bar');
$a['foo']
# what
$a['baz'] = 'another'
extract(a)
$baz
# another
Is th...
When running the following python code:
>>> f = open(r"myfile.txt", "a+")
>>> f.seek(-1,2)
>>> f.read()
'a'
>>> f.write('\n')
I get the following (helpful) exception:
Traceback (most recent ...