extract PDF pages

2005-10-13 Thread David Isaac
While pdftk is awesome http://www.accesspdf.com/pdftk/ I am looking for a Python solution. Just for PDF page extraction. Any hope? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

grep

2005-10-24 Thread David Isaac
What's the standard replacement for the obsolete grep module? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: calling matlab

2005-10-24 Thread David Isaac
"hrh1818" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There is a module named pymat avvailable from > http://sourceforge.net/projects/pymat that provides a limited set of > functions for intertfacing Python to Matlab. I think that pymat was superceded by mlabwrap http://mlabwrap

Re: grep

2005-10-25 Thread David Isaac
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:: def grep(pattern, *files): search = re.compile(pattern).search for file in files: for index, line in enumerate(open(file)): if search(line): print ":".join((file, str(index+1), line[:-1])

best cumulative sum

2005-11-20 Thread David Isaac
What's the good way to produce a cumulative sum? E.g., given the list x, cumx = x[:] for i in range(1,len(x)): cumx[i] = cumx[i]+cumx[i-1] What's the better way? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: best cumulative sum

2005-11-21 Thread David Isaac
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > He seems to want scanl Yes. But it's not in Python, right? (I know about Keller's version.) Robert Kern wrote: > Define better. More accurate? Less code? Good point. As Bonono (?) suggested: I'd most like a solution that relies on a

Re: best cumulative sum

2005-11-21 Thread David Isaac
> Alan Isaac wrote: >> Like SciPy's cumsum. "Colin J. Williams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Doesn't numarray handle this? Sure. One might say that numarray is in the process of becoming scipy. But I was looking for a solution when these are available. Something

Re: Converting a flat list to a list of tuples

2005-11-22 Thread David Isaac
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> aList = ['a', 1, 'b', 2, 'c', 3] > >>> it = iter(aList) > >>> zip(it, it) > [('a', 1), ('b', 2), ('c', 3)] That behavior is currently an accident. http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail

Re: best cumulative sum

2005-11-23 Thread David Isaac
> Michael Spencer wrote: > > This can be written more concisely as a generator: <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If iterable has no elements, I believe the behaviour should be [init], > there is also the case of init=None that needs to be handled. Right. So it is "

Re: best cumulative sum

2005-11-23 Thread David Isaac
"Michael Spencer" <[EMAIL PROTECTED]> wrote in message news:mailman.1054.1132707811.18701.python-> This can be written more concisely as a generator: > > >>> import operator > >>> def ireduce(func, iterable, init): > ... for i in iterable: > ... init = func(init, i) > ...

Re: best cumulative sum

2005-11-23 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > - allows arbitrary iterables, not sequences only > - smaller memory footprint if sequential access to the items is sufficient Sure; I meant aside from that. > - fewer special cases, therefore > - less error prone, e. g.

Re: best cumulative sum

2005-11-23 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Of course nothing can beat a plain old for loop in terms of readability and > -- most likely -- speed. Here are two versions, meant to be comparable. Thanks, Alan Isaac def cumreduce(func, seq, init = None): cr = seq

Re: best cumulative sum

2005-11-23 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You are in for a surprise here: You got that right! > >>> def empty(): > ... for item in []: > ... yield item > ... > >>> bool(empty()) > True Ouch. > >>> bool(iter([])) > True # python 2.3 and probably

Re: best cumulative sum

2005-11-24 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd rather have a second look whether the test is really needed. That's too obscure of a hint. Can you be a bit more explicit? Here's an example (below). You're saying I think that most of it is unnecessary. Thanks, Alan

Re: FTP over TLS

2005-11-25 Thread David Isaac
"Carl Waldbieser" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does anyone know of any good examples for writing client side code to upload > files over a secure FTP connection? http://trevp.net/tlslite/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: best cumulative sum

