I have gotten to know my way around a few programming languages, and I'd like to try my hand at making a command-line text editor -- something that runs in the terminal, like vim/emacs/nano, but is pure text (no guis, please). Preferably, I'd like to do this in python. Where do I start? Are there any (python) libraries to do command-line...
I have been struggling with managing some data. I have data that I have turned into a list of lists each basic sublist has a structure like the following
<1x>begins
<2x>value-1
<3x>value-2
<4x>value-3
some indeterminate number of other values
<1y>next observation begins
<2y>value-1
<3y>value-2
<4y>value-3
some indeterminate number of...
How to make sure that code is still working after refactoring ( i.e, after variable name change)?
In static language, if a class is renamed but other referring class is not, then I will get a compilation error.
But in dynamic language there is no such safety net, and your code can break during refactoring if you are not careful enoug...
I am trying to use Twitter OAuth and my POST requests are failing with a 401 (Invalid OAuth Request) error.
For example, if I want to post a new status update, I am sending a HTTP POST request to https://twitter.com/statuses/update.json with the following parameters -
status=Testing&oauth_version=1.0&oauth_token=xxx&
oauth_nonce=xxx&o...
Hey guys,
I need to parse an XML file and build a record-based output from the data. The problem is that the XML is in a "generic" form, in that it has several levels of nested "node" elements that represent some sort of data structure. I need to build the records dynamically based on the deepest level of the "node" element. Some exa...
I got a QtWebKit.QWebView widget in a PyQt application window that I use to display text and stuff for a chat-like application.
self.mainWindow = QtWebKit.QWebView()
self.mainWindow.setHtml(self._html)
As the conversation gets longer the vertical scrollbar appears.
What I'd like to get, is to scroll the displayed view to the...
I'm on Fedora Core 6 (64 bit)
after "yum install libjpeg-devel" I have downloaded and built PIL. It gives the message:
--- JPEG support ok
Looks like JPEG built okay, but when running selftest.py:
IOError: decoder jpeg not available
Why would it appear to have built correctly, but fail the selftest?
...
Like an idiot, I completely overlooked the timezone setting when I first built an application that collects datetime data.
It wasn't an issue then because all I was doing was "time-since" style comparisons and ordering. Now I need to do full reports that show the actual datetime and of course, they're all stored at America/Chicago (the ...
Hi guys, my proble is to avoid that users upload some malicious file on my web-server.
Im working on linux environment (debian).
Actually the uploads are handled via php by this code:
function checkFile($nomeFile, $myExt = false){
if($myExt != false){ $goodExt = "_$myExt"."_"; }else{ $goodExt = "_.jpg_.bmp_.zip_.pdf_.gif_.doc_.xls_.csv...
With django 1.0.2 and Python 2.5, when I use the keyword DateField.input_formats, I get the error that __init__() got an unexpected keyword argument 'input_formats'. When I look in the __init__ file, I don't see input_formats as one of the acceptable keyword arguments.
I thought that input_formats had been around long enough that it sho...
One of my favorite features about python is that you can write configuration files in python that are very simple to read and understand. If you put a few boundaries on yourself, you can be pretty confident that non-pythonistas will know exactly what you mean and will be perfectly capable of reconfiguring your program.
My question is, ...
Hi,
I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.
So is it possible given a users POP email server details to access their sent mail?
If so any examples in Python or fetchmail?
Regards
Mark
...
Hi,
I often find myself writing if / elif / else constructs in python, and I want to include options which can occur, but for which the corresponding action is to do nothing. I realise I could just exclude those if statements, but for readability I find it helps to include them all, so that if you are looking through the code you can se...
I know the link template to reach an object is like following:
"{{ domain }}/{{ admin_dir }}/{{ appname }}/{{ modelname }}/{{ pk }}"
Is there a way built-in to get a permalink for an object?
from django.contrib import admin
def get_admin_permalink(instance, admin_site=admin.site):
# returns admin URL for instance change page
...
How can I get Django 1.0 to write all errors to the console or a log file when running runserver in debug mode?
I've tried using a middleware class with process_exception function as described in the accepted answer to this question:
http://stackoverflow.com/questions/238081/how-do-you-log-server-errors-on-django-sites
The process_e...
Hi all,
I was wondering what you guys think about these two frameworks.
I'm going to build a turn-key solution for a vertical market and would like to offer both options: software as a service and give them the opportunity to host the app on their own. In other words I'd aim at having similar deployment options as Joel's FogBugz.
I'm ...
In Python, what is the best way to determine if an IP address (e.g., '127.0.0.1' or '10.98.76.6') is on a private network? The code does not sound difficult to write. But there may be more edge cases than are immediately apparent, and there's IPv6 support to consider, etc. Is there an existing library that does it?
...
Hi,
I'm going to implement a tokenizer in Python and I was wondering if you could offer some style advice?
I've implemented a tokenizer before in C and in Java so I'm fine with the theory, I'd just like to ensure I'm following pythonic styles and best practices.
Listing Token Types:
In Java, for example, I would have a list of fields...
I have Exhibit objects which reference Gallery objects both of which are stored in the Google App Engine Datastore.
How do I order the Exhibit collection on each Gallery object when I get around to iterating over the values (ultimately in a Django template)?
i.e. this does not work
class Gallery(db.Model):
title = db.StringProperty...
So, Python functions can return multiple values. It struck me that it would be convenient (though a bit less readable) if the following were possible.
a = [[1,2],[3,4]]
def cord():
return 1, 1
def printa(y,x):
print a[y][x]
printa(cord())
...but it's not. I'm aware that you can do the same thing by dumping both return value...