python

Sum and Division example (Python)

>>> sum((1, 2, 3, 4, 5, 6, 7)) 28 >>> 28/7 4.0 >>> sum((1,2,3,4,5,6,7,8,9,10,11,12,13,14)) 105 >>> 105/7 15.0 >>> How do I automate this sum and division using a loop maybe? Edit: Maybe I wasn't clear - I want a loop to keep doing the sum (of multiples of 7, eg 1-7, 1-14, 1-21 etc..) until it reaches x (x is the user input) Okay, fig...

Google Wave Python Tutorial - What next?

I just finished working through Google's Wave Robot: Python Tutorial. The API Reference looks a bit imposing. Is there anything else I can look at to get up to speed? ...

How to define the help of the CLI program in the __doc__ ?

Hello guys, I would like to do something like this : def main(): """ Display Information about a Google Calendar -u --user login Google Login -p --pass password Google Password -d --debug Set DEBUG = True -h --help Display this help """ print(__doc__) if __name__ == "__main...

Is there a speed difference between WSGI and FCGI?

From the web I've gleaned that WSGI is a CGI for python web development/frameworks. FCGI seems to be a more generalised gateway for a variety of languages. Don't know the performance difference between the two in reference to the languages python and C/++. ...

How to use doctest on a Client script ?

I am playing with Google Calendar API, creating some useful function. I another hand, I want to do it right puting some useful doctest and starting agile development. How to write doctest since the result of each function is not really predictible (Depending of what is new on the server) : >>> calendar = GoogleCalendar(user='blabla',...

How make Qt Designers autosize layouts work with Pyqt4?

I'm trying a simple example with Qt Designer and Pyqt4, when I preview the UI in Qt Designer (control+R) it looks good, but when I try to execute the generated UI code, layouts don't work properly and instead of autosizing widgets to the max they are so small that they can't be used. If I use fixed sizes it works well. The code used to...

Getting data from an Excel sheet

How do I load data from an Excel sheet into my Django application? I'm using database PosgreSQL as the database. I want to do this programmatically. A client wants to load two different lists onto the website weekly and they don't want to do it in the admin section, they just want the lists loaded from an Excel sheet. Please help becaus...

Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse via Django Server >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258427784 This time indicates GMT: Tue, 17 Nov 2009 03:16:24 GMT...

Google Wave - Adding a participant to a Wave with the Python API

How do I add a participant to a Wave using the Python API given their email address? ...

More efficient method for this calculation?

a = 218500000000 s = 6 f = 2 k = 49 d = k + f + s r = a i = 0 while (r >= d): r = r - d #print ('r = ',r) i = i+1 #print ('i = ',i) print (i) I think it does what I expect it to, but its way too slow to calculate such a large number, I waited 5 mins for i to print (while python used 100% cpu to calculate..), but it didn't. ...

python lxml beautifulsoup problem

Hello all, im making some script by use python and lxml beautifulsoup. while im making i was encounter some problem..and i was try to resolve it but failed always. i want to post some word in following at the end of web page. to leave some words in this page, have to login use with id and password here is test id and pass: pass: 1qa...

Integration Testing for a Web App

I want to make a full integration testing for a web application. I want to test many things like AJAX, positioning and presence of certain phrases and HTML elements using several browsers. I'm seeking a tool to do such automated testing. On the other hand; this is my first time with integration testing, is there any specific recommendat...

Python: create a dictionary with list comprehension

I like the python list comprehension operator (or idiom, or whatever it is). Can it be used to create dictionaries too? For example, by iterating over pairs of keys and values: dict = {(k,v) for (k,v) in blah blah blah} # doesn't work :( ...

Multiprocessing Pool inside Process time out

When ever I use the following code the pool result always returns a timeout, is there something logically incorrect I am doing? from multiprocessing import Pool, Process, cpu_count def add(num): return num+1 def add_wrap(num): new_num = ppool.apply_async(add, [num]) print new_num.get(timeout=3) ppool = Pool(processes=cpu_count(...

Properties dictionary for Events in the Google Wave Python API

The Google Wave documentation contains the Robot Events, but doesn't list what values will be put into the properties dictionary. Is this documented anywhere? ...

cron in google app engine python

i have made app using google app engine in pythonof weekly Project and assessment report submitting... i want to check that on Friday who have submitted the report and who don't just send the scheduled notification mail that he haven't submitted the report in last week... ** but i dont want to send the notification mail on monday who h...

Scheduling Filter on Database with Time Interval

Let's you have a science experiment called Weather and it records general information about the weather, one of which is recording the humidity every minute. After say 10 hours, you'll have 600 database values stored. Weather.objects.filter().exclude(time__lt = commence).exclude(time__gt = cease) This would create a filter for the Wea...

How connect blender with WinTracker 2

i try to do project about control model in blender by using wintracker machine ,but i don't know how to connect it with blender game engine ...

Boolean in Python

Does Python actually contain a Boolean value? I know that you can do: checker = 1 if checker: #dostuff But I'm quite pedantic and enjoy seeing booleans in Java. For instance: Boolean checker; if (someDecision) { checker = true; } if(checker) { //some stuff } Is there such a thing as this in Python? I can't seem to find ...

Does Python use NFAs for regular expression evaluation in the re module?

Does anybody know if Python (any version) used NFAs (Non-Deterministic Finite Automata) to evaluate regular expressions or does it use some other mechanism? Please provide links/reference if available. ...