Re: How do you control _all_ items added to a list?

2005-03-01 Thread Nick Coghlan
item__ and keys() With an appropriate ListMixin, providing the first three methods would suffice to support the full list API. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: assigning a custom mapping type to __dict__

2005-03-01 Thread Nick Coghlan
Dict_* API calls [1] to manipulate tp_dict, rather than the abstract PyMapping_* calls [2]. The reason behind using the concrete API is, presumably, a question of speed :) Cheers, Nick. [1] http://www.python.org/dev/doc/devel/api/dictObjects.html [2] http://www.python.org/dev/doc/devel/api/ma

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
g the question up on py-dev as well. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Nick Coghlan wrote: a) Checking that replacing the relevant "raise TypeError" calls in Lib/Decimal.py with "return NotImplemented" gives you friendlier behaviour. It turns out this isn't really practical - there's too much code in the module relying on those TypeErr

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Nick Coghlan wrote: Nick Coghlan wrote: a) Checking that replacing the relevant "raise TypeError" calls in Lib/Decimal.py with "return NotImplemented" gives you friendlier behaviour. It turns out this isn't really practical - there's too much code in the modu

Re: Decimal, __radd__, and custom numeric types...

2005-03-01 Thread Nick Coghlan
Batista, Facundo wrote: [Nick Coghlan] #- >> a) Checking that replacing the relevant "raise TypeError" #- calls in #- >> Lib/Decimal.py with "return NotImplemented" gives you friendlier #- >> behaviour. #- > #- > #- > It turns out this isn'

Re: What's the cost of using hundreds of threads?

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

Re: reuse validation logic with descriptors

2005-03-02 Thread Nick Coghlan
nload/Descriptor.htm about 4 times along with your help to get this straight. If it only takes 2 or 3 re-reads to get descriptors, does that mean Python's black magic is really only a kind of off-white colour? Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane,

Re: Initializing subclasses of tuple

2005-03-02 Thread Nick Coghlan
, please consider posting them on SF :) It's currently conspicuous by its absence: http://www.python.org/dev/doc/devel/ref/customization.html Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: assigning a custom mapping type to __dict__

2005-03-02 Thread Nick Coghlan
they already are (as Duncan pointed out). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: assigning a custom mapping type to __dict__

2005-03-02 Thread Nick Coghlan
dle this, but I can't". Maybe "__op__ = NotImplemented" should clear the associated slot. It would also make it easier to inherit from list and handle slices in __getitem__ by writing "__getslice__ = NotImplemented" instead of overriding __getslice__ to delegate t

Re: Decimal, __radd__, and custom numeric types...

2005-03-02 Thread Nick Coghlan
Blake T. Garretson wrote: Thanks for the suggestions and modified module. I will probably just use this "fixed" module to solve my immediate problem. Expect its performance to be worse than the standard version - it does the right thing, but it sure ain't pretty. . . Cheers

Re: yield_all needed in Python

2005-03-02 Thread Nick Coghlan
eyword gains a native genexp syntax). If anyone thinks that this would result in a couple of parentheses making too much difference, consider this: Py> [x for x in []] [] Py> [(x for x in [])] [] Cheers, Nick. -- Nick Coghlan

Re: yield_all needed in Python

2005-03-03 Thread Nick Coghlan
s clear as adding an asterisk to the front :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: yield_all needed in Python

2005-03-03 Thread Nick Coghlan
le): for item in iterable: if item is iterable: # Do the right thing for self-iterative things # like length 1 strings yield iterable raise StopIteration try: itr = iter(item): except TypeError: yield item else: yield x for x in flatten(item)

Re: Call variable as a function

2005-03-04 Thread Nick Coghlan
Steve Holden wrote: There's always a way: >>> def test(): ... print "hello" ... >>> var = "test" >>> eval("%s()" % var) hello I'd go with locals() for the simple case of a name lookup: Py> def test(): ... print "

Re: Integer From A Float List?!?

2005-03-04 Thread Nick Coghlan
t(x))" 1000 loops, best of 3: 992 usec per loop For builtin functions, map is usually the fastest option (and, IMO, the most readable). List comprehensions should be preferred to map + lambda, though. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisba

