Re: Better writing in python

2007-10-24 Thread Neil Cerutti
in groupby(sorted(cls.dArguments, key=truth), truth): result[k].extend(g) I like your initial attempt better. P.S. I didn't realize until working out this example that extend could consume an iterator. -- Neil Cerutti The word genius isn't applicable in football. A genius is a guy like Norman Einstein

Re: about functions question

2007-10-25 Thread Neil Cerutti
': print SOME_CONST if not do_something(): try_somethin_else() That idiom is useful in modules for launching tests or examples that should not be run when the module is imported. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: about functions question

2007-10-26 Thread Neil Cerutti
On 2007-10-26, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-10-25, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The canonical case for small scripts is to have first all functions and globals defined, then the main code protected by a guard, ie: There's

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Neil Cerutti
, os.R_OK | os.W_OK | os.X_OK) which explicitly (rather than implicitly) spells it out? And the equivalent of ``os.chmod(filename, 0777)`` looks like what!? os.chmod(filename, int('777', 8)) It's good enough for most other bases. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: A Python 3000 Question

2007-10-30 Thread Neil Cerutti
32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import timeit timeit.Timer('len(seq)', 'seq = range(100)').timeit() 0.20332271187463391 timeit.Timer('seq.__len__()', 'seq = range(100)').timeit() 0.48545737364457864 -- Neil Cerutti -- http

Re: setting variables in outer functions

2007-10-30 Thread Neil Cerutti
, post_transaction fred_balance, fred_post = account(1500) joe_balance, joe_post = account(12) fred_post(20) joe_post(-10) fred_balance() 1520 joe_balance() 2 Python classes will of course nearly always win, though the idiom looks like it might be faster (I don't have Python 3000 to try it out). -- Neil

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-30, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Tue, 30 Oct 2007 15:25:54 GMT, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-30, Eduardo O. Padoan [EMAIL PROTECTED] wrote: This is a FAQ: http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-30, George Sakkis [EMAIL PROTECTED] wrote: On Oct 30, 11:25 am, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-30, Eduardo O. Padoan [EMAIL PROTECTED] wrote: This is a FAQ: http://effbot.org/pyfaq/why-does-python-use-methods-for-some-function... Holy Airy Persiflage Batman

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-31, George Sakkis [EMAIL PROTECTED] wrote: On Oct 31, 8:44 am, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-30, George Sakkis [EMAIL PROTECTED] wrote: On Oct 30, 11:25 am, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-30, Eduardo O. Padoan [EMAIL PROTECTED] wrote

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
any methods at all). Thanks for the interesting note. I didn't know that tuples originally had no methods. That made len mandatory, I suppose. -- Neil Cerutti The Pastor would appreciate it if the ladies of the congregation would lend him their electric girdles for the pancake breakfast next

Re: setting variables in outer functions

2007-11-01 Thread Neil Cerutti
implementation mechanism. That is missing the point of closures. It really depends on how wide your definition of primitive object system is. Can you come up with a use-case for nonlocal that doesn't appear to be a primitive object system? -- Neil Cerutti To succeed in the world it is not enough

Re: How can I have one element list or tuple?

2007-11-01 Thread Neil Cerutti
On 2007-11-01, nico [EMAIL PROTECTED] wrote: The following example returns a string type, but I need a tuple... var = (Hello) print type(var) type 'str' I need that for a method parameter. var = hello, -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax coloring in Python interpreter

2007-11-01 Thread Neil Cerutti
for Python? I believe IPython can do this: http://ipython.scipy.org/moin/ IPython's syntax coloring doesn't work with Windows 2000 and up, since (last I checked) it relies on a readline.py file, which relies on ANSI.SYS, which is not supported by the Windows console. -- Neil Cerutti -- http

Re: Syntax coloring in Python interpreter

2007-11-01 Thread Neil Cerutti
On 2007-11-01, Chris Mellon [EMAIL PROTECTED] wrote: On Nov 1, 2007 3:01 PM, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-11-01, Lee Capps [EMAIL PROTECTED] wrote: On Nov 1, 2007, at 1:45 PM, braver wrote: Greetings -- as a long time user of both Python and Ruby interpreters, I got used

Re: python newbie

2007-11-02 Thread Neil Cerutti
and every variable be a field of that module? You are almost correct. Every identifier/name in Python is conceptually an attribute of an object. But identifiers in Python are not typed. It is the objects that they refer to that are typed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: Syntax coloring in Python interpreter

