2009/6/27 julie :
> Hello,
>
> I need help with the following problem:
>
> Write a loop that reads each line of a file and counts the number of lines
> that are read until the total length of the lines is 1,000 characters. Use a
> break statement to make sure that you don't continue reading the fil
2009/6/25 Lie Ryan :
>
> Although pickle output only ascii string, it is not meant to be human
> readable at all. Basically there is no difference how it is stored as
> long as what goes in is equal with what goes out. I can't think of a
> need to sort or compare raw pickle data.
>
> __
(oops... forgot to reply-all)
-- Forwarded message --
From: Richard Lovely
Date: 2009/6/25
Subject: Re: [Tutor] Problems with parameter queries
To: Eduardo Vieira
2009/6/24 Eduardo Vieira :
> Hello, I am accessing a Pervasive SQL data source using odbc and I'm
>
2009/6/24 Dinesh B Vadhia :
> Hi Vince
>
> That's terrific! Once a string is compressed with gzip.zlib does it make a
> difference whether it is stored it in a TEXT or BLOB column?
>
> Dinesh
>
>
>From the MySQL language reference:
"""A BLOB is a binary large object that can hold a variable amount
2009/5/31 Nick Burgess :
> Got it.
>
> the row is not a string or buffer but the cell is..
>
> for row in spamReader:
> for cell in row:
> if pattern.search(cell):
> print ', '.join(row)
>
>
Alternatively, if you know that the string you want to search for only
appears in a sin
2009/5/10 Emilio Casbas :
>
> Hello,
>
> I have some problems testing keys not existent in a dictionary.
> The code works testing existent keys with his corresponding value, but
> If I enter a not existent key, an exception is raised.
> How can I control the not existent key and assign him a defaul
2009/5/11 David :
> Hi, I am going through Wesley Chun's book and this is Exercise 8-11;
> Write a program to ask the user to input a list of names, format "Last Name"
> "comma" "First Name". Write a function that manages the input so that
> when/if the user types in the names in the wrong format t
forgot to reply-all...
-- Forwarded message --
From: Richard Lovely
Date: 1 Apr 2009 18:13
Subject: Re: [Tutor] range() fractional increment
To: Alan Gauld
There's always the itertools solution:
import itertools
def rangeInThirds(start,end):
for whole, fr
2009/3/30 pa yo :
> I need to add one minute to a string that has a date and a time in
> MMDDHHMM format.
> e.g: 200903281346 should become 200903281347
>
> the following script converts the string into time and adds one
> minute; but somehow I also add an hour and I don't understand why.
>
>
2009/3/20 Chris Fuller :
> You should iterate over the keys of the dictionary:
> for k in a.keys():
> because if you iterate over the full dictionary, your items are the values,
> not the keys. Otherwise your code looks correct, and I don't think its
> terribly bad form. You could do something in
2009/2/28 Alan Gauld :
>
> "Richard Lovely" wrote
>
>> > Sorry, I should have pointed out that you will need to redefine
>> > all your functions to accept a parameter.
>>
>> Always makes me smile when (experienced) people redesign the wheel...
&
On 25/02/2009, Alan Gauld wrote:
>
> "nathan virgil" wrote
>
> > Whenever I try to use the talk method (which reports the mood, and doesn't
> > take parameters), it says I gave it too many parameters.
> >
>
> Sorry, I should have pointed out that you will need to redefine
> all your functions to
The Activestate package IS vanilla python. It just comes packaged
with a few addon modules for things such as ActiveX and with windows
GUI libraries. If it works with Vanilla Python, there's virtually no
reason it won't work with the activestate distribution, and vice
versa, as long as you don't
2009/1/8 Kent Johnson :
>
> This is a strange requirement. If you want to try all combinations of
> lowercase letters, the simplest way to do that is with nested loops.
> The loops will generate all combinations without repeating, so there
> is no need to save the used combinations.
>
or itertool
OK, going on Kent's post:
from urllib import urlopen
class fetch(object):
def __init__(self, *args):
self.response = urlopen(*args)
self.content = self.response.read()
I forgot urlopen was a function. It made sense in my head for it to
be a class, instead of _returning_ a c
There are three ways as I see it: using __getattr__, using a new init,
or using a property decorator. The last two are probably the most
pythonic, but I'm not familiar with decorators, so here's how I'd do
the second of the three:
try:
from google.appengine.api.urlfetch import fetch
except:
When you need indexes for a list you're iterating over, you want to
look at the function enumerate(), which returns an iterator yielding
(key, value) tuples.
If you're working with multiple lists, itertools.imap and
itertools.imap_longest are handy if you want to keep the lists in
lockstep:
>>> l
There's probably something like what you want within the "random" module.
at the interactive prompt, try:
import random
help(random)
---
Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
www.theJNP.com
2008/12/2 Alan Gauld <[EMAIL PROTECTED]>:
>
> "Christopher Spears" <[EMAIL PROTECTED]
I'm pretty new to code optimisation, so I thought I'd ask you all for advice.
I'm making an iterative prime number generator. This is what I've got so far:
Code: Select all
import math, array
def count2(start_at=0):
'Yield every third integer, beginning with start_at'
# this has been tes
Hi, I'm trying to teach myself Tkinter by making a desktop calculator.
I've got the Tkinter bit working, but getting the output to work how I
want it to is causing serious brainfreeze...
The buttons 0 through 9 and '.' all append to a queue, which
makeNumber(queue) returns as an actual python nu
Why not throw in itertools.cycle while you're at it? ;-)
pi = sum(4. / (1+x) * itertools.cycle((1,-1)).next() for x in range(0,
4 * n, 2))
I'd also be so tempted just to call the file 'approximate' (read it
with extension...)
Let's also not forget about integer division...
2008/10/23 bob gailer
I felt I need to appolgise for my first post in this thread...
I don't have internet access, and I've yet to find a public computer
with Python, so I'm unable to test any code I write. I'm going have
to discpline myself not to post to here unless its: a) a problem of my
own, or b) an answer that
Guessing you mean [5,100] as the inclusive interval notation, so all
but the last element of the example pass?
if any(True for x, y in listoflists if 5 <= x and y <= 100):
#do stuff
does this do it for you?
Or if you want to know if any elements of the lists within the larger
list are within
In a slightly related matter, Is is possible to use all() with a list
comprehension to check if a word contains all of the letters of
another?
--
Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
www.theJNP.com
___
Tutor maillist - Tutor@python.
If you're compiling from source you do:
http://oss.itsystementwicklung.de/trac/pysqlite/browser/doc/install-source.txt
If you've got an installer, it shouldn't let you install if you don't
have the right things installed.
Even if you can install pysqlite, you wouldn't be able to run any
pysqlite
Hi, I'm not going to guess at why this doesn't work, but I've got a
potential solution for you:
class Z(object):
def __init__(self,y):
self.y = y
def replaceZ (self,withWhat):
self.__dict__ = withWhat.__dict__
Is there a reason you can't use a simple assignment (x=y) outsi
The way I'd do it is create a dict mapping extensions to folders
(something like {'doc': 'word', 'pdf': 'acrobat'} ), then use
os.renames(old, new), which works the same as moving when you give it
a different path for new, and also magically handles creating new
directories for you. The documentat
Does anyone have any links and or know of any good libraries for
writing chat servers similar to IRC? I'm looking to add chat
facilities to a game I'm working on.
Thanks.
--
Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
www.theJNP.com
___
Tut
I'd absolutely recommend "Python for Dummies" published by Wileys.
I've not used that actual book, but I've found other books in the
series extremely helpful.
http://www.amazon.com/Python-Dummies-Computer-Tech/dp/0471778648/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1221146720&sr=8-1
On Thu, Sep 11, 20
Just a couple of quick questions:
What differences are there in efficency (i.e. time and memory) between
string concatenation ("foo" + "bar") and printf style formatting
("%s%s" % ("foo","bar")).
Is there any place where one is better than the other, and any places
where either should be avoided?
30 matches
Mail list logo