python

importing modules' files into submodules

i have a module with many files, which i import in themselves for sharing of functionality myModule/ -myFile1.py -myFile2.py -mySubmodule/ --myFile3.py i can do import myFile2, inside of myFile1, but how can i do a import myFile2 in myFile3 without referencing the base module? i dont want to reference myModule, because i am working o...

Assign class methods from YAML file.

In short,I've written an application that parses text files in specified formats from different email feeds. Currently, there are two formats allowed by users in order to correctly upload information. I've also included a simple YAML file that allows people with non-programming backgrounds (ie sysadmins) to define the basics parsing pa...

Does IronPython .net based DLL need to be deployed with Python Standard Library if it uses the Standard Library?

If I reference the Python Standard Library using IronPython do I have to deploy any Python related libraries or runtimes along with my .net dll? Or, can I just deploy the dll? ...

Twill - how do choose multiple selects with same name

I am using twill and python to write a web crawler. showforms() returns Form name=customRatesForm (#1) ## ## __Name__________________ __Type___ __ID________ __Value__________________ 10 originState hidden originState TN 11 destState hidden destState IL 12 originZip text ...

Form.save(commit=False) behaving differently in Django 1.2.3?

Prior to today, I've been using Django 1.1. To ensure I'm keeping up with the times, I decided to update my Django environment to use Django 1.2.3. Unfortunately, I've encountered an issue. The following code did not raise a ValueError in 1.1: instance = FormClass( request.POST, instance=existing_instan...

IMAP access to Gmail inbox with XOAUTH

I'm following the example, I already have authorized my application (=obtained the access token) but trying to access the inbox results in this: 21:14.12 > NDIB1 AUTHENTICATE XOAUTH 21:14.17 < + 21:14.17 write literal size 480 21:14.74 < NDIB1 NO [ALERT] Invalid credentials (Failure) 21:14.74 NO response: [ALERT] Invalid cred...

Python Reportlab PDF - Centering Text on page

I am using ReportLab to generate a pdf dynamically with python. I would like a line of text to be centered on a page. Here is the specific code I currently have, but do not know how to center the text horizontally. header = p.beginText(190, 740) header.textOut("Title of Page Here") # I know i can use TextLine etc in place of textOu...

Trying to use my subnet address in python code

Hello, I'm trying to get my ip subnet address (192.168.1.xxx) into my python code. I'm running linux/osx. How do I do this/ What is the best way to do this? Thanks in advanced for your help. ...

Django modules for working with DoubleClick?

Since Django has its roots in news websites, I'm surprised that I haven't been able to find any good modules for working with DoubleClick / DART ads. I'm going to being doing some DoubleClick integration, and I'd hate to have to reinvent the wheel so if an existing project exists, I'd appreciate a point in the right direction. edit: I ...

How to declare a method that takes an instance as an argument in Python?

I know it is probably a stupid question, but I am new to OOP in Python and if I declare a function def myFunction( b) and pass an instance of an object to it, I get TypeError: expected string or buffer. To be more specific, I have a following code that I use to parse a summary molecular formula and make an object out of it. class Summa...

How would I write some values/strings in particular columns of a file in python

I have some values that I want to write in a text file with the constraint that each value has to go to a particular column of each line. For example, lets say that I have values = [a, b, c, d] and I want to write them in a line so that a is going to be written in the 10th column of the line, b on the 25th, c on the 34th, and d on the 4...

how to keep multiprocessing main process always exists?

I want to achieve a application, to spawn new process execute tasks, basically like below. web----->pyro----->multiprocessing Through web send command,and communicate with pyro, and then pyro spwan new process to handle the task script. What confused me is.. When I send tasks through pyro once, I send another task, is it possible? ...

Timing/Recording input() in Python 3.1

Hi, I am a beginner at using Python, I am trying to request input from the user via stdin as a string, but record the time it takes for the user to enter the input, so that it may be played back later. For example: "It could take me 10 seconds to type this sentence" and then if I played that sentence back it would take the same amou...

wxPython for Python: How to remove the 1px border under a toolbar?

Hello. I need your help. I have a toolbar, which is next to a slider (screenshot: http://i54.tinypic.com/w2n6ag.jpg) and wxPython automatically puts a tiny 1px border under the [Play/Pause/Stop | Previous/Next] buttons. This does not look nice at all so is it possible to remove it/set it to 0px? Thank you very much. Here is part of...

python regex retrieve only one group

Hi, I have juste a little experience with the regex, and now I have a little problem. I must retrieve the strings between the . So here is a sample : Categories: <a href="/car/2/page1.html">2</a>, <a href="/car/nissan/">nissan</a>,<a href="/car/all/page1.html">all</a> And this is my little regex: re.findall("""<a href=".*">.*</a>"...

Unable to load profile in django

Hey! I am trying to add additional fields to the default User model. I had a look around the internet and done something like this: Made a new model named UserProfile with the following in /UserProfile/models.py: from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): # This is the...

Python multiprocessing : progress report from processes

I have some tasks in an application that are CPU bound and I want to use the multiprocessing module to use the multi-cores processors. I take a big task (a video file analysis) and I split it into several smaller tasks which are put in a queue and done by worker processes. What I want to know is how to report progress to the main process...

Python- how to convert Datetimefield from model into UTC time zone

For python, how do i convert a DatetimeField (has my local server time) to a datetimefield in UTC zone? ...

PyQT: Rotate a QLabel so that it's positioned diagonally instead of horizontally

Hi folks, I'm working on a touch screen app where gui space is very tight. I'd like to rotate a QLabel a bit so that it's either vertical, or offset at a diagonal a bit. Any suggestions? I couldn't find anything relevant on the QLabel interface. Thanks so much! ...

How to create a rollback button in django with MySQLdb?

I want to create a rollback button in my django project using MySQLdb. I have tried to use commit() and rollback() with InnoDB as database engine, rollback() seems not work because the database was updated even though rollback() was put after commit(). Here is some related lines in python code: def update(request): if 'weight' in r...