python

How to draw a translucent rectangle on a static text?

Hello, I draw a tranlucent rectangle on my panel but on the places that have static text's the rectangle is not filled. I've drawn rectangles inside each static text but when I do that, the correspondent text doesn't happear. How can I draw a translucent rectangle inside the statix text without making the text disappear? The code is ...

python - Which is the better way to enable/disable logging?

Which is better way to enable/disable logging? 1) Changing log levels, logging.disable(logging.CRITICAL) 2) log = None And logging messages this way, if log: log.info("log message") So that we can avoid unnecessary string constructions in case of logging disabled... ...

unusual django admin behavior when storing string values

Using django trunk r13359 and django piston, I created a small restful service that stores string values. This is the model I am using to store strings: class DataStore(models.Model): data = models.CharField(max_length=200) url = models.URLField(default = '', verify_exists=False, blank = True) I used curl to post following d...

Optimizing operations on lists

I need to process lots of data in lists and so have been looking at what the best way of doing this is using Python. The main ways I've come up with are using: - List comprehensions - generator expressions - functional style operations (map,filter etc.) I know generally list comprehensions are probably the most "Pythonic" method, b...

Why do python statements end with : (colon)?

Possible Duplicate: What is the purpose of the colon before a block in Python? I've just done a bit of research on Python and am intrigued by the language construct. if expression: print 1 ... print 2 I'm surprised and impressed that python group commands for a statement by indentation. It seems as though the de...

(python) recursively remove capitalisation from directory structure?

uppercase letters - what's the point of them? all they give you is rsi. i'd like to remove as much capitalisation as possible from my directory structure. how would i write a script to do this in python? it should recursively parse a specified directory, identify the file/folder names with capital letters and rename them in lowercase. ...

how can I get href links from html code

Hello, import urllib2 website = "WEBSITE" openwebsite = urllib2.urlopen(website) html = getwebsite.read() print html so far so good. But i want only href links from the plain text html. How can i solve this problem? ...

add playlist entry via youtube python api

i am trying to add entries to a playlist in youtube via the code below. when i pass the playlist uri (http://gdata.youtube.com/feeds/api/users/nashrafeeg/playlists/0F4EF4B14F514476?client=Reddit+playlist+maker) to AddPlaylistVideoEntryToPlaylist method i get from the get playlist method i get error saying Invalid request URI. what is th...

Where shall I start in making a scraper or a bot using python?

I'm not that new in programming languages(python) but I got no clue on where will I start in making a bot or a scrapper using python?. should I study in cgi programming? or does the scrapper runs just using a python script? Should I build a server for that? Got no clue for this... thanks for the help ...

Call the Python interactive interpreter from within a Python script

Is there any way to start up the Python interpreter from within a script , in a manner similar to just using python -i so that the objects/namespace, etc. from the current script are retained? The reason for not using python -i is that the script initializes a connection to an XML-RPC server, and I need to be able to stop the entire prog...

Force download of files on App Engine

How would I go about forcing the browser to download media files instead of attempting to stream them? These are static files in my application directory. ...

HTTP Banner Grabbing with Python

Hi, everyone. I am interested in making an HTTP Banner Grabber, but when i connect to a server on port 80 and i send something (e.g. "HEAD / HTTP/1.1") recv doesn't return anything to me like when i do it in let's say netcat.. How would i go about this? Thanks! ...

How to update facebook via python

Possible Duplicate: Update Facebooks Status using Python Please help i need working code that can update my facebook status using a user name and password. ...

Pylons: Proper Way to Establish Per-Thread/Per-Request Resource?

I have a connection to an external resource that I need to make for my Pylons app (think along the lines of a database connection.) There is a modest amount of overhead involved in establishing the connection. I could setup a piece of middleware that opens and closes the connection with every request but that seems wasteful. I'd like to...

How to make django messages StackOverflow style?

I'd like to use Django's Messages module, however, I would like my messages to persist until the user clicks an X next to the message as opposed to having messages disappear as soon as the user reloads the page. I am stumped with two issues: How do I make the messages' context processor not delete the messages once they are accessed? Ho...

how to introspect a couchdb document for its set of fields via couchdb-python

How can I get the fields for a couchdb document? I'm thinking of how to use couchdb-python, and often will not know the complete set of fields for a document. I haven't seen anything about how to introspect a document in the docs. What's the best way? If the document was a python object I would query object.__dict__ for its attributes...

Python virtual classes: doing it right ?

I have been reading documentation describing class inheritance, abstract base classes and even python interfaces. But nothing seams to be exactly what I want. Namely, a simple way of building virtual classes. When the virtual class gets called, I would like it to instantiate some more specific class based on what the parameters it is giv...

How can I read all availably data from subprocess.Popen.stdout (non blocking)?

Hi, I need a way to either read all currently available characters in stream created by Popen or to find out how many characters are left in the buffer. Backround: I want to remote control an interactive application in Python. So far I used Popen to create a new subprocess: process=subprocess.Popen(["python"],shell=True,stdin=subproce...

What is the difference between these two solutions - lambda or loop - Python

I want to calculate the sum of even numbers within a domain. I have two solutions, but I'm not sure of the advantages/disadvantages of each. Which is the optimal solution? import sys domain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Cal1 = sum(filter(lambda n : n % 2 == 0, domain)) Cal2 = sum([n for n in domain if n % 2 == 0]) sys.stdout.write("...

akntextutils installation on mobile

i tried to use akntextutils which ran successfully on emualator but trying to run this on mobile device is a problem... we using python 1.4.5 with a 2nd edition FP2 can u help us in this... ...