Re: what is wrong with that r"\"

2007-07-03 Thread Neil Cerutti
uble quote; r"\" is not a valid string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw string cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by

Re: Pretty Scheme, ??? Python

2007-07-03 Thread Neil Cerutti
, line 810, in _ parseNoCache tokens = fn( instring, tokensStart, retTokens ) File "C:\edconn32\Python25\Lib\site-packages\pyparsing.py", line 658, in t mp return f(t) File "wae.py", line 118, in binop.setParseAction(lambda t: BinOp(t.op, t.lhs,

Re: Pretty Scheme, ??? Python

2007-07-03 Thread Neil Cerutti
out the Python version is the cruft required by the class hierarchy. -- Neil Cerutti I pulled into a lay-by with smoke coming from under the bonnet. I realized the car was on fire so took my dog and smothered it with a blanket. --Insurance Claim Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3.0 or 3000 ....is it worth waiting??? Newbie Question

2007-07-03 Thread Neil Cerutti
On 2007-07-03, Méta-MCI <[EMAIL PROTECTED]> wrote: > Hi! > >> Python 3000 doesn't include many significant changes to the language > > One exemple : non-Ascii characters in identifiers (= no significatif > change?) It is one of not many? -- Neil Cerutti --

Re: what is wrong with that r"\"

2007-07-04 Thread Neil Cerutti
n we could remove b) also and r"" strings > would work as everyone expects. > > Does anyone know the justification for a)? Maybe we should > remove it in py3k? If the escaped quotes didn't function in raw strings, I'd be unable to construct (with a single notat

Re: what is wrong with that r"\"

2007-07-04 Thread Neil Cerutti
On 2007-07-04, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-07-04, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote: >> >>> If the escaped quotes didn't function in raw strings, I&#

Re: what is wrong with that r"\"

2007-07-04 Thread Neil Cerutti
On 2007-07-04, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote: > >> If the escaped quotes didn't function in raw strings, I'd be >> unable to construct (with a single notation) a regex t

Re: disappearing documentation of `coerce`

2007-07-04 Thread Neil Cerutti
in Library Reference 2.2 Non-essential Built-in Functions. Apparently it is no longer needed or useful, but only kept for backward compatibility. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Re-raising exceptions with modified message

2007-07-05 Thread Neil Cerutti
f something like the following would help: >>> def foo(): ... try: ... 12/0 ... except ZeroDivisionError, e: ... e.my_info = "Oops!" ... raise ... >>> try: ... foo() ... except ZeroDivisionError, e: ... print e.my_info ... Oops! Users could get at the e

Re: The best platform and editor for Python

2007-07-05 Thread Neil Cerutti
t; > Then tell us, pray, who was willing to pay for the epitome of useless > features in MS Word, that Useless Features' Useless Feature, the > ability to format text with the animated effect "Marching Red Ants"? > I'm sure I paid for it, but it wasn't willingly... You should count your blessings. At least it doesn't play pinball any more. At least, I hope not. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Neil Cerutti
gt; > import csv > > dictZipZones = {} > > reader = csv.reader(open("some.csv", "rb")) > for row in reader: > # Add the row to the dictionary In addition to Chris's answer, the csv module can read and write dictionaries directly. Look up csv.DictReader an

Re: Re-raising exceptions with modified message

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> The documentation for BaseException contains something that might >> be relevant: >> >>[...] If more data needs to be attached to the exception, >>attach it throu

Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Neil Cerutti
? It's a string to start with, since it comes from a text file. Besides, a string is an excellent epresentation for a zip code, since arithmetic upon them is unthinkable. I shared your frustration with the csv module docs when I first read them. But happily you can skip them and just read the easily adapted examples (9.1.5 Examples). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Re-raising exceptions with modified message

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> You may need the traceback module to get at the error message, if >> trying to read e.message can fail. >> >> Something like this mess here: ;) >> >>... >

Re: Re-raising exceptions with modified message

2007-07-06 Thread Neil Cerutti
guy, but I am a newbie. I would really > appreciate if you can show in this thread how this can be done > in Python. Chech out the docs for sys.exc_info(), and for the raise statement. When handling an exception, you can rethrow a different exception, but with the same traceback, by using the three-arg version of raise. See one of my earlier posts in this thread for a working example (although it didn't solve Chris's problem). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: The best platform and editor for Python

