Re: generator expressions: performance anomaly?

2005-01-18 Thread Nick Coghlan
t. I once spent a good deal of effort exploring where it made sense, and I was surprised to find that it only rarely works out. Length transparency is an unexpectedly thorny subject with many dead-ends which precludes a fully general solution such as that proposed by Nick. For a recap of my research

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

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

2005-01-20 Thread Nick Coghlan
data structure). This aligns quite well with the stated goal of the collections module (providing data structures that are less general purpose than the standard builtins, but deliver better performance for their particular use cases) Regards, Nick. -- Nick Coghlan | [EMAIL PROT

Freezing a mutable (was Re: lambda)

2005-01-20 Thread Nick Coghlan
ot;Read via mutated y:", dct[y.frozen()] x.unfreeze() y.unfreeze() print "x:", x print "y:", y print "Found unfrozen x:", x.frozen() in dct print "Found unfrozen y:", y.frozen() in dct -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --

Re: Zen of Python

2005-01-20 Thread Nick Coghlan
to make sure you end up with the features you need, without the irrelevant baggage an overengineered solution may bring with it. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Class introspection and dynamically determining function arguments

2005-01-20 Thread Nick Coghlan
lf, **kwds) ... for attr in Buildable.__slots__: ... setattr(self, attr, kwds[attr]) ... Py> b = Buildable(x = 1 , y = 2) Py> b.x 1 Py> b.y 2 (Note that you don't *have* to use slots, you can use a non-special class attribute if you don't want the other side effects)

Re: Freezing a mutable (was Re: lambda)

2005-01-20 Thread Nick Coghlan
to a different data structure that works natively as a dict key, naturally). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Class introspection and dynamically determining function arguments

2005-01-21 Thread Nick Coghlan
Diez B. Roggisch wrote: Nick Coghlan wrote: If this only has to work for classes created for the purpose (rather than for an arbitrary class): Certainly a step into the direction I meant - but still missing type declarations. And that's what at least I'd like to see - as otherwise you

Re: Zen of Python

2005-01-21 Thread Nick Coghlan
containing scope is viewed as a feature. But knowing a priori that copying the for loop semantics exactly would turn out to be a misfeature? I'll go with Steve's assessment of psychic powers ;) Cheers, Nick. -- Nick Coghlan

Re: Print a string in binary format

2005-01-21 Thread Nick Coghlan
27; Py> show_base(0, 16) '0' Py> for base in range(2, 36): ... for testval in range(1000): ... assert testval == int(show_base(testval, base), base) ... Py> Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic properties

2005-01-21 Thread Nick Coghlan
y = 1 Setting y to 1 on <__main__.C object at 0x00A9A990> Py> del c.y Deleting y from <__main__.C object at 0x00A9A990> The decorator syntax is the only 2.4'ism I'm aware of in that code, so porting to 2.3 or even 2.2 shouldn't be an issue. Cheers, Nick

Re: need help on need help on generator...

2005-01-21 Thread Nick Coghlan
, but completing the transition to an iterator based approach isn't going to be possible until Python 3.0, when things that currently return lists can be converted to return iterators (i.e. it has been suggested that the fundamental construct in Python 3.x should be an iterator just a

Re: Print a string in binary format

2005-01-21 Thread Nick Coghlan
Bengt Richter wrote: On Sat, 22 Jan 2005 00:45:19 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: Here's an interesting twiddle, though (there's probably already something along these lines in the cookbook): Looks like you also played with this problem, after Alex posted a request

Re: specifying constants for a function (WAS: generator expressions: performance anomaly?)

2005-01-21 Thread Nick Coghlan
ction constants declared separate from arguments > since they mean such different things. I played around with this, and I think it's basically implementable: Raymond's constant binding decorator is probably a good model for how to do it: http://aspn.activestate.com/ASPN/Cookbook/Pytho

Re: dynamic call of a function

2005-01-22 Thread Nick Coghlan
t 'not always' which can end up hurting. . . Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list unpack trick?

2005-01-22 Thread Nick Coghlan
File "", line 1, in ? AttributeError: 'list' object has no attribute 'ljust' Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: default value in a list

2005-01-22 Thread Nick Coghlan
e, it.repeat(default)), N) ... >>> a,b,c,d = ipad(4,line) >>> a,b,c,d ('A', 'B', 'C', None) Good idea! (+1 if this was posted on python-dev!) Please, please Google the python-dev archives before doing so ;) Cheers, Nick. I seem to recall &

Re: Unbinding multiple variables

