Re: merits of Lisp vs Python

2006-12-08 Thread Neil Cerutti
But either system comes naturally enough with practice. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Snake references just as ok as Monty Python jokes/references in python community? :)

2006-12-08 Thread Neil Cerutti
ave anything to do with the name of our >> favorite language? (*Everyone* gets snake jokes! :) > > It's people like you wot cause unrest! I think the decent people of this newsgroup are sick and tired of being told that the decent people of this newsgroup are sick and tired. I'

Quake 3 and the Python interpreter

2006-12-10 Thread Neil Toronto
download a Quake 3 mod from someone, you can be fairly sure it won't hose your system. In particular, it won't let you access files outside of the game directory. Is there a way I can accomplish something similar in an embedded Python application? I probably only have to make it secure

Re: merits of Lisp vs Python

2006-12-11 Thread Neil Cerutti
pathname library. I suppose I missed whatever the point was supposed to be in the midst of the mind-boggling. I meant to get back to it but haven't yet. -- Neil Cerutti We will sell gasoline to anyone in a glass container. --sign at Santa Fe gas station -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
es to matching the Python code), but whatever it is would be a better foundation for comparing brain units with the above Python. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
On 2006-12-13, hit_the_lights <[EMAIL PROTECTED]> wrote: > Neil Cerutti schrieb: > >> >> a[i] = b[n] >> >> >> >> with >> >> >> >> (setf (aref a i) (aref b n)) >> >> >> >> and the attractions of Py

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
ups in > copy-paste cannot be fixed by the editor automatically, because > it cannot read the original programmer's mind, and you have to > fix it manually, and risk screwing it up. It is very easy a manual process, possibly as simple as selecting the correct s-expr and pasting i

Re: Conditional iteration

2006-12-13 Thread Neil Cerutti
't annoy me that it didn't work, but it did seem natural to me given the syntax of comprehensions. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-14 Thread Neil Cerutti
On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Neil Cerutti wrote: >> On 2006-12-13, [EMAIL PROTECTED] >> <[EMAIL PROTECTED]> wrote: >> > Expressions keep the same meaning even if you have to start >> > breaking them across lines,

Re: merits of Lisp vs Python

