python

urllib.py doesn't work with https?

In my python app I try to open a https url, but I get: File "C:\Python26\lib\urllib.py", line 215, in open_unknown raise IOError, ('url error', 'unknown url type', type) IOError: [Errno url error] unknown url type: 'https' my code: import urllib def generate_embedded_doc(doc_id): url = "https://docs.google.com/document/ub?id...

How to open a link with different proxy IP adresses in python?

I want to click a link over and over again while different proxies are enabled to trick the host into thinking I am doing it on different IP adresses. What is the simples way to do this in python? Thanks! ...

Python27 IDLE GUI stopped working

Hi For some reason my Python IDLE interface stopped working :( I ran a some code which seems to have been buggy since i couldn't even exit it with ctrl+F6. I had to close the IDLE window down and since then it won't launch anymore. Reinstalling Python didn't make any difference....any ideas to help me get it runnig again would be great....

Custom multivaluefield isn't displayed in empty form

Hi, I'm trying to build a custom multivaluewidget in my django app. Widget class DayInputWidget(MultiWidget): def __init__(self, attrs=None): widgets = (DayInput(day_name='Mo'), DayInput(day_name='Di'), DayInput(day_name='Mi'), DayInput(day_name='Do'), DayInput(day_name='Fr')) super(DayInputWidget, self).__init__(...

reload (update) a .py file in the interpreter

I'm new to python (and to programming in general) and here I have a newbie question: let's say I have this python script "script.py" and I load it in the interpreter by typing import script and then I execute my function by typing: script.testFunction(testArgument) OK so far so good, but when I change "script.py", if I try to impo...

Building python Shell

I have some small python 2.6 scripts built.... Now, I would like run them as seperate processes within a python shell. Each as a seperate process. If one fails to run maybe with its timer, I would like others to continue without killing all scripts. Should I do this as singleton gui's or combine them into bigger launch pad. My perfere...

Getting BadValueError on Google App Engine Datastore Delete

I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader er...

Read each line of HTML form submission Python.

Hi, I'm building a small web app with Python on GAE. I have an HTML form with a where users enter a list of items (one item per line). When the form is submitted I want to read each line and store separate entries in the datastore for each item (i.e. line). I want to do something similar to f.readline() for files, but on the form sub...

First element of a path in python

Hey, I got a list of paths and I need to extract the first element of each path in a portable way, how would I do that? ['/abs/path/foo', 'rel/path', 'just-a-file'] to ['abs', 'rel', 'just-a-file'] Thanks in advance Oli ...

Python meta-debugging

Heyo, Just started writing an assembler for the imaginary computer my class is creating wire-by-wire since the one the TA's provided sucks hard. I chose python even though I've never really used it that much (but know the basic syntax) and am loving it. My favorite ability is how I can take a method I just wrote, paste it into the she...

syntax to insert one list into another list in python

syntax to insert one list into another list in python ...

webapp folder structure for securing plaintext passwords and sqlite database

Im building a simple web app in Python using web.py - and was wondering what best practices are in terms of securing the application. I had two main questions at this stage: I want the application to be able to send email - its not hosted on GAE, but I thought a simple solutions might be to write / find a s script tha...

How to make a file which is on local server download-able over HTTP in python?

Framework: Django Language: Python OS: Ubuntu For example, let us assume that I have a file "xyz.pdf" at "/home/username/project/". I have a webpage with download button. So if people click on that download button, the file xyz.pdf should be downloaded. What I have done, Created a webpage with download button with href as "download/...

how to create a class in python which would store a tree

I want to make a class in python, which would store a tree.Keeps taking three inputs the main node the left node and right node and stores it in such a way that later I can print it in tree format. ...

List of floats on the google appengine

Been hunting for an hour or so. It would appear that db.Float does not exist. Is there any way to store a list of floats in a ListProperty? Here's the basic idea: class Data(db.Model): temperatures = db.ListProperty(item_type=???) Thanks in advance. ...

Getting the SQL from a Django QuerySet

How do I get the SQL that Django will use on the database from a QuerySet object? I'm trying to debug some strange behavior, but I'm not sure what queries are going to the database. Thanks for your help. ...

Summarizing inside a Django template

I have the following template in django, i want to get the totals of the last 2 columns for each of my document objects {% for documento in documentos %} {% for cuenta in documento.cuentasxdocumento_set.all %} <tr {% cycle 'class="gray"' '' %} > {% if forloop.first %} <td>{{ documento.fecha_cr...

Adding optional parameters to the constructors of multiply-inheriting subclasses of built-in types?

My multiple-inheritance-fu is not strong. I am trying to create a superclass whose __init__ takes an optional named parameter and subclasses of it which also inherit from built-in types. Sadly, I appear to have no idea how to make this work: >>> class Super(object): name = None def __init__(self, *args, name=None, **kwargs): ...

Complete newbie excited about Python. How hard would this app be to build?

I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff. I'd like to be able to set expectations for myself, so based on the following requirements how long do you ...

erase template cache

I have a Django app where users can select between 2 interface modes, that mode affect some pages... for those pages I use different templates In urls.py I have something like this: mode = Config.objects.get().mode urlpatterns = patterns('', url(r'^my_url/$', 'custom_view', {'template':'my_template.html', 'mode':mode} ), ) Then m...