python

What type is on the other end of relation in sqlalchemy without creating objects?

How to obtain a name of the class that should be on the other end of the relation? It was declared when creating relationship. I guess that information should be somwhere in sqlalchemy.orm.util.class_mapper Let's say we have these three classes and a relations between them. Book * --- 1 Shelf and Book * --- * Author class Shelf(Base)...

Convert ascii encoding to int and back again in python (quickly)

I have a file format (fastq format) that encodes a string of integers as a string where each integer is represented by an ascii code with an offset. Unfortunately, there are two encodings in common use, one with an offset of 33 and the other with an offset of 64. I typically have several 100 million strings of length 80-150 to convert ...

Python: Inconsistent behaviour using sqlite3.Row to index into results by name

Hi all. In my Python application I have been using sqlite3.Row as the row factory to index results by name for a while with no issues. Recently I moved my application to a new server (no code changes), and I discovered this method of indexing is now unexpectedly failing on the new server given quite a specific condition. I cannot see ...

New to google app engine ! what to do next ?

hi all . I want to develop some web apps using Google app engine. I had deployed a guest book application which was their in "gooleappengine" folder by changing its ID.and also was successful.This is simple one.But not getting how to develop complex web apps. Can anyone please suggest me any good Tutarial or example codes Or any books to...

emacs python mode preferences

I 'm just starting to use Python, but I'm a very experienced emacs user. I'd trying to decide between python.el and python-mode.el (or any other equivalent mode people can suggest). Currently I'm leaning strongly towards python-mode.el, mainly because it has a useful "indent-region" method... However, there's a couple of features of C...

How to delete a record in django models.

I want to delete a record. But I of a particular record. Such as delete from table_name where id = 1; How can I do this in a django model? I am writing a function: def delete(id):` ----------- ...

Django web interface components

Hi I am using python and django and like it a lot. But than i use it, I catch myself thinking what i do a lot of work to render result data and write specific actions for it. For example than i pass result set of objects to template i must render all data and write all possible actions such as sorting by columns,filtering,deletion,edit ...

How to protect a Google App Engine app with a password?

How would you implement simple password protection on a Google App Engine application? No users authentication, just simple requirement to enter a password in order to open specific page. The other requirement is that the target page should not be displayed if its URL is entered directly. I'm looking for a solution using Python. ...

Altering data in GQL

I need to change values for an entry, but the following code doesn't work. logList = db.GqlQuery("SELECT * FROM Log ORDER BY date DESC LIMIT 1") logList[0].content = "some text" db.put(logList) The value for the newest element doesn't change when I run this. I checked the output with Print, it gives correct value (to what the content...

My facebook authentication is not working?

I changed my domain from abc.com to xyz.com. After that my facebook authentication is not working. It is throwing a key error KeyError: 'access_token'I am using python as my language. ...

Python regular expressions

what is the regular expressions that will identify the class of valid NRIC numbers (inclusive of the ending alphabets) ...

python interprocess querying/control

Hi, I have this Python based service daemon which is doing a lot of multiplexed IO (select). From another script (also Python) I want to query this service daemon about status/information and/or control the processing (e.g. pause it, shut it down, change some parameters, etc). What is the best way to send control messages ("from now o...

How to get field with ForeignKey('self') without the possibilty to link to same entry?

Hallo Folks, I hope you can help me with a little problem I came in touch with while building a model with a foreign key to itself. Here an example: class Example (model.Model): parent = models.ForeignKey('self', null=True, blank=True) # and some other fields After creating a new entry in the admin panel and going into this ...

Function to validate an E-mail (IDN aware)

Hey. Is there any python function that validates E-mail addresses, aware of IDN domains ? For instance, [email protected] should be as correct as user@zääz.de or user@納豆.ac.jp Thanks. ...

python - Week number of the month

Hi. Does python offer a way to easily get the current week of the month (1:4) ? ...

Ways to Move up and Down the dir structure in Python

#Moving up/down dir structure print os.listdir('.') print os.listdir('..') print os.listdir('../..') Any othe ways??? I got saving dirs before going deeper, then reassigning later. ...

Django, Python calling Python code without waiting for response?

I am using Django and am making some long running processes that I am just interacting with through my web user interface. Such as, they would be running all the time, checking a database value every few minutes and stopping only if this has changed (would be boolean true false). So, I want to be able to use Django to interact with thes...

how can I stop all tests from inside a test or setUp using python's unittest framework

I'm extending the python 2.7 unittest framework to do some function testing. One of the things I would like to do is to stop all the tests from running inside of a test, and inside of a setUpClass method. Sometimes if a test fails, the program is so broken it is no longer of any use to keep testing, so I want to stop the tests from runn...

Am diving into web development using python. Will Flask be a good place to start!

Hi so as the title suggests, am just diving into web development. And if you might see my last post, it was about understanding the concept of sessions. So that is the level of my expertise in there. I went across a couple of frameworks, and I seriously dont have the patience of going through the entire django docs. So I stumbled across...

how to have command as input for a shell launched inside a python subprocess

Hello, all, I want to create a GUI python script to launch several processes. All of these processes originally were called by setting up a shell with a perl script (start_workspace.perl), and type the executable file name under the shell. inside, start_workspace.perl, it first set some ENV variables, and then call exec(/bin/bash), wh...