2006-12-14 Thread Neil Cerutti
On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Neil Cerutti wrote: >> On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > >> > Neil Cerutti wrote: >> >> On 2006-12-13, [EMAIL PROTECTED] >> >> <[EMAIL

Re: Routine for prefixing '>' before every line of a string

2006-12-14 Thread Neil Cerutti
adipiscing [...]''' > prefix = '>' > > import textwrap > lines = ["%s %s" % (prefix, line) for line in textwrap.wrap(text, > width=75)] The solution will need to be instrumented in case of text that is already quotes to one level. All

Re: tuple.index()

2006-12-14 Thread Neil Cerutti
oes. It makes perfect sense. > I did say that I thought it would be a rarely used feature :-) Though the full rationale no longer applies to strings, which now have plenty of methods. -- Neil Cerutti Weight Watchers will meet at 7 p.m. Please use large double door at the side entrance. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: WHAT is [0] in subprocess.Popen(blah).communicate()[0]

2006-12-14 Thread Neil Cerutti
I like using pattern matching in these simple cases: last_line, _ = subprocess.Popen([r"tail","-n 1", "x.txt"], stdout=subprocess.PIPE).communicate() -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-15 Thread Neil Cerutti
u *really* think > that the Lisp savings are not worth it, then you would begin > with my suggestion today. I don't know how to build a house. It doesn't make me want to live in a cave. ;-) -- Neil Cerutti The third verse of Blessed Assurance will be sung without musical accomplishment. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: array, a better shell

2006-12-20 Thread Neil Cerutti
ot;, "hello") > > But it seems such capability isn't shared with the append: > >>>> a.extend("hello") > Traceback (most recent call last): > File "", line 1, in > TypeError: an integer is required Try: >>> a.fromstring(&qu

Chris Akre

2006-12-30 Thread Neil Agron
Chris, If my name is familiar, please contact me. -Neil-- http://mail.python.org/mailman/listinfo/python-list

Re: DOS, UNIX and tabs

2007-01-02 Thread Neil Cerutti
my code. I first came accross it in Stroustrup's _The C++ Programming Language_. I liked the look and the idea immediately, but my editor of choice (by historical accident) Vim, doesn't yet support it. -- Neil Cerutti I've had a wonderful evening, but this wasn't it. --Groucho Marx -- http://mail.python.org/mailman/listinfo/python-list

Re: array of class / code optimization

2007-01-03 Thread Neil Cerutti
efinition S, say, rename it to be xyz.cpp > and feed it to a C++ compiler, the S sure remains a struct and > the C++ compiler has no difficulty in handling it as a struct, > so ?!? That's true. But it's also true that struct foo { int x, y; }; is exactly equivalent to:

Re: Sorting on multiple values, some ascending, some descending

2007-01-04 Thread Neil Cerutti
tory that's not stored in a format that's easy to sort. >>> a = [("Neil Cerutti", "8025552954"), ("Ted Smith", "8025552281"), ("Barny >>> Fife", "8025551105")] >>> b = [(" ".join(reversed(x.

Re: Sorting on multiple values, some ascending, some descending

2007-01-04 Thread Neil Cerutti
On 2007-01-04, Peter Otten <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> Another trick is to factor the key application out of the >> sort. This may be a good idea if when you want to minimize the >> number of times your key function is called. >>

Re: Why less emphasis on private data?

2007-01-08 Thread Neil Cerutti
_x = 'mod2' > > And the test is: > > from mod1 import B as B1 > from mod2 import B as B2 > > class A(B1, B2): pass > > a = A() > a.foo() > print a._B__x > a.bar() > print a._B__x > > Sure enough, mod2 messes up mod1's pr

Re: recursive function

2007-01-08 Thread Neil Cerutti
gh if only I knew the > number of keys/lists beforehand len(dict.keys()). -- Neil Cerutti Next Sunday Mrs. Vinson will be soloist for the morning service. The pastor will then speak on "It's a Terrible Experience." --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Why less emphasis on private data?

2007-01-08 Thread Neil Cerutti
static int i; > } > > > Do you agree that i is "private" to test ? In C one uses the pointer to opaque struct idiom to hide data. For example, the standard FILE pointer. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Why less emphasis on private data?

2007-01-08 Thread Neil Cerutti
On 2007-01-08, Jussi Salmela <[EMAIL PROTECTED]> wrote: > Neil Cerutti kirjoitti: >> In C one uses the pointer to opaque struct idiom to hide data. >> For example, the standard FILE pointer. > > To Neil Cerutti: If a programmer in C has got a pointer to some > piece o

Re: Colons, indentation and reformatting.

2007-01-09 Thread Neil Cerutti
foo: > print "Foo!" > if bar: > print "Bar!" That's the key issue. The colon gives the editor an easy clue where a block starts, but the there's no simply way to determine where the block is supposed to end. -- Neil Cerutti Remember in prayer the many who are sick of our church and community. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine an object is a subclass of another

2007-01-09 Thread Neil Cerutti
n doesn't even try to make educated guesses. class Thing: pass class Animal(Thing): pass class Dog(Animal): pass -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

A simple lexer

2007-01-09 Thread Neil Cerutti
x27;) o_bracket = re.compile('\\[') c_bracket = re.compile('\\]') colon = re.compile(':') ix = 0 lexed_line = [] m = lambda regex, ix: match(regex, proto, ix, lexed_line) while ix < len(proto): old = ix ix = m(arg_count, i

Re: Read from Serial Port

2006-01-23 Thread Neil Benn
self.fireNewMessage(strReceivedString) except: raise finally: self.__objLock.release() PySerial wraps all the platform specific stuff you, so you should really use that, it behaves fairly well - the only real problem is a lack o

Re: Using non-ascii symbols

2006-01-27 Thread Neil Hodgson
ot; with "←" also an improvement. I'm so used to "/" for division that "÷" now looks strange. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Python module for LX200 telescope command set

2006-01-30 Thread Neil Benn
If you really want to get the operation correct then start with the serial communication, get a bit of paper and think what could ever possibly go wrong with the communication. Then design your serial communication for that. Here's a few communciations thigns to worry about: Requested p

Re: Generators vs. Functions?

2006-02-04 Thread Neil Schemenauer
atch in the first place. Right. Resuming a generator is faster than calling a function. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Generators vs. Functions?

2006-02-05 Thread Neil Schemenauer
ll may be faster due to CPU cache effects or branch prediction. In any case, the difference you are trying to measure is extremely small. Try adding some arguments to the functions (especially keyword arguments). What your test does show is that the speed difference should not come into the d

Re: Thread imbalance

2006-02-05 Thread Neil Hodgson
sibly also lua and C#. Lua has coroutines rather than threads. It can cooperate with threading implemented by a host application or library. See the coroutines chapter in http://www.lua.org/pil/index.html Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Thread imbalance

2006-02-06 Thread Neil Hodgson
's interpreter will perform synchronization if you create multiple threads that attach to a shared Lua state. You have to provide some functions for Lua to call to perform the locking. If you create multiple Lua states they are completely separate worlds and do not need to be synchronized.

Re: UTF16, BOM, and Windows Line endings

2006-02-06 Thread Neil Hodgson
line endings u'\r\n' ? (This > sequence obviously encodes to four bytes in UTF16). I would only do > this to ensure compatibility with other programs the user may use to > create the text files. Notepad will read u'\r\n'. It doesn't like '\n' or u

Re: UTF16, BOM, and Windows Line endings

2006-02-06 Thread Neil Hodgson
ine > endings in use. You can normalise line endings: >>> x = "a\r\nb\rc\nd\n\re" >>> y = x.replace("\r\n", "\n").replace("\r","\n") >>> y 'a\nb\nc\nd\n\ne' >>> print y a b c d e The empty line is because "\n\r" is 2 line ends. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check...

2006-02-11 Thread Neil Hodgson
CII characters: The €200 encyclopædia defines the “coördinates” in ¼ ångströms. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another GUI toolkit question...

2006-02-11 Thread Neil Hodgson
ated smooth background. > http://www.wordtech-software.com/ireveal-linux.png Totally native. If you are still using a 10 year old desktop environment. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: commenting out blocks of code

2006-02-17 Thread Neil Hodgson
lf. Wouldn't that be fun? Your imaginary command makes no sense as it is described. What are its full semantics? Why was it implemented this way? BTW, I have been implementing GUIs for over 20 years so maybe me and the other SciTE users are in our own world. It does feel like a friendly, enjoyable, comfortable world, though. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: commenting out blocks of code

2006-02-19 Thread Neil Hodgson
; is common in much source code particularly in barrier comments and comment sections: Persistence section ## These functions are responsible for load ## and save for the core media database. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode and MoinMoin

2006-02-26 Thread Neil Hodgson
;replace') u'AUTHOR: blahblah\n\nTITLE: Reading Course Readings... G. A. \ufffd For references see blahblah.\n\n\n-\n\n' BTW, its probably in Windows-1252 where it would be a dash. Depending on your context it may pay to handle the exception instead of using "replace" and attempt interpreting as Windows-1252. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: XP rich text cut-n-paste

2006-03-05 Thread Neil Hodgson
ying that to the clipboard. It only works on Windows due to the simpler clipboard API compared to X and since RTF is a common format on Windows. Other projects sometimes include code from SciTE even though the code isn't really written for reuse. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: gtk/qt scintilla help !

2005-05-01 Thread Neil Hodgson
ciTE .api format. The SciTE editor is shipped with some keyword lists, including some for POV in the pov.properties file. To set keywords, call SCI_SETKEYWORDS as described on the documentation page. I do not personally use the Qt or PygtkScintilla wrappers for Scintilla. Neil

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Neil Hodgson
did not give a definitive answer but there were complaints from people about not being able to do this. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Fw: evidence john bokma al jazeera connection ?

2005-05-21 Thread Neil Hodgson
There is a response to this on John's web site: http://johnbokma.com/mexit/2005/05/19/daniel-joseph-min.html Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem accessing Python Business Forum

2005-05-26 Thread Neil Hodgson
ts # -- but fixing the website is not one of them. # # If anybody here wants this job, it is all yours. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: using boost to return list

2005-06-04 Thread Neil Hodgson
GujuBoy: > i am trying to make a "cpp" file which will make an array and pass it > to python as a list. > > how is this possible...i am using BOOST...please can someone point me > at some examples This returns a list when called from Python. static list retrieval_as_list(SplitText &self, in

Re: error in usin list with boost

2005-06-05 Thread Neil Hodgson
eded but it was in the code I copied from) to already be in your code if you are using Boost Python: #include #include using namespace boost::python; Have you read the Tutorial Introduction? http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: GUI builders considered harmful (Was: anygui, anydb, any opinions?)

2005-06-05 Thread Neil Hodgson
e '=' onto the pixel grid will distort the text appearance. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: getmtime differs between Py2.5 and Py2.4

2007-06-01 Thread Neil Hodgson
mes cache time values. Even closing and reopening the properties can show the old value. dir should always read the times though. Neil -- http://mail.python.org/mailman/listinfo/python-list

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

2007-06-01 Thread Neil Cerutti
=re.compile('>|<'), end='---') > BlockReader(f, start=lambda x: x.startswith('>')) > > Maybe make variations for character-based readers and > line-based readers. I would 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
> 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 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
ntly, and with similar data 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 >>&g

Re: lists - append - unique and sorted

2007-06-06 Thread Neil Cerutti
ria? Consult the Python Docs about the heapq 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

Baffled on Windows.

2007-06-07 Thread Neil Cerutti
that list. 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.p

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

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: >> >> > i

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:

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: >> &

Working with fixed format text db's

2007-06-08 Thread Neil Cerutti
ily, the output format has not changed yet, so issues with maintaining the above haven't arisen. However, I'd like something better. Is there already a good module for working with fixed format records available? I couldn't find one. If not, please suggest how I might improve the above co

Re: Working with fixed format text db's

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: >> Luckily, the output format has not changed yet, so issues with >> maintaining the above haven't arisen. > > The problem surely is that when you want to ch

Re: Working with fixed format text db's

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Neil Cerutti wrote: > >> new = file("new.dat", "w") >> if not new: >> print "Error. Could not open file new.dat for writing

Re: *Naming Conventions*

2007-06-11 Thread Neil Cerutti
On 2007-06-11, Marius Gedminas <[EMAIL PROTECTED]> wrote: > On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> > Since 'i' and 'j' are canonically loop indices, I find it >> > totally confusing to use them to name the iteration var

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-12 Thread Neil Cerutti
igned not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary. Of course, that was written well before Scheme had most of its current features. -- Neil Cerutti These people haven't seen the last of my fa

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
and non-recursive tail-calls. You can't reasonably hand-optimize away the stack frame for all tail-calls. def foo(x) bar(x) The only way to hand-optimize the call to bar is to inline it yourself. -- Neil Cerutti Will the highways on the Internet become more few? --George W. Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
her behavior would be absurd, > anyhow. There's a reason it's generally refered to as "tail-call" optimization and not "tail-recursive" optimization. The former is more general, and, I believe, easier to implement than the latter. -- Neil Cerutti The peace-making

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
ot;, line 525, in bar raise ValueError ValueError shell returned 1 What makes the latter harder to work with? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
On 2007-06-13, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-13, Anders J. Munch <[EMAIL PROTECTED]> wrote: >> General tail-call optimisation is of course completely >> out-of-bounds for Python, because it ruins tracebacks. Unlike >> tail recursion, w

Re: Method much slower than function?

2007-06-13 Thread Neil Cerutti
slowing it down in comparison to the non-method version. Try the following simple optimization, using a local variable instead of an attribute to build up the result. # The method in a class class bar: def readgenome(self, filehandle): s = '' for line in filehandle.xre

Re: Method much slower than function?

2007-06-14 Thread Neil Cerutti
On 2007-06-14, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Neil Cerutti a écrit : > (snip) >> class bar: >> def readgenome(self, filehandle): >> self.s = ''.join(line.strip() for line in filehandle) > >=> >self.s

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-16 Thread Neil Cerutti
t provides to deal with multiple inheritance, or generic, type-safe code. I don't think it's inconsistent, though. The complexity of a feature *tends* to mirror the *real* complexity. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-16 Thread Neil Cerutti
On 2007-06-16, Paul Rubin wrote: > Neil Cerutti <[EMAIL PROTECTED]> writes: >> I vote for C++ as being astoundingly complex. But it provides >> complex features, e.g.,the machanisms it provides to deal with >> multiple inheritance, or generic, type-safe code. > &

Re: Goto

2007-06-17 Thread Neil Cerutti
ns long before I learned about functions in Programming 101. 100 NAME$="TED" 110 AGE=40 120 GOSUB 1000 1000 PRINT NAME$, " IS ", AGE, " YEAR(S) OLD." 1010 RETURN Named functions are so much nicer than numbered ones. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-17 Thread Neil Cerutti
On 2007-06-17, Paul Rubin wrote: > Neil Cerutti <[EMAIL PROTECTED]> writes: >> I don't know that much about ML. I know is does a really nice job >> of generic containers, as does C++. But can it 'foo' any type as >> easily as C++? >> >&

Re: Parsing HTML, extracting text and changing attributes.

2007-06-18 Thread Neil Cerutti
s and what technique I should use. You could get good results, and save yourself some effort, using links or lynx with the command line options to dump page text to a file. Python would still be needed to automate calling links or lynx on all your documents. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE

2007-06-19 Thread Neil Cerutti
directory and read python.vim. Unfortunately, the current version contains no documention, so it's harder to figure out what you get than it ought to be. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-19 Thread Neil Cerutti
impractical discussions of Scheme's dark corners. Python is either much more free of dark corners, or else simply doesn't attract that kind of aficionado. -- Neil Cerutti Let us join David and Lisa in the celebration of their wedding and bring their happiness to a conclusion. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
an instance of the class: foo f; f.bar(); } In C++ they are used most often for factory functions, since they conveniently have access to the class's private members, and don't want or need an existing instance. Python seems to have adopted this use-case (ConfigParser, for example)

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> In C++ they are used most often for factory functions, since they >> conveniently have access to the class's private members, and >> don't want or n

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-20, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote: >> Neil Cerutti <[EMAIL PROTECTED]> wrote: >>> In C++ they are used most often for factory functions, since >>> they conveniently have a

Re: Python and (n)curses

2007-06-20 Thread Neil Cerutti
s implementation of your Python curses program. It doesn't actually use the windows console, however. You could write your own little console interface, tailored to your needs, which is implemented using curses on Unix, and the effbot's 'console' on Windows. -- Neil Cerutti Symphonies of the Romantic era were a lot longer in length. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list

Re: Split file into several and reformat

2007-06-21 Thread Neil Cerutti
> > And so on. Many thanks, I think I'd put together a simple grammar and then write a recursive descent parser that spit out my output files. But that's just because I find that kind of thing fun. ;) -- Neil Cerutti I'm tired of hearing about money, money, money, money

Re: strip() 2.4.4

2007-06-21 Thread Neil Cerutti
open('in.txt', 'r') > > for line in f1: > print line.rsplit(':')[4].strip("'"), > > Output: > > Afghanistan' > Albania' > Algeria' > American Samoa' > > Why is there a apostrophe still at the end? Most likely it's the newline at the end of each record that's getting in your way. You can double-strip it. for line in f1: print line.strip().rsplit(':')[4].strip("'") -- Neil Cerutti The world is more like it is now than it ever has been before. --Dwight Eisenhower -- http://mail.python.org/mailman/listinfo/python-list

Re: Globals in nested functions

2007-06-21 Thread Neil Cerutti
t the intended effect. def f(): a = [12] def g(): if a[0] < 14: a[0] = 13 g() return a[0] You'll get better results, in Python, by using a class instances instead of closures. Not that there's anything wrong with Python closures, but the scoping rules make some fun tricks too tricky. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-21 Thread Neil Cerutti
ge prior to the adoption of CLOS. Is there a second example? ;) Seriously, maybe Python looks like 'blub' (thanks, Paul Graham), to the skilled Lisp user, but it makes a lot of other languages look like 'blub', too, including, sometimes, Lisp: Lisp has to 'blub' generators. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing two lists and returning "position"

2007-06-21 Thread Neil Cerutti
27;] > > what I need to do is compare l1 against l2 and return the "position" > of where each object in l1 is in l2 > > ie: pos = 0, 2, 4 > > Thanks in advance, -h Come, come! You can try harder than that. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-22 Thread Neil Cerutti
On 2007-06-21, Douglas Alan <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> writes: >> Seriously, maybe Python looks like 'blub' (thanks, Paul >> Graham), to the skilled Lisp user, but it makes a lot of other >> languages look like 'blu

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-22 Thread Neil Cerutti
On 2007-06-22, Douglas Alan <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> writes: >> That said, I wouldn't give up the summer I spent studying _Simply >> Scheme_. > > Sounds like fun. Is this like a kinder, gentler version of SICP? No, it i

Re: I need some cleanings tips and advice.

2007-06-22 Thread Neil Cerutti
's see if I get this right. > > You create a website for a subject that you know nothing about. Then you > try to solicit content in a bunch of programming language newsgroups. > > Wow, that's pretty pathetic, even for a google-groups poster! Maybe they lost the business

Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Neil Cerutti
for the .split method. x = 'Smith, Ted, 15 Smedly Rd." last, first, street = x / ', ' Tongue-in-cheekily-yours, -- Neil Cerutti Strangely, in slow motion replay, the ball seemed to hang in the air for even longer. --David Acfield -- http://mail.python.org/mailman/listinfo/python-list

Re: listing all property variables of a class instance

2007-06-25 Thread Neil Cerutti
only those variables? This is off the cuff. There's likely a better way. for k, v in MyClass.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ -- Neil Cerutti 22 members were present at the church meeting held at the home of Mrs. Marsha Crutchfield last evening.

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Neil Cerutti
how to make > the interpreter find instance name space first? Or any way to > make programmer's life easier? Try thinking of "self." as a notation that provides vital information to you, the programmer. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Reversing a string

2007-06-27 Thread Neil Cerutti
iliar > with generators yet so don't laugh) which changed my code just > a slight bit: Experimentation with stuff you don't fully understand is a great way to learn, but not that useful for solving exercises. ;) -- Neil Cerutti This team is one execution away from being a very good basketball team. --Doc Rivers -- http://mail.python.org/mailman/listinfo/python-list

Re: listing the type of an object

2007-06-28 Thread Neil Cerutti
ation... > This should be: > > class Led(Device): > #... Using a naming convention for class objects, e.g., camel-case, is a practice very similar to hungarian notation. I would've said something like: start learning the Python community's naming conventions, and use t

Pretty Scheme, ??? Python

2007-07-02 Thread Neil Cerutti
SyntaxError("Ill-formed expression") return parse_ast(sexp.read(expr)) The sexp parser I wrote returns a tuple that represents the parse tree of an s-expression, and recognizes only s-expressions, strings and integers. How can I make the Python more idiomatic Python? How can I make it more "beautiful"? A type hierarchy seems over-engineered in comparison to Scheme's type-case, but I liked a cascade of isinstance calls (as in parse) even less. The type hierarchy did allow me to factor out the code duplication in the (sub ...) and (add ...) types of Scheme, and seems like a nice benefit over type-case. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Pretty Scheme, ??? Python

2007-07-02 Thread Neil Cerutti
On 2007-07-02, Laurent Pointal <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> How can I make the Python more idiomatic Python? > > Have you taken a look at pyparsing ? Yes, I have it. PyParsing has, well, so many convenience features they seem to shout down whatever

Re: Pretty Scheme, ??? Python

2007-07-03 Thread Neil Cerutti
On 2007-07-02, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Jul 2, 3:56 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > from pyparsing import * It's always good when your messages start like that. ;) > """ > Ok, here is the step-by-step, beginning with

<    6   7   8   9   10   11   12   13   14   15   >