2005-11-27 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think that the test for an empty iterator makes ireduce() unintuitive. OK. I misunderstood you point. But that is needed to match the behavior of reduce. >>> reduce(operator.add,[],42) 42 Thanks, Alan -- http://mail.

Re: best cumulative sum

2005-11-28 Thread David Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > sufficiently similar I think I understand your points now. But I wanted to match these cases: >>> import operator >>> reduce(operator.add,[],42) 42 >>> reduce(operator.add,[1],42) 43 The idea is that the i-th yield of i

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 7)

2005-12-08 Thread David Isaac
"Cameron Laird" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jibes against the lambda-clingers lead eventually to serious > questions of style in regard to variable namespacing, > lifespan, cleanup, and so on: > http://groups.google.com/group/comp.lang.python/browse_th

Re: lambda (and reduce) are valuable

2005-12-09 Thread David Isaac
>>> Jibes against the lambda-clingers lead eventually to serious >>> questions of style in regard to variable namespacing, >>> lifespan, cleanup, and so on: >>> http://groups.google.com/group/comp.lang.python/browse_thread/thread/ad0e15cb6b8f2c32/ Alan Isaac <[EMAIL PROTECTED]> wrote:

Re: problems with duplicating and slicing an array

2005-01-22 Thread David Isaac
Yun Mao wrote: >a[ [1,0], [0,1] ] , which should give me >[[4, 5], [1,2]] Numeric: take(take(a,[1,0]),[0,1],1) fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

extract files from MS-TNEF attachments

2005-01-28 Thread David Isaac
I'm looking for Python code to extract files from MS-TNEF attachments. (I'm aware of the C code at http://tnef.sourceforge.net/ ) Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

tuple.index(item)

2005-07-11 Thread David Isaac
Why don't tuples support an index method? It seems natural enough ... Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning histogram-like data for items in a list

