I'm converting some html parsing code from BeautifulSoup to lxml. I'm trying to figure out the lxml equivalent syntax for the following BeautifullSoup statement:
soup.find('a', {'class': ['current zzt', 'zzt']})
Basically I want to find all of the "a" tags in the document that have a class attribute of either "current zzt" or "zzt". ...
Hi all,
I have the following code
import smtplib
from email.mime.text import MIMEText
smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = '[email protected]' # for SMTP AUTH, set SMTP username here
smtppass = '123456' # for SMTP AUTH, set SMTP password here
RECIPIENTS = ['online8@gmai...
How can I revert back to the default function that python uses if there is no __str__ method?
class A :
def __str__(self) :
return "Something useless"
class B(A) :
def __str__(self) :
return some_magic_base_function(self)
...
I have background music for some songs available in both .MID and .KAR formats, but in each case it's being played somewhat faster than I'd like. What's the simplest way to create either .MID or .KAR files with the same content but at a slower tempo -- say, one slowed down by 20% or so, another by 15%, a third by 25%, and so on?
Ideally...
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako.
I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe?
Wouldn't templating JUST suffice wi...
Let's say I have a web application running on S servers with an average of C cores each. My application is processing an average of R requests at any instant. Assuming R is around 10 times larger than S * C, won't benefits from spreading the work of a request across multiple cores be minimal since each core is processing around 10 requ...
In agreement to this question, and its answer. I added the path of the egg and it worked. However, when I run python interactively and I import flup, it works without any problem or additional path specification. Where is the difference ?
Edit: It appears that while doing fastcgi stuff, the .pth files are not parsed, but this is only a ...
I'd like to roll my own server so I can have my projects available 24/7 but with more flexibility than one of the free providers like github can provide. Anyone have a good hosting service that includes shell access? I've been searching on google, but I get a weird spammy vibe from a lot of the places.
...
I've a model MyModel (extending Google's db.Model), and I want to keep track of the number of Models that have been created.
I think the code at from Google's I/O talk on Sharding Counters is quite good, so I'm using that. But I'm not sure where I ought to be calling the increment when creating a new code. (I'm using Django, and I've ke...
If a Python 3 class is pickled using protocol 2, it is supposed to work in Python 2, but unfortunately, this fails because the names of some classes have changed.
Assume we have code called as follows.
Sender
pickle.dumps(obj,2)
Receiver
pickle.loads(atom)
To give a specific case, if obj={}, then the error given is:
ImportErr...
I am in python31,
then I go to file open i left click to open file
and it opens in notepad(simple text editor)python31
The moment it opens the notepad, it starts python26
I thought it has something to open with, and I have changed that to python31
And it still opens python26
EDIT:
The file is created by python26, but it is not exec...
Hi,
I can't find if it's possible to call a non-static method from a static one in Python.
Thanks
EDIT:
Ok. And what about static from static? Can I do this:
class MyClass(object):
@staticmethod
def static_method_one(cmd):
...
@staticmethod
def static_method_two(cmd):
static_method_one(cmd)
...
I have seen 280slides.com and it is really impresive. But its developers had to create their own language.
Which platform or language would you use to have an as similar as possible functionality?
Is it possible to do something similar in python?
Could you give any working examples?
...
While trying to connect to the database I get a strange error:
DatabaseError: SQLCODE -1829 in CONNECT:
ì¦à : Cannot open file 'os.iem'
ì¦à : Cannot open file 'os.iem'
I can confirm that the file is present in $INFORMIXDIR/msg/en_us/0333/ directory. The environment variables INFORMIXDIR, INFORMIXSERVER and ONCONFIG are set corre...
I'm used that in Objective-C I've got this construct:
- (void)init {
if (self = [super init]) {
// init class
}
return self;
}
Should Python also call the parent class's implementation for __init__?
class NewClass(SomeOtherClass):
def __init__(self):
SomeOtherClass.__init__(self)
# init class
...
Hi! I've this django form
class CustomerForm(forms.Form):
first_name = forms.CharField(label=_('Nome'), max_length=30)
last_name = forms.CharField(label=_('Cognome'), max_length=30)
business_name = forms.CharField(label=_('Ragione Sociale'),
max_length=100)
...
from Tkinter import *
app = Tk()
text_field = Entry(app)
text_field.pack()
I want to be able to check if text_field is currently selected or focused so that I know whether or not to do something with its contents when the user presses enter.
...
I am trying to generate a list of all possible number combinations within a set of four numbers using all numbers from 0 through 9.
I'm getting close but the output doesn't show every possible combination starting from 0000 all the way to 9999.
Any clues as to why the following code is dropping certain combinations?
def permgen(item...
I would like to add a preprocessor to HTML pages. Basically, I have a program that takes the name of an HTML file containing preprocessor instructions and outputs the contents of the file after preprocessing to stdout. This mechanism could change if it makes things easier. All I want to do is hook this into Apache so that all the file...
SQLite docs specifies that the preferred format for storing datetime values in the DB is to use Julian Day (using built-in functions).
However, all frameworks I saw in python (pysqlite, SQLAlchemy) store the datetime.datetime values as ISO formatted strings. Why are they doing so?
I'm usually trying to adapt the frameworks to storing d...