Hi,
The time module can be initialized using seconds since epoch:
>>> import time
>>> t1=time.gmtime(1284286794)
>>> t1
time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19,
tm_sec=54, tm_wday=6, tm_yday=255, tm_isdst=0)
Is there an elegant way to initialize a datetime.datetime object in the sa...
I'm moving some tests from Selenium to the WebDriver. My problem is that I can't find an equivalent for selenium.wait_for_condition. Do the Python bindings have this at the moment, or is it still planned?
...
def Input():
c = raw_input ('Enter data1,data2: ')
data = c.split(',')
return data
I need to use list data in other functions, but I don't want to enter raw_input everytime. How I can make data like a global static in c++ and put it everywhere where it needed?
...
Hi,
I'm trying to divide one timedelta object with another to calculate a server uptime:
>>> import datetime
>>> installation_date=datetime.datetime(2010,8,01)
>>> down_time=datetime.timedelta(seconds=1400)
>>> server_life_period=datetime.datetime.now()-installation_date
>>> down_time_percentage=down_time/server_life_period
Traceback (...
hi
i used fft function in numpy which resulted in a complex array.how to get the exact frequency values?
...
I wrote a crawler in python, fetched urls has different types: it can be url with html and url with image or big archives or other files. So i need fast determine this case to prevent of reading of big files such as big archives and continue crawling. How is the best way to determine url type at start of page loading?
i understand what i...
I read help here http://twill.idyll.org/browsing.html, then i open python and write
export http_proxy="http://www.someproxy.com:3128"
but i just receive an error. How can i use proxy with twill to browser web ?
...
I'm in a Mako template, and I want to know what the current controller and action is (of the current page). How can I do this? I tried c.controller and c.action, but it didn't work. I also listed the keys of the context object but didn't find it.
As a workaround, I've been setting c.controller and c.action from within each controller me...
Hi,
Is there a good Python module for plotting Gantt Charts? I've tried CairoPlot, but it produces buggy results for complex data sets and lacks many configuration options.
Code samples and images are highly appreciated.
Thanks,
Adam
...
Hi folks
i don't know what to do after obtaining a set of complex numbers from FFT on a wav file.How could i obtain the corresponding frequencies.This is output i got after performing FFT which is shown below
[ 12535945.00000000 +0.j -30797.74496367 +6531.22295858j
-26330.14948055-11865.08322966j ..., 34265.08...
This follows a question I asked a few hours ago.
I have this code:
class A(object):
def __init__(self, a):
print 'A called.'
self.a = a
class B(A):
def __init__(self, b, a):
print 'B called.'
x = B(1, 2)
print x.a
This gives the error: AttributeError: 'B' object has no attribute 'a', as expected. I...
Hello there.
I'm trying to make a program in python which creates a fullscreen window and includes an image, but I don't really know how to do that. I've tried to read documentations on pygtk and I've searched in both goodle and stackoverflow, without any success.
Here's my current code.
def __init__(self):
pixbuf = gtk.gdk.pixbuf_n...
Hi, I have the following code in Python using Numpy:
p = np.diag(1.0 / np.array(x)
How can I transform it to get the sparse matrix p2 with the same values as p without creating p first?
Thanks!
...
Hi all,
I'm using the CGIHTTPServer to implement a simple cgi server. I'm trying to upload a file by a form with the post method and the multipart/form-data enctype but I have problems when I recover the value of the fields in the cgi script.
When the script catch the form fields, the value of the file is a MiniFieldStorage with two f...
I am using urlfetch to fetch a URL. When I try to send it to html2text function (strips off all HTML tags), I get the following message:
UnicodeEncodeError: 'charmap' codec can't encode characters in position ... character maps to <undefined>
I've been trying to process encode('UTF-8','ignore') on the string but I keep getting this e...
The index route works when I go to /home/index
But it doesn't work why I type /home/test
What is wrong here, very confused!
import logging
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from helloworld.lib.base import BaseController, render
log = logging.get...
I'm developing a fairly simple Python web app and I want to allow users to log in. I know the solution will probably involve installing some sort of framework rather than doing it in straight Python and I'm OK with that, I'm just wondering, what would be the easiest, most hassle-free way to add authentification? The app is already writte...
I have list of
34.00B
65.89B
346M
I need
34.
65.89
.344
So, how do i remove last character, is if B or M, divide M's by 1000.
...
The following code does not reach searchResults. I have printed out documentElement.findFirst('input[name="btnG"]') and found it to be <input name="btnG" type="submit" value="Google Search" class="lsb"> so we are good up to that point. Note that my goal is not to scrape Google but it's simpler to learn via the well known and public Googl...
In Django/Python, when you make a custom form, does it need to have a clean() method, or will calling .is_valid() perform a default validation?
if request.method == 'POST':
filter = FilterForm(request.POST)
if filter.is_valid():
print 'Month is ' + filter.cleaned_data['month']
print 'Type is ' +...