python

how do i get the username and email when someono login my site use google openid .what does google return .

i used pinax,the user who login my site use openid is successful now , i only want to get the username and email when they return . the google openid url is :https://www.google.com/accounts/o8/id and yahoo openid url is :http://yahoo.com/ how can i get it . thanks ...

Embed Google Docs PDF viewer in IFRAME

When I upload PDF to Google Docs (using Python's gdata library), I get link to the document: >>> e.GetAlternateLink().href Out[14]: 'http://docs.google.com/a/my.dom.ain/fileview id=<veery-long-doc-id>&hl=en' Unfortunately using that link in IFRAME is not working for me because PDF viewer is redirecting to itself, breaking out of IFRAM...

if i have the key of google openid when someone who login my site,how do i get the username.

if the key is https://www.google.com/accounts/o8/id?id=AItOawmqS0V2RR5FihojGdC90vXJpjcukoZ how do i get the username who login my site ? thanks ...

What statically typed languages are similar to Python?

Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I'm curious if there are any languages which try to add the benefits of Python to a statically typed language. In par...

How can I install django-stdimage in my django project, rather than as a module (jailed shell, no path access)

The question about covers it. I'm using dreamhost, and need to utilize the stdimagefield rather than image field so I can do this: image3 = StdImageField(upload_to='path/to/img', size=(640, 480)) If there is a better way to do this, please let me know. Edit: Trying it like this, everything is working with the "python manage.py shell...

Psychology researcher wants to learn new language

I'm currently considering R, matlab, or python, but I'm open to other options. Could you help me pick the best language for my needs? Here are the criteria I have in mind (not in order): Simple to learn. I don't really have a lot of free time, so I'm looking for something that isn't extremely complicated and/or difficult to pick up. I ...

How to read from stdin or from a file if no data is piped in Python ?

Hi, I have a CLI script and want him to read data from a file. It should be able to read it in two ways : cat data.txt | ./my_script.py ./my_script.py data.txt A bit like grep, for example. What I know: sys.argv and optparse let me read any args and options easily. sys.stdin let me read data piped in fileinput make the full proce...

How can I write a Python list to persistent storage?

I am currently trying to solve this problem in MySQL. I have MySQLdb installed. What is the best way to write a list in Python, e.g. [1, 2, -1, -2] to a column of a MySQL database table? I would like each consecutive entry of the list to be put into consecutive rows of a MySQL column. I can obviously run individual queries in a loop, ...

Python: How to access parent class object through derived class instance?

I'm sorry for my silly question, but... let's suppose I have this classes: class A(): msg = 'hehehe' class B(A): msg = 'hohoho' class C(B): pass and an instance of B or C. So, how to get the variable 'msg' from the parent's class object through this instance? I've tried this: foo = B() #or C() bar = super(foo.__class__)...

How to notify user when django's custom action doesn't behave as expected?

I am writing a custom action for django admin. This action should only work for records having particular state. For example "Approve Blog" custom action should approve user blog only when blog is not approved. And it must not appove rejected blogs. One option is to filter non approved blogs and then approve them. But there are still...

Design pattern to organize non-trivial ORM queries?

I am developing a web API with 10 tables or so in the backend, with several one-to-many and many-to-many associations. The API essentially is a database wrapper that performs validated updates and conditional queries. It's written in Python, and I use SQLAlchemy for ORM and CherryPy for HTTP handling. So far I have separated the 30-some...

Python - codec encoding ascii to unicode: error

Hi..:) I am trying to go about the process of reversing transliteration of an input file(currently in english) back to its original form(in hindi) A sample or a part of the input file looks like this: E-k- b-u-d-z*dhi-m-aan- p-ksii# E-k- ghn-e- j-ngg-l- m-e-ng E-k- b-h-u-t- UUNNc-aa p-e-dr thaa# U-s- k-ii p-t-z*t-o-ng s-e- l-d-ii shaa...

how to make an axes occupy multiple subplots in python pyplot

I would like to have three plots in single figure. The figure should have a subplot layout of two by two, where the first plot should occupy the first two subplot cells (i.e. the whole first row of plot cells) and the other plots should be positioned underneath the first one in cells 3 and 4. I know that matlab allows this by using the s...

Parse date and format it using python?

Hi, I want to parse a date and change the format using python. Date has the format like 'Mon Feb 15 2010' and i want to change the format into '15/02/2010'. Any one can help me. Thanks in advance. Nimmy ...

Adding class attributes using a for loop in Python

I was trying to generate a class from a dictionary: class attr: for key in objects_type: setattr(attr, key, lambda cl: list()) This gives the error that attr is not defined during the for loop. I know I could write: class attr: pass for key in objects_type: setattr(attr, key, lambda cl: list()) But I am sure I r...

How to init twisted reactor in the right way?

hi, i have a class MyJabber which init a basic jabber account that print the incoming messages to stdout + put them into a queue. The code that add the client to the reactor is this: def addReactor(self): print 'inside AddReactor' factory = client.basicClientFactory(self.jid, self.option['jabber']['password']) print "factory initiali...

How would you solve this GPS/location problem and scale it? Would you use a Database? R-tree?

Suppose I have a people and their GPS coordinates: User1, 52.99, -41.0 User2, 91.44, -21.4 User3, 5.12, 24.5 ... My objective is: Given a set of coordinates, Out of all those users, find the ones within 20 meters. (how to do a SELECT statement like this?) For each of those users, get the distance. As you probably guessed, these co...

showing list item in python

Hello, I want to manipulate feed which contains frequently updated (with time) contents using feed parser. Goal is to show all the contents of the updated feed. import feedparser d = feedparser.parse("some URL") print "Information of user" i = range(10) for i in d: print d.entries[i].summary print " " As parsing data is lis...

moving to Django 1.1 problem

Hi, I'm trying to move from django 1.0.2 to 1.1 and I am getting the following error in one of my templates: Request Method: GET Request URL: http://localhost:8000/conserv/media_assets/vod/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: 'NoneType' object has no attribute ...

Reading a binary file in Python: takes a very long time to read certain bytes.

This is very odd I'm reading some (admittedly very large: ~2GB each) binary files using numpy libraries in Python. I'm using the: thingy = np.fromfile(fileObject, np.int16, 1) method. This is right in the middle of a nested loop - I'm doing this loop 4096 times per 'channel', and this 'channel' loop 9 times for every 'receiver', an...