2005-01-22 Thread Nick Coghlan
ary. Updates in the other direction are far less common (exec without an 'in' clause, star imports, and monkeying with the frame via the C API are the only cases I am aware of). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTEC

Re: finding name of instances created

2005-01-22 Thread Nick Coghlan
written for me, but I believe there were Python 2.4 changes relating to using exec with non-standard dictionaries. Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlazines

Re: finding name of instances created

2005-01-22 Thread Nick Coghlan
move() Internally, idioms like "for robot in robots" should be entirely unaffected - the registration of the robot instance with the global list of robots can be handled by the robot initialisation method. Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: delay and force in Python

2005-01-24 Thread Nick Coghlan
Nick Coghlan wrote: Will Stuyvesant wrote: The program below creates a stream with the numbers 1..995 and then filters the stream, keeping only the even numbers, and then prints the second number in the stream (implemented as the first number of the tail, just like in the 3.5 Section in the Wizard

Re: finding name of instances created

2005-01-24 Thread Nick Coghlan
t; def f(): pass ... Py> f.func_name 'f' Py> f = lambda: None Py> f.func_name '' I think I've heard that explanation before, but it never really clicked. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: delay and force in Python

2005-01-25 Thread Nick Coghlan
Peter Otten wrote: Nick Coghlan wrote: Py> print islice((x for x in xrange(1, 996) if x % 2 == 0), 1, 2).next() 4 Wouldn't it be nice if this could be spelt: print (x for x in xrange(1, 996) if x % 2 == 0)[2] Well, I just put a patch on SF to enable exactly that: http://www.python.org/sf

Re: Instances of class object not modifiable?

2005-01-25 Thread Nick Coghlan
Steven Bethard wrote: Open Issues === What should the type be named? Some suggestions include 'Bunch', 'Record' and 'Struct'. Add 'namespace' to the list of name suggestions :) Cheers, Nick. The name came up in some thread a few weeks back. .

Re: Tuple slices

2005-01-25 Thread Nick Coghlan
oblem of holding a reference to the original sequence, though. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Another scripting language implemented into Python itself?

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

Re: Memory Usage

2005-01-25 Thread Nick Coghlan
mns" and activating "VM Size" is enough to find out how much memory that program actually has *mapped* (rather than currently loaded into RAM). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: string.atoi and string.atol broken?

2005-01-25 Thread Nick Coghlan
> show_base(10, 16, 2, complement=True) '0A' Py> show_base(-10, 16, 2, complement=True) 'F6' Py> show_base(127, 16, 2, complement=True) '7F' Py> show_base(-127, 16, 2, complement=True) '81' Py> show_base(255, 16, 2, complement=True) 'FF' Py&

Re: Can't load bytecode with execfile ?

2005-01-25 Thread Nick Coghlan
mpiled bytecode might make a reasonable feature request, though. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: python without OO

2005-01-25 Thread Nick Coghlan
blanket ban on OO techniques. Jeremy's "Bower's Law" page really does provide a good perspective on the benefits of judicious use of OO techniques (http://www.jerf.org/writings/bowersLaw.html). Cheers, Nick. -- Nick Coghlan

Re: delay and force in Python

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

Re: Tuple slices

2005-01-26 Thread Nick Coghlan
n (except any saving resulting from the memory saving). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple slices

2005-01-26 Thread Nick Coghlan
he reasons it was added in the first place. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: execute python code from db

2005-01-26 Thread Nick Coghlan
ot;", (id,)) for python_code in c.fetchall(): execute (python_code) Maybe feed python with stdin??. What's wrong with the exec statement? Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Help With Python

2005-01-26 Thread Nick Vargish
v = Viking() orders = [ v.order() ] * 511 print ', '.join(orders) ## cut here With no apologies to Eric Idle, Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?&#

Re: Inherting from object. Or not.

2005-01-27 Thread Nick Coghlan
advice is to use new-style classes unless you have a reason not to (if you're inheriting from a builtin type, then there is no need to inherit from object as well - the builtin types already have the correct basic type). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Aust

Re: python memory blow out

2005-01-27 Thread Nick Coghlan
esult set is created by one big allocation or lots of little ones (If the latter, other responses have pointed out how it may cause your problem). There's also a chance of a problem with the database API wrapper, so it may be worth checking with an API specific list. Cheers, Nick. -- Ni

Re: python without OO

2005-01-27 Thread Nick Coghlan
tion tables. What a language with OO support adds is special syntax for something that you could have done anyway - the OO support just makes it easier and clearer (well, C++ aside). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: python without OO

2005-01-27 Thread Nick Coghlan
tend(range(5)) and data.sort() are alternative spellings for the second and third lines doesn't change the fact that a class is just a data structure grouped with a bunch of functions that operate on that data structure. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED]

Re: python without OO

2005-01-27 Thread Nick Coghlan
HIJ Ditto list.sort() and sorted(). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Help With Python

2005-01-27 Thread Nick Vargish
"Matt" <[EMAIL PROTECTED]> writes: > Not to be nit-picky, but you got some issues here ;-). Never forget > the importance of "self"! Teach me to post untested code. *hangs head* Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a

