I'm trying to write a regular expression pattern (in python) for reformatting these template engine files.
Basically the scheme looks like this:
[$$price$$]
{
<h3 class="price">
$12.99
</h3>
}
I'm trying to make it remove any extra tabs\spaces\new lines so it should look like this:
[$$price$$]{<h3 class="price">$12.99</h...
I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think ...
I commonly write Python scipts to do conversion tasks for me and whenever I write one that takes a while I use this little progress bar to check on it
import sys
import time
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
barra = QtGui.QProgressBar()
barra.show()
barra.setMinimum(0)
barra.setMaximum(10)
for a in range(10):
...
How do I get the primary key after saving a ModelForm? After the form has been validated and saved, I would like to redirect the user to the contact_details view which requires the primary key of the contact.
def contact_create(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid(...
As this says:
http://mail.python.org/pipermail/python-list/2003-May/206149.html
Function overloading is absent in Python.
As far as I feel this a big handicap since its also an OO language. Initially I found that unable to differentiate between the argument types was difficult but the dynamic nature of Python made it easy (e.g. list, ...
I need to add leading zeros to integer to make a string with defined quantity of digits ($cnt).
What the best way to translate this simple function from PHP to Python:
function add_nulls($int, $cnt=2) {
$int = intval($int);
for($i=0; $i<($cnt-strlen($int)); $i++)
$nulls .= '0';
return $nulls.$int;
}
Is there a func...
I have a list that contains several tuples, like:
[('a_key', 'a value'), ('another_key', 'another value')]
where the first tuple-values act as dictionary-keys.
I'm now searching for a python-like way to access the key/value-pairs, like:
"mylist.a_key" or "mylist['a_key']"
without iterating over the list. any ideas?
...
I've just started learning how to use pygame yesterday. I was read this one book that was super helpful and followed all its tutorials and examples and stuff. I wanted to try making a really simple side scroller/platforming game but the book sorta jumped pretty fast into 3D modeling with out instructing how to make changing sprites for m...
I know a site can have many apps but all the examples I see have the site called "mysite". I figured the site would be the name of your site, like StackOverflow for example.
Would you do that and then have apps like "authentication", "questions", and "search"? Or would you really just have a site called mysite with one app called Stack...
Duplicate of What is the best (idiomatic) way to check the type of a Python variable?
Sometimes checking of arguments in Python is necessary. e.g. I have a function which accepts either the address of other node in the network as the raw string address or class Node which encapsulates the other node's information.
I use type(0 functi...
Suppose I wrote a compiler in Python or Ruby that translates a language into a C# AST.
How do I pretty-print this AST from Python or Ruby to get nicely indented C# code?
Thanks, Joel
...
I have a mechanize script written in python that fills out a web form and is supposed to click on the 'create' button. But there's a problem, the form has two buttons. One for 'add attached file' and one for 'create'. Both are of type 'submit', and the attach button is the first one listed. So when I select the forum and do br.submit(), ...
How to use a string containing a class name to reference a class itself?
See this (not working) exemple...
class WrapperClass:
def display_var(self):
#FIXME: self.__class_name__.__name__ is a string
print self.__class__.__name__.the_var
class SomeSubClass(WrapperClass):
var = "abc"
class AnotherSubClass(Wrapper...
Probably a very common question, but couldn't find suitable answer yet..
I have a (Python w/ C++ modules) application that makes heavy use of an SQLite database and its path gets supplied by user on application start-up.
Every time some part of application needs access to database, I plan to acquire a new session and discard it when ...
When I have a valid Django form, I can access the data with form.cleaned_data. But how do I get at the data a user entered when the form is not valid i.e., form.is_valid is false.
I'm trying to access forms within a form set, so form.data seems to just give me a mess.
...
Hello
Is there any way to generate words based on characters and checking if a domain exists with this word (ping)?
What I want to do is to generate words based on some characters, example "abcdefgh", and then ping generatedword.com to check if it exists.
...
I have a list called 'optionlist' which may change length from day to day, but I want a tkinter dropdown box to be able to select something from it.
Here's an example of how to define a tkinter optionmenu:
opt1 = OptionMenu(root, var1, 'A', 'B', 'C')
A, B, and C are the options you can select. The problem presented here is that whil...
Is it possible to have static methods in Python so I can call them without initializing a class, like:
ClassName.StaticMethod ( )
...
I've got some Python code that runs through a list of strings and converts them to integers or floating point numbers if possible. Doing this for integers is pretty easy
if element.isdigit():
newelement=int(element)
Floating point numbers are more difficult. Right now I'm using partition('.') to split the string and checking to ...
I am looking for a well-engineered, well-built python application that could serve as a guideline to demonstrate best practices relating to software development in general, and more specifically in python. (Note that software in other languages would also be welcome provided they are of good quality and could serve as models of good arch...