I am relatively new to Python and was hoping someone could explain the following to me:
class MyClass:
Property1 = 1
Property2 = 2
print MyClass.Property1 # 1
mc = MyClass()
print mc.Property1 # 1
Why can I access Property1 both statically and through a MyClass instance?
...
I'm opening a webpage in the default webbrowser on the system using python's webbrowser module.
I want to check if the site is already open in the browser and only open a new tab/window if it is not. Otherwise reload the already opened page.
Is there a way to do this with webbrowser module? If not, is there any other module i can use t...
I m building a python script using a setup.py file. In building process, it links to python framework. I want to change the linking framework path as its linking to the wrong location.
How to set the framework path before building the script.
Thanks in advance for sparring ur valuable time for this thread.
...
I'm working on a django project that serves multiple sites; depending on the site I want to import different functionality from a different module; how do I import a module in Python if I have the name of its package and the module name itself as a string?
...
Hi all!!!
I am new to python and scrapy .
I am running the scrapy-ctl.py from another python script using
subprocess module.But I want to parse the 'start url' to the spider from
this script itself.Is it possible to parse start_urls(which are
determined in the script from which scrapy-ctl is run) to the spider?
I will be greatful f...
When implementing a custom equality function for a class, does it make sense to check for identity first? An example:
def __eq__(self, other):
return (self is other) or (other criteria)
This interesting is for cases when the other criteria may be more expensive (e.g. comparing some long strings).
...
I have a list of lists that I want to unpack in for loops, but I'm running into an issue.
>>> a_list = [(date(2010, 7, 5), ['item 1', 'item 2']), (date(2010, 7, 6), ['item 1'])]
>>>
>>> for set in a_list:
... a, b = set
... print a, b
...
2010-07-05 ['item 1', 'item 2']
2010-07-06 ['item 1']
>>>
>>> for set in a_list:
... fo...
I'm using gae-sessions in my App Engine program, and I have the following function:
def get_token():
session = get_current_session()
access_token = session.get('access_token', None)
The code that sets the session up is simple enough:
session = get_current_session()
session['access_token'] = token
I've put error trapping in ...
I'm trying to use an Objective-C class made in Python to do this but Objective-C can't call the method which calls the python function.
Here's the framework code which the Objective-C code:
//
// scalelib.h
// Scalelib Cocoa Framework
//
// Created by Matthew Mitchell on 04/07/2010.
// Copyright 2010 __MyCompanyName__. All rights r...
The documentation for ConfigParser in Python talks a lot about the so-called "magical interpolation" feature, but never explains what it actually does. I've tried searching for it, but haven't found any answers.
...
This question is basically the inverse of this other question: http://stackoverflow.com/questions/1308079/calling-python-from-objective-c
I have implemented my iPhone application logic in Objective-C (obviously), and am now trying to re-use as much as possible from my XCode project in the server component to save on double-implementatio...
Hi Everyone,
I am getting at extremely fast rate, tweets from a long-lived connection to the Twitter API Streaming Server. I proceed by doing some heavy text processing and save the tweets in my database.
I am using PyCurl for the connection and callback function that care of text processing and saving in the db. See below my approach ...
I am looking for a simple library which can be given a set of items:value pair and which can generate a tag cloud as output.
Library can preferably be in python
...
How can I delete messages from the mail box? I am using this code, but the letters are not removed. Sorry for my English.
def getimap(self,server,port,login,password):
import imaplib, email
box = imaplib.IMAP4(server,port)
box.login(login,password)
box.select()
box.expunge()
typ, data = box.search(None, 'ALL')
...
This has already been asked here, but I was looking for a solution that would work on Linux.. Is tiffcp the only way?
...
Hello,
Note: Despite the mentioning of Python in the following there is a good chance for my problem not to be Python related at all. If I am not mistaken the “module” I mention is equivalent to a C library—at least for the concerns of my problem.
On Debian I am trying to create a Python module with C, which in turn uses the GSL. The f...
I have a Qt/C++ application that exposes some custom C++ classes via DBus methods (by registering them as MetaTypes, and using annotations in the xml), and I want my PyQt program to consume these methods.
The problem I see is that the exposed types are C++ classes, not python, so how can I make python aware of these classes?
...
I am looking for a python based microsoft office parser - specifically powerpoint.
I want to be able to parse PPT in python and extract things like text and images from the powerpoint file.
Is there a library available?
...
How can I define an option with an arbitrary number of arguments in Python's OptParser?
I'd like something like:
python my_program.py --my-option X,Y # one argument passed, "X,Y"
python my_prgoram.py --my-option X,Y Z,W # two arguments passed, "X,Y" and "Z,W"
the nargs= option of OptParser limits me to a defined number. How can ...
I would like to read different files in one directory with the following structure:
# Mj = 1.60 ff = 7580.6 gg = 0.8325
I would like to read the numbers from each file and associate every one to a vector.
If we assume I have 3 files, I will have 3 components for vector Mj, ...
How can I do it in Python?
Thanks for y...