WSDL parsing problem

2005-01-27 Thread Nick Caldwell
bugging import httplib httplib.HTTPConnection.debuglevel = 1 from SOAPpy import WSDL server = WSDL.Proxy('d:/googleapi/GoogleSearch.wsdl') print server.methods.keys() callInfo = server.methods['doGoogleSearch'] for arg in callInfo.inparams: print arg.name.ljust(15), arg.type Any help at all would be appreciated. Sincerely, Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Inherting from object. Or not.

2005-01-28 Thread Nick Coghlan
Nick Craig-Wood wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: Exactly. My advice is to use new-style classes unless you have a reason not to (if you're inheriting from a builtin type, then there is no need to inherit from object as well - the builtin types already have the correct

Re: Who should security issues be reported to?

2005-01-28 Thread Nick Coghlan
t. Is that the sound of a volunteer I hear? All you have to do is put your hand up, and the problem will be solved. If not you, who? Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: a sequence question

2005-01-28 Thread Nick Coghlan
(range(10), 3)) [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, None, None)] Py> list(padded_partition(range(10), 3, False)) [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, False, False)] Py> zip(*padded_partition(range(10), 3)) [(0, 3, 6, 9), (1, 4, 7, None), (2, 5, 8, None)] Not sure how useful that last

Re: limited python virtual machine

2005-01-28 Thread Nick Coghlan
tion not allowed in restricted build"); return NULL;". Then it doesn't matter *how* you get hold of file(), it still won't work. (I can hear the capabilities folks screaming already. . .) Combine that with a pre-populated read-only sys.modules and a restricted custom inter

Re: Who should security issues be reported to?

2005-01-28 Thread Nick Coghlan
Fredrik Lundh wrote: Nick Coghlan wrote: I'm sorry, but this isn't really good enough. If Open Source wants to say that they are better than these proprietary companies, they need to deal with these sorts of things more professionally and establish decent channels of communications f

Re: Who should security issues be reported to?

2005-01-28 Thread Nick Coghlan
ught directly to the attention of python-dev. At that point, the decision may be made to make a general announcement as to the feature which needs to be avoided or handled carefully. This would likely take the form of announcements on the www.python.org website, and on comp.lang.python.announce. Rega

Re: Daylight savings and getmtime

2005-01-28 Thread Nick Coghlan
created last winter, when Sydney was NOT on daylight savings: Py> time.localtime(os.path.getmtime("c:/log.txt")) (2004, 7, 20, 19, 46, 35, 1, 202, 0) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: Who should security issues be reported to?

2005-01-29 Thread Nick Coghlan
lla's security flag. Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Coding style article with interesting section on white space

2005-01-29 Thread Nick Coghlan
acmqueue.com/modules.php?name=Content&pa=showpage&pid=271&page=3 Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org

Re: tutorial idea

2005-01-29 Thread Nick Coghlan
thing.) Something like this? http://tams-www.informatik.uni-hamburg.de/applets/jython/demo.html Well, without the assumption of not knowing how to program :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Aust

Re: Coding style article with interesting section on white space

2005-01-29 Thread Nick Coghlan
pinion on _current_ Fortan has problems far bigger than a single article. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: limited python virtual machine

2005-01-29 Thread Nick Coghlan
g more sense to just use an OS-based sandbox that lets you execute arbitrary binaries relatively safely. The last suggestion I recall along these lines was chroot() plus a monitoring daemon that killed the relevant subprocess if it started consuming too much memory or looked like it had got stuc

Re: Nested scopes and class variables

2005-01-31 Thread Nick Coghlan
EF 0 (y) 9 STORE_NAME 3 (x) 12 LOAD_LOCALS 13 RETURN_VALUE Here we can see the "LOAD_DEREF" instead of the "LOAD_NAME" that was present in the version where the same name is reused. The dereference presumably pi

Re: Nested scopes and class variables

2005-01-31 Thread Nick Coghlan
, since they don't allow that initial lookup to be made from the outer scope. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.pytho

