Re: [python-committers] Thank you Larry Hastings!

2020-10-06 Thread Nick Coghlan
Thank you, Larry! Cheers, Nick. -- https://mail.python.org/mailman/listinfo/python-list

Re: when wxPython update to python2.4?

2005-01-01 Thread Nick Coghlan
e, and also include a Python 2.4 compatible version. The timeframe for that isn't entirely clear, though. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skyst

Re: Frameworks for "Non-Content Oriented Web Apps"

2005-01-01 Thread Nick Coghlan
, I'm not sure if that will provide enough of the 'web' side of things. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mai

Re: The Industry choice

2005-01-01 Thread Nick Coghlan
*Python* will ultimately inherit from either object or types.ClassType, but extension classes need not do any such thing. Yet list.sort works with them all, anyway. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED]

Re: PEP 288 ponderings

2005-01-01 Thread Nick Coghlan
for? Py> class mygen(object): ... def __init__(self, data): ... self.data = data ... def __iter__(self): ... while 1: ... print self.data ... yield None ... Py> g = mygen(0) Py> giter = iter(g) Py> giter.next() 0 Py> g.data = 1 Py> giter.next() 1 Chee

Re: screen clear question

2005-01-02 Thread Nick Coghlan
Alan Gauld wrote: But the bottom line is that there is no builtin command because the mechanism is different on each platform. I'd have said it was because the inpreter is line-oriented rather than screen-oriented, but YMMV. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: arbitrary number of arguments in a function declaration

2005-01-02 Thread Nick Coghlan
def tot_expenses(self, expenses): self.total_expenses = sum(expenses) Or, have the function take a variable number of arguments, and do the same thing: def tot_expenses(self, *args): self.total_expenses = sum(args) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Aust

Deferred expressions (was Re: Lambda as declarative idiom)

2005-01-04 Thread Nick Coghlan
Steven Bethard wrote: Nick Coghlan: def-from syntax [4] (def f(a) + o(b) - o(c) from (a, b, c)) (def x * x from (x)) (def x from ()) (def x.bar(*a, **k) from (*a, **k)) ((def x(*a, **k) from ()) for x, a, k in funcs_and_args_list) After a bit more musing, this is definitely my preferred syntax

Re: Hlelp clean up clumpsy code

2005-01-04 Thread Nick Coghlan
ata)): ... val_to_pos[x] = i + 1 ... Py> print val_to_pos {8: 4, 1: 1, 2: 3, 4: 5, 5: 2} It even works with strings as leaf elements: Py> data = [["abc","def",2],8,"xyz"] Py> flatt

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-04 Thread Nick Coghlan
dard dictionary interface, and not something the mixin can derive from the generic container methods. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-05 Thread Nick Coghlan
Steven Bethard wrote: Nick Coghlan wrote: .keys() is definitely part of the standard dictionary interface, and not something the mixin can derive from the generic container methods. Why is that? Isn't keys derivable as: def keys(self): return list(self) if __iter__ is defined? As yo

Re: python 3000 and removal of builtin callable

2005-01-05 Thread Nick Coghlan
builtins to be "removed" in Py3k, I believe the actual intent is to move them to a module (e.g. sys), with the removal being "remove from the builtins", not "remove from Python". Cheers, Nick. -- Nick Coghlan | [EMAIL PROTEC

Re: [Python-Dev] Let's get rid of unbound methods

2005-01-06 Thread Nick Coghlan
Andrew Koenig wrote: duck typing? That's the Australian pronunciation of "duct taping". More Kiwi, I'm thinking ;) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: Securing a future for anonymous functions in Python

2005-01-06 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Do you consider generator expressions or list comprehensions deficient because they don't allow several statements in the body of the for loop? I don't see what it would mean to do otherwise. Exactly the same as a su

Re: Deferred expressions (was Re: Lambda as declarative idiom)