2007-11-02 Thread Neil Cerutti
On 2007-11-02, Tim Golden [EMAIL PROTECTED] wrote: Neil Cerutti wrote: On 2007-11-01, Chris Mellon [EMAIL PROTECTED] wrote: On Nov 1, 2007 3:01 PM, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-11-01, Lee Capps [EMAIL PROTECTED] wrote: On Nov 1, 2007, at 1:45 PM, braver wrote: Greetings

Re: Is pyparsing really a recursive descent parser?

2007-11-03 Thread Neil Cerutti
(Word(alphas)) + Literal('end') Is there not an ambiguity in the grammar? In EBNF: goal -- WORD { WORD } END WORD is '[a-zA-Z]+' END is 'end' I think it is fine that PyParsing can't guess what the composer of that grammar meant. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: Is pyparsing really a recursive descent parser?

2007-11-03 Thread Neil Cerutti
On 2007-11-04, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 2007-11-03, Paul McGuire [EMAIL PROTECTED] wrote: On Nov 3, 12:33 am, Just Another Victim of the Ambient Morality [EMAIL PROTECTED

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
On 2007-11-04, Kay Schluehr [EMAIL PROTECTED] wrote: On 4 Nov., 03:07, Neil Cerutti [EMAIL PROTECTED] wrote: I wouldn't characterize it as pretending. How would you parse: hello end hello end WORD END WORD END and WORD WORD WORD END are both valid interpretations, according to the grammar

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
On 2007-11-04, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I believe there's no cure for the confusion you're having except for implementing a parser for your proposed grammar. Alternatively, try

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
On 2007-11-05, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 2007-11-04, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
circumstances compared to other well-known algotithms that you can't practically wait for an answer. Would you consider bubble-sort a suitable general-purpose sorting algorithm for Python? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyparsing really a recursive descent parser?

2007-11-04 Thread Neil Cerutti
On 2007-11-05, Neil Cerutti [EMAIL PROTECTED] wrote: def Ack(x, y): The Ackermann function. Creates a humongous mess even with quite tiny numbers. if x 0 or y 0: raise ValueError('non-negative integer') elif x == 0: return y + 1 elif y == 0

Re: Is pyparsing really a recursive descent parser?

2007-11-05 Thread Neil Cerutti
On 2007-11-05, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] There are different kinds of recursion. Compare: While interesting, none of this actually addresses the point I was making. I

Re: Is pyparsing really a recursive descent parser?

2007-11-06 Thread Neil Cerutti
ambiguous grammar without trouble. It is not as convenient or as well documented as PyParsing, but the parsing algorithm provides the power you're looking for. It might serve as a backend for the library you're currently working on. http://www.cpsc.ucalgary.ca/~aycock/spark/ -- Neil Cerutti

Re: Populating huge data structures from disk

2007-11-06 Thread Neil Cerutti
a while loop and manual index instead of an iterator, preallocate your list, e.g., [None]*1, and hope they don't have blasters! -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Neil Cerutti
On 2007-11-07, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You might be interested in the Early parsing algorithm. It is more efficient than the naive approach used in your prototype, and still

Re: Binary search tree

2007-11-09 Thread Neil Cerutti
to go. Python's library support for binary search trees consists of the bisect module. -- Neil Cerutti Ask about our plans for owning your home --sign at mortgage company -- http://mail.python.org/mailman/listinfo/python-list

Re: Some pythonic suggestions for Python

2007-11-10 Thread Neil Cerutti
proliferate. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert some Python code to C++

2007-11-13 Thread Neil Cerutti
into the function as well. I think lists are called arrays in C++. I don't know what the set equivalent is though. It is called set, oddly enough. ;) There's an overload of the set::insert function that takes a couple of iterators that will serve for Python's update method. -- Neil Cerutti -- http

Re: Python Design Patterns - composition vs. inheritance

2007-11-16 Thread Neil Cerutti
at the Python library... sys.stdout.write(), if following Law of Demeter would turn into: myStdout = sys.getStdout() myStdout.write() The Law of Demeter doesn't apply to that example. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Robin Becker [EMAIL PROTECTED] wrote: Neil Cerutti wrote: ... see why. You are no longer making m copies of active_nodes. my profiling indicated that the main problem was the removes. Yeah, I should've added, for one thing. I'm glad Chris correctly pointed out

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
. for i in xrange(m): ... saved_nodes = [] for A in active_nodes[:]: .. if not cond: saved_nodes.append(A) .. active_nodes = saved_nodes . -- Neil Cerutti Sermon Outline: I. Delineate your fear II

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Neil Cerutti [EMAIL PROTECTED] wrote: Instead, filter your list. It looks like you can't use filter directly, so just do it manually. for i in xrange(m): ... saved_nodes = [] for A in active_nodes[:]: I meant to remove the slice. That line should

