I need to store the content of a site that can be in any language. And I need to be able to search the content for a Unicode string.
I have tried something like:
import urllib2
req = urllib2.urlopen('http://lenta.ru')
content = req.read()
The content is a byte stream, so I can search it for a Unicode string.
I need some way that wh...
I need to write a Python script that can run another command line program and interact with it's stdin and stdout streams. Essentially, the Python script will read from the target command line program, intelligently respond by writing to its stdin, and then read the results from the program again. (It would do this repeatedly.)
I've loo...
Is there a well maintained package available in Python for creating and validating HTML forms? I will deploying it finally on Google Appengine.
...
I'm changing some classes of mine from an extensive use of getters and setters to a more pythonic use of properties.
But now I'm stuck because some of my previous getters or setters would call the corresponding method of the base class, and then perform something else. But how can this be accomplished with properties? How to call the pr...
I am writing a daemon program that spawns several other children processes. After I run the stop script, the main process keeps running when it's intended to quit, this really confused me.
import daemon, signal
from multiprocessing import Process, cpu_count, JoinableQueue
from http import httpserv
from worker import work
class Manager:...
okay folks...thanks for looking at this question. I remember doing the following below in college however I forgotten the exact solution. Any takers to steer in the right direction.
I have a time series of data (we'll use three) of N. The data series is sequential in order of time (e.g. obsOne[1] occurred along with obsTwo[1] and obs...
I would like to write a python script that would generate a 3d captcha like this one:
Can you please tell me which graphics librarys I can use?
Thanks!
Source: ocr-research.org.ua
...
Is it possible, using pywikipedia, to get just the text of the page, without any of the internal links or templates & without the pictures etc.?
Cheers!
...
Is there a possibility to check if two python functions are interchangeable? For instance, if I have
def foo(a, b):
pass
def bar(x, y):
pass
def baz(x,y,z):
pass
I would like a function is_compatible(a,b) that returns True when passed foo and bar, but False when passed bar and baz, so I can check if they're interchangeable...
I receive as input a list of strings and need to return a list with these same strings but in randomized order. I must allow for duplicates - same string may appear once or more in the input and must appear the same number of times in the output.
I see several "brute force" ways of doing that (using loops, god forbid), one of which I'm ...
Hi
I'm using Notepad++ as an editor to write programs in Python. It might sound daft but I looked around in the editor and could not find any means (not the manual way but something like in Emacs) to do a block comment in my code.
Since so many language settings are supported in Notepad++, I'm curious to find a way to block comment cod...
In trying to capitalize a string at separators I encountered behavior I do not understand. Can someone please explain why the string s in reverted during the loop? Thanks.
s = 'these-three_words'
seperators = ('-','_')
for sep in seperators:
s = sep.join([i.capitalize() for i in s.split(sep)])
print s
print s
stdo...
Hi!
Is there any way to edit StringListProperty fields via Google's Data Viewer, or some other clever approach?
The last I want to do is to modify my application in such way that it provides special throwaway page for just that reason - I don't feel like it's the optimal solution.
Cheers,
MH
...
I have some IronPython code which makes use of XmlTextWriter which allows me to write code like
self.writer = System.Xml.XmlTextWriter(filename, None)
self.writer.Formatting = Formatting.Indented
self.writer.WriteStartElement(name)
self.writer.WriteString(str(text))
self.writer.WriteEndElement()
...
self.writer.Close()
I would like ...
Hi, I am used to that Python allows some neat tricks to delegate functionality to other objects. One example is delegation to contained objects.
But it seams, that I don't have luck, when I want to delegate __contains __:
class A(object):
def __init__(self):
self.mydict = {}
self.__contains__ = self.mydict.__contains_...
It looks like http://portland.beerandblog.com/feed/atom/ is messed up (as are the 0.92 and 2.0 RSS feeds).
Universal Feed Parser (latest version from http://code.google.com/p/feedparser/source/browse/trunk/feedparser/feedparser.py?spec=svn295&r=295 ) doesn't see any dates.
<title>Beer and Blog Portland</title>
<atom:link ...
I was reading about the Weighted slope one algorithm ( and more
formally here (PDF)) which is supposed to take item ratings from different users and, given a user vector containing at least 1 rating and 1 missing value, predict the missing ratings.
I found a Python implementation of the algorithm, but I'm having a hard time porting it t...
How do I set Perl's %ENV to introduce a Perl script into the context of my web application?
I have a website, written in a language different from Perl (Python). However I need to use a Perl application, which consists of a .pl file:
#!/usr/bin/env perl
"$ENV{DOCUMENT_ROOT}/foo/bar.pm" =~ /^(.+)$/;
require $1;
my $BAR =...
When finding web hosting for Rails apps, the hoster must have support for ruby on rails -- that is evident. What about hosting for Django? What support does the hoster need to provide? Python, or more than just Python?
This might seem like an obvious question, but I'm new to web development frameworks so I must ask :)
...
I've got a pretty strong background in C-style languages. And have worked on several different types of projects. I have just started taking a serious look at Python after reading Programming Collective Intelligence. I understand that Python can solve any problem that C# can, and vice-versa. But I am curious to know from those who us...