I ended up using len(sys.argv) > 1 for this particular problem. But I
think slicing is closer to the tool I was looking for.
I found a.has_key(k) or "k in a" for dictionaries - but haven't found
anything similar for lists. Does it exist?
I guess my example from php would technically be a dictio
DiveIntoPython.org was the first book I read on python, and I really
got a lot out of it. I need to start learning Java (to maintain a
project I've inherited), and was wondering if anyone knew of any
similar books for Java?
Maybe once I know my way around the language, I can sneak Jython in...
:-
Hi all,
I've created a script that reads in a file, replaces some data (regex),
then writes the new data back to the file.
At first I was convinced that "w+" was the tool for the job. But now
I'm finding that the contents of the file are deleted (so I can't read
the data in).
f = open('_i_defin
To make it write over the data, I ended up adding, which seems to work
fine.
f = open('_i_defines.php', 'w+')
data = f.read()
f.seek(0)
f.truncate(0)
...process data, write file, close...
Now that I look at it, I could probably take out the f.seek().
Thanks for your help!
On Nov 3, 4:00 pm, "m
Hi all,
I have a collection of ordered numerical data in a list. The numbers
when plotted on a line chart make a low-high-low-high-high-low (random)
pattern. I need an algorithm to extract the "significant" high and low
points from this data.
Here is some sample data:
data = [0.10, 0.50, 0.60,
Hi,
I'm trying to send an email message with python, and I'm getting this
error:
Traceback (most recent call last):
File "wa.py", line 430, in ?
main()
File "wa.py", line 425, in main
smtp.sendmail(fromaddr, to, msg.encode('utf-8'))
File "/usr/local/lib/python2.4/smtplib.py", line 6
Hi,
I need to match 3 small strings in a small text file (about 200 words
of text).
Would it be faster to write 1 compiled regex that matches all 3
substrings in one go, or to use 3 separate regular expressions to do
the same job?
Thanks!
Erik
--
http://mail.python.org/mailman/listinfo/python-
On May 27, 11:06 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
> > On May 27, 2007, at 4:01 PM, Steve Holden wrote:
>
> >>erikcwwrote:
> >>> On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote:
> >>>> O
Hi,
I'm working on a django powered website, and need to dynamically
generate some graphs (bar, pie, and line) from users' data stored in
MySQL.
Can anyone recommend a good library I can use for this?
Thanks!
Erik
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I'm trying to run the following query:
amember_db = MySQLdb.connect(host="localhost", user="**",
passwd="*", db="***")
# create a cursor
self.amember_cursor = amember_db.cursor()
# execute SQL statement
sql = """SELECT paymen
On May 25, 10:51 am, "Dave Borne" <[EMAIL PROTECTED]> wrote:
> > I'm trying to run the following query:
> ...
> > member_id=%s AND expire_date > NOW() AND completed=1 AND (product_id
>
> Shouldn't you be using the bind variable '?' instead of '%s' ?
> (I'm asking because I'm not entirely sure how t
On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-05-25 at 09:51 -0500, Dave Borne wrote:
> > > I'm trying to run the following query:
> > ...
> > > member_id=%s AND expire_date > NOW() AND completed=1 AND (product_id
>
> > Shouldn't you be using the bind variable '?' ins
On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote:
>
>
>
> > On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
> > > On Fri, 2007-05-25 at 09:51 -0500, Dave Borne wrote:
Hi,
I'm trying to turn o list of objects into a dictionary using a list
comprehension.
Something like
entries = {}
[entries[int(d.date.strftime('%m'))] = d.id] for d in links]
I keep getting errors when I try to do it. Is it possible? Do
dictionary objects have a method equivalent to [].appe
On May 27, 4:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> erikcw wrote:
> > On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote:
> >> On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote:
>
> >>> On May 25, 11:28 am, Carsten Haese <
On May 28, 2:47 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Mon, 28 May 2007 14:53:57 -0300, Dennis Lee Bieber
> <[EMAIL PROTECTED]> escribió:
>
> > On Sun, 27 May 2007 20:35:28 -0400, Carsten Haese <[EMAIL PROTECTED]>
> > declaimed the following in comp.lang.python:
>
> >> On Sun, 2007
HI all,
I'm trying to use Matplotlib to render a pie chart for a django site
I'm working on.
I can't figure out how to get rid of the grey background, or make the
dimensions square (it's getting stretched).
Here is the code:
def oldchart(request):
from PIL import Image as PILImage
from
Hi,
I'm trying to create a multidimensional data structure. However, id
doesn't seem to work past the 2nd dimension.
Here is my method:
def endElement(self, name):
if name == 'row' :
if not self.data.has_key(self.parent):
self.data[self.parent] = {}
On Mar 30, 5:23 pm, [EMAIL PROTECTED] wrote:
> On Mar 30, 4:56 pm, "erikcw" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I'm trying to create a multidimensional data structure. However, id
> > doesn't seem to work past the 2nd dimensio
Hi,
I'm getting the following error when I try to pass a list into a
function.
My List: crea =[(u'218124172', u'536', u'32394'), (u'218320282',
u'1323', u'77931')]
Traceback (most recent call last):
File "wa.py", line 118, in ?
curHandler.walkData()
File "wa.py", line 49, in walkData
Hi,
I'm parsing xml data with xml.sax and I need to perform some
arithmetic on some of the xml attributes. The problem is they are all
being "extracted" as unicode strings, so whenever I try to perform
math operations on the variables, I get this error:
cr[0] = data['cls1']/data['ims1'];
TypeErr
Hi,
I'm trying to format a string like so:
string = "You have a 75% chance of success with %s, don't use %s" %(a,
b)
This gives me:
TypeError: not enough arguments for format string
I've tried 75\%, but that doesn't seem to help. What am I missing?
Thanks!
Erik
--
http://mail.python.org/mai
Hi,
I'm trying to build a SQL string
sql = """INSERT INTO ag ('cid', 'ag', 'test') VALUES(%i, %s, %d)""",
(cid, ag, self.data[parent][child]['results']['test'])
It raises this error: AttributeError: 'tuple' object has no attribute
'encode'
Some of the variables are unicode (test and ag) - is th
On Apr 5, 11:41 am, [EMAIL PROTECTED] wrote:
> On Apr 5, 10:31 am, "erikcw" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm trying to build a SQL string
>
> > sql = """INSERT INTO ag ('cid', 'ag', 'test
On Apr 5, 12:37 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> erikcw wrote:
>
> > I'm trying to build a SQL string
>
> > sql = """INSERT INTO ag ('cid', 'ag', 'test') VALUES(%i, %s, %d)"""
Hi all,
I'm trying to extract zip file (containing an xml file) from an email
so I can process it. But I'm running up against some brick walls.
I've been googling and reading all afternoon, and can't seem to figure
it out.
Here is what I have so far.
p = POP3("mail.server.com")
print p.getwelco
On Apr 5, 8:00 pm, hlubenow <[EMAIL PROTECTED]> wrote:
> erikcw wrote:
> > Hi all,
>
> > I'm trying to extract zip file (containing an xml file) from an email
> > so I can process it. But I'm running up against some brick walls.
> > I've been go
On Apr 6, 12:51 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> erikcw wrote:
> > resp = p.retr(msg_num)
> > if resp[0].startswith('+OK'):
>
> You don't have to check this; errors are transformed into exceptions.
&
Hi,
I'm trying to insert some data from an XML file into MySQL. However,
while importing one of the files, I got this error:
Traceback (most recent call last):
File "wa.py", line 304, in ?
main()
File "wa.py", line 257, in main
curHandler.walkData()
File "wa.py", line 112, in walkD
Hi all,
I'm trying to parse an email message, but am running into this
exception.
Traceback (most recent call last):
File "wa.py", line 336, in ?
main()
File "wa.py", line 332, in main
print out['msg']
UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in
position 238: o
o
> ÿN|I|ñ|o
> Niño
> El Niño
> El Nino
> Traceback (most recent call last):
> File "C:\books\python\CH2\code\unicode_str.py",
> line 19, in ?
> print newStr.encode('ascii')
> UnicodeEncodeError: 'ascii' codec can't encode
> charact
Hi all,
When trying to run this python script from cron, I get the following
error:
Traceback (most recent call last):
File "/home/lybp/public_html/wa/wa.py", line 14, in ?
import MySQLdb
ImportError: No module named MySQLdb
The cron command is python /home/lybp/public_html/wa/wa.py
Any id
On Apr 14, 10:50 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 14 Apr 2007 18:56:00 -0700, "erikcw" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>
>
> > The cron command is python /home/lybp/public_html/wa/wa.py
&g
Hi,
I have a list of numbers each with a +/- margin of error. I need to
identify which ones overlab each other.
For example:
55 +/- 3
20 +/- 2
17 +/- 4
60 +/- 3
#base, max, min
list = [
(55, 58, 52),
(20, 22, 18),
(17, 21, 13),
(60, 63, 57),
]
In this example the range of list[0] overlaps the
Hi,
I'm trying to devise a scheme to encrypt/obfuscate a short string that
basically contains the user's username and record number from the
database. I'm using this encrypted string to identify emails from a
user. (the string will be in the subject line of the email).
I'm trying to figure out w
On Feb 11, 3:07 pm, [EMAIL PROTECTED] wrote:
> erikcw napisal(a):
>
>
>
> > Hi,
>
> > I'm trying to devise a scheme to encrypt/obfuscate a short string that
> > basically contains the user's username and record number from the
> > database. I'
On Feb 11, 4:07 pm, [EMAIL PROTECTED] wrote:
> erikcw napisal(a):> But that can't be reversed, right? I'd like to be able to
> decrypt the
> > data instead of having to store the hash in my database...
>
> In such case it seems you have no choice but to use a symmet
Hi,
I'm trying to use xml.sax (from xml.sax.handler import ContentHandler)
to processes the following data:
I've figured out how to access the attributes in "row" - but I want to
also access the "analytics" child element.
I've tried:
class YahooHandler(ContentHandler):
ccountNum)
def
Hi all,
I'm starting to translate a large legacy php app to python (django),
and was wondering if anyone knew of a bridge between the 2 languages.
(access php objects from python and vice versa).
Some of the solutions I've come across so far include using php's
passthru() ( http://us3.php.net/pas
Hi,
When I use sys.exc_info() on one of my custom exception classes, the
"message"/value isn't returned. But it is when I use a built in
exception.
Example:
In [32]: class Test(Exception):
: def __init__(self, x):
: self.value = x
: def __str__(self):
...
Hi,
I'm trying to create an undo/redo feature for a webapp I'm working on
(django based). I'd like to have an undo/redo function.
My first thought was to use the difflib to generate a diff to serve as
the "backup", and then if someone wants to undo their operation, the
diff could just be merged/
Hi all,
I was reading in the Beautiful Soup documentation that you should use
a "Soup Strainer" object to keep memory usage down.
Since I'm already using Element Tree elsewhere in the project, I
figured it would make sense to use ElementSoup to keep the api
consistent. (and cElementTree should be
On Mar 25, 12:17 am, John Nagle <[EMAIL PROTECTED]> wrote:
> erikcwwrote:
> > Hi all,
>
> > I was reading in the Beautiful Soup documentation that you should use
> > a "Soup Strainer" object to keep memory usage down.
>
> > Since I'm already using Element Tree elsewhere in the project, I
> > figure
Python seems to default to the main system IP for outbound connections
(such as urllib), but I want to bind to one of my other IPs for
outbound connections.
Any ideas?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I'm trying to write a loop that will build a list of "template
strings".
My current implementation is *really slow*. It took 15 minutes to
finish. (final len(list) was about 16k entries.)
#combinations = 12 small template strings ie "{{ city }},
{{ state }}..."
#states = either a django
Hi,
I keep getting this error from poplib:
(error_proto(-ERR EOF) line 121 poplib.py
Does this mean the connection has timed out? What can I do to deal
with it?
Thanks!
Erik
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I'm working on a web application where each user will be creating
several "projects" in there account, each with 1,000-50,000 objects.
Each object will consist of a unique name, an id, and some meta data.
The number of objects will grow and shrink as the user works with
their project.
I'm tr
Hi,
I'm working on a web application where each user will be creating
several "projects" in there account, each with 1,000-50,000 objects.
Each object will consist of a unique name, an id, and some meta data.
The number of objects will grow and shrink as the user works with
their project.
I'm tr
Hi,
The menubar of OS X is showing the application name as Python instead
of the name of my wxpython gui app. How do I make my application name
show-up in the menu bar?
Thanks!
Erik
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I have a cgi script where users are uploading large files for
processing. I want to launch a subprocess to process the file so the
user doesn't have to wait for the page to load.
What is the correct way to launch subprocess without waiting for the
result to return?
Thanks!
--
http://mail.py
On Sep 18, 3:33 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> erikcw <[EMAIL PROTECTED]> writes:
> > I have a cgi script where users are uploading large files for
> > processing. I want to launch a subprocess to process the file so the
> > user doesn't have to w
I'm trying to figure out how to download just the first few lines of a
large (50mb) text file form a server to save bandwidth. Can Python do
this?
Something like the Python equivalent of curl http://url.com/file.xml |
head -c 2048
Thanks!
Erik
--
http://mail.python.org/mailman/listinfo/python-l
Hi,
I'm trying to get multiprocessing to working consistently with my
script. I keep getting random tracebacks with no helpful
information. Sometimes it works, sometimes it doesn't.
Traceback (most recent call last):
File "scraper.py", line 144, in
print pool.map(scrape, range(10))
Fil
53 matches
Mail list logo