python

Python: How to find presence of every list item in string

Hi, What is the most pythonic way to find presence of every directory name ['spam', 'eggs'] in path e.g. "/home/user/spam/eggs" Usage example (doesn't work but explains my case): dirs = ['spam', 'eggs'] path = "/home/user/spam/eggs" if path.find(dirs): print "All dirs are present in the path" Thanks ...

Python MySQL - SELECTs work but not DELETEs?

Hey -- I'm new to Python and Python's MySQL adapter. I'm not sure if I'm missing something obvious here: db = MySQLdb.connect(# db details omitted) cursor = self.db.cursor() # WORKS cursor.execute("SELECT site_id FROM users WHERE username=%s", (username)) record = cursor.fetchone() # DOES NOT SEEM TO WORK cursor.execute("DELETE FROM ...

Simple file transfer over wifi between computer and mobile phone using python

I'd like to be able to transfer files between my mobile phone and computer. The phone is a smartphone that can run python 2.5.4 and the computer is running windows xp (with python 2.5.4 and 3.1.1). I'd like to have a simple python program on the phone that can send files to the computer and get files from the computer. The phone end...

Simple scraping of youtube xml to get a Python list of videos

I have an xml feed, say: http://gdata.youtube.com/feeds/api/videos/-/bass/fishing/ I want to get the list of hrefs for the videos: ['http://www.youtube.com/watch?v=aJvVkBcbFFY', 'ht....', ... ] ...

Detecting symlinks (mklink) on Vista/7 in Python without Pywin32

Currently the buildout recipe collective.recipe.omelette uses junction.exe on all versions of Windows to create symlinks. However junction.exe does not come with Windows by default and most importantly does not support creating symlinks to files (only directories) which causes a problem with quite a few Python packages. On NT6+ (Vista a...

Python - Writing pseudocode?

How would you write pseudocode for drawing an 8-by-8 checkerboard of squares, where none of the squares have to be full? (Can all be empty) I don't quite get the pseudocode concept. ...

TurtleGraphics Python - Constraining random-moving turtle in a circle?

How would I be able to make a randomly moving turtle be constrained inside a circle with a radius of 50, the circles center being at (0, 0)? So if the turtle is currently at location (x, y), it's distance from the center is math.sqrt(x ** 2 + y ** 2). Whenever the turtle's distance from the center is more than 50, have it turn around and...

Evaluation of boolean expressions in Python

What truth value do objects evaluate to in Python? Related Questions Boolean Value of Objects in Python: Discussion about overriding the way it is evaluated ...

What kind of applications are built using Python?

Dear Stackoverflow Readers, I wanted to know Python is suited for what kind of applications? I am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information. Than...

How to rapidly build a Web Application?

To build a Web Application, what kind of open source web application frameworks / technologies are currently present that would be: Faster to learn. Ease of use. Have widgets for rapid development(From a GUI perspective). Database integration. I would want this web app to communicate to a Java client. I am not bound to Java ...

Creating Simultaneous Loops in Python

I want to create a loop who has this sense: for i in xrange(0,10): for k in xrange(0,10): z=k+i print z where the output should be 0 2 4 6 8 10 12 14 16 18 ...

RTSP library in Python or C/C++ ?

I am trying to find any RTSP streaming library for Python or C/C++. If not is there any other solutions for real time streaming? How much easy or difficult it is to implement RTSP in Python or C/C++ and where to get started? ...

Is there an C++ equivalent to Python's "import bigname as b"?

I've always liked Python's import big_honkin_name as bhn so you can then just use bhn.thing rather than the considerably more verbose big_honkin_name.thing in your source. I've seen two type of namespace use in C++ code, either: using namespace big_honkin_name; // includes fn(). int a = fn (27); (which I'm assured is a bad thing) ...

What is the meaning of #XXX?

I have seen this a lot in code, even vim marks it as a special case. #TODO and #FIXME are two other fix markers vim highlights but what does #XXX means? ...

Why doesn't a python dict.update() return the object?

I 'm trying to do : award_dict = { "url" : "http://facebook.com", "imageurl" : "http://farm4.static.flickr.com/3431/3939267074_feb9eb19b1_o.png", "count" : 1, } def award(name, count, points, desc_string, my_size, parent) : if my_size > count : a = { "name" : name, "description" : desc_st...

Should I create mapper objects or use the declarative syntax in SQLAlchemy?

There are two (three, but I'm not counting Elixir, as its not "official") ways to define a persisting object with SQLAlchemy: Explicit syntax for mapper objects from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy.orm import mapper metadata = MetaData() users_table = Table('users', metadata, ...

Python HTTPS client with basic authentication via proxy

From Python, I would like to retrieve content from a web site via HTTPS with basic authentication. I need the content on disk. I am on an intranet, trusting the HTTPS server. Platform is Python 2.6.2 on Windows. I have been playing around with urllib2, however did not succeed so far. I have a solution running, calling wget via os.syste...

Django: use archive_index with date_field from a related model

Hello (please excuse me for my ugly english :p), Imagine these two simple models : from django.contrib.contenttypes import generic from django.db import models class SomeModel(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField(_('object id')) content_object = generic.Generi...

Programming libraries!

Specifically within Python (may extend to C and Java), what is the paramount library that every programmer should know how to use and why? ...

How to filter query in sqlalchemy by year (datetime column)

I have table in sqlalchemy 0.4 that with types.DateTime column: Column("dfield", types.DateTime, index=True) I want to select records, that has specific year in this column, using model. How to do this? I though it should be done like this: selected_year = 2009 my_session = model.Session() my_query = my_session.query(model.MyRecord)....