I'm working on a little script to help me learn the Japanese Kana (Hiragana/Katakana). In total, there are probably 100+ (+||-).
Basically, all it would do is take in the english version and convert it to the character.
ie. a = 'あ' which is 12354 in decimal
What I have so far is this:
hiraDict = { "a" : 12354, "i" : 12356 ...}
if ...
I was reading about Go, and I can see that it's very good and can be a language used by many developers in some months, but I want to decide a simple thing: Learn Go or improve my Python or Ruby knowledge?
Years developing with Python: 1
Years developing with Ruby: 0.3
...
I am making several http requests to a particular host using python's urllib2 library. Each time a request is made a new tcp and http connection is created which takes a noticeable amount of time. Is there any way to keep the tcp/http connection alive using urllib2?
...
Hi guys, I'm getting an error when trying to execute python program that uses multiprocessing package:
File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock
return RLock()
File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__
SemLock.__init__(self, RECURSIVE_MUTEX, 1,...
import re
from decimal import *
import numpy
from scipy.signal import cspline1d, cspline1d_eval
import scipy.interpolate
import scipy
import math
import numpy
from scipy import interpolate
Y1 =[0.48960000000000004, 0.52736099999999997, 0.56413900000000006, 0.60200199999999993, 0.64071400000000001, 0.67668...
Closures are an incredibly useful language feature. They let us do clever things that would otherwise take a lot of code, and often enable us to write code that is more elegant and more clear. In Python, closures are read-only affairs; that is, a function defined inside another lexical scope cannot change variables outside of its local...
I'm trying to think about how a Python API might look for large datastores like Cassandra. R, Matlab, and NumPy tend to use the "everything is a matrix" formulation and execute each operation separately. This model has proven itself effective for data that can fit in memory. However, one of the benefits of SAS for big data is that it ...
When working in interactive python, I tend to rely on the builtin help() function to tell me what something expects and/or returns, and print out any documentation that might help me. Is there a ruby equivalent to this function?
EDIT
I'm looking for something I could use in irb. For example in interactive python I could type
>>> help(1...
I'm running a py2exe-compiled python program from one server machine on a number of client machines (mapped to a network drive on every machine, say W:).
For Windows XP and later machines, have so far had zero problems with Python picking up W:\python23.dll (yes, I'm using Python 2.3.5 for W98 compatibility and all that). It will then ...
I [surely re] invented this [wheel] when I wanted to compute the union and the intersection and diff of two sets (stored as lists) at the same time. Initial code (not the tightest):
dct = {}
for a in lst1:
dct[a] = 1
for b in lst2:
if b in dct:
dct[b] -= 1
else:
dct[b] = -1
union = [k for k in dct]
inter = [k for k in dct...
Hi Folks,
I'm getting seriously frustrated at how slow python startup is. Just importing more or less basic modules takes a second, since python runs down the sys.path looking for matching files (and generating 4 stat() calls - ["foo", "foo.py", "foo.pyc", "foo.so"] - for each check). For a complicated project environment, with tons o...
I have a text-box which allows users to enter a word.
The user enters: über
In the backend, I get the word like this:
def form_process(request):
word = request.GET.get('the_word')
word = word.encode('utf-8')
#word = word.decode('utf-8')
print word
For some reason, I cannot decode or encode this!!
It gives me the err...
import itertools
print itertools#ok
the code is ok
but i can't find the itertools file.
who can tell me where is the 'itertools file'
my code is run python2.5
import itertools
print itertools.__file__
Traceback (most recent call last):
File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in <module>
print itertools.__file__
A...
I have two files:
metadata.csv: contains an ID, followed by vendor name, a filename, etc
hashes.csv: contains an ID, followed by a hash
The ID is essentially a foreign key of sorts, relating file metadata to its hash.
I wrote this script to quickly extract out all hashes associated with a particular vendor. It craps out before it fin...
Using SQLAlchemy, I have a one to many relation with two tables - users and scores. I am trying to query the top 10 users sorted by their aggregate score over the past X amount of days.
users:
id
user_name
score
scores:
user
score_amount
created
My current query is:
top_users = DBSession.query(User).opt...
Hi all,
I know this is really basic, but I am really trying to learn Python and want to learn it to scrape data from the web. It may be basic, but I really am trying to learn how to read a HTML table. I can read it into Open Office and it says that it is Table #11.
It seems like BeautifulSoup is the preferred choice, but can anyone...
A python program that I'm debugging has the following code (including print statements for debugging):
print "BEFORE..."
print "oup[\"0\"] = " + str(oup["0"])
print "oup[\"2008\"] = " + str(oup["2008"])
print "oup[\"2009\"] = " + str(oup["2009"])
oup0 = oup["0"]
oup2008 = oup["2008"]
oup2009 = oup["2009"]
ouptotal = oup2008 + oup2009
p...
I'm using PyCrypto (on google app engine) for AES encryption.
PyCrypto gives I guess a raw interface to AES--i need to pad my keys and my inputs to 16 byte multiples.
Is there a higher level library which takes care of this stuff for me?
...
in django.utils.funcitonal.py:
for t in type(res).mro():#<-----this
if t in self.__dispatch:
return self.__dispatch[t][funcname](res, *args, **kw)
i don't understand mro
i search by google,and saw much english Article,but i still can't anderstand it,
who can give me a simple example ,thanks...
This has always bothered me, and I've never really come up with my own preferred way of doing this.
When importing something from one of your own applications in a django project, do you import with:
from myproject.mymodule.model import SomeModel
from myproject.anotherone.model import AnotherModel
or, do you do:
from mymodule.model ...