2007-07-06 Thread Neil Cerutti
er category make up the whole (one > half plus the other half) and so that WE DON'T EXIST!!! A > ridiculous claim to be sure, but we'd better let Herr Schluehr > know that in no uncertain terms... Wow! That explains why I had so much trouble eating me Wheaties

Re: Where is the syntax for the dict() constructor ?!

2007-07-06 Thread Neil Cerutti
On 2007-07-05, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 6, 5:31 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> >> Mostly you can use the default 'excel' dialect and be quite >> happy, since Excel is the main reason anybody still cares about >

Re: Where is the syntax for the dict() constructor ?!

2007-07-06 Thread Neil Cerutti
On 2007-07-06, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-07-05, John Machin <[EMAIL PROTECTED]> wrote: >> On Jul 6, 5:31 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >>> >>> Mostly you can use the default 'excel' dialect and be quite

Re: Getting the home directory in Python and a bug in os.path.expanduser

2007-07-07 Thread Neil Hodgson
s Me/2000 or later. CSIDL_APPDATA is probably a better idea than CSIDL_PROFILE (its equivalent to "%USERPROFILE%\Application Data" and roams) but %USERPROFILE% (CSIDL_PROFILE) is compatible with previous Python behaviour. http://msdn2.microsoft.com/en-us/library/ms647764.aspx

Re: variable naming query

2007-07-13 Thread Neil Cerutti
private'' attributes of base and derived classes. Further, from the _Python Tutorial (9.6) Private Variables_: (Buglet: derivation of a class with the same name as the base class makes use of private variables of the base class possible.) In other words, it's a mis

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Neil Cerutti
procedural language. Going back to the stack machine question, and using it as an example: Assume you design your program as a state machine. Wouldn't it be easier to implement in a (hypothetical) state-machine-based programming language than in a procedural one? I think John was insinuating th

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Neil Cerutti
tand it--so they invented Smalltalk and now don't > understand _it_!" Heh, heh. Thanks for the intersting info. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Private functions and inheritance

2007-07-16 Thread Neil Cerutti
ttributes that should not be overrided or accessed by derived classes. the weasel words from the documentation (which I put in quotes) are there because the feature doesn't work (in all cases). -- Neil Cerutti The doctors X-rayed my head and found nothing. --Dizzy Dean -- http://mail.python.org/mailman/listinfo/python-list

Re: a=0100; print a ; 64 how to reverse this?

2007-07-17 Thread Neil Cerutti
her than base 10, but conversions to integer is the only support. You can do: >>> d = int(s, base). but not: >>> s = str(d, base) The % format operator can do hex and octal, I believe. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementaion of random.shuffle

2007-07-19 Thread Neil Cerutti
>> Wow, can you make a coffee in.. 57ms ? > > [snip demonstration of xrange raising an exception] > > Of course! Can't you? > > And if I use a microwave oven, the coffee is made so quickly > that I actually go backwards in time... But what happens if you use a microwave oven? ... What the!?!? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way for missing dict keys

2007-07-20 Thread Neil Cerutti
ion to the dictionary of defaulted elements is what I really want. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's handling of unicode surrogates

2007-04-19 Thread Neil Hodgson
support for supplemental planes (surrogates, 4 byte UTF-8 sequences) for Scintilla, a text editing component. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's handling of unicode surrogates

2007-04-20 Thread Neil Hodgson
ate positions so is proportional to log(number of surrogates). Code (not thoroughly tested): /** @file surstr.cxx ** A simple Unicode string class that stores in UTF-16 ** but indexes by character. **/ // Copyright 2007 by Neil Hodgson <[EMAIL PROTECTED]> // This source code is publi

Re: No speedup on multi-processor machine?

2007-04-21 Thread Neil Hodgson
iel/pybench/ Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-23 Thread Neil Cerutti
like this I want to cry... > > >>>> adict = {(1,2): "parrot"} > > Try replacing that tuple with a list. "Just optimization" my eye! So the question becomes: Why do Python dictionaries require keys to be of an immutable type? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-23 Thread Neil Cerutti
On 2007-04-23, Chris Cioffi <[EMAIL PROTECTED]> wrote: > On 23 Apr 2007 17:19:15 +0200, Neil Cerutti <[EMAIL PROTECTED]> > wrote: >> So the question becomes: Why do Python dictionaries require >> keys to be of an immutable type? > > Dictionary keys are hashed

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-23 Thread Neil Cerutti
On 2007-04-23, Steve Holden <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> So the question becomes: Why do Python dictionaries require >> keys to be of an immutable type? > > Because otherwise people would expect to be able to use a list > to select a dict