2005-01-06 Thread Nick Coghlan
expression". On backticks, they have a major problem in that many fonts make ` and ' virtually indistinguishable. A secondary problem is that printed text often renders an opening single quote like a backtick. Guido has already mentioned this in one of Python Regrets talks (in th

Re: Python evolution: Unease

2005-01-06 Thread Nick Coghlan
r and linked to from the main documentation (rather than from the sidebar menu on the webpage). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skyst

Re: Python evolution: Unease

2005-01-06 Thread Nick Coghlan
"About the Python Documentation" link that explains how to do this. Compare: http://www.python.org/doc/2.4/ To: http://www.python.org/dev/doc/devel/ Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: Is there any way/where to subscribe for automated PEP status emails?

2005-01-06 Thread Nick Coghlan
list. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: navigating/changing directories

2005-01-06 Thread Nick Coghlan
The script is executed in a process separate from your command shell, and hence has no effect on your shell's current directory. There are some things that batch files and shell scripts are still good for - manipulating the shell :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROT

Re: get the IP address of a host

2005-01-06 Thread Nick Coghlan
output of ipconfig instead. Use subprocess to run the command in Python 2.4, or work something out with one of the popen variants for earlier versions. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: Getting rid of "self."

2005-01-07 Thread Nick Coghlan
BJörn Lindqvist wrote: So I'm asking here if someone knows a better way, maybe using decorators or metaclasses or other black magic? Wait for Python 3k when this will work: class c: def __init__(self): with self: .x = 1 .y = 2 .hi = "Hi there!" Cheers, Nick.

Re: 2 versions of python on 1 machine

2005-01-07 Thread Nick Coghlan
ONHOME and PYTHONPATH because the docs don't seem to contain a whole lot of info. I think PYTHONPATH is discussed in the tutorial. PYTHONHOME, I'm not so sure on (PYTHONPATH and PYTHONSTARTUP are the only two you're likely to care about, though - and I think the Tutorial covers both of them

Re: sorting on keys in a list of dicts

2005-01-07 Thread Nick Coghlan
hat only allows sorting a table on one column at a time, you'll appreciate the frustration that can cause :) Also, it's required to match the behaviour of the Python 2.4 version (which gets to take advantage of the stability of the builtin sort). Cheers, Nick. -- Nick Coghlan |

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Nick Coghlan
enuinely taught them that, you may have done them a disservice: Py> def f(x): ...print x ... Py> f1 = f Py> f2 = lambda x: f(x) Py> f1("hi") hi Py> f2("hi") hi Py> def f(x): ... print x * 2 ... Py> f1("hi") hi Py> f2("hi&qu

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Nick Coghlan
keywords currently in that category are three letters or less: and, or, is, in, for) 4. People complaining about 2 Oh hell yes, this bugs me. And I think changing the syntax and calling them "deferred expressions" instead of "lambdas" would go a long way towa

Re: Please Contribute Python Documentation!

2005-01-07 Thread Nick Coghlan
ng a bug report :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Packaging, dependencies and rates of development

2005-01-07 Thread Nick Coghlan
kage versioning system. Then all module developers would have to do is be aware of how to use the distutils versioning system, and installing side-by-side versions of packages would be create straightforward. Cheers, Nick.

Re: sorting on keys in a list of dicts

2005-01-07 Thread Nick Coghlan
sure about Python 2.2 and earlier. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Notification of PEP Updates

2005-01-07 Thread Nick Coghlan
mary of the differences between the old version and the new version (handy if you can read a context diff, not so handy otherwise). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://bore

Re: sorting on keys in a list of dicts

2005-01-07 Thread Nick Coghlan
Craig Ringer wrote: Well, that's several hundred more words than were probably required, but I hope I made sense. Remarkably similar to what I just posted. . . I guess numeric 2-tuples are just too good to pass up when discussing sorting :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROT

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Nick Coghlan
in languages where "the compiler knows about types and functions, and the runtime knows about variables and instances". Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://bore

Re: Developing Commercial Applications in Python

2005-01-07 Thread Nick Coghlan
Stephen Waterbury wrote: A notable example is Verity's search engine -- see http://python.oreilly.com/news/PythonSS.pdf Not to mention the kind words of the current reigning king of the search engine world. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Aust

Re: Calling Function Without Parentheses!

2005-01-07 Thread Nick Coghlan
anity checks on Python code. http://pychecker.sourceforge.net/ Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: What could 'f(this:that=other):' mean?

2005-01-07 Thread Nick Coghlan
amespaces instead of bunches. . . def f(ns1, ns2): print ns1.a, ns1.b, ns2.a, ns2.b f(ns1 = namespace(a=1, b=2), ns2 = namespace(a=3, b=4)) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- h

Re: sorting on keys in a list of dicts

2005-01-07 Thread Nick Coghlan
e dictionaries which could save a *lot* of number crunching (as well as making otherwise unsortable lists sortable). So it's a good thing you did decide to send it :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: Getting rid of "self."

2005-01-07 Thread Nick Coghlan
Roy Smith wrote: It's actually kind of neat, but boy does it play headgames with me when I switch back and forth between that and Python. Switching back and forth betwen C++ and Python plays headgames *anyway* }:> Cheers, Nick. Hardware control with Python is nice. . . -- Nick

Re: python3: 'where' keyword

2005-01-07 Thread Nick Coghlan
e clause really isn't appropriate for break, continue, import or global statements, as they don't contain any expressions :) For compound statements, a where clause probably isn't appropriate, as it would be rather unclear what the whe

Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Nick Coghlan
. Py> c = C() Py> c.useval(4) Py> c.x 4 Py> c.usefunc(list) Py> c.x [] -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-07 Thread Nick Coghlan
Nick Coghlan wrote: It also allows the necessary but uninteresting setup for an expression to be moved "out of the way", bringing the expression that does the real work to prominence. Killer app for this keyword: class C(object): x = property(get, set) where: def get(self):