Re: Closing files

2004-11-30 Thread Nick Coghlan
idea gets adopted, it is unlikely to use the 'with' keyword - see PEP 3000 for the reason why) Regards, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: The use of :

2004-11-30 Thread Nick Coghlan
on general lack of *other* punctuation (e.g. the colon would be entirely ineffective at improving readability if every line ended with a semi-colon). Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: slicing, mapping types, ellipsis etc.

2004-11-30 Thread Nick Coghlan
rary make use of these (although the point may have been implied by the references to PyNumeric as the place to look for more exact documentation. Python's own documentation of the slice() builtins makes reference to Numeric!). Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: pre-PEP generic objects

2004-11-30 Thread Nick Coghlan
ce consistent order matters for a tuple. Comparison semantics are inherited directly from tuple, and don't care about names (they're only interested in values). Also, it seems like there has to be a better way to do the "opposite of zip()" in fromPairs(), but I sure as he

Re: Class methods in Python/C?

2004-11-30 Thread Nick Coghlan
o.some_static_method(some_args) In Py2.4, the method definition can be collapsed to: class Demo(object): @staticmethod def some_static_method(some_arg_list): pass Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Restricted Execution on the cheap

2004-11-30 Thread Nick Coghlan
isn't accidental that Bastion and rexec got deprecated - the developers just can't guarantee that the modules are actually providing adequate protection. A chroot() jail, setuid() to some permission-less sandbox user and your monitoring daemon are likely to get you a lot further. Reg

Re: Python code and C code in the same module?

2004-11-30 Thread Nick Coghlan
Fredrik Lundh wrote: if you insist on doing it the other way around, This paragraph should actually continue ". . .you clearly have too much free time" };> Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: slicing, mapping types, ellipsis etc.

2004-11-30 Thread Nick Coghlan
: http://www.python.org/dev/doc/devel/ref/sequence-types.html Regards, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: debian python2.4

2004-12-02 Thread Nick Vargish
ions with Python (v2.4) It sure looks like it's there. 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: help running python in a limited interpreted environment

2004-12-03 Thread Nick Coghlan
sible for the circularity to a different - possibly new - module) If you don't have any circular imports, then I'm out of ideas :) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Pre-PEP: Executing modules inside packages with '-m'

2004-12-03 Thread Nick Coghlan
PEP is aimed at fixing that :) Cheers, Nick. === PEP: XXX Title: Executing modules inside packages with '-m' Version: $Revision:$ Last-Modified: $Date:$ Author: Nick Coghlan <[EMAIL PROTECTED]>, Status: Draft Type: Standards Track Content-T

Re: Python 3000 and "Python Regrets"

2004-12-03 Thread Nick Coghlan
to a proposed feature list for Py3K/3.0. Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: assymetry between a == b and a.__eq__(b)

2004-12-03 Thread Nick Coghlan
can interact with parent classes correctly. So, in Steven's original code, B.__eq__(A) was invoked, and returned False (since A was the parent class of B, not a subclass). Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me asap!!

2004-12-04 Thread Nick Coghlan
ot;it doesn't work" with no idea which *bit* isn't working) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newby Q: nested classes, access of upper method

2004-12-04 Thread Nick Coghlan
def __init__(self, owner): self._owner = owner def B1(self): self._owner.A1() def A1(self): pass def makeB(self): return A.B(self) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic use of CSV module to skip headers?

2004-12-04 Thread Nick Coghlan
int sorted(row.items()) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP: __source__ proposal

2004-12-04 Thread Nick Coghlan
ting, though (this capability would then be available to anyone embedding Python as a scripting engine). Cheers, Nick. == >>>import source >>>class bob: ... def mary(): ...pass ... def tim(): ...print 'Tim' ... >>>print bob.

Re: help needed

2004-12-04 Thread Nick Coghlan
In response to your first message, I offered some ideas on how to get more useful responses, along with a couple of general techniques for finding the problem yourself. Reposting almost exactly the same message 8 or so hours later wasn't a suggestion featured in either category. Cheers,

Re: Bug in py32win manual for file_locking for Python 2.4