Re: how to serialize a COM object ?

2007-04-24 Thread Neil Hodgson
mented. DCOM is fiddly to set up particularly the security aspects. IIRC I did get it to work with Python but that was maybe 8 years ago. Here's an overview of DCOM: http://msdn2.microsoft.com/en-us/library/ms809311.aspx Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-25 Thread Neil Cerutti
. Python's dictionaries are a proven winner--I'm definitely not an advocate for changing them. But the general requirement for a mapping container *isn't* that keys be immutable, but that you either don't mutate keys, or don't do so without also reording (rehashing?) the mapping. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Tutorial creates confusion about slices

2007-04-25 Thread Neil Cerutti
he divider-between-elements model presented in the tutorial really the "best way" to understand half-open range notation? I vote we change the word "best" to "possible" in the excerpt. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-25 Thread Neil Cerutti
On 2007-04-25, Steve Holden <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> That would be documented as undefined behavior, and users >> exhorted not to do such things. >> >> Python's dictionaries are a proven winner--I'm definitely not an >

Re: Tutorial creates confusion about slices

2007-04-26 Thread Neil Cerutti
f [2:4] as a half-open range much easier. I suppose the above model could avoid this notational problem if you say that a[k] means the one element slice a[k:k+1] (technically true for strings, but false for lists), rather than ever thinking of item indexes as pointing directly at an item. So

Re: My python annoyances so far

2007-04-26 Thread Neil Cerutti
inition. > And before someone get's all technical, I know everything in > Python is an 'object' even None, which implies class, or is it > the other way around? Classes are just objects like everything else. -- Neil Cerutti Bach's death is attributed to the end of the Baroque era. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list

Re: use urllib library to have an upload status bar

2007-04-27 Thread Neil Hodgson
project that has implemented an upload progress bar: http://www.opensky.ca/~jdhildeb/software/kodakloader/ Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-URL! - weekly Python news and links (Apr 30)

2007-05-01 Thread Neil Hodgson
rmat that can be revivified on the second machine. Sometimes these are references to 'short lived' objects in the original process, in which case they should have been addrefed which will also lock the process alive. Other times they may be monikers to stable objects which can be

Re: My newbie annoyances so far

2007-05-06 Thread Neil Hodgson
ll we're not looking at C or Lisp compiler levels of performance even with type declarations. Neil -- http://mail.python.org/mailman/listinfo/python-list

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: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Neil Hodgson
Paul Rubin wrote: >> Plenty of programming languages already support unicode identifiers, > > Could you name a few? Thanks. C#, Java, Ecmascript, Visual Basic. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Neil Hodgson
has a strong heritage as a glue language and this has been enabled by adapting to the features of various environments rather than trying to assert a Pythonic view of how things should work. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Neil Hodgson
e help for multilingual text such as allowing ranges of characters to be represented as hex escapes or character names automatically. Then someone who only normally uses ASCII can more easily audit patches that could contain non-ASCII characters. Neil -- http://mail.python.org/mailman/li

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Neil Hodgson
Martin v. Löwis: > Specification-wise, C99 and C++98 also support Unicode identifiers, > although many compilers still don't. Ada 2005 allows Unicode identifiers and even includes the constant 'π' in Ada.Numerics. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Neil Hodgson
3131 uses a similar definition to C# except that PEP 3131 disallows formatting characters (category Cf). See section 9.4.2 of http://www.ecma-international.org/publications/standards/Ecma-334.htm Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Neil Hodgson
t provide a mapping from your input to the target language. Other platforms provide similar services. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Neil Hodgson
ed from simplest to more complex so you can get a feel for where to look. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Neil Hodgson
of a problem. Its certainly not "virtually impossible" nor is there "absolutely no way of entering the word" (売り場). I think you should moderate your exaggerations. Is there a realistic scenario in which foreign character set identifier entry would be difficult for yo

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: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-17 Thread Neil Hodgson
Martin v. Löwis: > ... regardless of whether this PEP gets accepted > or not (which it just did). Which version can we expect this to be implemented in? Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-18 Thread Neil Hodgson
ax since the third line is an assignment with target identifiers separated only by spaces. Neil -- http://mail.python.org/mailman/listinfo/python-list

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: List Moderator

2007-05-21 Thread Neil Hodgson
pam messages are recognised and expired early - I don't know what mechanism is used for this. Neil -- http://mail.python.org/mailman/listinfo/python-list

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

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