Re: python3: 'where' keyword

2005-01-07 Thread Nick Coghlan
nts of the where clause). Putting the statement of interest after the where suite still gives the benefits of avoiding namespace clutter, but doesn't really help readability (it makes it worse, if you ask me). Particularly, what if the next statement is a compound statement? Cheers, Nick.

Re: switching an instance variable between a property and a normal value

2005-01-07 Thread Nick Coghlan
_func to lambda: x when working by value :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Other notes

2005-01-08 Thread Nick Coghlan
: -> float( + "." + ) -> getattr(int(), ) -> xrange(, ) However, the problem comes when you realise that 1e3 is also a floating point literal, as is 1.1e3. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
3k. So let's use it for expression naming in 'if' statements, too. if someregexp.match(s) as m: # blah using m elif someotherregexp.match(s) as m: # blah using m Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: "A Fundamental Turn Toward Concurrency in Software"

2005-01-08 Thread Nick Coghlan
multi-threaded. See here for some more info on Python's threading: http://www.python.org/doc/2.4/api/threads.html Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Bengt Richter wrote: On Sat, 08 Jan 2005 16:42:16 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: And, is the whole thing after the '=' an expression? E.g., x = ( foo(x) where: x = math.pi/4.0 ) where: def foo(x): print 'just for illustration', x

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
of how you might do that more than once in a statement. I think having to keep the names unique within the statement you are currently writing is a reasonable request :) Cheers, Nick -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
pressions. Here's a version using my preferred syntax from the AlternateLambdaSyntax page: if test(something(), (def x < 10 from x)) as m: print "Case 1:", m elif test(something(), (def x > 20 from x)) as m: print "Case 2:", m

Re: mysterious buggy behavior

