Hello guys and gals,
Is it common in Python to keep testing for type values when working in a OOP fashion?
class Foo():
def __init__(self,barObject):
self.bar = barObject
def setBarObject(barObject);
if (isInstance(barObject,Bar):
se...
Why are the commands to change the window position before and after sleep(3.00) being ignored?
if self.selectedM.get() == 'Bump':
W1 = GetSystemMetrics(1) + 200
print W1
w1.wm_geometry("+100+" + str(W1))
w2.wm_geometry("+100+" + str(W1))
...
I have an application (CLI) which includes the feature of editing account information. It does this by asking a question and putting in the old value in the answer so that it is editable. Currently I'm using the readline module to do this. I'd like another way of doing the same th...
I'm using os.statvfs to find out the free space available on a volume -- in addition to querying free space for a particular path, I'd like to be able to iterate over all volumes. I'm working on Linux at the moment, but ideally would like something which returns ["/", "/boo...
hey guys, im trying to internationalize my site, so i have the django cms multilingual middleware class in my settings.py , when viewed from brasil, the url changes to
www.ashtangayogavideo.com/pt/ash/homepage/ resulting in a 404, because my site is in www.ashtangayogavideo.com/ash/en/homepage...
I want to run automatic newsletter function in my crontab, but no matter what I try - I cannot make it work. What is the proper method for doing this ?
This is my crontab entry :
0 */2 * * * PYTHONPATH=/home/muntu/rails python2.6 /home/muntu/rails/project/newsletter.py
I have a set of a vectors (10k's worth). And I need to extract the set of value that are seen in any one of the positions where all the others value are know.
I'm hoping for a solution that is sub linear (re the item count) in time and at most linear (re the total size of all the items...
I want it to run the first line print 1 then wait 1 second to run the second command print 2, etc.
Pseudo-code:
print 1
wait(1 seconds)
print 2
wait(0.45 seconds)
print 3
wait(3 seconds)
print 4
I have a python datetime object which I would like to convert to UTC. I am planning to output them in RFC 2822 format to put in an HTTP header, but I am not sure if that matters for this question. I found some information on this site about converting time objects, and it looks simpler that wa...
I'm new to Google Apps and I've been messing around with the hello world app that is listed on the google app site. Once I finished the app, I decided to try to expand on it. The first thing I added was a feature to allow the filtering of the guestbook posts by the user that submitted them. ...
On the surface, this is pretty simple, and I could implement it myself easily. Just successively call dirname() to go up each level in the file's path and check each one to see if it's the directory we're checking for.
But symlinks throw the whole thing into chaos. Any directory alon...
How do you create multiple HTTPDownloader instance with partial download asynchronously? and does it assemble the file automatically after all download is done?
class SomeModel(models.Model):
text = models.TextField()
ip = models.IPAddressField()
created_on = models.DateTimeField()
updated_on = models.DateTimeField()
Say I have that as a model, what if I wanted to only display 'text' field widget for the user to su...
I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good funct...
Python docs say that * and / have the same precedence.
I know that expressions in python are evaluated from left to right.
Can i rely in that and assume that j*j/m is always equal to (j*j)/m
avoiding the parentheses?
If this is the case can i assume that this hold for operator ...
Is it possible to add an additional condition to join statement created by django ORM?
What I need in SQL is
'SELECT "post"."id", COUNT("watchlist"."id") FROM "post" LEFT OUTER JOIN "watchlist" ON ("post"."id" = "watchlist"."post_id" AND "watchlist"."user_id" = 1...
I have a VPS that's hosting multiple virtual hosts. Each host has it's own access.log and error.log. Currently, there's no log rotation setup, though, this may change.
Basically, I want to parse these logs to monitor bandwidth and collect stats.
My idea was to write a parser an...
hello every body ..
first see the code
import poplib
def con(pwd):
M = poplib.POP3_SSL('pop3.live.com', 995)
try:
M.user(pwd)
M.pass_('!@#$%^')
except:
print "[-]Not Found!:",pwd
else:
print '[+]Found password'
exit()
f...
Hi all. Consider this code:
>>> num = int(raw_input('Enter the number > '))
If the user types nothing and presses 'Enter', I want to capture that. (Capture an empty input)
There are two ways of doing it:
I do a simple nu...
Hello, Experts
I've got a question. I'm currently trying out the Django framework and I would share/present/show some stuff I've made to my workmate/friends. I work in Ubuntu under Win7 via VMware. So my wish/desire is to send my current pub-IP with port (e.g
Hi all!
I am new to python and am using it to use nltk in my project.After word-tokenizing the raw data obtained from a webpage I got a list containing '\xe2' ,'\xe3','\x98' etc.However I do not need these and want to delete them.
I simply tried
if '\x' in a
Hi,
I would like to monitor system IO load from a python program, accessing statistics similar to those provided in /proc/diskstats in linux (although obviously a cross-platform library would be great). Is there an existing python library that I could use to query disk IO...
I was sure there was something like this in the standard library, but it seems I was wrong.
I have a bunch of urls that I want to urlopen in parallel. I want something like the builtin map function, except the work is done in parallel by a bunch of threads.
I have developed pure Python packages that are installed via the standard python setup.py install. The files inside each distribution get converted without errors by the 2to3 conversion tool. Is there an easy way to modify the setup.py file such that if the python version is 3, th...
Hi,
How can I convert a number (file size in bytes) to a string like the --human-readable option does in some UNIX commands ?
Examples :
42e5 => 4.2M
2000 => 2.0K
Many thanks !
Hi ,
the app is working this way. That i have a simple news adding model as below:
class News(models.Model):
title = models.CharField(max_length=100)
publication_date = models.DateField(auto_now_add=True)
content = models.TextField()
the view
I have to send make some text bold in between plain text and send it to the template from the view. I do this:
I save a string like this <b>TextPlaintext</b> in a variable and return it to the template.
The "<b>" tags are not interpreted.
How can make some tex...
Hello. I'm trying to wrote parsing script using python/scrapy. How can I remove [] and u' from strings in result file?
Now I have text like this:
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.utils.markup import remove_ta...
Is there any way to limit connection rate in Python Twisted? I need to simulate the slow dataline, with timeouts and optionally data loss and use twisted framework.
What does '\r' mean? What does it do? I have never seen it before and its giving me headaches. It doesnt seem to have any purpose, since 'a\ra' prints as 'aa', but its not the same as the string 'aa'. Im using python 2.6
if I have a series of subplots with one column and many rows, i.e.:
plt.subplot(4, 1, 1) # first subplot
plt.subplot(4, 1, 2) # second subplot
# ...
how can I adjust the height of the first N subplots? For example, if I have 4 subplots, each on its own row, I ...
Hi All:
I'm weaving my c code in python to speed up the loop:
from scipy import weave
from numpy import *
#1) create the array
a=zeros((200,300,400),int)
for i in range(200):
for j in range(300):
for k in range(400):
a[i,j,k]=i*300*400+j*400...
Is there a library out there which will validate CSS?
The only tools I can find to do so are web sites. If one of these sites has an API, that would fit the bill, too.
I have a script that serves as a CSS compiler. It sets various variables according to settings for a theme, an...
Hi folks,
This is my table:
unicorns = {'name':'George',
'actions':[{'action':'jump', 'time':123123},
{'action':'run', 'time':345345},
...]}
How can I perform the ...
Is it possible for a single process running a 32bit compiled version of python in Snow Leopard (64bit machine) to appear to consume > 4gb (say 5.4gb) of virtual memory as seen by the top command?
I did a file ...python to see that the binary was not x86, yet it appeared t...
Hi folks,
I'm using MongoDB an nosql database. Basically as a result of a query I have a list of dicts which themselves contains lists of dictionaries... which I need to work with.
Unfortunately dealing with all this data within Python can be
class MyModel(models.Model)
image = models.FileField(upload_to="blagh blagh...")
#more spam...
I have a file in memory and I want to save it via Django FileField save method, like this:
photo.image.save(name, buffer) # second arg should be django Fil...
Here is a brief summary of my aims. I have a list of data in the data text file that are basically names or identifiers. The list of names is all on one line and seperated by a space. I want to make each data a seperate line. These data are identifiers. If for instance one name from the origin...
My question is how to use data attributes in a method but allow them to be overridden individually when calling the method. This example demonstrates how I tried to do it:
class Class:
def __init__(self):
self.red = 1
self.blue = 2
self.yellow = 3...
Having a list like this:
['foo','spam','bar']
is it possible, using list of comprehension, to obtain this list as result?
['foo','ok.foo', 'spam', 'ok.spam', 'bar', 'ok.bar']
Hello, I think the title speaks for itself.
I have a complex query with a subquery, but sometimes it returns no values, which is absolutely normal. But I can not prevent the ValueError message, cuz I am not able to find out whether RawQuerySet is empty or not. The RQS object is always ...
except ImportError as xcpt:
print "Import Error: " + xcpt.message
Gets you a deprecation warning in 2.6 because message is going away.
Stackoverflow...
I believe eggdrop is the most active/popular bot and it's written in tcl ( and according to wiki the core is C but I haven't confirmed that ).
I'm wondering if there would be any performance benefit of recoding it's functionality in node.js or Python, in addition to making it more acce...
I want to make an "autofill" that works like this:
The site contains the Name and down the Name has the field to write it.
So, I want to make a program the search the "Name" in the website, and before that, click down the "Name" and write the name (easy part)...
How can...
I have this test:
from datetime import datetime
import random
import unittest
from ManagementReview import ManagementReview, ManagementReviewAction
# Default Values for ManagementReviewAction Object Type
DUMMY_ID = 1
DUMMY_ACTION = 'Action 1'
DUMMY_OWNER = 'Owner 1'
DUMMY_TIT...
I'm currently trying out websockets, creating a client in JavaScript and a server in Python.
I'm stuck on a simple problem, though: when I send something from the client to the server it always contains a special ending character, but I don't know how to remove it.
I've tried
Hello !
Here is a small challenge that I would like to submit to you.
My goal here is to see if some code I have developed really make life simpler for aggregating and grouping, or if I have just missed something big ...
PROBLEM
Here are 3 very si...
Hi there!
I'm searching in a way to limit the queryset which I can get through a model.
Suppose I have the following models (with dependencies):
Company
|- Section
| |- Employee
| |- Task
| `- more models...
|- Customer
| |- Contract
| |- Accoun...
Hi, I have a problem getting matplotlib 1.0.0 work in Python 2.5.2 (Ubuntu 10.04)
See attached console output. Any ideas appreciated. Thanks
Python 2.5.2 (r252:60911, Jul 23 2010, 23:04:44)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.