Re: Python Design Patterns - composition vs. inheritance

2007-11-17 Thread Neil Cerutti
language. -- Neil cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: What is python?????

2007-11-17 Thread Neil Cerutti
this, then?', 'Do you want to come back to my place?']) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: implement random selection in Python

2007-11-19 Thread Neil Cerutti
greatest to lowest, which would make a linear search fast, but unfortunately it would slow down removing probabilities. -- Neil Cerutti I make love to pressure. --Stephen Jackson -- http://mail.python.org/mailman/listinfo/python-list

s[i:j:t] = t stipulation

2007-11-20 Thread Neil Cerutti
you'd also have to define x[::2] = 'aaa' as resulting in ['a', 1, 'a', 2, 'a', 3, 5, 7, 9] But perhaps that's just adding more useless complexity to the already complex slicing rules (kudos for 'slice.indices', though curses that the method isn't cross-referenced in more places). -- Neil

Re: s[i:j:t] = t stipulation

2007-11-21 Thread Neil Cerutti
On 2007-11-20, Terry Reedy [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | s[i:j:t] = t (1) t must have the same length as the slice it is replacing. This is essentially the same rule as requiring a proper length of t for a,b,c = t

Re: eof

2007-11-21 Thread Neil Cerutti
= File.open(jopa) = #File:jopa f.read() = jopa\n f.eof = true Is there a Python analog? Yes. f = file('jopa') f.read() 'jopa\n' ...and in both Ruby and Python you are at EOF by definition. There's no need to check. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: eof

2007-11-22 Thread Neil Cerutti
to ask about certain control flow equivalents. And comparisons will always be good. :) Language comparisons are sometimes good. They are best when they are free of FUD. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: eof

2007-11-22 Thread Neil Cerutti
useful source of confusion. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-23 Thread Neil Cerutti
and removes the need to wrap it. 7return math.sqrt(.x * .x + .y * .y + .z * .z) +1 Readability counts, even on small screens. -1 Refactoring is a more expedient response than language redesign. def sum_of_squares(*args): return sum(arg*args for arg in args) -- Neil Cerutti -- http

Re: eof

2007-11-23 Thread Neil Cerutti
is not \n-terminated? Nothing bad happens as far as I know, but it may depend on the underlying clib. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Teach Python Variables

2007-11-27 Thread Neil Cerutti
-- not a completely new model. There are more differences than similarities. Pointers are are a low-level mechanism suitable for many purposes, referencing values amongst them. Python identifiers are a high-level machanism, suitable for only one purpose. -- Neil Cerutti -- http://mail.python.org

Re: the annoying, verbose self

2007-11-27 Thread Neil Cerutti
the time, until I learned that in ABC, one of Python's precursors, you had to use '__anInstanceOf_This_TYPE_or_Maybe_A__SubClassOfItInstead_arg0_'. -- Neil Cerutti Sermon Outline: I. Delineate your fear II. Disown your fear III. Displace your rear --Church Bulletin Blooper -- http

Re: A bug in Python's regular expression engine?

2007-11-27 Thread Neil Cerutti
code and language implementations will get you nowhere most of the time. Hint 2: regular expressions and Python strings use the same escape character. Hint 3: Consult the Python documentation about raw strings, and what they are meant for. -- Neil Cerutti -- http://mail.python.org/mailman

Re: How to Teach Python Variables

2007-11-28 Thread Neil Cerutti
On 2007-11-28, hdante [EMAIL PROTECTED] wrote: On Nov 28, 1:42 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-11-28, hdante [EMAIL PROTECTED] wrote: On Nov 28, 1:09 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote: Python variables

Re: Tip of the day generator.

2007-11-28 Thread Neil Cerutti
: quotelist.append(quote) qfile.close() sigfile = file(sigpath, w) sigfile.write(-- \n) sigfile.write(Neil Cerutti\n) random.seed() if random.choice([True, False]): quote = random.choice(quotelist) for line in textwrap.wrap(quote, 78): sigfile.write(line) sigfile.write('\n') sigfile.close

Re: Tip of the day generator.

2007-11-28 Thread Neil Cerutti
On 2007-11-28, Neil Cerutti [EMAIL PROTECTED] wrote: import textwrap import random import os print Sigswap v0.4 [...] Yikes! That program was in dire need of Pythonification. It must have been written early in my Pythonology. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: How do I not make a list?

2007-11-29 Thread Neil Cerutti
on each of the elements) and then pass it onto something else that expects and iterable. I'm pretty sure this something else doesn't need a list, either, and just wants to iterate over elements. Try itertools.imap. something_else(imap(do_operation, an_iterable)) -- Neil Cerutti You've got to take