2004-12-04 Thread Nick Coghlan
Pekka Niiranen wrote: However, using highbits=0x7fff # equals hex(sys.maxint) gives no errors, but does locking work if highbits are not exactly 0x? Try using highbits=-0x7fff as your mask. That should set the MSB without tripping over the sys.maxint limit. Cheers, Nick. -- http

Re: assymetry between a == b and a.__eq__(b)

2004-12-04 Thread Nick Coghlan
ossibly non-commutative op, and B is a proper subclass of A This is so that things like the following work: .>>> class SillyAdd(long): __add__ = long.__mul__ __radd__ = __add__ .>>> a = SillyAdd(4) .>>> a .4L .>>> a + 5 .20L .>>> 5 + a .20L Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP: __source__ proposal

2004-12-04 Thread Nick Coghlan
think your comments were basically on target, though - the idea is to be able to 'recompile' portions of the interactive session, replacing the code objects inside the function structure. (or adding entries to class dictionaries, etc, etc) Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with modules/packages.

2004-12-04 Thread Nick Coghlan
up, which happens at run time, not compile time. This can end up mattering if the lookup is being done inside a loop. The above idiom gives you a reference directly to the classes you want to use, thus allowing them to be found directly in the module's own dictionary. Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: long number multiplication

2004-12-04 Thread Nick Coghlan
bjects instead of a list of digits slows it down. The arithmetic is faster, but the exponentiation + division required for rounding is significantly slower than the list slicing that the current implementation is able to use). Cheers, Nick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive list comprehension

2004-12-06 Thread Nick Coghlan
ut I highly recommend learning about the stdlib module "itertools" (I only really looked into it recently). The above can be done in 3 lines (counting imports): from itertools import chain n = [['N', 'F'], ['E'], ['D']] print [chain(*n)]

Re: Recursive list comprehension

2004-12-06 Thread Nick Coghlan
Peter Otten wrote: Nick Coghlan wrote: from itertools import chain n = [['N', 'F'], ['E'], ['D']] print [chain(*n)] However, [generator] is not the same as list(generator): Heh - good point. As you say, replacing with list() gives the intended answer. Wit

Float to int conversions (was: int(float(sys.maxint)) buglet)

2004-12-06 Thread Nick Coghlan
ints. See the code for the gory details (the relevant function is 'float_int'): http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/floatobject.c?rev=2.134&view=markup Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisb

exec and thread.start_new

2004-12-06 Thread Nick Coghlan
module. 2. The 'in dict()' workaround is simple and effective Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand a little python

2004-12-07 Thread Nick Coghlan
his description, the relevant word is almost certainly "descriptors") Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: long number multiplication

2004-12-07 Thread Nick Coghlan
base 10->base 2 conversion. Indeed. Python's Decimal data type stores the digits in a list for ease of power of 10 multiplication & rounding (the precision rules means a *lot* of that goes on). However, it converts that list of digits to a long integer in order to do addition, multiplicatio

Re: win32 extensions for Python 2.4

2004-12-07 Thread Nick Coghlan
but i won't be bothered to download it. :) It's on the sourceforge download page. So long as you don't want to use Pythonwin, version 203 should work fine. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --

Re: deferred decorator

2004-12-08 Thread Nick Coghlan
ds. does anyone know how to port this recipe to the new class style? Override __getattribute__. I don't know why you think it doesn't let you override all attribute accesses, as that's exactly what it is for. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED]

Re: How do I do this? (eval() on the left hand side)

2004-12-08 Thread Nick Coghlan
the user's variables, easily avoiding namespace conflicts. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I do this? (eval() on the left hand side)

2004-12-08 Thread Nick Coghlan
rally, altering the contents of the dicts returned by locals() and globals() is unreliable at best. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.n

Re: [BUG] IMO, but no opinions? Uncle Tim? was: int(float(sys.maxint)) buglet ?

2004-12-08 Thread Nick Coghlan
you like in your own copy of Python . .>>> _int = int .>>> def int(*args): return _int(_int(*args)) .>>> from sys import maxint .>>> int(maxint) .2147483647 .>>> int(-maxint-1) .-2147483648 Pretty! };> Cheers, Nic

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Nick Coghlan
Peter Hansen wrote: Nick Coghlan wrote: Generally, altering the contents of the dicts returned by locals() and globals() is unreliable at best. Nick, could you please comment on why you say this about globals()? I've never heard of any possibility of "unreliability" in updating gl