2005-01-08 Thread Nick Coghlan
ou need to be a little more explicit than simply saying "something goes wrong". Exception? Wrong move? What? Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlazi

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
h, even further: z = C() where: class C(object): ... Lets you make anonymous classes and singleton objects. Here's another nice one if 'where' is added to compound statements as well: @dbc(pre, post) def foo(): pass where: def pre(): pass def post(

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: I think having to keep the names unique within the statement you are currently writing is a reasonable request :) Um, you could say the same thing about the function, the module, etc. ;) And, indeed, that is what Python currentl

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
nested-if approach that works right now if I wanted access to part of the condition instead of the whole thing. However, being able to bind a name to the conditions would be handy for many cases. Cheers, Nick. -- Nick Coghlan | [EMAIL P

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
Alex Martelli wrote: I wonder if 'with', which GvR is already on record as wanting to introduce in 3.0, might not be overloaded instead. Perhaps we could steal 'using' from the rejected decorator syntax. x = [f(x) for x in seq] using: def f(x): return x * x Cheers, N

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
;s grammar. And I don't think we'd actually have to wait for Python 3 for this, we'd just have to do the __future__ dance in order to introduce the new keyword. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Trying to push it a level further (down to expressions) would, IMO, be a lot of effort for something which would hurt readability a lot. I think we should just try to do things in a simple and general way and not try to e

Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-09 Thread Nick Coghlan
Is it actually possible to make it work? Keyword choice Should the clause be allowed on any statement (as described), or restricted to ones where it "makes sense"? Examples # Statement local functions (from Andrey Tatarinov) # aka How to cope if lambda goes away :) r

Re: Long strings as function parameters

2005-01-10 Thread Nick Coghlan
ually have a 'bytes' type, but I don't recall if that was going to be mutable or immutable. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.

Re: static compiled python modules

2005-01-10 Thread Nick Coghlan
Thomas Linden wrote: How can I tell python to use the compiled in modules and not try to load them from outside? http://www.python.org/dev/doc/devel/api/importing.html Take a look at the last three entries about registering builtin modules. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED

Re: python3: accessing the result of 'if'

2005-01-10 Thread Nick Coghlan
Steve Holden wrote: Excuse me, these are supposed to be IMPROVEMENTS to Python? I think it's more messing around before coming to the conclusion that, of the many things that 'where' helps with, this sure as hell ain't one of them :) Cheers, Nick. -- Nick Coghlan

Re: python3: 'where' keyword

2005-01-10 Thread Nick Coghlan
have to create the extra level of scoping all the time. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Nick Coghlan
Duncan Booth wrote: Nick Coghlan wrote: Grammar Change -- Current:: statement ::=stmt_list NEWLINE | compound_stmt New:: statement ::=(stmt_list NEWLINE | compound_stmt) [local_namespace] local_namespace ::= "with" ":" suite Semantics --

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Nick Coghlan
Nick Coghlan wrote: Disallowing local namespaces for statement lists would suggest something like this: statement ::= (simple_stmt (NEWLINE | ";" stmt_list NEWLINE | local_namespace) ) | (compound_stmt [local_namespace]) local

Re: windows mem leak

2005-01-10 Thread Nick Coghlan
nt of work went into making the Windows implementation of that module as solid as the *nix implementation, whereas there may still be issues with direct os.popen calls (as Roel's investigation suggests). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: Python3: on removing map, reduce, filter

2005-01-10 Thread Nick Coghlan
9 hits CVS (with functional.partial), maybe it can grow aliases for the three of them so people can get used to the idea. It might keep partial from getting too lonely. . . :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: Speed revisited

2005-01-10 Thread Nick Coghlan
. This let deque sacrifice some of list's flexibility in favour of increased speed. Appropriate parts of the core which needed a FIFO were then updated to use the new data type, while everything else continues to use lists. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() Bleh. Not only was my proposed grammar change wrong, my suggested semantics are wrong, too. Raise your hand if you can see the problem with applying the above semantics to

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Nick Coghlan wrote: Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() Bleh. Not only was my proposed grammar change wrong, my suggested semantics are wrong, too. Raise your hand if you can see the problem with applying the

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
and adding our suite-definitions there. A new scope essentially *is* a nested function :) My main purpose with the nested function equivalent is just to make the intended semantics clear - whether an implementation actually _does_ things that way is immaterial. Cheers, Nick. -- Nick Coghlan

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
o far ('where', 'with', 'in', 'using'), I'd currently vote for 'using' with 'where' a fairly close second. My vote goes to 'using' because it has a fairly clear meaning ('execute the statement using this extra information

