I'm having a problem passing strings that exceed 80 characters in JSON. When I pass a string that's exactly 80 characters long it works like magic. But once I add the 81st letter it craps out. I've tried looking at the json object in firebug and it seems to think the string is an array because it has an expander next to it. Clicking the ...
I use the following snippet to drop into a Python shell mid-program. This works fine, but I only get the standard console. Is there a way to do the same but using the IPython shell?
import code
class EmbeddedConsole(code.InteractiveConsole):
def start(self):
try:
self.interact("Debug console starting...")
...
I've created a method that generates a new class and adds some methods into the class, but there is a strange bug, and I'm not sure what's happening:
def make_image_form(image_fields):
''' Takes a list of image_fields to generate images '''
images = SortedDict()
for image_name in image_fields:
images[image_name] = fo...
On the intranet at my part time job (not IT related) there are various web applications that we use that do not require logging in explicitly. We are required to login to Windows obviously, and that then authenticates us some how.
I'm wondering how this is done? Without worrying about security TOO much, how would I go about authenticati...
I am trying to have some clever dates since a post has been made on my site ("seconds since, hours since, weeks since, etc..") and I'm using datetime.timedelta difference between utcnow and utc dated stored in the database for a post.
Looks like, according to the docs, I have to use the days attribute AND the seconds attribute, to get t...
Is there an existing function in numpy that will tell me if a value is either a numeric type or a numpy array? I'm writing some data-processing code which needs to handle numbers in several different representations (by "number" I mean any representation of a numeric quantity which can be manipulated using the standard arithmetic operato...
I'm using Reportlab to generate report cards. The report cards are basically one big Table object. Some of the content in the table cells needs to wrap, specifically titles and comments, and I also need to bold certain elements.
To accomplish both the wrapping and ability to bold, I'm using Paragraph objects within the Table. My tabl...
I'm trying to figure out how to implement my first RESTful interface using Django and django-rest-interface. I'm having problems with the HTTP PUT requests.
How do I access the parameters of the PUT request?
I thought they would be in the request.POST array, as PUT is somewhat similar to POST in my understanding, but that array is alwa...
Is there a built-in method in Python to execute a system command without displaying the output? I only want to grab the return value.
It is important that it be cross-platform, so just redirecting the output to /dev/null won't work on Windows, and the other way around. I know I can just check os.platform and build the redirection myself...
I have a generator and I would like to know if I can use it without having to worry about StopIteration , and I would like to use it without the for item in generator . I would like to use it with a while statement for example ( or other constructs ). How could I do that ?
...
First of all,I'm not into web programming. I bumped into django and read a bit about models. I was intrigued by the following code ( from djangoproject.com ) :
class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
def __str__(self):
# Note use of django...
There's no much documentation on how to deploy a Django project with Spawning and yet people are recommending it over apache/mod_wsgi.
In another similar question, other SO user suggested me to open a new question specific to Spawning, so hopefully others can share their experiences too.
...
In Python, I can compile a regular expression to be case-insensitive using re.compile:
>>> s = 'TeSt'
>>> casesensitive = re.compile('test')
>>> ignorecase = re.compile('test', re.IGNORECASE)
>>>
>>> print casesensitive.match(s)
None
>>> print ignorecase.match(s)
<_sre.SRE_Match object at 0x02F0B608>
Is there a way to do the same, bu...
while learning some basic programming with python, i found web.py. i
got stuck with a stupid problem:
i wrote a simple console app with a main loop that proccesses items
from a queue in seperate threads. my goal is to use web.py to add
items to my queue and report status of the queue via web request. i
got this running as a module but c...
Hi,
I want to store a row in an SQLite 3 table for each booking in my diary.
Each row will have a 'start time' and a 'end time'.
Does any one know how I can query the table for an event at a given time?
E.g. Return any rows that happen at say 10:30am
Thanks
...
I get the feeling this is probably something I should know but I can't think of it right now. I'm trying to get a function to build a list where the name of the list is an argument given in the function;
e.g.
def make_hand(deck, handname):
handname = []
for c in range(5):
handname.append(deck.pop())
return handname
...
If I were to tag a bunch of images via XMP, in Python, what would be the best way? I've used Perl's Image::ExifTool and I am very much used to its reliability. I mean the thing never bricked on tens of thousands of images.
I found this, backed by some heavy-hitters like the European Space Agency, but it's clearly marked as unstable.
No...
import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
Gives me error
File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError: EOL while scannning single-quoted string
Can you help me please, do you see the problem?
...
What does the last line mean in the following code?
import pickle, urllib
handle = urllib.urlopen("http://www.pythonchallenge.com/pc/def/banner.p")
data = pickle.load(handle)
handle....
I waste a lot of time between Vim and Python. I find it too slow to manually copy-paste from Python to Vim and vice versa. A good broken example is:
%!python for i in xrange(25); print 6*i \n
How can you do such tweaks direcly in Vim? [Solved]
[Clarification] I need things to Vim, like printing sequences, arithmetics... - ...