Re: a newbie question

2004-12-09 Thread Nick Coghlan
on any platform: python -c "import pdb; print pdb.__file__" The rest of the standard library will be in the same directory as pdb.pyc. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: deferred decorator

2004-12-09 Thread Nick Coghlan
Bryan wrote: Nick Coghlan wrote: Bryan wrote: i'm also curious if it's possible to write this recipe using the new class style for the Deffered class.it appears you can nolonger delegate all attributes including special methods to the contained object by using the __getattr__

Re: Wrapper objects

2004-12-10 Thread Nick Coghlan
from object or another builtin, that recipe fails. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Rationale behind the deprecation of __getslice__?

2004-12-10 Thread Nick Coghlan
itely solve the OP's problem... It might be better handled at construction time - if the class supplied to __new__ is a subclass of the builtin type, swap the __getslice__ implementation for one which delegates to __getitem__. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED]

Re: Rationale behind the deprecation of __getslice__?

2004-12-10 Thread Nick Coghlan
e development of extended slicing in the first place (it wasn't until 2.3 that Python's builtin sequences supported extended slicing at all). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: Wrapper objects

2004-12-10 Thread Nick Coghlan
Kent Johnson wrote: Nick Coghlan wrote: Simon Brunning wrote: This work - <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52295>? Only for old-style classes, though. If you inherit from object or another builtin, that recipe fails. Could you explain, please? I thought __get

Re: building python extensions with .net sdk compiler?

2004-12-11 Thread Nick Coghlan
Mike C. Fletcher wrote: Which is what the patch here: http://www.vrplumber.com/programming/mstoolkit/ does. Has that patch been posted to Python's SourceForge patch tracker? I think the distutils folks will be interested. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: Upgrade woes: Numeric, gnuplot, and Python 2.4

2004-12-11 Thread Nick Coghlan
ownside is that the total download to get all the pieces you need is on the order of 400 MB. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net

Re: uptime for Win XP?

2004-12-11 Thread Nick Coghlan
han just the up time) There's also info about the 'uptime' utility here: http://support.microsoft.com/kb/q232243/ I don't know if that works for XP. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia -

Re: Upgrade woes: Numeric, gnuplot, and Python 2.4

2004-12-11 Thread Nick Coghlan
her I nor the win32 gurus can figure out what the heck happened. And reinstallation of 2.3 and the Py2.3 win32all didn't fix it? Very strange. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: PEP 338: Executing modules inside packages with '-m'

2004-12-11 Thread Nick Coghlan
was already in beta at the time. So I went with the cookbook recipe instead. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.

Re: while 1 vs while True

2004-12-13 Thread Nick Coghlan
#x27;False' are in line for similar treatment (there are obvious backwards compatibility issues in doing so). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Renaming __getattribute__ (PEP?)

2004-12-13 Thread Nick Coghlan
r than working on changing the names of special methods. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 338: Executing modules inside packages with '-m'

2004-12-13 Thread Nick Coghlan
pdb and profile for the interpreter you're working with. For usability, you can hide all of the above behind a menu item or desktop shortcut. However, the major target of the feature is Python developers rather than the end-users of applications built using Python. Cheers, Nic

Re: newbie questions