Re: Securing a future for anonymous functions in Python

2005-01-11 Thread Nick Coghlan
ldn't help much. (The out-of-order execution is what really makes the property definition example pretty, IMO) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlazine

Re: "Architecture of Python" was removed ?

2005-01-11 Thread Nick Coghlan
e document was removed. Who knows what happened? > > Does anyone here have a copy of that document? Or who can tell me what is the > email address of Jim Jackson or Kar-Han Tan. http://web.archive.org/web/2003101953/http://wiki.cs.uiuc.edu/cs427/PYTHON Cheers, Nick. --

Re: else condition in list comprehension

2005-01-11 Thread Nick Coghlan
. . just that it works :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP 246, redux

2005-01-11 Thread Nick Coghlan
ype(protocol, Abstract): raise LiskovViolation # etc Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception not captured

2005-01-11 Thread Nick Coghlan
run. Has common.py been reload()'ed at some point? Then previously imported modules may still have names bound to the old instances. And so forth. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: else condition in list comprehension

2005-01-12 Thread Nick Coghlan
nt i to be "i-2" if i%2 is not equal to 0? Hmm: z = [newval(i) for i in range(10)] using: def newval(x): if x % 2: return x - 2 else: return x + 2 Just some more mental twiddling relating to the thread on statement local namespaces. Chee

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() I've come to the conclusion that these semantics aren't what I would expect from the construct. Exactly what I would expect can't really be expressed in current

Re: else condition in list comprehension

2005-01-13 Thread Nick Coghlan
e said the point was both :) But yeah, unfortunately the 'leaking list comp' problem won't be fixed in the 2.x series due to the compatibility problem. Fortunately, generator expressions didn't inherit the issue. Cheers, Nick. -- Nick Coghlan |

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Nick Coghlan
f pre(): pass def post(): pass # Singleton classes as C: C = _C() using: class _C: pass # Complex default values as f: def f(x=default()): pass using: def default(): return "Demo default" Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Nick Coghlan
into a context which doesn't care in the slightest? Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Class initialization from a dictionary, how best?

2005-01-13 Thread Nick Coghlan
est.__init__ function. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Nick Coghlan
ement. Actually appending either of those tokens means the string is no longer an expression. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.pyt

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-14 Thread Nick Coghlan
Nick Coghlan wrote: as equivalent to: def __use_stmt(): def _in_clause(): return return _in_clause() __use_stmt_args = {} = __use_stmt() del __use_stmt The more I think about this return-based approach, the less I like it. It could probably be made to work, but it just feels

Re: import keyword behaviour - performance impact if used multiple times?

2005-01-14 Thread Nick Coghlan
neophyte wrote: Nick Coghlan wrote: > Is > this something to do with system modules being singletons? They aren't singletons in the GoF design pattern sense. However, Python's import machinery operates in such a way that it takes effort to get multiple version of the same module in

Re: Why 'r' mode anyway?

2005-01-15 Thread Nick Coghlan
g koans don't really cover the concept. Its addition also seems fitting in light of the current PEP 246 discussion which is *all* about playing well with others :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: How to del item of a list in loop?

2005-01-15 Thread Nick Coghlan
best you can do for an in-place version: for i, x in enumerate(reversed(lst)): if x == 2: del lst[-i] The effbot's version is still going to be faster though: lst = [x for x in lst if x != 2] Cheers, Nick. -- Nick Coghlan | [EMAIL PROTEC

Re: Producer/consumer Queue "trick"