Re: Embedding Python - Passing by Reference

2007-11-29 Thread Neil Cerutti
update the value of a in C? I tried (greatly simplified): You cannot do it. You'll have to insist on a boxed value of some kind, like one stored in a list or an object. Python equivalent: def foo(x): ... x[0] = 'foo' ... a = [0] foo(a) a ['foo'] -- Neil Cerutti -- http://mail.python.org

Re: Oh no, my code is being published ... help!

2007-11-30 Thread Neil Cerutti
the above would be something like: my_print(Error Squeezing %s... % the_thingy) With my_print defined appropriately for the time and place. Moreover, publishing code today with print(...) will, at best, require a needless digression. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: Python is not a good name, should rename to Athon

2007-12-01 Thread Neil Cerutti
in the side-effect. Anyhow, Pythonistas know it should've been called C+=1. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is not a good name, should rename to Athon

2007-12-03 Thread Neil Cerutti
as a scientist, but as the most important one who ever lived. To paraphrase Bertrand Russell, Newton was too successful. Over-veneration of Newton was eventually an impediment to progress--this was not, of course, his fault. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is not a good name, should rename to Athon

2007-12-03 Thread Neil Cerutti
response, but failed. Others jumped in to fill the gap, and well... things progressed from there. But your opinion is noted. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is not a good name, should rename to Athon

2007-12-03 Thread Neil Cerutti
is that it doesn't explain how to come up with theories. You need luck, genius, or both. The same applies to language naming. There's no theory of good language names (except for a short list of don'ts); you have to attempt it and see what happens. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: read lines

2007-12-04 Thread Neil Cerutti
, key=itemgetter(1)) print minimum =, min(table, key=itemgetter(1)) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: An Object's Type

2007-12-05 Thread Neil Cerutti
for strings--oh never mind). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: How to split string

2007-12-05 Thread Neil Cerutti
On 2007-12-05, Tim Chase [EMAIL PROTECTED] wrote: http://docs.python.org/lib/module-textwrap.html The Python library has already done all the heavy lifting--no need to re-invent the wheel. Well no, clearly we need xwrap methods and a ctextwrap module. ;) -- Neil Cerutti -- http

Re: Best way to merge/sort two sorted lists?...

2007-12-06 Thread Neil Cerutti
: rval.append(a[aix]) aix += 1 while bix bstop: rval.append(b[bix]) bix += 1 return rval It should beat ResortEverything consistently once the lists become larger than a certain size. Do you get better results at all with the above function? -- Neil Cerutti The audience

Re: Best way to merge/sort two sorted lists?...

2007-12-06 Thread Neil Cerutti
. . . . I'm beginning to think a sorted list merger might make a nice tiny extension module (at least for my purposes). See recipes: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491285 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305269 That's fairly awesome. -- Neil

Re: Best way to merge/sort two sorted lists?...

2007-12-06 Thread Neil Cerutti
On 2007-12-06, Neil Cerutti [EMAIL PROTECTED] wrote: It should beat ResortEverything consistently once the lists become larger than a certain size. Do you get better results at all with the above function? With psyco, my merge_sorted becamse faster than relying on timsort at roughly 80

Re: Best way to merge/sort two sorted lists?...

2007-12-06 Thread Neil Cerutti
On 2007-12-06, Aaron Watters [EMAIL PROTECTED] wrote: On Dec 6, 2:14 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-12-06, Raymond Hettinger [EMAIL PROTECTED] wrote: See recipes: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491285 http://aspn.activestate.com/ASPN/Cookbook

Re: __iadd__ useless in sub-classed int

2007-12-06 Thread Neil Cerutti
. Looks like I stuck, however. You have to implement only the operations you actually use. So to save yourself drudge-work, use fewer operations. ;-) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: File to dict

