What are some advantages and disadvantages to doing statistical analyses in SciPy vs. R? They seem to have been designed with opposite philosophies (plain old library vs. DSL). What are some rules of thumb about which is the right tool for the job?
...
Hi, I'm trying to create a simple unique username function for use in a Formencode schema. Here is the function:
class UniqueUsername(formencode.FancyValidator):
def _to_python(self, value, state):
user = DBSession.query(User.user_name).filter(User.username==value)
if user is not None:
raise form...
My package have the following structure:
mobilescouter/
__init__.py #1
mapper/
__init__.py #2
lxml/
__init__.py #3
vehiclemapper.py
vehiclefeaturemapper.py
vehiclefeaturesetmapper.py
...
basemapper.py
vehicle/
__init__.py #4
vehic...
i know this code is right
class A:
def __init__(self):
self.a = 'a'
def method(self):
print "method print"
a = A()
print getattr(a, 'a', 'default')
print getattr(a, 'b', 'default')
print getattr(a, 'method', 'default')
getattr(a, 'method', 'default')()
but the next is wrong,
dose __getattr...
I have a basic chat server which I can easily connect to with telnet. I simply enter the host and port and, without any further authentication, can begin entering commands that the server can interpret. In an effort to simulate user traffic, I would like to create a script that will open telnet, connect to the server, and immediately beg...
Python 2.6 defines str.format(…), which, from Python 3.0, is preferred to the old % style of string formatting. Looking at the "mini-language", however, it seems that it is impossible to use the } character as a fill character.
This seems like a strange omission to me. Is it possible to somehow escape that character and use it as a fill...
In Django I get this error "Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format." when I try to assign a string "22-DEC-2009" to a DateTimeField in a model.
How is it possible to make DateTimeField accept a date string in format "22-DEC-2009"?
...
def makeActions():
acts=[]
for i in range(5):
print len(acts)
acts.append(lambda x: i ** x)
print acts[i]
return acts
acts=makeActions()
for i in range(5):
print acts[i](2)
Output:
16
16
16
16
16
Expected output:
0
1
4
9
16
...
Hello, this is first post here and I am a noob programmer.
This may be a stupid question.
I'd like to create a personal Twitter notifier on GNOE Desktop. And I've decided to use pynotify and Tweepy.
Now I just want to make pynotify show Twitter user's icon, and there seems to be 2 ways using pynotify; setting URI to local image file, or...
Hello, I have a product list that put 3 products on a row and clears the row and adds another 3, this works fine everywhere but IE6, i know that adding <div> around each group of 3 products will solve this is the template file at the moment
{% for product in category.products.all %}
<div class="{% cycle 'clear' '' '' %}">
<a ...
Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with.
Python does support some functional programming constructs.
Was thinking of revisiting Functional Programming. What would be a better language to code?...
I have a python class working in zope 3 zcml kind of way, but i want to move the python into a standalone script that a could access via something along the lines of tal:content='context/get_tags'. This is the code as it stands:
class TagListView(BrowserView):
def getCategories(self):
categories = set()
for cat in self.portal_c...
Hello,
The below code will not join, when debugged the command does not store the whole path but just the last entry.
os.path.join('/home/build/test/sandboxes/', todaystr, '/new_sandbox/')
When I test this it only stores the '/new_sandbox/' part of the code.
Can anyone help.
Thanks
...
When I run the code below it removes deleted_partner from B. But as it removes it from B it also removes it from A. So that when I try to remove it from A the program crashes. What is the problem?
for deleted_partner in self.list_of_trading_partners:
B = A[:]
print("t", deleted_partner)
print(B[self.ID].list_of_trading_part...
Hello,
How can I control the mouse and the keyboard in python?
The idea is to do the same as the Robot() class in java. Be able to say : move the mouse from here to here, clic there, write that whatever is on the screen.
For windows there is win32api but I'm using mainly linux
For linux there is Xlib but does it works for keyboard as...
I would like to provide my Python GAE website in the user's own language, using only the tools available directly in App Engine. For that, I would like to use GNU gettext files (.po and .mo files).
Has someone successfully combined Python Google App Engine and gettext files? If so, could you please provide the steps you used?
I had st...
A part of my web app involves creating 'appointments' (shifts) using a drag-and-drop selector for each day. Currently, this data is serialized to something like this:
9,10,11,12,13,14,15,16,76,77,78,298,299,300,301,302,303,304,
Where each number represents the nth half-hour of the week (so 304 is the 300th half-hour of the week, or 8a...
The following code in one of my views returns unescaped html string which cannot be parsed in frontend since it is an Ajax request.
return render_to_response(template_name, {
'form': form,
redirect_field_name: redirect_to,
'site': current_site,
'site_name': current_site.name,
}, context_instance=Reque...
How would you make the give code more Pythonic?
I want to get Paths out of the sample like /usr/local/sources/devel/algebra.py: def _alg(...) without the character :.
My code
import os
FunctionPath = "/usr/local/sources/devel/sage-main/build/sage/"
cmd = "grep -R 'def ' %s | cut -d' ' -f1" % (FunctionPath)
cmd += ' &'
raw_path = os.sy...
Possible Duplicate:
Convert hex string to int in Python
Hello, I want to use some string like "0xFF123456" as a 32-bit unsigned integer.
Please give me some advice.
Thanks.
...