Hi,
After downloading an image from the site i need to detect the color of the downloaded image.I successfully downloaded the image but i need to detect the color of the corresponding image and to be save it in the name of the corresponding color.Code used is given below.Tell me how can i achieve it from the current position.
imageur...
I am using urllib2 and HTTPCookieProcessor to login to a website. I want to login to multiple accounts concurrently and store the cookies to be reused later.
Can you recommend an approach or library to achieve this?
...
This may not really be a Python related question, but pertains to language encoding in general. I'm mining tweets from Twitter, and it appears that there is a large Japanese user community (with messages in Japanese). When I tried encoding the tweets for an XML file I used utf-8. e.g tweet=tweet.encode('utf-8') and none of the Japanese t...
Hi!
Is there a way (using eval or whatever) to evaluate eagerly boolean expressions in python?
Let's see this:
>>> x = 3
>>> 5 < x < y
False
Yikes! That's very nice, because this will be false regardless of y's value. The thing is, y can be even undefined, and I'd like to get that exception. How can I get python to evaluate all expre...
I am trying to implement a calendar system with the ability to schedule other people for appointments. The system has to be able to prevent scheduling a person during another appointment or during their unavailable time.
I have looked at all the existing django calendar projects I have found on the internet and none of them seem to have...
I have a .txt file containing data like this:
1,Rent1,Expense,16/02/2010,1,4000,4000
1,Car Loan1,Expense,16/02/2010,2,4500,9000
1,Flat Loan1,Expense,16/02/2010,2,4000,8000
0,Rent2,Expense,16/02/2010,1,4000,4000
0,Car Loan2,Expense,16/02/2010,2,4500,9000
0,Flat Loan2,Expense,16/02/2010,2,4000,8000
I want to replace the first...
I want to define a new class that inherit the build in str type, and create a method that duplicates the string contents.
How do I get access to the string value assigned to the object of my new class ?
class str_usr(str):
def __new__(cls, arg):
return str.__new__(cls, arg)
def dub(self):
# H...
I am writing a file copying utility in Python. But I am getting some error messages when processing files with very long file paths.
I suspect Python has some limitations when handling very long file paths.
...
I want to make sure that I delete required files.
I have code something like
dir="/some/path/"
file = "somefile.txt"
cmd_rm= "rm -rf "+dir + file
os.system(cmd_rm)
The dir and file values are fetched from a database. How can I make sure I never end up running rm -rf /?
What things should I check before doing rm -rf?
...
Hi
I have a bash shell script which calls some python scripts. I am running windows with cygwin which has python in /usr/bin/python. I also have python and numpy installed as a windows package. When I execute the script from cygwin , I get an ImportError - no module named numpy. I have tried running from windows shell but the bash scri...
Hi,
I'm looking for the most efficient way to bulk-insert some millions of tuples into a database. I'm using Python, PostgreSQL and psycopg2.
I have created a long list of tulpes that should be inserted to the database, sometimes with modifiers like geometric Simplify.
The naïve way to do it would be string-formatting a list of INSERT...
I can't understand how x and y are the same list. I've been trying to debug it using print statements and import code; code.interact(local=locals()) to drop into various points, but I can't figure out what on earth is going on :-(
from collections import namedtuple, OrderedDict
coordinates_2d=["x","y"]
def virtual_container(virtual_co...
Is there a build-in function that can round like this:
10 -> 10
12 -> 10
13 -> 15
14 -> 15
16 -> 15
18 -> 20
...
I need to write a python script that retrieves tar.Z files from an FTP server, and uncompress them on a windows machine. tar.Z, if I understood correctly is the result of a compress command in Unix.
Python doesn't seem to know how to handle these, it's not gz, nor bz2 or zip. Does anyone know a library that would handle these ?
Thanks ...
Hi to all. I have notebook on my form and on each notebook's tab i have gtk.TextView. textview adding automaticaly when new notebook's tab add. Let's say I want to open a file in 3 textview into 3 tabs and when i open file i want that in tab-label will be file path.
Tab add:
def new_tab(self):
scrolled_window = gtk.ScrolledWindow(...
Hello,
I have 3 classes and I run the first class and declare a variable in the second class and want the 3rd class to be able to print out this variable. I have code below to explain this more clearly.
from class2 import Class2
class Class1(Class2):
def __init__(self):
self.value1 = 10
self.value2 = 20
def a...
I'm trying to install MySql interface for python,but I got an error(mentioned below).And I know the solution,install the Microsoft Visual C++.So what my question is there any alternative solution apart from installing Microsoft Visual C++,I mean it's really hurt me,why should I install Microsoft Visual C++ just because to build this sing...
Let's say we have a list:
a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9]
Now, a.sort() will sort the list in place. What if we want to sort only a part of the list, still in place? In C++ we could write:
int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 };
int * ptr = array;
std::sort( ptr + 1, ptr + 4 );
Is there a similar way in Python?
...
With this code:
import scipy
from scipy import *
x = r_[1:15]
print x
a = select([x > 7, x >= 4],[x,x+10])
print a
I get this answer:
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
[ 0 0 0 14 15 16 17 8 9 10 11 12 13 14]
But why do I have zeros in the beginning and not in the end? Thanks in advance.
...
I want to define several plugins.
They all inherit from the superclass Plugin.
Each plugin consists on a wx.Panel that have a more specific method called "draw".
How can I define a class as a Panel and afterwards call that class in my frame?
I've tried like this:
class Panel(wx.Panel):
def __init__(self, parent):
wx.Panel...