2007-12-07 Thread Neil Cerutti
) of course) csv reader/writer... before realizing there was such a thing as the csv module :-/ Should have known better... But probably it has made you a better person. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: New subclass vs option in __init__

2007-12-07 Thread Neil Cerutti
factors in deciding the tipping point are: clarity, simplicity, and extensibility. ... The THREE major tipping point factors ARE: clarity, simplicity, extensibility. And efficiency. Among the many factors in deciding the tipping point are: (etc., etc.) -- Neil Cerutti -- http://mail.python.org/mailman

Re: File to dict

2007-12-07 Thread Neil Cerutti
On 2007-12-07, Duncan Booth [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-12-07, Duncan Booth [EMAIL PROTECTED] wrote: from __future__ import with_statement def loaddomainowners(domain): with open('/etc/virtual/domainowners','r') as infile: I've been thinking

Re: File to dict

2007-12-07 Thread Neil Cerutti
On 2007-12-07, Duncan Booth [EMAIL PROTECTED] wrote: from __future__ import with_statement def loaddomainowners(domain): with open('/etc/virtual/domainowners','r') as infile: I've been thinking I have to use contextlib.closing for auto-closing files. Is that not so? -- Neil Cerutti

Re: Equivalent of perl's Pod::Usage?

2007-12-08 Thread Neil Cerutti
verboseness of usage messages with setting exit codes with calling the exit function seems a little bizarre. But I believe optparse will handle parsing arguments and printing usage messages, though not, I think, setting verbosity levels and exiting the program. -- Neil Cerutti -- http

Re: Are Python deques linked lists?

2007-12-09 Thread Neil Cerutti
explain. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem

2007-05-09 Thread Neil Cerutti
? -- Neil Cerutti If we stay free of injuries, we'll be in contention to be a healthy team. --Chris Morris -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie look at Python and OO

2007-05-10 Thread Neil Cerutti
and immutable objects that's the root of your current confusion. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: append

2007-05-10 Thread Neil Cerutti
as much is 1.2.1: Built-In Functions. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: searching algorithm

2007-05-10 Thread Neil Cerutti
the words held in leaf nodes held in the current node. -- Neil Cerutti We shall reach greater and greater platitudes of achievement. --Richard J. Daley -- http://mail.python.org/mailman/listinfo/python-list

Re: searching algorithm

2007-05-10 Thread Neil Cerutti
on solving the problem completely with a binary search returning a range (I'm not sure of the name), which would be more expensive at run time, but might be fast enough, and would use a minimal amount of 'resources'. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: searching algorithm

2007-05-11 Thread Neil Cerutti
the data structure. But you could convert everything to tuples in the end, it's true. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: vim e autoindentazione commenti

2007-05-11 Thread Neil Cerutti
(Spiacente per la mia scrittura difettosa. Sto utilizzando il traduttore di altavista.) -- Neil Cerutti You've got to take the sour with the bitter. --Samuel Goldwyn -- http://mail.python.org/mailman/listinfo/python-list

Re: searching algorithm

2007-05-17 Thread Neil Cerutti
On 2007-05-11, Terry Reedy [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Every node is a tuple of its letter, a list of its children, and | a list of its words. So the two 'pelin' nodes would be (with 'e' | referenced in the 'h' node

Re: converting strings to most their efficient types '1' -- 1, 'A' --- 'A', '1.2'--- 1.2

2007-05-21 Thread Neil Cerutti
experience with Excel-related mistakes leads me to think that column one contains dates that got somehow misformatted on export. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python compared to other language

2007-05-21 Thread Neil Cerutti
strongly typed or untyped? It's strongly typed (only a handful of type conversions are automatic), and dynamically typed (no type declarations for identifiers are needed, types are checked at run time, not compile time). -- Neil Cerutti The doctors X-rayed my head and found nothing. --Dizzy Dean

Re: Installing Python in a path that contains a blank

2007-05-22 Thread Neil Cerutti
' behaviour. I tried both already, but neither one works. If I use a backslash, it doesn't end up in the Makefile, and if I use quotes, I get lots of error messages that I don't really want to analyze. Try adding *more* backslashes. Sometimes, it's the only way. ;) -- Neil Cerutti There are two

Re: converting text and spans to an ElementTree

2007-05-23 Thread Neil Cerutti
[follow_end:end], elem)) else: return %s /%s % (elem, get_tree(text, tail)) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists vs tuples (newbie)

2007-05-23 Thread Neil Cerutti
..except statement the exception specification must be an exception to be caught or a tuple of exception specifications: a list won't work to catch multiple exceptions. I use tuples simply because of their mellifluous appellation. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo

Re: converting text and spans to an ElementTree

2007-05-24 Thread Neil Cerutti
On 2007-05-23, Steven Bethard [EMAIL PROTECTED] wrote: Neil Cerutti wrote: On 2007-05-22, Steven Bethard [EMAIL PROTECTED] wrote: Thanks a lot! This put me on the right track (though the devil's definitely in the details). It's working now:: tree = xmltools.text_and_spans_to_etree('aaa aaa

Re: converting text and spans to an ElementTree

2007-05-24 Thread Neil Cerutti
On 2007-05-24, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-05-23, Steven Bethard [EMAIL PROTECTED] wrote: You mean... I left out the hard part? Shucks. I had really hoped it didn't matter. * the recursive (or stack) part assigns children to parents * the non-recursive part assigns text

Re: just a bug (was: xml.dom.minidom: how to preserve CRLF's inside CDATA?)

2007-05-25 Thread Neil Cerutti
because the CDATA is truncated in mid-character). I'm surprised Mozilla lets it slip by. Web browsers are in the very business of reasonably rendering ill-formed mark-up. It's one of the things that makes implementing a browser take forever. ;) -- Neil Cerutti Potluck supper: prayer and medication

Re: file reading by record separator (not line by line)

2007-06-01 Thread Neil Cerutti
prefer, f.readlines(delim='') etc., a la C++ str::getline. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: *Naming Conventions*

2007-06-05 Thread Neil Cerutti
and j preferable to overly generic terms like item. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Who uses Python?

2007-06-05 Thread Neil Cerutti
inputs and outputs. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: *Naming Conventions*

2007-06-06 Thread Neil Cerutti
On 2007-06-06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-04, Michael Hoffman [EMAIL PROTECTED] wrote: Wildemar Wildenburger wrote: I agree with Bruno that i and j should be used only for indices, but I'm usually less terse than that. I find i and j

Re: lists - append - unique and sorted

2007-06-06 Thread Neil Cerutti
module. -- Neil Cerutti Beethoven wrote fewer symphonies than Haydn and Mozart because he wrote longer, and besides he went death. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list

Re: lists - append - unique and sorted

2007-06-06 Thread Neil Cerutti
On 2007-06-06, Josiah Carlson [EMAIL PROTECTED] wrote: Neil Cerutti wrote: On 2007-06-06, rhXX [EMAIL PROTECTED] wrote: and/or - SORTED - INSERT in the correct place using some criteria? Consult the Python Docs about the heapq module. Heaps (as produced by heapq) are not sorted

Baffled on Windows.

2007-06-07 Thread Neil Cerutti
. The 'other' program is called 'new.py'. Is that what's causing my problem? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Baffled on Windows.

2007-06-07 Thread Neil Cerutti
On 2007-06-07, Robin Becker [EMAIL PROTECTED] wrote: BartlebyScrivener wrote: On Jun 7, 8:17 am, Neil Cerutti [EMAIL PROTECTED] wrote: A good habit for naming your scripts: If you have a script and you want to name it text.py, or list.py or new.py or old.py or some common name

Re: running a random function

2007-06-07 Thread Neil Cerutti
On 2007-06-07, Stebanoid [EMAIL PROTECTED] wrote: if you have a list of functions you can try this: import random import math m[int(math.floor(len(m)*random.random()))]() # seems like Lisp Or rather m[random.randint(0, len(m))]() -- Neil Cerutti Caution: Cape does not enable user to fly

Re: running a random function

2007-06-07 Thread Neil Cerutti
On 2007-06-07, Dustan [EMAIL PROTECTED] wrote: On Jun 7, 1:30 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-07, Stebanoid [EMAIL PROTECTED] wrote: if you have a list of functions you can try this: import random import math m[int(math.floor(len(m)*random.random()))]() # seems

Re: *Naming Conventions*

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-04, Michael Hoffman [EMAIL PROTECTED] wrote: Wildemar Wildenburger wrote: I agree with Bruno that i and j should

Re: running a random function

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Stebanoid [EMAIL PROTECTED] wrote: On 8, 00:07, Dustan [EMAIL PROTECTED] wrote: On Jun 7, 1:30 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-07, Stebanoid [EMAIL PROTECTED] wrote: if you have a list of functions you can try this: import random import math

<    1   2   3   4   5   6   7   8   9   10   >