python

Need Help Creating GAE Datastore Loader Class?

Need Help Creating GAE Datastore Loader Class for uploading data using appcfg.py? Any other way to simplified this process? is there any detailed example better than here When try using bulkloader.yaml: Uploading data records. [INFO ] Logging to bulkloader-log-20100701.041515 [INFO ] Throttling transfers: [INFO ] Bandwidth: 25...

Py2exe Directory Structure

I use Py2exe to package a Python application with quite a few dependant packages. While Py2exe works flawlessly the resulting dist/ folder with the executable contains a large number (10-15) of support files (.dll, .pyd, .zip). Ideally I would like to be able to place all of these dependant files in a folder called support/ or lib/ or s...

How to pickle a empty file?

I want to pickle a file that sometime's is empty. Right now its empty, but my idea is that its going to grow over time. How do i check if a file is "pickable" since it seems that you can not pickle a empty file? ...

One-to-one relationships between entities in the Python Google App Engine

Is to possible to create one-to-one relations in the Python version of Google App Engine? I know it is possible in Java. ...

Extract text from PDF

I have a bunch of PDF files that I need to convert to TXT. Unfortunately, when i use one of the many available utilities to do this, it loses all formatting and all the tabulated data in the PDF gets jumbled up. Is it possible to use Python to extract the text from the PDF by specifying postions, etc? Thanks. ...

python/matplotlib - parasite twin axis scaling

Trying to plot a spectrum, ie, velocity versus intensity, with lower x axis = velocity, on the upper twin axis = frequency The relationship between them (doppler formula) is f = (1-v/c)*f_0 where f is the resulting frequency, v the velocity, c the speed of light, and f_0 the frequency at v=0, ie. the v_lsr. I have tried to solve ...

How do I get the class of a ManyToMany field in django models?

Hi Django newbie here, I have some fields in a model that are ManyToMany, I want the ManyToMany class itself, when I only have the field name. Is there any way I can retrieve it? ...

error in connecting to a smtp server with python

import smtplib SERVER = "my.smtp.server.com" FROM = "[email protected]" TO = ["[email protected]"] # must be a list SUBJECT = "Hello!" TEXT = "hello" Here is my code: # Prepare actual message message = """\ From: %s To: %s Subject: %s %s """ % (FROM, ", ".join(TO), SUBJECT, TEXT) # Send the mail server = smtplib.SMTP(...

Netbeans + sqlite3 = Fail?

Hello, I've decided to give Python a try on Netbeans. The problem so far is when try to run program I know works, i.e. if I ran it through the terminal. For the project I selected the correct Python version (2.6.5). And received the following error: Traceback (most recent call last): File "/Users/XXX/NetBeansProjects/NewPythonPr...

Manipulating the db with SQL Server 2005 - Django

Hi folks, I'm trying to accomplish the following: Grab the db schema Grab any constraints* Alter tables Add/Drop tables I'm currently using pyodbc backend for Django. I would like to perform all these tasks within a view file. I'm using the following in order to grab fields of tables starting with 'core_': SELECT table_name,or...

Python splitting list based on missing numbers in a sequence

I am looking for the most pythonic way of splitting a list of numbers into smaller lists based on a number missing in the sequence. For example, if the initial list was: seq1 = [1, 2, 3, 4, 6, 7, 8, 9, 10] the function would yield: [[1, 2, 3, 4], [6, 7, 8, 9, 10]] or seq2 = [1, 2, 4, 5, 6, 8, 9, 10] would result in: [[1, 2], [4, ...

Python Script Hangs, Potentially an Infinite Loop?

Once again working on Project Euler, this time my script just hangs there. I'm pretty sure I'm letting it run for long enough, and my hand-trace (as my father calls it) yields no issues. Where am I going wrong? I'm only including the relevant portion of the code, for once. def main(): f, n = 0, 20 while f != 20: f = 0 ...

How do I get the index of the largest list inside a list of lists using Python ?

I am storing animation key frames from Cinema4D(using the awesome py4D) into a lists of lists: props = [lx,ly,lz,sx,sy,sz,rx,ry,rz] I printed out the keyframes for each property/track in an arbitrary animation and they are of different lengths: track Position . X has 24 keys track Position . Y has 24 keys track Position . Z has 24 ke...

How to recognize current location in python?

My client has two offices in Germany and USA and a python program should recognize the office location. What will be the most elegant way to implement this? It only have to recognize the country. Furthermore it also could happens that there will be no permanent internet connection. The program works on windows but the solution should be ...

How to make a fancy shortcut on the desktop to my python app?

I've made this nice python app that runs when i use "python main.py" in terminal, but going thru the terminal each time is boring :-) how can i make a nice shortcut button with a img to have on my desktop? ...

ctypes outputting unknown value at end of correct values

Hi all - I have the following DLL ('arrayprint.dll') function that I want to use in Python via ctypes: __declspec(dllexport) void PrintArray(int* pArray) { int i; for(i = 0; i < 5; pArray++, i++) { printf("%d\n",*pArray); } } My Python script is as follows: from ctypes import * fiveintegers = c_int * 5 x = fivei...

How can I avoid circular imports in Python?

I'm having a problem with circular imports. I have three Python test modules: robot_test.py which is my main script, then two auxiliary modules, controller_test.py and servo_test.py. The idea is that I want controller_test.py to define a class for my microcontroller and servo_test.py to define a class for my servos. I then want to inst...

Python Google App Engine: How do you find the count number of a particular entity in the datastore?

I want to be able to give each instance of a particular object a unique number id in the order that they are created, so I was thinking of getting the number of the particular entity already in the datastore and add 1 to get the new number. I know I can do something like query = Object.all() count = query.count() but that has some l...

apns-python-wrapper device token issues

To use the module apns-python-wrapper here: http://code.google.com/p/apns-python-wrapper/ you need to convert your iPhone's APNS device token, however, I'm not sure how to convert it. Here is the fresh new token returned from the device: 8fa9c60685c158a3cf6f9c5de164b3817e68a075fcfdafcd982aa4b3d2ca99c7 And this is what it needs to look...

What HTML parser to choose and why BeautifulSoup doesn't work?

I need to parse a HTML-page with windows-1251 charset (it's in russian). The problem is that it is the web application and I have to use Python 2.4 without any opportunity to install modules on server. The only thing I tried to do was asking an administrator to install lxml module but nevertheless it wasn't built in the right way on 2....