2004-12-13 Thread Nick Coghlan
types (e.g. strings, numbers, tuples) are generally returned directly from functions, rather than returned as 'output parameters'. The ability to return multiple values easily (via "return a, b, c" & "x, y, z = myfunc()" generally eliminates the need for 

Re: can't find python2.4 source code

2004-12-13 Thread Nick Coghlan
. Does the python24 source code released? http://sourceforge.net/projects/python/ Which is linked from www.python.org However, as Fredrik said, the source tarballs are available on the release page for 2.4 (and yes, they do contain the source code). Cheers, Nick. -- Nick Coghlan | [EMAIL

Organising data within a program

2004-12-13 Thread Nick Evans
nfo to a standard txt file. Probably CSV or something. Is there any particular way I should be saving this data to file? Thanks in advance Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 338: Executing modules inside packages with '-m'

2004-12-13 Thread Nick Coghlan
Fredrik Lundh wrote: my suggestion was to make sure that the user can type "bar arg" to start a Python program called "bar" with the argument "arg". that's trivial, on all major platforms, despite what Nick says -- and yes, you can start threads from a progra

Re: [dictionary] how to get key by item

2004-12-13 Thread Nick Coghlan
value, keys in grouped) .>>> r {16: ['mary', 'fred'], 1: ['bar', 'foo'], 42: ['jane'], 7: ['bob']} Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: while 1 vs while True

2004-12-13 Thread Nick Coghlan
* flexible - and in this case, the flexibility eliminates some potential optimisations (in this case, "I know what this is" compile time name binding). I believe modifying a module's globals dictionary from outside the module is in the process of being deprecated - the

Re: PEP 338: Executing modules inside packages with '-m'

2004-12-13 Thread Nick Coghlan
age points out (eventually) - this feature is intended for developers and Python version specific utility scripts like pdb, profile and pychecker.checker, rather than launch scripts for full applications. For end users, I agree with you wholeheartedly - applications should behave like applications

Re: while 1 vs while True

2004-12-15 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Until this code: .>>> import pdb .>>> pdb.True = 0 .>>> pdb.x = "Darn writeable module dictionaries" .>>> from pdb import True .>>> True 0 .>>> from pdb import x .&g

Re: do you master list comprehensions?

2004-12-15 Thread Nick Coghlan
n" "''.join(chain(*data))" 10 loops, best of 3: 1.2 sec per loop ** OUCH!! C:\>python -m timeit -s "data = [map(str, range(x)) for x in range(1000)]; from itertools import chain" "''.join(list(chain(*data)))" 10 loops, best of 3: 107 msec per loop Yikes - loo

Re: jython and concatenation of strings

2004-12-15 Thread Nick Coghlan
#x27;.join(string_list) (Python switches to the unicode version automatically if it finds any unicode strings in the supplied sequence. Jython may not do that - I'm not a Jython user though, so I'm not sure). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |

Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-16 Thread Nick Coghlan
seful for web tools that strip leading whitespace. Prepending every line with . is not an ideal solution though... I think it gets tiresome very quickly. Aye, can't argue with that. It does have the virtues of reliability and portability, though :

Re: do you master list comprehensions?

2004-12-16 Thread Nick Coghlan
Nick Coghlan wrote: (FYI, I filed bug report #1085744 on SF about this) And Raymond Hettinger was able to decipher my somewhat incoherent rambling (tip: don't try to write bug reports in the wee hours of the morning) and produce a potentially useful modification to PySequence_Tuple. Anyw

Re: why not arrays?

2004-12-16 Thread Nick Coghlan
(increase the base Python download too much) - portability (less portable than the core interpreter) - stability (the numpy folks aren't yet prepared to commit to the backwards compatibility issues associated with being part of the standard library) - logistics (merging numpy into Python is like

Re: Python mascot proposal

2004-12-17 Thread Nick Vargish
"EP" <[EMAIL PROTECTED]> writes: > (what is the mascot for C++?) I can't seem to find a goatse link... (But I didn't try very hard.) Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),&#x

Re: How do I do this? (eval() on the left hand side)

2004-12-10 Thread Nick Coghlan
aside from the detail that modifying a module's contents via a reference to that module is far more evil than playing with globals() ;) Even if that module is the one you're running in. . . Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bris

Re: Wrapper objects

2004-12-10 Thread Nick Coghlan
require calls to methods like int() or str() in your application code to make the types work out correctly. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skyst

Re: New versions breaking extensions, etc.

2004-12-10 Thread Nick Coghlan
ual Studio license ;) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Overriding properties

2004-12-11 Thread Nick Patavalis
Why does the following print "0 0" instead of "0 1"? What is the canonical way to rewrite it in order to get what I obviously expect? class C(object): __val = 0 def set_value(self, val): if val < 0 : self.__val = 0 else : self.__val = val def get_value(self)