Re: test_socket.py failure

2005-01-31 Thread Nick Coghlan
lowing code give when you run it at the interactive prompt?: Py> import socket Py> socket.getservbyname('daytime') 13 Second, is there an entry for 'daytime' in /etc/services? Cheers, Nick. -- Nick Coghla

Re: variable declaration

2005-02-01 Thread Nick Vargish
guy in the T-shirt is in more danger. A _lot_ more danger. Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?') -- http://mail.python.org/mailman/listinfo/python-list

Re: Where are list methods documented?

2005-02-01 Thread Nick Coghlan
list Setset, frozenset Mappingdict File file """ Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.n

Re: test_socket.py failure

2005-02-01 Thread Nick Coghlan
, that should give the behaviour we want - any protocol will match. However: Linux 2.6.4-52-default (Suse 9.1) Glibc 2.3.3 gcc 3.3.3 So it may be that your older platform doesn't have this behaviour - I'd be very interested in what 'man getservbyname' has to say. Chee

Re: a sequence question

2005-02-01 Thread Nick Coghlan
ctly when the padding wasn't needed. Padding with one less than the partition length fixes that quite neatly. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skys

Re: how to separate hexadecimal

2005-02-01 Thread Nick Coghlan
x27;0xbe') Py> hex(hi + lo) '0x145' Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: how to separate hexadecimal

2005-02-02 Thread Nick Coghlan
if val == 0: ... return 0 ... return limit - val ... Py> hex(complement(0x55)) '0xab' Py> hex(complement(0x55, 256*256)) '0xffab' Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --

Re: how to separate hexadecimal

2005-02-02 Thread Nick Coghlan
Nick Coghlan wrote: When not working at the hardware level, just go with the definition: Py> def complement(val, limit=256): ... if val >= limit or val < 0: ... raise ValueError("Value out of range for complemented format") ... if val == 0: ... return 0 ... return

Re: access to serial port

2005-02-02 Thread Nick Coghlan
Pawe³ Chrobak wrote: Hi How to take access to serial port (rs232) ?? Is't possible?? Just tell me guy's where I can take o look The same place you should always look - Google. Keywords: python serial Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: new style exception handleing

2005-02-03 Thread Nick Coghlan
ut killing backward compatibility with string exceptions is hard :) Doesn't mean people aren't trying though (Google the python-dev archives, as well as the python-list ones). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: test_socket.py failure

2005-02-03 Thread Nick Coghlan
run "ldd python24" to see which shared C library it is linking to. For me, it's /lib/tls/libc.so.6. Running that library directly prints out the message about GNU C library 2.3.3. Cheers, Nick. -- Nick Coghlan | [EM

Re: Learning Python for a new beginner

2005-02-04 Thread Nick Coghlan
pect to Perl, I find it to be such an inconsistent dog's breakfast that I have the docs page open whenever I have to write or read it. With Python, I first used it for one subject at University, and was able to pick it back up a few years later without even looking at the documentation. Chee

Re: python equivalent to haskells iterate.

2005-02-04 Thread Nick Coghlan
(((val // (10 ** i)) % 10) for i in count()) ) ) ) Usually you're going to be better served by making the generator function smarter if you're going to be writing one anyway, though. Cheers, Nick. -- Ni

Re: Why does super() require the class as the first argument?

2005-02-04 Thread Nick Coghlan
ite recursion. It *is* possible to eliminate the explicit class argument, but it takes a bit (*cough*) of work: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: Is there a market for python developers?

2005-02-04 Thread Nick Coghlan
f the tests and the post-analysis of the generated data). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: global variables

2005-02-04 Thread Nick Coghlan
A Steve wrote: A Steve wrote: A Steve wrote: There we go, much clearer ;) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org

Re: changing local namespace of a function

2005-02-04 Thread Nick Coghlan
evil hack and almost certainly not what anyone should be doing. Also, variables created this way will be slower than normal variables due to the way the associated code works. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: changing local namespace of a function

2005-02-04 Thread Nick Coghlan
hael's is going to be much easier to debug, much easier to understand later, and far more reliable all the way along. The performance is almost certainly going to be acceptable. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: string issue

2005-02-04 Thread Nick Coghlan
tion This feature can't be added to lists because it is possible to iterate sensibly over a mutating list: Py> l = range(10) Py> for i in reversed(l): del l[i] ... Py> l [] Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Nick Coghlan
n Python 2.5 the line should be spelt "from itertools import flatten" Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Nick Coghlan
itself into a generator? Py>def iter_collapse(myList): ... for x in it.groupby(myList): ... yield x[0] Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- h

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-04 Thread Nick Coghlan
nge files and folders search behaviour Advanced OK Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
would absolutely be the *best* solution to my problem. Bo Guido van Rossum has stated that he wants Python to eventually have a 'with' statement of the form: with d: .z = .x + .y (The leading '.' being required to avoid ambiguity in name lookups) Cheers, Nick. -- Ni

Re: PythonWin and PyWin32

2005-02-05 Thread Nick Coghlan
Windows. pywin32 is about better support for Windows specific idioms (e.g. easier COM support, more convenient registry access). Pythonwin is a windows native Python IDE built using MFC. Idle uses TKinter and doesn't really feel like a standard Windows app. Cheers, Nick. -- Nick Co

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
ipulator, simply define additional calculator methods, and define the attribute with make_prop. Use a class. Giving meaningful form to a collection of attributes is what they're for, and Python provides many features designed to make that process e

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
ttr__(self, "_data", data) def __getattr__(self, attrname): return self._data[attrname] def __setattr__(self, attrname, value): self._data[attrname] = value Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: a type without a __mro__?

2005-02-05 Thread Nick Coghlan
pcopy Py> deepcopy(x) Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\copy.py", line 172, in deepcopy y = copier(memo) TypeError: cannot deepcopy this pattern object Py> x.__de

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
z = _utils.make_prop('z', _utils.calc_z) Py> d = DataManipulator(dict(x=1, y=2)) Py> d.x 1 Py> d.y 2 Py> d.z 3 Py> d.x = 10 Py> d.z 3 Py> del d.z Py> d.z 12 Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Michael Spencer also posted an interesting idea recently about setting up a view of an existing dictionary, rather than as a separate object: class attr_view(object): def __init__(self, data): object.__setattr__(self,

Re: variable declaration

2005-02-05 Thread Nick Coghlan
so how does it look?: S=0 for eps in xrange(10): S @= S + ups Meh. At symbols are still ugly. A full stop might work better, since the semantics aren't very different from a reader's point of view: S=0 for eps in xrange(10): S .= S + ups Anyway, the e

Re: variable declaration

2005-02-05 Thread Nick Coghlan
er has explicitly requested an unconditional name binding by using '=' and then made a typo on the left hand side. Cheers, Nick. Did I mention the possible incidental benefit of reducing the whinging about the lack of variable declarations? -- Nick Coghlan | [EMAIL PR

Re: variable declaration

2005-02-05 Thread Nick Coghlan
tem != lastitem: yield item lastitem .= item (Note that doing this *will* slow the code down, though, since it has to check for the existence of the name before rebinding it) Cheers, Nick. -- Nick Coghlan | [EMA

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
making you jump through irrelevant hoops. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
hat said, one of the reasons I like CPython is that it lets you drop into C/C++ really easily when you need to (generally for hardware interface or performance reasons). The builtin profiler can also give some decent hints on the bottlenecks where you need to focus your performance improvements. C

Re: variable declaration

2005-02-05 Thread Nick Coghlan
ms of elementary operations of getting and setting (of attributes, items, &c). I was thinking of something simpler: x.y x.y = z That is, before the assignment attempt, x.y has to resolve to *something*, but the interpreter isn't particularly fussy about what that something is. Che

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
Steven Bethard wrote: Nick Coghlan wrote: I think the idea definitely deserves mention as a possible implementation strategy in the generic objects PEP, with the data argument made optional: That's basically what the current implementation does (although I use 'update' instea

Re: Insane import behaviour and regrtest.py: heeelp

2005-02-05 Thread Nick Coghlan
file = sys.argv[0] else: file = __file__ testdir = os.path.dirname(file) or os.curdir return testdir So intead of adding anything to sys.path, tweak the call to 'main' on the final line to set "testdir" appropriately. Cheers, Nick. -- Nick Coghlan

Re: sudoku dictionary attack

2005-06-21 Thread Nick Atty
On Mon, 20 Jun 2005 23:30:27 +0200, Oliver Albrecht <[EMAIL PROTECTED]> wrote: >Has some one an sodoku-task-generator? >Here another solutions-ways: >http://www.python-forum.de/viewtopic.php?t=3378 It's presumably easy to turn a solver into a generator. Start with a random grid, and remove squar

Seeking IDE

2005-06-30 Thread Nick Mountford
Hi, Complete newb to Python and programming, looking for an open source IDE to download. Any suggestions? Thanks, Nick -- http://mail.python.org/mailman/listinfo/python-list

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