Re: Inheritance problem

2007-05-09 Thread Neil Cerutti
> print a Similarly: self.a.extend([4, 5, 6]) print self.a Does that give you better results? -- 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
who think in Python, will understand right away > that: > > math.count(x) > > is counting the substring "x" in the "math" string. But can you > see where that might be confused to be a function called > count() in the math module? The only thing you know for sure (without tracing backwards) is that count is an attribute of the object bound to the name 'math' (or something masquerading as an attribute. Look under the hood at descriptors for the details). > I'm not complaining. Python is a great language in many > respects. But, I would take some issue with those claiming > Python is intuitive and easy. IMO: there seems to be many > ambiguous, unintuitve, and confusing, aspects to Python. Name binding can seem confusing at first, but it's really the distinction between mutable 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
The only thing you'll look at nearly 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
lt;-h t e->(odrije?iti, osloboditi) | | (pelin)<-e e->(apsolutan, apsolutni kod) As the user enter letters, you just march down the tree, printing all 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
#x27;, [], ['pelin'])], ['pelin']) [])] [])] []), ('o' trie (thanks Terry) omitted for my sanity)]) It's a lot harder to write by hand than it would be to use. My intuition says it shouldn't be terribly hard on resources for for a 180K dict

Re: searching algorithm

2007-05-11 Thread Neil Cerutti
onvenient while building 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
e Vim: :help format-comments (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' n

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

2007-05-21 Thread Neil Cerutti
At worst, you will get to know how much you >> must check for human errors. >> > > Here you go, Paddy, the following has been generated very methodically; > what data type is the first column? What is the value in the first > column of the 6th row likely to be? > >

Re: Python compared to other language

2007-05-21 Thread Neil Cerutti
; dynamic language with implicit declaration. " > > Is Python 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). --

Re: Installing Python in a path that contains a blank

2007-05-22 Thread Neil Cerutti
;t >> verify it either, just guess from other terminals' 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 an

Re: converting text and spans to an ElementTree

2007-05-23 Thread Neil Cerutti
; """ if not spans: return '' else: head, tail = spans[0], spans[1:] elem, start, end = head if tail: _, follow_start, follow_end = tail[0] else: follow_start, follow_end = (end, end) if end > start: return ("<%s>%s%s%s" % (elem, text[start:follow_start], get_tree(text, tail), text[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
few other cases where you have to use a tuple, for > example in a try..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 mell

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 deta

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

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

2007-05-25 Thread Neil Cerutti
ntal problem, which is > that it isn't correctly encoded (presumably 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

Re: Where do they tech Python officialy ?

2007-07-24 Thread Neil Cerutti
x/concrete-abstractions.html) instead. One cool advantage of SICP is the free online lectures, which helps make up for its non-programmer slant. http://www.swiss.ai.mit.edu/classes/6.001/abelson-sussman-lectures/ -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Closures / Blocks in Python

2007-07-24 Thread Neil Cerutti
prehensions and a few simple statements, rather than promoting the use of nameless functions. Ruby's some_list.each do |item| puts item end if I understood it correctly, In Python would be: for item in some_list: print item That works for any object that supports the iterat

Re: classmethod & staticmethod

2007-07-24 Thread Neil Cerutti
with class list %s" % class_list There's no implicit self or class for Python identifiers. The name class_list must be quailified: self.class_list or MyClass.class_list. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime.time() class - How to pass it a time string?

2007-07-24 Thread Neil Cerutti
ever, the > __init__() method only takes integers (which means I'd be > forced to parse the string myself). Does anyone know of a way I > can make it use the string? Thanks. Consult the documentation about time.strptime (to start) and then datetime.strptime (which refers back to the time.str

Re: datetime.time() class - How to pass it a time string?

2007-07-24 Thread Neil Cerutti
On 2007-07-24, Ben Finney <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> writes: > >> On 2007-07-24, Robert Dailey <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > I have a string in the following format: >> > >>

Re: classmethod & staticmethod

2007-07-24 Thread Neil Cerutti
and dir(MyClass()) for some insight, if it turns out that it matters. Preferably, the user of a class doesn't have to really think about it much. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethod & staticmethod

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: > >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Neil Cerutti
gs!" > d = {"foo": "bar", "baz": "bat"} e = [[1], 2, 3, , 4] f = [1, 2, 3, 4, []] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2007-07-25 at 19:26 +0000, Neil Cerutti wrote: >> Speaking of the iter builtin function, is there an example of the >> use of the optional sentinel object somewhere I could see? > > Example 1: If you use a

Re: is_iterable function.

2007-07-25 Thread Neil Cerutti
mapped(func, iterable): for item in iterable: try: for it in flattened(item): yield func(it) except TypeError: yield func(item) I'd be more confortable excepting some sort of IterationError (or using an is_iterable function, of course). I guess there's

Re: is_iterable function.

2007-07-25 Thread Neil Cerutti
): > return '__iter__' in dir(thing) So then: def is_iterable(thing): return '__iter__' in dir(thing) or '__getitem__' in dir(thing) Speaking of the iter builtin function, is there an example of the use of the optional sentinel object somewhere I could s

Re: is_iterable function.

2007-07-26 Thread Neil Cerutti
> deeply_mapped is reduced down to itertools.imap. I chose to implement deeply_mapped because it illustrated the problem of trying to catch a TypeError exception when one might be thrown by some other code. I agree with your opinion that it's a design flaw, and most of my problems with the code were caused by that flaw. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-26 Thread Neil Cerutti
None: yield it else: yield func(it) else: if func is None: yield item else: yield func(item) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: first, second, etc line of text file

2007-07-26 Thread Neil Cerutti
ine() if line == "": break self.lines.append(line) self.upto += 1 def __getitem__(self, n): self._readupto(n) return self.lines[n] -- Neil Cerutti Eddie Robinson is about one word: winning and losing. --Eddie Robinson's agent Paul Collier -- http://mail.python.org/mailman/listinfo/python-list

Re: pyparser and recursion problem

2007-07-26 Thread Neil Cerutti
step you're missing (and that I missed until my third try) is the setParseAction method, with which you can monkey around with the resulting parse tree. On the other hand, since you got it working without pyparsing, probably you're problem doesn't need pyparsing. Hopefully I'

Re: is_iterable function.

2007-07-26 Thread Neil Cerutti
On 2007-07-26, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 26 Jul 2007 15:02:39 +, Neil Cerutti wrote: > >> Based on the discussions in this thread (thanks all for your >> thoughts), I'm settling for: >> >> de

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-07-25, Jeff <[EMAIL PROTECTED]> wrote: >> Here's a quick flatten() function: >> >> def flatten(obj): >> if type(obj) not in (list, tuple, str): >> raise TypeEr

is_iterable function.

2007-07-25 Thread Neil Cerutti
def is_iterable(obj): try: iter(obj) return True except TypeError: return False Is there a better way? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: <> vs !=

2007-07-27 Thread Neil Cerutti
On 2007-07-27, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I believe Guido doesn't like '<>' and decided to enforce != > instead. Guess it's his language :). I like 'not ==', cf 'not in'. Sadly it's a syntax error. However, as

Re: adding a docstring to an instancemethod

2007-07-27 Thread Neil Cerutti
own masculinity... The trumpet shall sound! -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Where do they tech Python officialy ?

2007-07-28 Thread Neil Cerutti
ality of C++, soon embroiling inexperienced programmers with the difficulties of manual dynamic memory management. That's a big side-show. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: this must be a stupid question ...

2007-07-28 Thread Neil Cerutti
I get a compiler error, so it > probably has some special meaning. It means something in regular expressions, namely, the end of the string/line. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Hex editor display - can this be more pythonic?

2007-07-30 Thread Neil Cerutti
nd XP, and it will work with simply batch files. But it doesn't work with Python, for reasons I don't know enough about Windows console programs to understand. -- Neil Cerutti The audience is asked to remain seated until the end of the recession. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting __future__ features

2007-07-30 Thread Neil Cerutti
What's wrong with just importing what you want and using it? If it's already been enabled, no harm will come from the import statement. -- Neil Cerutti Will the highways on the Internet become more few? --George W. Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting __future__ features

2007-07-30 Thread Neil Cerutti
On 2007-07-30, André <[EMAIL PROTECTED]> wrote: > On Jul 30, 9:39 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> I don't understand the qualification, "at runtime," you're >> making. What's wrong with just importing what you want and >>

Re: Detecting __future__ features

2007-07-30 Thread Neil Cerutti
t would indeed be lame. Of course, it isn't true, right? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Neil Cerutti
27; % type(obj)) The article you linked, when discussing Python closures is really just advocating the use of higher-order functions. But Java's verbosity and lack of free functions are the only irritating obstacle to using them just as you would in Python. I'm not sure what the author

Re: Python end of file marker similar to perl's __END__

2007-08-01 Thread Neil Cerutti
dent all the non-working code by one level, but with a good editor that's a snap. Python will still parse the following lines (it must be valid Python syntax), but the resulting parse tree won't be executed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Extending doctest

2007-08-01 Thread Neil Cerutti
s to must match the actual location in storage. Currently, the doctest stinks because it depends on internal details of my implementation. Is there a doctest feature that will allow me to stipulate that one thing in a result is arbitrary, but identical to another thing in that result? -- Neil C

Re: Python end of file marker similar to perl's __END__

2007-08-01 Thread Neil Cerutti
On 2007-08-01, Cameron Laird <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Neil Cerutti <[EMAIL PROTECTED]> wrote: >>On 2007-08-01, beginner <[EMAIL PROTECTED]> wrote: >>> Thanks everyone for responding. It doesn't look like pytho

Re: Awkward format string

2007-08-01 Thread Neil Cerutti
also tedious and error-prone. Providing a suitable .str or .__repr__ method for your class may make that problem disappear. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python end of file marker similar to perl's __END__

2007-08-02 Thread Neil Cerutti
On 2007-08-02, Magnus Lycka <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2007-08-01, Cameron Laird <[EMAIL PROTECTED]> wrote: . >>> I want to re-emphasize the "triple-quote it" tip mentioned >>> earlier in this thread. I think

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread Neil Cerutti
self.last_value = value return self.compare(lv, value): a = range(15) >>> reduce(is_consecutive(0), a) True >>> reduce(is_consecutive(0), a + [1,2]) False It's been a while since I had to be in the STL mindset, so I couldn't think of a better example. -- Ne

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread Neil Cerutti
On 2007-08-02, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-08-02, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> I don't personally use __call__ methods in my classes, but I >> have encountered it every now and then here at work in code >> written by o

Re: i am new to python-Please somebody help

2007-08-02 Thread Neil Cerutti
s "Yes." I guess literally they have > contributed. Or someone calls your house and asks, "Is > so-and-so there?" You just say "Yes" and hang up on them :-) Those kind of replies are posted for the fun of it, and with the knowledge that somebody else will feel l

Re: Efficient Rank Ordering of Nested Lists

2007-08-03 Thread Neil Cerutti
def rankLists(nestedList): def rankList(singleList): sortedList = list(sorted(singleList)) return map(functools.partial(bisect.bisect_left, sortedList), singleList) return map(rankList, nestedList) -- Neil Cerutti Facts are stupid things. --Ronald Reagan -- http://mail.python.org/mailman/listinfo/python-list

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Neil Cerutti
t; What advantage is there to "elif", apart from it needing three > fewer characters to type? It's a great boon to the authors of auto-indenting text editors. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Neil Cerutti
the language that's brain-dead! ;-) The switch statements I'm aware of are less generally applicable than a tower of "if { else if }* else". For example, with a switch statement you have to dispatch on the one value for every case. In some languages, it's even of

Re: the one python book

2007-08-04 Thread Neil Cerutti
reat tutorial and an awesome language reference. With Python, you won't find anything like that. Python is too huge. So get used to the idea of needing several books. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: the one python book

2007-08-04 Thread Neil Cerutti
On 2007-08-04, Michael Tobis <[EMAIL PROTECTED]> wrote: > On Aug 4, 9:32 am, Neil Cerutti <[EMAIL PROTECTED]> wrot >> With Python, you won't find anything like that. Python is too >> huge. > > That's silly. Python is small in the sense that C is sma

Re: Misleading wikipedia article on Python 3?

2007-08-06 Thread Neil Cerutti
rg/pipermail/python-dev/2005-September/056154.html http://www.python.org/dev/peps/pep-3105 -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Misleading wikipedia article on Python 3?

2007-08-06 Thread Neil Cerutti
On 2007-08-06, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-08-06, Paul Rubin wrote: >> Carsten Haese <[EMAIL PROTECTED]> writes: >>> For instance, if you never use print statements in your code, >>> you won't notice that print is becoming a

Re: Something in the function tutorial confused me.

2007-08-06 Thread Neil Cerutti
default arguments isn't obvious, and for expressions that result in mutable objects, it's not intuitive. -- Neil Cerutti The outreach committee has enlisted 25 visitors to make calls on people who are not afflicted with any church. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-06 Thread Neil Cerutti
On 2007-08-06, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-08-06, Lee Fleming <[EMAIL PROTECTED]> wrote: >> def f(x, y=None): >> if y is None: y = [] >> y.append(x) >> return y > > >>> f(f(23)) > [23, 42] Sorry. That

Re: Scope question

2007-08-06 Thread Neil Cerutti
unc's env is {} >>> func() # env is {y: , func: } 0 In the above case, Python attempts to look up y in func's environment, fails to find it, and so looks it up in the outer environment, where y is bound to . The reason Python does this peculiar thing is that functions don't really have their own fully-fledged environements, the way that modules and classes do. They use an--I presume--simpler, leaner, more efficient construct. One requirement of this simpler construct seems to be that a name must be either defined or undefined inside a function. It can't be defined at one time, and undefined at another time, as can happen in more full-featured environments. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-06 Thread Neil Cerutti
On 2007-08-06, Lee Fleming <[EMAIL PROTECTED]> wrote: > On Aug 6, 6:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > Because when the function is called, the line > > >> if y is None: y = [] > > > is executed, binding a brand new empty list to y. Th

Re: Something in the function tutorial confused me.

2007-08-06 Thread Neil Cerutti
Note that while [] and None may appear to be similar expressions, they are not. None evaluated to itself, while [] evaluates to a new empty list. >>> None is None True >>> [] is [] False -- Neil Cerutti 8 new choir robes are currently needed, due to the addition of several new members and to the deterioration of some of the older ones. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: seeking tinter module

2007-08-07 Thread Neil Cerutti
/repos/geezer/trunk/boss3client/geezer/widgets/tinter.py+tinter.py&hl=en&ct=clnk&cd=1&gl=us -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: All leading tabs or all leading spaces - why isn't that enforced?

2007-08-07 Thread Neil Cerutti
omewhere that Python 3000 will > ban tabs as indentation characters, but now I can't turn up a > link for it... Tabs are going to be banned in the C Style Guide for Python 3000 source code, but they aren't being banned from Python 3000 code. -- Neil Cerutti The concert held i

Re: Another question about variable args.

2007-08-07 Thread Neil Cerutti
maker(ff, a, b, c, d, e, f, g, h) >>> mpack() # Call the function >>> mpack(slice(5, 7), [0, 7]) # Change args 5 and 6, and call again. The args you can change are limited by the slicing powers of Python, and probably combining arg-changing with calling the functio

Re: re.sub does not replace all occurences

2007-08-07 Thread Neil Cerutti
rrences will be replaced. Empty matches for the pattern are replaced only when not adjacent to a previous match, so "sub('x*', '-', 'abc')" returns '-a-b-c-'. In other words, the fourth argument to sub is count, not a set of re flags. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Dealing with multiple excel sheets

2007-08-07 Thread Neil Cerutti
On 2007-08-07, Rohan <[EMAIL PROTECTED]> wrote: > I would like to write a script which does the following job. > Take column1 and 7 from 10 different excel sheets and pasthe > them into a new excel worksheet. Any ideas on how to do it Get the xlrd Python module. It'll come

Re: Misleading wikipedia article on Python 3?

2007-08-08 Thread Neil Cerutti
On 2007-08-08, Istvan Albert <[EMAIL PROTECTED]> wrote: > On Aug 6, 6:49 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> Incidentally, from the second link I find it shocking that the >> keyword parameter "file" shadows a builtin. It seems to >> endorse a

Re: Something in the function tutorial confused me.

2007-08-08 Thread Neil Cerutti
nt statements The former refers to "augmented arithmetic operations", which I think is a nice terminology, since assignment is not necessarily taking place. Then the latter muddies the waters. So Steve was both wrong and right, depending on the terminology. I tend to think the world

Re: Misleading wikipedia article on Python 3?

2007-08-08 Thread Neil Cerutti
On 2007-08-08, Istvan Albert <[EMAIL PROTECTED]> wrote: > On Aug 8, 2:00 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> I thought, in fact, that open was on more shaky ground. ;) > > yeah, that too ... OK, I had misremembered. The current docs say that open is p

Re: Misleading wikipedia article on Python 3?

2007-08-08 Thread Neil Cerutti
() can be "removed", actually, unless the file type itself is getting axed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with Dictionaries and Classes requested please.

2007-08-09 Thread Neil Cerutti
;Adam") Now you'll get a list of names for every age. >>> d[50] ["Gary", "Guido"] You can use the same function to build a mapping from names to lists of ages. d = {} multidict_add(d, "Gary", 50) multidict_add(d, "Gary", 23) multidict_add(d, "Adam", 25) >>> d["Gary"] [50, 23] -- Neil Cerutti The choir invites any member of the congregation who enjoys sinning to join the choir. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: check if regeular expression has results

2007-08-09 Thread Neil Cerutti
a match. > > What's the way to do that simply? Newgroups are a poor substitute for the docs. For one thing, newsgroups sometimes contain cranky people who say, "RTFM!" The docs will never do that. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with Dictionaries and Classes requested please.

2007-08-09 Thread Neil Cerutti
On 2007-08-09, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Neil Cerutti a écrit : >> On 2007-08-09, special_dragonfly <[EMAIL PROTECTED]> wrote: >>> Is there anyway for python to consider the values within a >>> string when entering the data into a dicti

Re: Something in the function tutorial confused me.

2007-08-09 Thread Neil Cerutti
manually for new data types, but if you get it wrong your code is pretty much useless. You are free to create your own assignment semantics, as long as they match the semantics of the built in types. Python has this property as well, though you're limited to screwing up the "augmente

Re: Stackless Integration

2007-08-09 Thread Neil Cerutti
On 2007-08-09, Justin T. <[EMAIL PROTECTED]> wrote: > >> It's not Pythonic. >> >> Jean-Paul > > Ha! I wish there was a way to indicate sarcasm on the net. You > almost got people all riled up! Sorry. There's NO WAY to show sarcasm on the net. ;

Re: Puzzled by "is"

2007-08-09 Thread Neil Cerutti
immutable, the rules for literals apply (i.e., two occurrences of the empty tuple may or may not yield the same object). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Puzzled by "is"

2007-08-09 Thread Neil Cerutti
han a certain length are 'interned'. This makes them very fast to compare for equality, and cheaper to store (maybe?). > a is b > true > c = 'q' * 10 > c > 'qq' #10 q's > d = 'q' * 10 > d > 'qq' #10 q's > c is d > false > > So from what I've read "==" tests for equivalence, "is" tests > for identity but that does not explain the behaviour above. The 10 q's constructed with string arithmetic were not interned, because they were not literals. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-11 Thread Neil Cerutti
On 2007-08-11, Alex Martelli <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: >... >> The Python Language Reference seems a little confused about the >> terminology. >> >> 3.4.7 Emulating numeric types >> 6.3.1 Augmente

Re: Something in the function tutorial confused me.

2007-08-11 Thread Neil Cerutti
> On 2007-08-11, Alex Martelli <[EMAIL PROTECTED]> wrote: >> Neil Cerutti <[EMAIL PROTECTED]> wrote: >>... >>> The Python Language Reference seems a little confused about >>> the terminology. >>> >>> 3.4.7 Emulating numeric

Re: Adventure-Engines in Python

2007-08-13 Thread Neil Cerutti
on system distributed as a library for a general-purpose language has ever caught on. Every system that's enjoyed even moderate success has been a language+library implementation. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Colored text

2007-08-13 Thread Neil Cerutti
des -- http://en.wikipedia.org/wiki/ > ANSI_escape_code: Unfortunately, most versions of Windows of the last 7 years (2000, XP, probably Vista) don't support ANSI escape codes well enough to work with Python. -- Neil Cerutti We have to play hard for the full 40 minutes. 48? Oh

Re: Something in the function tutorial confused me.

2007-08-13 Thread Neil Cerutti
On 2007-08-12, Alex Martelli <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: >... >> OK, I've thought about this some more and I think the source >> of my confusion was I thought assignment in Python meant >> binding a name to

Re: Car Air Conditioners

2007-08-13 Thread Neil Cerutti
se days, > that's not entirely beyond the realms of > possibility... Well, I thought the post was about a cool new version of Lisp. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Module imports during object instantiation

2007-08-14 Thread Neil Cerutti
; import rick >>>> os.name > 'posix' >>>> import foobar > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named foobar >>>> > > > > For the 'posix' OS, I'm doing an erratic import which should fail and print > the error message. > > See, it prints nothing. This _is_ what has made me conclude > that imports aren't executed in __init__(). But hey, they will > get executed if you put them in any of the methods (which is > again illogical because methods can/are called multiple times). If you want an import inside an __init__ to run, you must call the __init__ function that contains it. >>> log = rick.Log() You'll get another surprise when you do this, though. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: LEGB rule, totally confused ...

2007-08-14 Thread Neil Cerutti
ue to X, X is assumed to be a local variable unless you say otherwise with a global statement. Note that the global statement in Init applies only in Init's code block. Run must have it's own 'global X' statement, if applicable. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Module imports during object instantiation

2007-08-14 Thread Neil Cerutti
On 2007-08-14, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > >> If you want an import inside an __init__ to run, you must call >> the __init__ function that contains it. > > Doesn't __init__ get called automatically ? It gets called

Re: curses library

2007-08-14 Thread Neil Cerutti
as one of its included batteries. First try the curses module. It does come with Python on systems with a curses port. For Windows, there's the Effbot's console module. http://effbot.org/zone/console-index.htm Or go to plan B: Use a Tkinter or other GUI interface's text widget. -- N

closing StringIO objects

2007-08-15 Thread Neil Cerutti
The documentation says the following about StringIO.close: close( ) Free the memory buffer. Or else... what? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinions about this new Python book?

2007-08-15 Thread Neil Cerutti
tions accepting predicates as aruments: 6.5.1 Itertools functions 6.5.3 Recipes 11.47 Creating a new Distutils command 26.10.1 Types and members The following provides a few predicate functions (weird! I'd have never thought to look there for, e.g., ismodule): 6.7 operator -- Standard operat

Re: closing StringIO objects

2007-08-15 Thread Neil Cerutti
On 2007-08-15, Alex Martelli <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: >> The documentation says the following about StringIO.close: >> >> close( ) >> Free the memory buffer. >> >> Or else... what? > >

Re: Module imports during object instantiation

2007-08-15 Thread Neil Cerutti
On 2007-08-15, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > >>> >>> Doesn't __init__ get called automatically ? >> >> It gets called automatically when you construct an instance of >> the class in which it's

Re: A problem with Time

2007-08-16 Thread Neil Cerutti
ime.datetime.today() - datetime.timedelta(days=1) >>> yesterday.strftime('%m%d%Y') '08152007' -- Neil Cerutti It might take a season, it might take half a season, it might take a year. --Elgin Baylor -- http://mail.python.org/mailman/listinfo/python-list

Re: Who told str() to round my int()'s!!!

2007-08-16 Thread Neil Cerutti
for the old str type called, I think, 'bytes'. So the 3000 devs seem to agree with you to some extent. -- Neil Cerutti Ushers will eat latecomers. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: help on object programing

2007-08-17 Thread Neil Cerutti
pinion the classes section of the official tutorial is unfortunately the least tutorial part of the tutorial. But it won't steer you wrong. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbee Question

2007-08-20 Thread Neil Cerutti
could make a deal like that. I stop working all the time! -- Neil Cerutti Customers who consider our waitresses uncivil ought to see the manager --sign at New York restaurant -- http://mail.python.org/mailman/listinfo/python-list

Re: reading a line in file

2007-08-21 Thread Neil Cerutti
On 2007-08-20, Shawn Milochik <[EMAIL PROTECTED]> wrote: > Everybody hates regexes. Except me. Discrimination! I love them when I'm editing files with Vim, hate 'em when I'm analyzing files with Python code. So I'm a descriminate descriminator. -- Neil Cerutti The

Re: for statement on empty iterable

2007-08-22 Thread Neil Cerutti
grasp the idioms of the language, around here > ofter referred to as "beeing pythonic." It's hard to keep up with the new buzzwords that keep popping up in this group. -- Neil Cerutti A billion here, a billion there, sooner or later it adds up to real money. --Everett Dirksen -- http:

Re: beginner, idiomatic python

2007-08-27 Thread Neil Cerutti
e count each iteration. This sort of suggests a direct solution: for i in xrange(self.parent.GetPageCount()): if i >= self.parent.GetPageCount(): break # do stuff At least that way you're spared the manual manipulation of i. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   10   11   12   >