PEP 338: Executing modules inside packages with '-m'

2004-12-11 Thread Nick Coghlan
eed to comment). Or, it could just be a sign that Python 2.4 hasn't been out long enough for anyone to care what I'm yabbering on about :) Anyway, all comments are appreciated (even a simple "Sounds good to me"). Cheers, Nick. **

Re: Why are tuples immutable?

2004-12-13 Thread Nick Coghlan
;>> x is y False .>>> y is z True Immutable objects can use optimisation tricks that mutable objects can't rely on. So, no, a 'mutable tuple' of any description would not be as fast as the current tuple implementation. If you want numbers to look at, try some timings c

Re: PEP 338: Executing modules inside packages with '-m'

2004-12-15 Thread Nick Coghlan
Martin Bless wrote: [Nick Coghlan <[EMAIL PROTECTED]>] One thing I stumbled across with the current implementation: Why doesn't "python -m abc" work with ./abc/ ./abc/__init__.py assuming ./abc/ is directly on the path? In analogy to normal module import? It doesn't wor

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
n certainly *do* the former (using __hash__ and appropriate comparison overrides), but it isn't particularly easy to do correctly, and hence usually isn't a great idea unless copies are *really* expensive (and even then, a shallow copy approach can often suffice). Cheers, Nick. -- Nick Co

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
st) Py> d[KeyByIdentity(key_with_new_id)] Traceback (most recent call last): File "", line 1, in ? KeyError: <__main__.KeyByIdentity object at 0x009DA418> It would also be trivial to inherit from dict to make an "IdentityDict" which automatically used KeyByIdentity on it

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
(NotHashable()) 10297264 Py> d = {NotHashable(): "Hi"} Py> d {<__main__.NotHashable object at 0x009D1FF0>: 'Hi'} That may be a bug rather than a feature :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: better lambda support in the future?

2004-12-17 Thread Nick Coghlan
etween them 3. That function is then passed as an argument to another function call All of that is contained in the lambda version, too, but the excessive brevity makes for rather confusing reading. Cheers, Nick. -- Nick Coghlan

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
Nick Coghlan wrote: Although, it looks like new-style classes currently don't apply this rule - you get the default hash implementation from object no matter what: That may be a bug rather than a feature :) And indeed it is: http://sourceforge.net/tracker/index.php?func=detail&a

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Nick Coghlan
code meant to parse out data from my finditer() object. Take a look at itertools.tee Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.pytho

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Nick Coghlan
Nick Coghlan wrote: Chris Lasher wrote: Hello, I really like the finditer() method of the re module. I'm having difficulty at the moment, however, because finditer() still creates a callable-iterator oject, even when no match is found. This is undesirable in cases where I would like to circu

Re: better lambda support in the future?

2004-12-18 Thread Nick Coghlan
ss ... Py> for t in sorted(dispatcher.items()): print '%5s: %r'%t ... a: b: c: -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Cool object trick

2004-12-18 Thread Nick Coghlan
Robert Brewer wrote: Bengt Richter wrote: >>> m=type('',(),{})() >>> m.title = 'not so fast ;-)' >>> m.title 'not so fast ;-)' Now THAT is a cool object trick. :) Heh. Look ma, Perlython! Cheers, Nick. -- Nick

Re: better lambda support in the future?

2004-12-18 Thread Nick Coghlan
;. They're probably less evil than sys._getframe hacks, though :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list

Re: A rational proposal

2004-12-18 Thread Nick Coghlan
h case, I would also hope to see a __decimal__ special method. The correct answer would then be for Rational.rational to handle decimals in its constructor, and provide an implementation of __decimal__ (similar to the way Decimal.decimal interacts with the other builtin types). Cheers, Nick. -- N

Re: A beginner's problem...

2004-12-18 Thread Nick Coghlan
ort x Py> # Do stuff Py> import module Py> reload(module) Py> from module import x Py> # We now have the updated version of x Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Plugin system; imp module head scratch

2004-12-18 Thread Nick Coghlan
ent, it is pulling in the __init__.py from the current directory, and assigning it to the name you requested) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystor

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