2005-07-22 Thread David Isaac
"Ric Deez" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a list: > L1 = [1,1,1,2,2,3] > How can I easily turn this into a list of tuples where the first element > is the list element and the second is the number of times it occurs in > the list (I think that this is referred

Re: Software needed

2005-07-22 Thread David Isaac
"niXin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Can anyone direct me to where I can find free software to do the following: > Document Management Software > --- > 1. Written in PHP or Python > 2. scanning feature - where I can scan a document http://

can list comprehensions replace map?

2005-07-27 Thread David Isaac
Newbie question: I have been generally open to the proposal that list comprehensions should replace 'map', but I ran into a need for something like map(None,x,y) when len(x)>len(y). I cannot it seems use 'zip' because I'll lose info from x. How do I do this as a list comprehension? (Or, more gen

MultiFile object does not iterate

2005-08-09 Thread David Isaac
Why is a MultiFile object not an iterator? For example if mfp = multifile.MultiFile(fp)I cannot dofor line in mfp: do_somethingRelated:MultiFile.next seems badly named.(Something like next_section would be better.)Is this just historical accident or am I missing the point?Thanks,Alan Isaac -- ht

FTP over SSL (explicit encryption)

2005-08-10 Thread David Isaac
I am looking for a pure Python secure ftp solution. Does it exist? I would have thought that the existence of OpenSSL would imply "yes" but I cannot find anything. ftplib does not seem to provide any secure services. I know about fptutil http://codespeak.net/mailman/listinfo/ftputil but that doe

Re: FTP over SSL (explicit encryption)

2005-08-10 Thread David Isaac
"Eric Nieuwland" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do you want SFTP or FTP/S? The latter. > I'm having a look at FTP/S right now. That's a little > more complicated, but it seems doable. > If I succeed, I guess I'll donate the stuff as an extension to ftplib. Great!

Re: FTP over SSL (explicit encryption)

2005-08-11 Thread David Isaac
> David Isaac wrote: > > I am looking for a pure Python secure ftp solution. > > Does it exist? "Andrew MacIntyre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I recall coming across an extension package (pretty sure it wasn't pure > Pyt

Re: FTP over SSL (explicit encryption)

2005-08-12 Thread David Isaac
"Alan Isaac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > http://www.lag.net/paramiko/ > However it requires the PyCrypto module. > http://www.amk.ca/python/code/crypto > > Can you briefly outline how to use this as a client > to upload and down files from a server using SFTP? OK

Re: Permutation Generator

2005-08-13 Thread David Isaac
"Talin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I wanted to share > this: a generator which returns all permutations of a list: Try this instead: def permuteg(lst): return ([lst[i]]+x for i in range(len(lst)) for x in permute(lst[:i]+lst[i+1:])) \ or [[]

Re: Permutation Generator

2005-08-14 Thread David Isaac
"Casey Hawthorne" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's hard to make "complete" permutation generators, Knuth has a whole > fascicle on it - "The Art of Computer Programming - Volume 4 Fascicle > 2 - Generating All Tuples and Permutations" - 2005 Can you elaborate a

Re: FTP over SSL (explicit encryption)

2005-08-14 Thread David Isaac
"Eric Nieuwland" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm having a look at FTP/S right now. That's a little > more complicated, but it seems doable. > If I succeed, I guess I'll donate the stuff as an extension to ftplib. Just found this: http://trevp.net/tlslite/ I haven

Re: FTP over SSL (explicit encryption)

2005-08-14 Thread David Isaac
> > http://www.lag.net/paramiko/ "Alan Isaac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > sock.settimeout(20) > sock.connect((hostname, port)) > my_t = paramiko.Transport(sock) > my_t.connect(hostkey=None ,username=userna

Re: a sequence question

2005-02-10 Thread David Isaac
"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Using zip(*[iter(l)]*N) or zip(*(iter(l),)*N) simply extends the above to the > general case. Clearly true. But can you please go into much more detail for a newbie? I see that [iter(l)]*N produces an N element list with

Re: a sequence question

2005-02-11 Thread David Isaac
> Alan Isaac wrote: > > I see that [iter(l)]*N produces an N element list with each element being > > the same iterator object, but after that > > http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > just didn't get me there. "Nick Coghlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL P

Re: Iteration over two sequences

2005-02-11 Thread David Isaac
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]: > Numarray is the future, Numeric is the "past", This statement is not obviously true. See the recent discussion on the developer lists. (Search for Numeric3.) Alan Isaac -- http://mail.python.org/mailman/listin

Re: a sequence question

2005-02-12 Thread David Isaac
"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > A bug report on Sourceforge would help in getting the problem fixed for the 2.5 > docs Done. > For the 'left-to-right' evaluation thing, that's technically an implementation > artifact of the CPython implementation, si

checkbook manager

2005-04-03 Thread David Isaac
I'd like to try personal financial management using Python. I just found PyCheckbook, but it does not support check printing. Is there a Python check printing application kicking around? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: checkbook manager -> cross platform printing

2005-04-04 Thread David Isaac
"Alan Isaac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd like to try personal financial management using Python. > I just found PyCheckbook, but it does not support check printing. > Is there a Python check printing application kicking around? OK, I'll assume silence means "

cross platform printing

2005-04-05 Thread David Isaac
"Alan Isaac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd like to try personal financial management using Python. > I just found PyCheckbook, but it does not support check printing. > Is there a Python check printing application kicking around? OK, I'll assume silence means "

Re: cross platform printing

