I can use urllib.request module with Python 3.1. But when I execute the same program using Python 2.7, an error comes along the lines of;
AttributeError: 'module' object has no attribute 'request'.
I believe this error is because theres no request module in urllib for Python 2.7. Because I need to use tweepy i'll have to stick with Py...
hello ,
I'm writing a program using python 2.6 and pyqt4 , i want this program to automatically start whenever i start windows . (something like uTorrent client).so how do i make this work ?i use windows 7
please help
...
I created a simple model and then mapped it to a class using sqlalchemy in pylons:
tag_table = schema.Table('tag', meta.metadata,
schema.Column('id', types.Integer,
schema.Sequence('tag_seq_id', optional=True),
primary_key=True),
schema.Column('name', types.Unicode(20), nullable=False, unique=...
I'm confused about which to use djangoforms.ModelForm or django.forms.Form took djangoforms.ModelForm trying form post, preview and edit with same template. post and edit work. Can you point me to an example with combined FormPreview, GAE SDK and djangoforms.ModelForm usage? I try to avoid patch the latest django and think the SDK comes ...
Hi all,
I am building a system that has dependencies such as Apache, Postgresql, and mod_wsgi. As part of my deployment process, I would like to write a sanity-checking script that tries to determine whether the server environment conforms to various assumptions, the most basic of which is whether the dependencies are installed.
Checks...
I think is is best explained with an example. Suppose I have a method that calculates the distances between two vectors and prints it. I also want that method to print the distance measure that was used. The distance measure is given to the function by the caller in the form of a callable object. If the callable is an instance of some cl...
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do.
I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does?
Eg. I have read that people compare Expect with Awk and also Perl.
Could Awk and Per...
I'm writing a Python program with a GUI built with the Tkinter module. I'm using a class to define the GUI because it makes it easier to pass commands to buttons and makes the whole thing a bit easier to understand.
The actual initialization of my GUI takes about 150 lines of code. To make this easier to understand, I've written the __i...
Basically what I'm trying to do is fetch a couple of websites using proxies and process the data. The problem is that the requests rarely fail in a convincing way, setting socket timeouts wasnt very helpful either because they often didn't work.
So what I did is:
q = Queue()
s = ['google.com','ebay.com',] # And so on
for item in s:
...
I have an authentication script in ejabberd (XMPP server) that based off of THIS LINK
I have slightly modified the script so that instead of setting the variable out, it just returns true or false.
I'm using Ubuntu, MySQL, ejabberd, and Python.
I can authenticate all the records that are already on the database. But, when I add or re...
I have always wondered about this and seen this among lots of programmers. Why is a VB programmer or VB code easily dismissed as too noobish and easy while the same does not apply to Python or Python code? After all, isn't Python as easy as VB is? And it does provide drag-n-drop GUI application building also. So why is it that VB is flam...
I have a script which connects to database and gets all records which statisfy the query. These record results are files present on a server, so now I have a text file which has all file names in it.
I want a script which would know:
What is the size of each file in the output.txt file?
What is the total size of all the files present ...
I have my css file in
/var/www/media/static/style.css
and added
(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': '/var/www/media/static'}),
to my urls but when I go to http://localhost:8000/media/style.css I get: "Page not found: /media/style.css" what is wrong?
...
Hi,
I have a GUI Windows application and I want to control it using the extension Win32gui in Python. How can I find the string s that I must give to the FindWindow function?
I need to use the following code:
import win32gui as gui
gui.FindWindow(s, None)
Thaks!
...
Hi all!
I want to make my Book model belongs to multiple Libraries, Collections, References and Editors, together.
Is it possible to do it with generic relations ?
Like that :
content_type = generic.GenericManyToMany(ContentType)
Thanks.
from django.conf import settings
from django.contrib.contenttypes import generic
from django.con...
I want to keep some global settings for my project in Django. I need to have access to these settings from the code. For example, I need to set a current theme for my site that I can set using admin console or from the code. Or I need to set a tagline that will show in the header of all pages. I suppose I should use models for keeping th...
I've been using Django and Django passes in a request object to a view when it's run. It looks like (from first glance) in Flask the application owns the request and it's imported (as if it was a static resource). I don't understand this and I'm just trying to wrap my brain around WSGI and Flask, etc. Any help is appreciated.
...
Hi there, i'm searching a Python lib with good image processing functionalities .
I was searching for CImg (which i've already used on C++ projects) bindings, but i wasn't lucky.
I found PIL, but it lacks a lot of features that CImg has so, is there any good alternative ?
Thanks
UPDATE
PIL is good, but i need Python 3 support on a Mac...
I'm using python to play with the stackoverflow API. I run the following commands:
f = urllib.request.urlopen('http://api.stackoverflow.com/1.0/stats')
d = f.read()
The type of d is class 'bytes' and if I print it it looks like:
b'\x1f\x8b\x08\x00\x00\x00 .... etc
I tried d=f.read().decode('utf-8') as that is the charset indicated...
For example, c++ have cplusplus.com/reference which contain all of c++ standard library complete with definitions and more importantly examples, so I was wondering if there is such a website for python.
I know that python is self documented, like i could use
help(object)
object.__doc__
dir(object)
I know of
doc.python.org/library
w...