python

what is the simplest way to create a table use django db api ,and base on 'Standalone Django scripts'.

we can call this 'Standalone Django table' i am not successful now . can you ??? thanks if you don't know 'Standalone Django scripts', look this http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ 2.this is my code: from django.core.management import setup_environ from sphinx_test import settings setup_environ(...

Method of Multiple Assignment in Python

I'm trying to prepare for a future in computer science, so I started with ECMAScript and I am now trying to learn more about Python. Coming from ECMAScript, seeing multiple assignments such as a, b, c = 1, 2, 3 leaves me bewildered for a moment, until I realize that there are multiple assignments going on. To make things a bit clearer, I...

How to approach Google groups discussions crawler

Hi, as an exercise in RSS I would like to be able to search through pretty much all Unix discussions on this group. comp.unix.shell I know enough Python and understand basic RSS, but I am stuck on ... how do I grab all messages between particular dates, or at least all messages between Nth recent and Mth recent? High level description...

Python memory usage? loading large dictionaries in memory

hey all, I have a file on disk that's only 168MB. It's just a comma separated list of word,id the word can be 1-5 words long. There's 6.5 million lines. I created a dictionary in python to load this up into memory so I can search incoming text against that list of words. When python loads it up into memory it shows 1.3 GB's of RAM space ...

Building an Inference Engine in Python

I am seeking direction and attempting to label this problem: I am attempting to build a simple inference engine (is there a better name?) in Python which will take a string and - 1 - create a list of tokens by simply creating a list of white space separated values 2 - categorise these tokens, using regular expressions 3 - Use a highe...

How to implement an efficient infinite generator of prime numbers in Python?

This is not a homework, I am just curious. INFINITE is the key word here. I wish to use it as for p in primes(). I believe that this is a built-in function in Haskell. So, the answer cannot be as naive as "Just do a Sieve". First of all, you do not know how many consecutive primes will be consumed. Well, suppose you could concoct 100...

optional arguments when calling a function without modifying function definition

I want to know how to call a function, passing a parameter that it might not be expecting. I faced this problem a few days ago, and found a way around it. But today, I decided I'd see if what I wanted to do was possible. Unfortunately, I don't remember the context which I used it in. So here is a stupid example in which there are plenty...

python virtualbox API

please give some suggestions on how to control virtualbox from commandline from a python program using python virtualbox API.if u know any useful website ,please give its address ...

Counting the Number of keywords in a dictionary in python

I have a list of words in a dictionary with the value = the repetition of the keyword but I only want a list of distinct words so i wanted to count the number of keywords. Is there a to count the number of keywords or is there another way I should look for distinct words? ...

Python recursive folder read

I have a C++/Obj-C background and I am just discovering Python (been writing it for about an hour). I am writing a script to recursively read the contents of text files in a folder structure. The problem I have is the code I have written will only work for one folder deep. I can see why in the code (see #hardcoded path), I just don't kn...

virtualbox and python API

0 vote down I have installed virtualbox . but i cant import the module xpcom. but the synaptic package shows that it is installed. what could be wrong? -ASK ...

Python: Why is IDLE so slow?

Hi, IDLE is my favorite Python editor. It offers very nice and intuitive Python shell which is extremely useful for unit-testing and debugging, and a neat debugger. However, code executed under IDLE is insanely slow. By insanely I mean 3 orders of magnitude slow: bash time echo "for i in range(10000): print 'x'," | python Takes 0.0...

Python IRC Client

When I run the script: import socket from time import strftime time = strftime("%H:%M:%S") irc = 'irc.tormented-box.net' port = 6667 channel = '#tormented' sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((irc, port)) print sck.recv(4096) sck.send('NICK supaBOT\r\n') sck.send('USER supaBOT supaBOT supaBOT :supaBOT S...

pros and cons: php vs python

Possible Duplicate: Python VS PHP, Differences? Am starting a new project, and although I'm proficient with PHP, I'm wondering what are the pros and cons of python over php. In what situation or what kind of projects where python shines over php and when it's not? ...

pyparsing question

This code works: from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234", "! sfs" ] for t in tests: try: results = query.parseString( t ) print t,"->", results except ParseEx...

Python regex for reading CSV-like rows

I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row: data1, data2 ,"data3'''", 'data4""',,,data5, but this one is malformed: data1, data2, da"ta3", 'd...

How to create a scrollable screen in text mode with Python

I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this? For example: >>> def jhelp(object): >>> text = # get text for object >>> display_text(text) # display a scrollable screen. How do I do t...

What is a nicer alternative to a namedtuples _replace?

Take this code: >>> import urlparse >>> parts = urlparse.urlparse('http://docs.python.org/library/') >>> parts = parts._replace(path='/3.0'+parts.path) parts._replace works but as it is an underscored method, it's supposed to be internal, and not used. Is there an alternative? I don't want to do: >>> parts = parts[:2] + ('/3.0'+parts...

Reading request parameters in Python

Hi All I am very new to python and having to get into this stuff for a simple program to integrate with an ASP.NET application that I am building. The pseudo code is as follows. Get two parameters from request. (A ASP.NET will be calling this url by POST and sending two parameters) Internally execute some business logic and build some...

Access a subset of functions of a Python class

Using a class that has an xmlrpc proxy as one of it's object's properties def __init__(self): self.proxy = ServerProxy(...) # ... I'm trying to ease the use of some of the proxy's functions. Only a subset of the proxy functions are supposed to be used and I thus thought of creating a set of tiny wrapper functions for them like...