2005-04-24 Thread David Isaac
> Alan Isaac wrote: > > What is the current best practice for cross platform printing of PostScript > > files from Python? "Warren Postma" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Well since printing postscript files on most Unix systems (probably > including Mac OSX although

mbx repair script

2005-04-27 Thread David Isaac
I'm looking for a Python script to repair the mbx header for a mail file where only the header is corrupted. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: mbx repair script

2005-04-29 Thread David Isaac
"Donn Cave" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > All mbx files start with a 2048 byte > header, and a valid header can be copied to another > file and still be valid. For example, if the damaged > file still has 2048 bytes of header, > >1. Find or create another mbx

Re: Tkinter weirdness item count

2005-04-29 Thread David Isaac
"phil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Using Tkinter Canvas to teach High School Geometry > with A LOT of success. Can you post a link to your code. I'd like to see what you are doing. Thx, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

mbx repair script: Python vs perl

2005-04-30 Thread David Isaac
I'm looking for the Python equivalent of the perl script and module described at http://comments.gmane.org/gmane.mail.imap.uw.c-client/707 Any hope? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda (and reduce) are valuable

2005-12-11 Thread David Isaac
> Alan Isaac wrote: > >>> #evaluate polynomial (coefs) at x using Horner's rule > >>> def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) > > It just cannot get simpler or more expressive. "Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > But is it correct?

Re: lambda (and reduce) are valuable

2005-12-11 Thread David Isaac
"Chris Mellon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > As someone who does a tremendous amount of event-driven GUI > programming, I'd like to take a moment to speak out against people > using us as a testament to the virtues of lamda. Event handlers are > the most important

import from containing folder

2006-07-26 Thread David Isaac
Suppose I have inherited the structure PackageFolder/ __init__.py mod1.py mod2.py SubPackageFolder/ __init__.py mod3.py and mod3.py should really use a function in mod2.py. *Prior* to Python 2.5, what is the best way to access that? (Please assu

Re: import from containing folder

2006-07-26 Thread David Isaac
Simon Forman wrote: > I would assume (but I haven't checked) that this should work as long as > delmepy (in your case PackageFolder) was somewhere on sys.path. Sorry that was not clear: I do not want to make any assumptions about this particular package being on sys.path. (I want a relative import

Re: import from containing folder

2006-07-26 Thread David Isaac
Alan wrote: > I do not want to make any assumptions about > this particular package being on sys.path. > (I want a relative import, but cannot assume 2.5.) I should mention that to get around this I have been using sys.path.append(os.path.split(sys.argv[0])[0]) in the script I care most about. I

Re: using names before they're defined

2006-07-26 Thread David Isaac
Suppose I have inherited the structure PackageFolder/ __init__.py mod1.py SubPackageFolder/ __init__.py mod2.py mod3.py When mod1 is run as a script, I desire to import either mod2 or mod3 but not both conditional on an option detected b

__contains__ vs. __getitem__

2006-08-09 Thread David Isaac
I have a subclass of dict where __getitem__ returns None rather than raising KeyError for missing keys. (The why of that is not important for this question.) I was delighted to find that __contains__ still works as before after overriding __getitem__.So even though instance['key'] does not ra

Re: __contains__ vs. __getitem__

2006-08-09 Thread David Isaac
> Alan Isaac wrote: > > I have a subclass of dict where __getitem__ returns None rather than > > raising KeyError for missing keys. (The why of that is not important for > > this question.) "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote: > Well, actually it may be important... What's so wrong wi

Re: How to draw line on Image?

2006-08-18 Thread David Isaac
"Daniel Mark" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I want to draw some shapes, such as lines, circles on an image. http://www.pythonware.com/library/pil/handbook/psdraw.htm hth, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: text editor suggestion?

2006-08-18 Thread David Isaac
http://www.american.edu/econ/notes/soft.htm#EDITORS has some relevant discussion and suggestions. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

item access time: sets v. lists

2006-10-04 Thread David Isaac
Is it expected for access to set elements to be much slower than access to list elements? Explanation? Thanks, Alan Isaac >>> t1=timeit.Timer("for i in set(xrange(1)):pass","") >>> t2=timeit.Timer("for i in list(xrange(1)):pass","") >>> t1.timeit(1000) 9.806250235714316 >>> t2.timeit(1000

Re: loop beats generator expr creating large dict!?

2006-10-04 Thread David Isaac
> Alan Isaac wrote: > > The current situation is: use a loop because the obvious generator > > approach is not efficient. "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "not efficient" compared to what ? I already guess that I've missed your point, but to prove it

Re: item access time: sets v. lists

2006-10-04 Thread David Isaac
Paul M. wrote: > Random access to item in list/set when item exists > set -> 0.000241650824337 > list -> 0.0245168031132 > > Random access to item in list/set when item does not exist > set -> 0.000187733357172 > list -> 0.522086186932 OK, that's a much better set of answers including to questi

yet another "groupsofn" function (newbie entertainment)

2006-10-04 Thread David Isaac
I have not seen this posted and I kind of like it. Shared for entertainment value only. Alan Isaac PS Easily adapted if the residual group is not desired. def groupsofsize(iterable,size): itr = iter(iterable) c=count() for k,it in groupby(itr,lambda x:c.next()//size): yield tup

return same type of object

2006-10-24 Thread David Isaac
Instances of MyClass have a method that returns another instance. Ignoring the details of why I might wish to do this, I could return MyClass() or return self.__class__() I like that latter better. Should I? Should I do something else altogether? Thanks, Alan Isaac -- http://mail.python.org/

Re: return same type of object

2006-10-24 Thread David Isaac
Bruno wrote: > This is usually known as a 'factory method'. You do realise that both solutions are *not* strictky equilavent, do you? Your point I believe is that after inheritance the factory method in the subclass will still return MyClass() but will return an instance of the subclass if I retu

numbers to string

2006-10-24 Thread David Isaac
>>> y [116, 114, 121, 32, 116, 104, 105, 115] >>> z=''.join(chr(yi) for yi in y) >>> z 'try this' What is an efficient way to do this if y is much longer? (A numpy solution is fine.) Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: numbers to string

2006-10-25 Thread David Isaac
Robert Kern wrote: >>> from numpy import * >>> y = [116, 114, 121, 32, 116, 104, 105, 115] >>> a = array(y, dtype=uint8) >>> z = a.tostring() >>> z 'try this' Very nice! Thanks also to Paul and Travis! Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

argmax

2006-06-01 Thread David Isaac
1. Why is there no argmax built-in? (This would return the index of the largest element in a sequence.) 2. Is this a good argmax (as long as I know the iterable is finite)? def argmax(iterable): return max(izip( iterable, count() ))[1] 3. If this is the only place in a module where I need count a

Re: argmax

2006-06-01 Thread David Isaac
Thanks for all the replies. A couple of comments. 1. I think the usefulness of an argmax built-in can be assessed by looking at other languages (and e.g. at numpy). So I do not buy the "not needed" argument as presented. More like "haven't got around to it," I'm thinking. 2. The particular use

Re: numpy bug

2006-06-03 Thread David Isaac
"Boris Borcic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > after a while trying to find the legal manner to file numpy bug reports, > since it's a simple one, I thought maybe a first step is to describe the bug > here. Then maybe someone will direct me to the right channel. > > So

FreeImagePy and PIL

2006-06-03 Thread David Isaac
I am just starting to think about image processing. What are the overlaps and differences in intended functionality between FreeImagePy and PIL? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Request new feature suggestions for my PDF conversion toolkit - xtopdf

2006-06-08 Thread David Isaac
"vasudevram" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > http://sourceforge.net/projects/xtopdf Serendipity: I was just looking for this functionality. Thanks! So here is an idea for a great enhancement: rst -> PDF The good news: the project is all Python, so you will only have

Re: Writing PNG with pure Python

2006-06-09 Thread David Isaac
> Em Sex, 2006-06-09 às 12:30 -0400, Alan Isaac escreveu: > > It's your code, so you get to license it. > > But if you wish to solicit patches, > > a more Pythonic license is IMHO more likely > > to prove fruitful. "Felipe Almeida Lessa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED

Re: Writing PNG with pure Python

2006-06-09 Thread David Isaac
"Johann C. Rocholl" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What license would you suggest? I recommend that you choose the license that will best achieve your long run goals for the code. As I understand them, and as I understand your application and software development,

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread David Isaac
"Rob Cowie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > alpha = ['a','b','c','d'] #shortened for brevity > alpha2 = ['a','b','c','d'] > alpha3 = ['a','b','c','d'] > > def generator(): > for char in alpha: > for char2 in alpha2: > for char3 in alpha3: > yield c

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread David Isaac
alpha = string.lowercase x=(a+b+c for a in alpha for b in alpha for c in alpha) -- http://mail.python.org/mailman/listinfo/python-list

Re: Legitimate use of the "is" comparison operator?

2006-06-19 Thread David Isaac
> > (I was using *small* integers). "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > "small integers" is what the phrase "small integers" in the "small > integers" and "small integers" parts of my reply referred too, of course. But aren't "*small* integers" likely to be smaller than "small integers

property __doc__

2006-06-30 Thread David Isaac
To access the doc string of a property, I have to use the class not an instance. Why? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Mahogany mail

2006-08-27 Thread David Isaac
Somewhat OT: Just wondering if anyone is doing something cool with the Python support in Mahogany mail. If so, please describe it or post some code. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-27 Thread David Isaac
"Jacob Hallen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Unfortunately there is a side effect to slots. They change the behaviour of > the objects that have slots in a way that can be abused by control freaks > and static typing weenies. This is bad, because the contol freaks s

TNEF decoder

2006-08-28 Thread David Isaac
I'm aware of http://cheeseshop.python.org/pypi/pytnef/ but it uses the tnef utility, and I'd like a pure Python solution (along the lines of http://www.freeutils.net/source/jtnef/ ). Is there one? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

methods and functions, instances and classes

2006-09-04 Thread David Isaac
When I create an instance of a class, are the class's functions *copied* to create the methods? Or are method calls actually calls of the class's functions? I am sure this is both obvious and FAQ, but I did not find a clear answer (e.g. here http://docs.python.org/tut/node11.html#SECTION001134

replace deepest level of nested list

2006-09-04 Thread David Isaac
I have a list of lists, N+1 deep. Like this (for N=2): [[['r00','g00','b00'],['r01','g01','b01']],[['r10','g10','b10'],['r11','g11' ,'b11']]] I want to efficiently produce the same structure except that the utlimate lists are replaced by a chosen (by index) item. E.g., [['r00','r01'],['r10','r11']

Re: methods and functions, instances and classes

2006-09-04 Thread David Isaac
> Alan Isaac wrote: > > When I create an instance of a class, > > are the class's functions *copied* to create the methods? > > Or are method calls actually calls of the class's functions? "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On the class functions. You

Re: replace deepest level of nested list

2006-09-04 Thread David Isaac
Thanks to both Roberto and George. I had considered the recursive solution but was worried about its efficiency. I had not seen how to implement the numpy solution, which looks pretty nice. Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: methods and functions, instances and classes

2006-09-04 Thread David Isaac
> Alan Isaac wrote: > > are method calls actually calls of the class's functions? "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Depends on how the method was associated to the instance (you can set > methods on a per-instance property), but in the general case

change property after inheritance

2006-09-06 Thread David Isaac
Suppose a class has properties and I want to change the setter in a derived class. If the base class is mine, I can do this: http://www.kylev.com/2004/10/13/fun-with-python-properties/ Should I? (I.e., is that a good solution?) And what if I cannot change the base class? How to proceed then? Than

Re: change property after inheritance

2006-09-06 Thread David Isaac
Le mercredi 06 septembre 2006 16:33, Alan Isaac a écrit : >> Suppose a class has properties and I want to change the >> setter in a derived class. If the base class is mine, I can do this: >> http://www.kylev.com/2004/10/13/fun-with-python-properties/ >> Should I? (I.e., is that a good solution?)

best small database?

2006-09-11 Thread David Isaac
I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/pyth

Re: best small database?

2006-09-12 Thread David Isaac
Thanks to all for the suggestions and much else to think about. Summarizing: Those who were willing to consider a database suggested: anydbm Gadfly SQLite (included with Python 2.5) Schevo Some preferred using the file system. The core suggestion was to choose a directory structure along with sp

newbie division question

2006-09-18 Thread David Isaac
Suppose x and y are ints in moduleA. If I put from __future__ import division in moduleA then x/y will produce the truediv result. If I put from __future__ import division in moduleB and from moduleB import * in module A then x/y will NOT produce the truediv result (in moduleA). Why? And is ther

Re: newbie division question

2006-09-18 Thread David Isaac
> Alan Isaac wrote: > > Suppose x and y are ints in moduleA. > > > > If I put > > from __future__ import division > > in moduleA then x/y will produce the truediv result. > > > > If I put > > from __future__ import division > > in moduleB > > and > > from moduleB import * > > in module A > > then x

"what's new" missing

2006-09-23 Thread David Isaac
Where does one get the "What's New" document for Python 2.5? http://docs.python.org/dev/whatsnew/whatsnew25.html pretends to hold it, but the links are corrupt. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: "what's new" missing

2006-09-23 Thread David Isaac
"Alan Isaac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Where does one get the > "What's New" document for Python 2.5? > http://docs.python.org/dev/whatsnew/whatsnew25.html > pretends to hold it, but the links are corrupt. OK, here it is: http://docs.python.org/whatsnew/whatsn

SimpleParse installer available for 2.5

2006-10-02 Thread David Isaac
This is important for my move to Python 2.5, so I thought others might want to know... Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread David Isaac
Does George's example raise the question: why do dictionaries not implement efficient creation for two common cases? - Making a dict from two sequences of the same length. - Making a dict from a sequence and a function (as in George's example in this thread). The current situation is: use a loo

define loop statement?

2006-02-17 Thread David Isaac
I would like to be able to define a loop statement (nevermind why) so that I can write something like loop 10: do_something instead of for i in range(10): do_something Possible? If so, how? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: define loop statement?

2006-02-18 Thread David Isaac
> Alan Isaac wrote: > > I would like to be able to define a loop statement > > (nevermind why) so that I can write something like > > > > loop 10: > > do_something > > > > instead of > > > > for i in range(10): > > do_something > > > > Possible? If so, how? "Jeffrey Schwab" <[EMAIL PROT

Re: define loop statement?

2006-02-19 Thread David Isaac
"Benji York" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here's a flagrant hack: Admiration wins out over revulsion. ;-) Thanks, Alan Isaac PS Here's the motivation. Python closely resembles pseudocode. With a very little LaTeX hacking, it is often possible to write algorith

Re: Numerical solver

2006-03-01 Thread David Isaac
"Laszlo Zsolt Nagy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would like to use a numerical solver for a specific problem. Another possibility: http://nlpy.sourceforge.net/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

evaluated function defaults: stored where?

2005-05-25 Thread David Isaac
Default parameter values are evaluated once when the function definition is executed. Where are they stored? (A guess: in a dictionary local to the function.) Where is this documented? As a Python newbie I found this behavior quite surprising. Is it common in many other languages? Is it unsurpris

Re: evaluated function defaults: stored where?

2005-05-27 Thread David Isaac
Alan Isaac wrote: > Default parameter values are evaluated once when the function definition is > executed. Where are they stored? ... Where is this documented? Forgive any poor phrasing: I'm not a computer science type. At http://www.network-theory.co.uk/docs/pytut/tut_26.html we read: "The execu

default values of function parameters

2005-06-05 Thread David Isaac
Alan Isaac wrote: > Default parameter values are > evaluated once when the function definition is > executed. Where are they stored? ... Where is this documented? Forgive any poor phrasing: I'm not a computer science type. At http://www.network-theory.co.uk/docs/pytut/tut_26.html we read: "The exe

  1   2   >