I have a wrapper function that returns a function. Is there a way to programmatically set the docstring of the returned function? If I could write to __doc__ I'd do the following:
def wrapper(a):
def add_something(b):
return a + b
add_something.__doc__ = 'Adds ' + str(a) + ' to `b`'
return add_something
Then I could...
The string contains one or more "@" symbols. One or more of those symbols must have a character after it (not a space).
...
Write a function spaced(s) that outputs spaces and a dashdot border around a string s.
The sample code, which calls spaced("Hello") would output:
--.-.-.-.-
. .
- Hello -
. .
-.-.-.-.-.
Please help me out with this :D. Im new to programming and im trying to learn this stuff. I dont have any programming ...
App Engine provides a way to set the current "namespace". Is this a way to be able to easily reference variables, and thus not always have to insert database lookups in one's code?
...
db.mycollection.find(HAS IMAGE URL)
...
I need a query that can return the records from table A that have greater than COUNT records in table B. The query needs to be able to go in line with other filters that might be applied on table A.
Example case study:
I have a person and appointments table. I am looking for all people who have been in for 5 or more appointments. It mu...
I'm writing an immutable linked list class in C, but one method is mysteriously segfaulting. The code is intended to be roughly equivalent to this:
class PList(object):
def __init__(self, first, rest=None):
self.first = first
self.rest = rest
def cons(self, item):
return PList(item, self)
Here is my c...
What's wrong with this implementation of the Durand-Kerner algorithm (here) ?
def durand_kerner(poly, start=complex(.4, .9), epsilon=10**-16):#float('-inf')):
roots = []
for e in xrange(poly.degree):
roots.append(start ** e)
while True:
new = []
for i, r in enumerate(roots):
new_r = r - (p...
has any app engine already do this ?
thanks
...
Im an emacs newbie, I want emacs to be able to indent my code like this
egg = spam.foooooo('vivivivivivivivivi')\
.foooooo('emacs', 'emacs', 'emacs', 'emacs')
It's not possible to do this automatically by default (without manually inserting spaces or C-c >), since emacs always indents 4 spaces (unless Im splitting multiple a...
I'm coming from a javascript backend to Python and I'm running into a basic but confusing problem
I have a string that can contain a value of either 'left', 'center', or 'right'. I'm trying to test if the variable contains either 'left' or 'right'.
In js its easy:
if( str === 'left' || str === 'right' ){}
However, in python I get a ...
i seem like this :
class myData(db.Model):
today= db.DateTimeProperty()
how to set 'today' to now time for Per hour ,not using open the webpage ?
thanks
...
I'm writing a python applet for data acquisition from scientific instruments and I'm trying to figure out the best way to manage my device "drivers".
Each driver is represented by a separate python module in the package that is my program. They each implement some standard interface, but mostly it's a gigantic list of commands (and func...
Hi at all friends :)
I have a problem with a control inside a wx.Panel.
With my code the wx.GenericDirCtrl inside a wx.Panel don't fit in all directions in the Panel (or fit only in a direction if I use wx.BoxSizer).
I use an istance of MyPanel in a wx.Frame.
How I can solve it? Thanks
The code is:
class MyPanel(wx.Panel):
def __ini...
Hi,
how do I put my menu bar buttons on menu bar's left ? Right now I pack() them with side=LEFT but still they're in the middle. Here's the code for my menu bar: http://pastebin.com/bgncELcb
...
Hi I have a form class which looks like below:-
class UserCreateForm(wtf.Form):
name=wtf.TextField('Name',validators=[validators.Required(),username_check])
email=wtf.TextField('Email')
userimage=wtf.FileField(u'Upload Image',validators=[checkfile])
The custom validator function " checkfile" looks like this:-
def checkfi...
Hi,
I need to get data from JSON, transfered by ajax from client. Basically I used something like this:
@route('/ajax')
def serve_ajax():
return main.parse_request(json.dumps(dict(request.GET)))
Where main.parse_request is a function, that contains some logics to deal with variables in JSON (it is a main procedure of our game engi...
According to the documentation:
The configuration file consists of
sections, led by a [section] header
and followed by name: value entries,
with continuations in the style of RFC
822 (see section 3.1.1, “LONG HEADER
FIELDS”); name=value is also accepted.
Python Docs
However, writing a config file always use the equal si...
I am sending a POST request to a URL. It works correctly in python but in php-curl, I always get a bad request error (i.e. my POST data is not as expected by the server)
Python code: (works correctly. 200 OK)
import httplib, urllib, json
def SendRequest(param1):
url = "api.xyz.com"
body = {"version": "1.0", "data":[{"param1":p...
I'm a full time c# developer, but I want to get more into Python. At the same time, I have a friend who will learn it with me, he however has no programming knowledge.
I was thinking about starting with some visual programming. I.E: having buttons, labels and text boxes on a form.
Does some kind of IDE exist which allows you to very ...