Hello all,
I have a template like this:
foo_tmplte = Template("fieldname_${ln}_${type} = $value")
and a lot of strings parsed with this template like this:
foo_str1 = "fieldname_ru_ln = journal"
foo_str2 = "fieldname_zh_TW_ln = journal"
foo_str3 = "fieldname_uk_ln = номер запису"
Now i want to extract back the variables from the t...
I wanted to ask what known existing Python 2.x libraries there are for parsing an XML document with built-in DTD without automatically expanding the entities. (File in question for those curious: JMdict.)
It seems lxml has some option for not parsing the entities, but last I tried, the entities just ended up being converted to blanks. ...
Okay, in python one can do this:
def foo(monkeys):
def bar(monkey):
#process and return new monkey
processed_monkeys = list()
for monkey in monkeys:
processed_monkeys += bar(monkey)
return processed_monkeys
(This is just a stupid example)
I sometimes miss this functionality of declaring a method inside ...
When coding python, I use the logging module a lot.
After some bad experiences and reading articles like this one, I try to prevent import-time executed code wherever possible.
However, for the sake of simplicity, I tend to get my logging object right at the beginning of the module file:
# -*- coding: utf-8 -*-
import logging
logger =...
A few weeks ago, I was able to build Apps using py2app. I just tried it again and during the build process, I get dumped into a pdb session with the stack trace below.
It appears to be in import problem with modulegraph.py but I have the most update to date version.
This happens even with a bare minimum test file with no imports other ...
I have a GridSizer with StaticBitmap images in it. I want to put each of the images in their own panels so I can change the background color to highlight an image if it has been selected. When I try to do this, however, the images are not centered in their panels and the highlighted background color is only present on two borders. How ca...
Hi,
I have a big search field, where users could type in any peice of text and it would search for it.
Now I have a requirement to add in dob to my search. I am not adding a new textbox with a dob picker. I just want users to be able to input a dob in a range of formats and it would figure it out.
IE users can search using any combin...
I wrote application and other application which will connect to first application. I have process ID of these processes and know how to get process ID of second application in first. But I dont know how can I connect to process knowing their id.
Any suggestions?
I use windows 32bit
...
for control in form.controls:
if control.type == 'text':
if 'user' in control.name:
control.value = 'blah'
if 'mail' in control.name:
control.value = 'blah'
if control.type == 'password':
if 'pass' in control.name:
control.value = 'blah'...
I have a python app that uses GIMP gradients to color images. Other than letting the user choose which GIMP gradient to use, the user doesn't have much more control over the coloring. I'm thinking of how to make it easier to let users edit or create color gradients. Are there preexisting tools for working with creating/editing color grad...
Being probably one of the worst OOP programmers on the planet, I've been reading through a lot of example code to help 'get' what a class can be used for. Recently I found this example:
class NextClass: # define class
def printer(self, text): # define method
self.message = text ...
I want to make pipe or queue in Python between one process (current) and other existing in system. how can I make it? I know current and other proces ID.
I work on Windows 32bit.
...
How would it be possible to do the following:
Scan through an html page (preferably through a whole domain (www.python.org) and extract all
h1 h2 ...hn Tags
and write all Headings to a file. In the correct order:
Start with h1
Than h2
until we reach the next h1
...
Hello for everybody.
Sorry for totally stupid question, but the situation is that I have to make some changes to the Django website, and I have about zero knowleges in python.
I've been reading Django docs and found out where to make changes, but there is very strange situation. When I change view, template, config or anything on web si...
I'm looking for some forum software to work along side a Plone site.
Unfortunately the Plone bolt on offerings are fairly poor, so the next best bet (for my skill set) is one written in Python - I'm not to bothered about the framework, as long as it can live on the same server as the Plone site.
Do any exist? What have you tried / wou...
I have a script that looks something like this:
export foo=/tmp/foo
export bar=/tmp/bar
Every time I build I run 'source init_env' (where init_env is the above script) to set up some variables
To accomplish the same in python I had this code running
reg = re.compile('export (?P<name>\w+)(\=(...
Disclaimer: Sensible semantics do dictate that the LHS of as behaving differently depending on the RHS lexeme is ludicrous. But I am curious nontheless.
Hi guys,
Simple question, but one that somone may be able to answer better than my hack. I'm currently messing with metaclasses etc and working out a comfortable syntax for some th...
I would like to run a Django project on a server using virtualenv in Apache using mod_python. Now I know that the recommended apache module to use is mod_wsgi, but I don't want to install that for now.
The default python installation on the server is python2.4, which is used by some other website on the server. Because my project was bu...
I have two instances of an object in a list
class Thing():
timeTo = 0
timeFrom = 0
name = ""
o1 = Thing()
o1.name = "One"
o1.timeFrom = 2
o2 = Thing()
o2.timeTo = 20
o2.name = "Two"
myList = [o1, o2]
biggestIndex = (myList[0].timeFrom < myList[1].timeTo) & 1
bigger = myList.pop(biggestIndex)
lesser = myList.pop()
...
Hi everyone,
I have a piece of fortran code that reads some numbers from STDIN and writes results to STDOUT. For example:
do
read (*,*) x
y = x*x
write (*,*) y
enddo
So I can start the program from a shell and get the following sequence of inputs/outputs:
5.0
25.0
2.5
6.25
Now I need to do this from within python. After fut...