2005-01-15 Thread Nick Coghlan
times, I now make sure to release the GIL as part of my SWIG wrapper (since the code I'm wrapping knows nothing of Python, and sure as heck doesn't need to be holding the GIL!). Cheers, Nick. -- Nick Coghlan | [EMAIL

Re: How to del item of a list in loop?

2005-01-16 Thread Nick Coghlan
John Machin wrote: Nick Coghlan wrote: The effbot's version is still going to be faster though: lst = [x for x in lst if x != 2] Have you measured this? Nope. I'm going purely on the fact that it is O(n), and the in-place modification will always be worse than that. Cheers, Nic

Re: generator expressions: performance anomaly?

2005-01-16 Thread Nick Coghlan
rrently the case. There's a similar performance glitch associated with constructing a tuple from a generator expression (with vanilla 2.4, detouring via list is actually faster) Cheers, Nick. -- Nick Coghlan | [EMAIL PROT

Re: (objects as) mutable dictionary keys

2005-01-17 Thread Nick Coghlan
* the solution for most such cases where the standard Python rule doesn't apply :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net --

Re: Executing a script created by the end user

2005-01-17 Thread Nick Coghlan
... """ Py> main() hello1 hello2 'exec' is quite happy to deal with newlines and indenting. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: getting a class attribute using a keyword argument

2005-01-17 Thread Nick Coghlan
ame[, default]) -> value Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y. When a default argument is given, it is returned when the attribute doesn't exist; without it, an exception is raised in that case. Cheers, Nick. -- Nick Coghlan

Re: [perl-python] 20050117, filter, map

2005-01-17 Thread Nick Coghlan
ython] mailing list tag, so automatic filtering isn't that difficult. It is an unfortunate shame that his consideration doesn't extend to removing the general Perl and Python discussion groups from his recipients list. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bris

Re: [Python-Dev] Getting rid of unbound methods: patch available

2005-01-18 Thread Nick Coghlan
the type check. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: extension module, thread safety?

2005-01-18 Thread Nick Coghlan
d. This is what PyGILState_Ensure and PyGILState_Release are for - so C code can leave the GIL unlocked by default, and only grab it when they want to call into the C/Python API. Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bris

Re: generator expressions: performance anomaly?

2005-01-18 Thread Nick Coghlan
ven when the source *doesn't* mutate, though. I'll have to think some more to see if I can come up with any concrete ideas for you to shoot down :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: extension module, thread safety?

2005-01-18 Thread Nick Coghlan
that PEP 311 (which added these functions) went in. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda

2005-01-18 Thread Nick Coghlan
ptions are rare, and not worth worrying about at that point in their learning. Only when one is aware of the reasons for a principle, can one be aware of good reasons not to follow it :) Cheers, Nick. -- Nick Coghlan | [EM

Dictionary keys (again) (was Re: lambda)

2005-01-19 Thread Nick Coghlan
le keys acquire the requisite immutability is going to be application dependent. Provision of a safe_dict or identity_dict would merely allow a programmer to state their intent at the time the container is created, rather than having to state it whenever keys

Re: lambda

2005-01-19 Thread Nick Coghlan
l be making copies all the time. Alternatively, the class could declare itself to work reliably only with immutable objects. Performance will improve, since copies need only be made when an object *actually* changes (and the old immutable copy is deleted and the new version inserted in its p

Re: delay and force in Python

2005-01-19 Thread Nick Coghlan
limit is platform dependent, but something around 1000 sounds fairly normal. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary keys (again) (was Re: lambda)

2005-01-20 Thread Nick Coghlan
David Eppstein wrote: Yes, and what should the following do? lst1 = [1] lst2 = [2] dct = {lst1: "1", lst2: "2"} lst2[0]=1 lst1[0]=2 print dct[[1]] print dct[[2]] Provide yet another example for why mutable keys are almost guaranteed to result in suprising semantics :) C

  1   2   3   4   5   >