Hello,
I am looking for an integrated pygame text editor, that is, something that can run in a pygame window without hijacking the event loop. I don't need anything fancy, just a basic editor. I have looked at pgu, and it is just barely ok, I am in the midst of modifying it to better suit my needs. Ocempgui is pretty cool, but seems a b...
Question: How do I kill an instantiation or insure i'm creating a new instantiation of the python universal feedparser?
Info:
I'm working on a program right now that downloads and catalogs large numbers of blogs. It has worked well so for except for an unfortunate bug. My code is set up to take a list of blog urls and run them throug...
I have two classes:
class Dog(object):
def __init__(self, name):
self.name = name
class Toy(object):
def play(self):
print "Squeak!"
I need to come up with a method called play(self, toy, n) for class Dog. It prints "Yip! " (with a space) followed by the output from toy.play on the same line. This happens n ti...
I write scientific software in Numpy/Scipy/Matplotlib. Having developed applications on my home computer, I am now interested in writing simple web applications. Example: user uploads image or audio file, my program processes it using Numpy/Scipy, and output is displayed on the browser using Matplotlib, or perhaps the user can download a...
I'm working with a django form, and I have a choice field. I think the problem may be that the choices are fetched dynamically, and right now there's only one value. I'm getting the TemplateSyntaxError: too many values to unpack. Some of the other posts seem to say that having only one value is a problem, so i adjusted my function that f...
from django import template
register = template.Library()
class_converter = {
"textinput":"textinput textInput",
"fileinput":"fileinput fileUpload"
}
@register.filter#<--------
def is_checkbox(field):
return field.field.widget.__class__.__name__.lower() == "checkboxinput"
@register.filter#<--------
def with_class(field):
...
I have a pretty simple file upload form class in django:
class UploadFileForm(forms.Form):
category = forms.ChoiceField(get_category_list())
file = forms.FileField()
one problem is that when i do {{ form.as_p }}, It has no submit button. How do i add one?
...
Django is incompatible with Python 3:
For larger Python-based software like
Django, the transition is expected to
take at least a year or two (since it
involves dropping support for older
Python releases and so must be done
gradually).
Which other web framework is recommended for Python 3.1?
Thanks
...
I'm having troubles with the multiprocessing module. I'm using a Pool of workers with its map method to load data from lots of files and for each of them i analyze data with with a custom fuction. Each time a file has been processed I would like to have a counter updated so that i can keep track of how many files remains to be processed....
I am learning Twisted, especially its XMPP side. I am writing a Jabber client which must send and recieve messages. Here is my code: http://pastebin.com/m71225776
As I understood the workflow is like this:
1. I create handlers for important network events (i.e. connecting, message recieving, disconnecting, etc)
2. I run reactor. At this ...
Hello,
I'm trying to do connect form on my django website
If in a shell I do :
$ ./manage.py shell
Python 2.6.4 (r264:75706, Oct 27 2009, 06:25:13)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib import auth
>>> user = auth.authenticate(username...
I'm calling a python script from the below one using subprocess. From the command line the user chooses which file to open using raw_input
import optparse
import subprocess
import readline
import os
def main():
options = {'0': './option_0.py',
'1': './option_1.py',
'2': './option_2.py',
'3': './...
Possible Duplicate:
Deleting files by type in Python on Windows
How can I delete all files with the extension ".txt" in a directory? I normally just do
import os
filepath = 'C:\directory\thefile.txt'
os.unlink(filepath)
Is there a command like os.unlink('C:\directory\'*.txt) that would delete all .txt files? How can I do that...
list1 = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
for item in list1:
print item
Not sure why the above code is throwing this error:
NameError: "name 'a' is not defined"
...
Hi,
I've just installed python 2.6 on my win7 machine.
Now I tried to install mysqldb. But when run "python setup.py install"
C:\MySQL-python-1.2.3c1>python setup.py install
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\MySQL-python-1.2.3c1\setup_windows.p...
Here is an example in c:
#include <stdio.h>
#include <string.h>
void bad() {
printf("Oh shit really bad~!\r\n");
}
void foo() {
char overme[4] = "WOW";
*(int*)(overme+8) = (int)bad;
}
int main() {
foo();
}
...
With the following code I upload file.txt to a ftp server. When the file has been uploaded I delete it on my local machine.
import os
from ftplib import FTP
HOST = 'host.com'
FTP_NAME = 'username'
FTP_PASS = 'password'
filepath = 'C:\file.txt'
while True:
try:
ftp = FTP(HOST)
ftp.login(FTP_NAME, FTP_PASS)
fi...
I'm trying to use pydiction to autocomplete Python/Django statements in VIM Editor.
When I try to add django modules to complete-dic using this:
python pydiction.py /usr/lib/pymodules/python2.6/django
or:
python pydiction.py /usr/lib/pymodules/python2.6/django/__init__.py
I receive this error:
Couldn't import: (...). Import by fi...
import string
print string.ascii_lowercase # abcdefghijklmnopqrstuvwxyz
print type(string.ascii_lowercase) # <type 'str'>
print string.ascii_lowercase is str # False
Shouldn't it be True?
...
When coding in Python, I often need to write a function like this one:
def delete_dir(dir_name):
if os.path.exists(dir_name):
reply = raw_input("Delete directory "+dir_name+"? [y/[n]] ")
if reply=='y':
os.system('rm -r '+dir_name)
else:
print "Aborting..."
sys.exit()
whi...