Hi,
I have been doing some functional programming and had a question. Perhaps I might be missing something but is there any way to stop a "reduce()" function midway? Lets say when I reach a certain condition? The idea somehow seems anti functional. I haven't seen any such option in python or F#,
As an example, lets say I have a list s...
i am using the following code to post status update to a users profile in facebook but every time it just returns could not update what is wrong here ?
def fb_post_message(request):
import urllib2
try:
urllib2.urlopen('https://graph.facebook.com/me/feed',"message='hello world'")
except:
return HttpResponse('...
I am currently working on a website using, django, my problem is that the site has to be ported from using php scripts to using django.
Though the site content has been well maintained by the previous maintainer, I have to use markdown for files that already having a HUGE amount of content in them, like the main page is divided into thre...
Hi All,
I find myself continually sifting through the net to keep up with Python/Django/web development trends and news. Does anyone recommend any good news sites that focus on web development or they Python community? For example, what new Django modules are popular or interesting new jQuery plugins, etc. Just curious to know how ...
I have these models:
class Client(models.Model):
is_provider = models.BooleanField()
class Billing(models.Model):
client = models.ForeignKey(Client)
I want to limit the choices of ForeignKey to show only the clients with is_provider=True. Is there something like:
limit_choices_to = {'is_provider': True}
Or anything I can u...
I'd like to be able to track which application is currently focused on my X11 display from Python. The intent is to tie it into a timetracking tool so that I can keep track of how much time I spend being unproductive.
I already found this code at http://thpinfo.com/2007/09/x11-idle-time-and-focused-window-in.html:
import Xlib.display
d...
My Python application makes a lot of HTTP requests using the urllib2 module. This application might be used over very unreliable networks where latencies could be low and dropped packets and network timeouts might be very common. Is is possible to override a part of the urllib2 module so that each request is retried an X number of times ...
I want to use c++ load py.
But one of parameters of a function is dict.
So, can I pass the map in C++ to dict in py?
...
Hi,
To generate a Table of Content, I have these data available in a Python list:
data = [
{title: 'Section 1', level: 1, page_number: 1},
{title: 'Section 1.1', level: 2, page_number: 2},
{title: 'Section 1.2', level: 2, page_number: 3},
{title: 'Section 2', level: 1, page_number: 4},
{title: 'Section 2.1', level: ...
Hi All,
I am working on a Django project where I need to change almost half the features and the way Django admin manages the models. For e.g. I have to create an application and then create an administrator and assign that application such that this admin can manage only that particular application. The administrators would be create...
Hi, I need to interface a C console program (as subprocess) with Python using stdin/stdout.
the C program is more o less it:
tmp = 0.0;
printf("\ninput>>");
scanf_s("%f",&tmp);
printf ("\ninput was: %f",tmp);
tmp = 0.0;
printf("\ninput>>");
scanf_s("%f",&tmp);
printf ("\ninput was: %f",tmp);
tmp ...
Hi folks,
I'm using SQL Server 2005 with Django, I'm wondering if anyone has ever attempted to create an admin panel for SQL using Django.
Would be quite useful to have!
...
This wants me to dig deeper in Python sources, but since there are many people on SO that already done that, I would love to hear their pointers.
>>> import os
>>> def scope():
... print os
... import os
...
>>> scope()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in scope
U...
Hello people,
This probably has an obvious answer, but I'm a beginner. I've got a "module" (really just a file with a bunch of functions I often use) at the beginning of which I import a number of other modules. Because I work on many systems, however, not all modules may be able to load on any particular machine. To make things slig...
I want to know the programming language used by Boxee.tv guys to build their IPTV software. My company is building a IPTV software which will fetch channels and stream channels from the internet.
Boxee's desktop client does the same. Since we want to create a Similar UI, I would like to know what have they used to create such a UI.
Is ...
How can I create a class that extend QGraphicsItem to define a new kind of Item?
I'm trying to do that
#!/usr/bin/python
import sys
from PyQt4 import QtGui
class Node(QtGui.QGraphicsItem):
def __init__(self, parent = 0):
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
app = QtGui.QApplication(sys.argv)
scene = QtGui.QG...
Can I change the default __str__() function of the datetime.datetime object?
By default, it returns something like '2010-06-28 12:43:56.985790', and i need it to print something like '2010-06-28T12:44:21.241228'(which is the isoformat() function).
I need this for JSON serializing of a django model.
My model is:
class Transport(model...
I understand how both __init__ and __new__ work.
I'm wondering if there is anything __init__ can do that __new__ cannot?
i.e. can use of __init__ be replaced by the following pattern:
class MySubclass(object):
def __new__(cls, *args, **kwargs):
self = super(MySubclass, cls).__new__(cls, *args, **kwargs)
// Do __init...
I am using Eclipse 3.5.1 with PyDev 1.5.5 an Mac OS X 10.6.4 (Python 2.6.1). When using a type or function I have not imported yet, I usually write the code that uses it first, and then use quickfix to make PyDev import the necessary modules. However, it often makes weird suggestions here. For instance when I have the function itemgetter...
Hi,
I try to pass a pointer of a structure which is given me as a return value from the function 'bar' to the function 'foo_write'. But I get the error message 'TypeError: must be a ctypes type' for line 'foo = POINTER(temp_foo)'. In the ctypes online help I found that 'ctypes.POINTER' only works with ctypes types. Do you know of anothe...