Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Don't know about this particular case but sometimes, I don't want to > have a default argument value. That is, argument not there is different > from argument = None. Though in general, I prefer the None as special > meaning coding style. But even pyt

Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > I find this style of coding repulsive when compared to: > > > > def foo(arg1=None, arg2=None): > > print dict(arg1=arg1, arg2=arg2) > > > > I don't understand

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
benz <[EMAIL PROTECTED]> wrote: ... > def spin(delay): > > pattern=['-','\\','|','/','-','\\','|'] > > while 1: > for i in pattern: > sys.stdout.write(i + " ") > sys.stdout.flush() > sys.stdout.write("\b\b") > time.sleep(delay) > > pid = os.fork() > > if pid =

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > Have the spin function accept the pid argument and exit the loop if said > > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this > > will raise an OSError if no process with t

Re: Scanning a file

2005-10-30 Thread Alex Martelli
John J. Lee <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > [...] > > If you're trying to test your code to ensure it explicitly closes all > > files, you could (from within your tests) rebind built-ins 'file' and > > 

Re: Scanning a file

2005-10-30 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > > No. But if you get a totally unexpected exception, > > I'm more concerned about getting an expected exception -- or more > accurately, *missing* an expected exception. Matching on Exception is too > high. EOFError will probably need to be han

Re: Controlling output using print with format string

2005-10-30 Thread Alex Martelli
Paul Watson <[EMAIL PROTECTED]> wrote: > It is clear that just using 'print' with variable names is relatively > uncontrollable. However, I thought that using a format string would > reign the problem in and give the desired output. > > Must I resort to sys.stdout.write() to control output? In

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Alex Martelli
Alex <[EMAIL PROTECTED]> wrote: > I have a serious problem and I hope there is some solution. It is > easier to illustrate with a simple code: > > >>> class Parent(object): > __slots__=['A', 'B'] > def __init__(self, a, b): > self.A=a; self.B=b > def __getstate__(s

Re: putting a string in Mac Address form

2005-10-30 Thread Alex Martelli
kyle.tk <[EMAIL PROTECTED]> wrote: ... > new_mac = '' > c = 0 > while len(new_mac) < 16: > new_mac += mac[c:c+2] + ':' > c=c+2 > return new_mac[:-1].upper() ... > The part I think is bad is the while loop part. Could it be better? What abou

Re: mixin helper class for unknown attribute access?

2005-10-31 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > Trying to prevent setting new attributes is a pretty heavy-handed act just > to prevent a tiny subset of errors. Many people argue strongly that even > if you could do it, it would be pointless -- or at least, the cost is far > greater than whatev

Re: data hiding/namespace pollution

2005-10-31 Thread Alex Martelli
Alex Hunsley <[EMAIL PROTECTED]> wrote: > There's no really specific questions in this post, but I'm looking for > people's thought on the issues within... > > > The two main versions I've encountered for data pseudo-hiding > (encapsulation) in python are: > > method 1: > > _X - (single unde

Re: 'super' to only be used for diamond inheritance problems?

2005-10-31 Thread Alex Martelli
Alex Hunsley <[EMAIL PROTECTED]> wrote: > I've seen a few discussion about the use of 'super' in Python, including > the opinion that 'super' should only be used to solve inheritance > diamond problem. (And that a constructor that wants to call the > superclass methods should just call them by n

Re: Scanning a file

2005-10-31 Thread Alex Martelli
Steve Holden <[EMAIL PROTECTED]> wrote: ... > > The runtime knows it is doing it. Please allow the runtime to tell me > > what it knows it is doing. Thanks. > > In point oif fact I don't believe the runtime does any such thing > (though I must admit I haven't checked the source, so you may p

Re: Storing empties

2005-10-31 Thread Alex Martelli
Aahz <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Alex Martelli <[EMAIL PROTECTED]> wrote: > > > >the canonical idiom when you need such distinction is: > > > >_not_there = object() > >def foo(bar=_not_there, baz=_n

Re: Storing empties

2005-11-02 Thread Alex Martelli
Aahz <[EMAIL PROTECTED]> wrote: ... > >>>the canonical idiom when you need such distinction is: > >>> > >>>_not_there = object() ... > >> What's your preferred idiom when you're dealing with storable objects? > > > >What's a "storable object"? You mean, something that can be pickled, or > >p

Re: dictionary that have functions with arguments

2005-11-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } > > to call func1, i simply have to write execfunc[key1] . No, you ALSO have to write ( ) [[parentheses]] after that. MENTIONING a function doesn't call it, it's the parentheses that do it. > bu

Re: dictionary that have functions with arguments

2005-11-02 Thread Alex Martelli
Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > execfunc = { 'key1' : (func1, ()), > > 'key2' : (func2, args) } > > > > now, something like: > > > > f, a = execfunc[k] > > f(*

Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Alex Martelli
Paul Rubin wrote: ... > You can use re.search on array.array byte vectors. I don't know how > the speed compares with string.find. Pretty well, though of course one should measure on representative cases for one's specific application needs: Helen:~ alex$ python -mt

Re: Python for .NET and IronPython

2005-11-02 Thread Alex Martelli
hrh1818 <[EMAIL PROTECTED]> wrote: > For more information on Iron Python see http://www.ironpython.com/ > My take on Iron Python is the new job the develolper of Iron Python > started last year takes up just about all of his time and the developer > is currently spending very little time actively

Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Alex Martelli
Brandon K <[EMAIL PROTECTED]> wrote [inverting his topposting!]: > > Six megabytes is pretty much nothing on a modern computer. > BTW, it'd be 6 megabits or 750kb ;) ...but Mike was proposing using one digit per bit, hence, 6 megabytes. That makes it easy to search for bitpatterns with re or str

Re: Suggestion for (re)try statement

2005-11-02 Thread Alex Martelli
Sori Schwimmer <[EMAIL PROTECTED]> wrote: ... > 2) Rocco Morreti wrote: > > What is so repugnant about the equivalent, currently > valid way of writing it? > Nothing "repugnant". We have in almost all procedural > languages an "if-else" construct, and a "case" or > "elif" as well. Python has no

Re: Python's website does a great disservice to the language

2005-11-02 Thread Alex Martelli
The Eternal Squire <[EMAIL PROTECTED]> wrote: ... > 2) Consider what he really wants for a supervisor of software > engineers. Ideally such a person should be a software engineer with > at least 3 times the experience of the most junior member. Such a I like the general idea but not your fo

Re: weakrefs to functions for observer pattern

2005-11-02 Thread Alex Martelli
Michael Schneider <[EMAIL PROTECTED]> wrote: > I would like to use weak refs in an observer pattern implementation. > The problme that I have seems to be that weakrefs can't manage functions. They can manage just fine functions written in *Python*, just not "builtin functions*, i.e., ones written

Re: Nested List Question

2005-11-02 Thread Alex Martelli
Newsfeeds <[EMAIL PROTECTED]> wrote: > Hello All, > > Could anyone tell me why this code produces the output it does? ... > gridSystemId = [[None]*columns]*rows You've made gridSystemID a list of `rows` references to the SAME "inner" list, so the behavior you observe is the only possible on

Re: Most efficient way of storing 1024*1024 bits

2005-11-03 Thread Alex Martelli
Alex Stapleton <[EMAIL PROTECTED]> wrote: ... > >>> Six megabytes is pretty much nothing on a modern computer. > > > >> BTW, it'd be 6 megabits or 750kb ;) > > > > ...but Mike was proposing using one digit per bit, hence, 6 megabytes. > > That makes it easy to search for bitpatterns with re or

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Alex Martelli
Stuart Turner <[EMAIL PROTECTED]> wrote: ... > "Python is a scripting language like Perl, awk, tcl, Java etc... it is > not quite a fully developed OO language, but does support some OO that Perl > doesn't. To be clear, these scripting languages have their place in our > environment, but they

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > How about, Google use python extensively ? This I believe is a very > strong argument for any concern about python. I must admit to feeling very good when I read this kind of comment (it IS nice to see one's employer held up as a good example -- and,

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: > > because they do not come with the full range of libraries e.g GDI > > libraries. > > No language has libraries for everything you might ever possibly want to > do. Python has a wide range of libraries for many common tasks, but my no > means all. Still,

Re: How can I package a python script and modules into a single script?

2005-11-03 Thread Alex Martelli
Noah <[EMAIL PROTECTED]> wrote: > I would like to package my main script and all the > modules it imports into a single script that will > run just as the collection would. It should not > need to package standard Python lib modules -- just > my local modules. This is not the same question > that

Re: weakrefs to functions for observer pattern

2005-11-03 Thread Alex Martelli
Michael Schneider <[EMAIL PROTECTED]> wrote: ... > Thank you, I mis-read the docs. > > The mistake I made was having was using a weak reference as a key in > the dictionary. Rather than using a weakref.WeakKeyDictionary , I guess? > Weak references will be very useful for me. > > I really

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > But when we talk about organisation(and convincing sometimes not on > merit sake), banner name helps. I was once in organisation where The > MS/Intel/IBM combination is a sure thing because even if there is > anything went wrong, it wouldn't be the re

Re: Python's website does a great disservice to the language

2005-11-03 Thread Alex Martelli
Rocco Moretti <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > The Eternal Squire <[EMAIL PROTECTED]> wrote: > >... > > > >>2) Consider what he really wants for a supervisor of software > >>engineers. Ideally such a person should b

Re: Not Equal to Each Other?

2005-11-03 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > Rather than writing > > cellboard[0] is not* (cellboard[1] and cellboard[2] and cellboard[3] > and cellboard[4] ... cellboard[8]) > cellboard[1] is not (cellboard[0] and cellboard[2] and cellboard[3] and > cellboard[4] ... cellboard[8]) Urgh... the fastest way

Re: How can I package a python script and modules into a single script?

2005-11-03 Thread Alex Martelli
Noah <[EMAIL PROTECTED]> wrote: > This is interesting, but requires two separate files -- the ZIP file > and the boot script. No, it doesn't. > This is because zipimport can only import from file paths. It can import from a file, and the file (like all zipfiles) can have a prefix. That prefix

Re: when and how do you use Self?

2005-11-03 Thread Alex Martelli
Tieche Bruce A MSgt USMTM/AFD <[EMAIL PROTECTED]> wrote: ... > I am new to python, > Could someone explain (in English) how and when to use self? A class's methods use 'self' to refer to the object (instance of the class) they're being called on; mostly, they access (get or set) attributes on s

Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: > John Salerno wrote: > > LOL. As weird as it sounds, that's what I *don't* want to happen with > > C#! I've spent a lot of time with it, and I love it, but I don't want > > Python to take over! :) > > Then it might be better to keep away from Python. It *

Re: Anomaly in creating class methods

2005-11-03 Thread Alex Martelli
venk <[EMAIL PROTECTED]> wrote: > Hi, > given below is my interaction with the interpreter In one case, i > have created the class method using the "famous idiom"... and in the > other, i have tried to create it outside the class definition... why > isn't the latter working ? (of course, the

Re: Can Anyone Help me on this

2005-11-03 Thread Alex Martelli
[EMAIL PROTECTED] wrote: > Thanks Guys, Wow, i didnt knew that there was alist reverse function. > thx. also. i need a good documentation of the os and sys modules as > well as builtin functions of python. > > the standard python documentation doesnt work for me. can u recommend > something? I

Re: Anomaly in creating class methods

2005-11-03 Thread Alex Martelli
venk <[EMAIL PROTECTED]> wrote: > Cool, > i got it now... accessing thru attribute reference always > returns a bound or unbound method... so, D.f is an unbound method Right. Specifically, accessing through a (newstyle) class or instance always calls the __get__ method of a descriptor [

Re: I need Motivation

2005-11-03 Thread Alex Martelli
[EMAIL PROTECTED] wrote: > I m not a python Expert or anythin > i need help, i m losin my motivation to continue with python > can anyone inspire me again.??? Not without knowing more about your motivations for starting Python in the first place... Alex -- http://mail.python.org/mailman/listi

Re: Learning multiple languages (question for general discussion)

2005-11-04 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > Yes, but I haven't found knowing (and using) Python dampens my > > enthusiasms for learning new languages. > > But you're more enthusiatic than most of us Alex. I wish > I could say th

Re: GMPY: divm() memory leak revisited

2005-11-05 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > Unfortunately, I don't have any means of testing this theory. Yep -- I reproduced the memory leak you mentioned, and easily fixed it (exactly as you suggest) in the current CVS version of gmpy (meant to be "1.01 release candidate"). I need to

Re: __new__

2005-11-06 Thread Alex Martelli
Peter Otten <[EMAIL PROTECTED]> wrote: ... > is as __new__ had left it). Thus, for a new-style class C, the statement > x=C(23) is equivlent to the following code: > > x = C.__new__(C, 23) > if isinstance(x, C): C.__init__(x, 23) ... > the "Nutshell" example should be changed to > >

Re: Learning multiple languages (question for general discussion)

2005-11-06 Thread Alex Martelli
Paul Rubin <http://[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > > I can't imagine NOT getting enthusiastic and stimulated by reading Van > > Roy and Hariri's book -- it IS quite as good and readable as SICP. > > It's been o

gmpy 1.01 rc near... anybody wanna test>

2005-11-06 Thread Alex Martelli
I have fixed almost all of the outstanding bugreports and feature request for gmpy: divm doesn't leak memory any more, truediv and floordiv are implemented for all types, etc -- in the current CVS version (one thing I must still look at is divm's behavior when its args are not mutually prime). It

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-07 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I downloaded and tried the CVS version. Division still didn't work as > expected. Now that's truly interesting... > >>> import gmpy > >>> gmpy.version() > '1.01' > >>> gmpy.mpz(9)//gmpy.mpz(4) > Traceback (most recent call last): > File "", line 1, in ? > TypeError

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-07 Thread Alex Martelli
Paul Rubin <http://[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > > gmpy users able to download and build from sourceforge's cvs are > > encouraged to test the current CVS version. > > Oh cool, I wondered whether any gmpy maintenance was

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-07 Thread Alex Martelli
Steve Holden <[EMAIL PROTECTED]> wrote: ... > I tried compiling it with the MS free toolkit but the C compile > complains about the absence of "gmp.h". Since I see such a header in my > Cygwin installation I presume it's something that a full VC7 > installation could expect to be present. gmp

Re: PYTHON LOOSING FOR JAVA???????

2005-11-07 Thread Alex Martelli
Fcamattti <[EMAIL PROTECTED]> wrote: > So I have a doubt. I'd like to know what do you think about the joint > of efforts of Sun Microsystems and the Google to create a office web > based. I sincerely enjoy the idea althoug I'd like to know what will be > the future of this wonderful language cal

Re: overloading *something

2005-11-07 Thread Alex Martelli
Ron Adam <[EMAIL PROTECTED]> wrote: > James Stroud wrote: > > > Hello All, > > > > How does one make an arbitrary class (e.g. class myclass(object)) behave > > like a list in method calls with the "*something" operator? What I mean > > is: > > You need to base myclass on a list if I understand

Re: BayPIGgies: November 10, 7:30pm (Google)

2005-11-07 Thread Alex Martelli
Aahz <[EMAIL PROTECTED]> wrote: > The next meeting of BayPIGgies will be Thurs, November at 7:30pm at > Google (Bldg 43, room Tunis). 1600 Amphitheater Parkway in Mountain View (CA), btw. > Hasan Diwan will demonstrate a prototype GPS system written in Python. > Let's all work to convince him t

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-07 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Everything works fine with v1.16. I'm sure I was doing something wrong. > I shouldn't be testing that late at night. ;-) > > It looks like the warning about "tp_compare" has been fixed. I didn't touch tp_compare specifically, so the fix must have been a side effect (

Re: Storing empties

2005-11-08 Thread Alex Martelli
Aahz <[EMAIL PROTECTED]> wrote: ... > >For pickling, object() as a unique "nothing here, NOT EVEN a None" > >marker (AKA sentinel) works fine. > > How does that work? Maybe I'm missing something obvious. > > sentinel = object() > class C: > def __init__(self, foo=sentinel): >

Re: Newb ??

2005-11-09 Thread Alex Martelli
Norman Silverstone <[EMAIL PROTECTED]> wrote: ... > challenging. What I am thinking about at the moment is how to program for > the computer to guess the number which I select. I know it can be done but > I suspect it requires an approach which I have not yet learnt. I would > welcome suggestion

Re: Python obfuscation

2005-11-09 Thread Alex Martelli
Anand S Bisen <[EMAIL PROTECTED]> wrote: > I dont know much !! But if somebody asks me this question my answer > would be to convert some of the meat inside my programs to C/C++ and > then provide the interface to those novel ideas to Python using swig. > And for another level of protection mayb

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-09 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I made a successful installer for Windows using Mingw32 and Python 2.4. Great, thanks. > I needed to edit setup.py to list gmp as a required library. > > if sys.version.find('MSC')==-1: > gmpy_ext = Extension('gmpy', sources=['src/gmpy.c'], > # lib

Re: [ x for x in xrange(10) when p(x) ]

2005-11-09 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I am wondering if there is such a thing, as python is moving away from This becomes a valid list comprehension by writing 'if' instead of 'when'. > FP functions like dropwhile/takewhile etc. No way -- the itertools module is and remains a

Re: [ x for x in xrange(10) when p(x) ]

2005-11-09 Thread Alex Martelli
George Sakkis <[EMAIL PROTECTED]> wrote: ... > > > FP functions like dropwhile/takewhile etc. > > > > No way -- the itertools module is and remains a PRECIOUS resource. > > If you want an iterator rather than a list, itertools.ifilter is quite > > appropriate here. > > What about the future of

Re: [ x for x in xrange(10) when p(x) ]

2005-11-09 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > This becomes a valid list comprehension by writing 'if' instead of > > 'when'. > valid, yes. efficient, I am not sure. > > [ x for x in xrange(1000) if p(x) ] > &

Re: Iterator addition

2005-11-09 Thread Alex Martelli
Paul Rubin wrote: > Is there a good reason to not define iter1+iter2 to be the same as > itertools.chain(iter1, iter2)? No -- feel free to define __add__ accordingly in every one of your iterator classes. If you mean for *ALL* built-in types, such as generators, lists,

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I use "list" in the name in "english"/general sense(say a list in > haskell is lazily evaluated), it could be a list or it could be a > lazily evaluated iterable. OK, but the general point is: [x for x in ] is best written list() (x for x in

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > takewhile(lambda x: condition(x), some_generator) is not very much > difference than(well, still more things to type) > > (x for x in some_generator when condition(x)) So use takewhile(condition, some_generator) which is LESS to type. When y

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-10 Thread Alex Martelli
Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > I tested gmpy cvs as of now on Debian/testing/x86 with python2.3. It > compiled perfectly, ran all of its unit tests and also all my test > programs - Well done! Thanks! > My test program seemed to run at the same speed with both versions > (not supri

Re: Python obfuscation

2005-11-10 Thread Alex Martelli
petantik <[EMAIL PROTECTED]> wrote: ... > I think that is not workable because it is easy to say the the internet > is available everywhere. This implies that, if it were difficult to say it, then the scheme WOULD be workable... which I doubt is what you mean, of course;-) > It is not availab

Re: Python obfuscation

2005-11-10 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: ... > My brother is bugged by Civilization IV's copy protection. A couple of > days ago, after consulting me on what other options he could try, he > finally said in frustration, "Maybe I should go buy the game." It's interesting, in this context, that Civi

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>> list (x for x in xrange(20) if x<5 or iter([]).next()) > > [0, 1, 2, 3, 4] > > > > Or a bit more readably: > > >>> def stop(): raise StopIteration > > ... > > >>> list (x for x in xrange(20) if x<5 or stop()) > > [0, 1, 2, 3, 4] > > > > IO

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I've created Windows binaries for Python 2.3 and 2.4. It should be > compatible with PentiumPro or later processors. Thanks! I hope to package up a release early next week, and to include these. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Newb ??

2005-11-11 Thread Alex Martelli
Norman Silverstone <[EMAIL PROTECTED]> wrote: ... > Incidentally, I am only just starting to learn about functions and have > not come across the module 're'. Also why is it (lo+hi)//2 and not > (lo+hi)/2. Using // ensures truncation, which is what you want. A single / may mean truncating divis

Re: LARGE numbers

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > Python does support large numbers, but it's not very fast for such > large numbers. There is a Python module called GMPY that uses the GMP > (Gnu Multiple Precision) library for faster operations on large > numbers. As the author of gmpy, I'd like to point out t

Re: Import statements for timeit module

2005-11-11 Thread Alex Martelli
ChaosKCW <[EMAIL PROTECTED]> wrote: > So timeit is mostly useless then ? No, it's a precious jewel, but if you want to use it you must allow it to import the code you want it to run. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: derived / base class name conflicts

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I don't think it is reasonable in general to only subclass from base > classes you have studied the full API of, however. The double I think you underestimate the level of coupling that inevitably occurs between base and derived classes. In general, such coupl

Re: Is there a built-in method for transforming (1, None, "Hello!") to 1, None, "Hello!"?

2005-11-11 Thread Alex Martelli
Daniel Crespo <[EMAIL PROTECTED]> wrote: > Is there a built-in method for transforming (1,None,"Hello!") to > 1,None,"Hello!"? You're mentioning two different literal syntaxes for the same object (a tuple) -- the one with parentheses works everywhere, the other one _almost_ everywhere (not where

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-11 Thread Alex Martelli
David Gutierrez <[EMAIL PROTECTED]> wrote: > Include me in your list, please. Uh, what list? If you mean gmpy-commits, you subscribe to it on gmpy.sf.net -- if you mean the general Python list, on www.python.org. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-11 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > Excellent work guys! > > Not only is the divm() bug fixed but it looks like we got a > significant performance increase. Thanks! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Is there a way to loop through all instantiated objects and update > their classes when a source file changes? I know about Michael Hudson's > method > (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164), but > you have to modify all your classes to subcla

Re: Python obfuscation

2005-11-11 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 10 Nov 2005 21:41:52 -0800, Alex Martelli wrote: > > >> Obfuscation has it's place. > > > > What I think of this thesis is on a par of what I think of this way of > > spelling the posse

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > There is no effective manner of protecting your code, except running it > > only on well-secured machines you control yourself. If you distribute > > your code, in ANY form, and it's at all interestin

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: > I hadn't seen any damage done from misusing "it's". Certainly not on par You should see my pharmacy bill for Maalox... and my liver ain't too happy about it either;-) Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Paul Rubin wrote: > "The Eternal Squire" <[EMAIL PROTECTED]> writes: > > Without copyright, how could one possibly earn a living writing a > > novel? > > This guy seems to be doing ok: http://craphound.com > His publishers are the only ones allowed to sell his novels

Re: Hash map with multiple keys per value ?

2005-11-12 Thread Alex Martelli
Chris Stiles <[EMAIL PROTECTED]> wrote: > "snoe" <[EMAIL PROTECTED]> writes: > > Are you looking for this type of thing? > > > > class Test: > > value = 900 > > No, what I'm trying to do is this, assume two sets of aliases: > > a, b, c, d and e > > x, y and z > > a returns b c d and e, b r

Re: Hash map with multiple keys per value ?

2005-11-12 Thread Alex Martelli
Chris Stiles <[EMAIL PROTECTED]> wrote: ... > > alias insertion just be of the form "x aliases to y" rather than "x > > names object XXX"? > > In this case, strictly speaking there are no such thing as an 'object XXX', > all the aliases are names for the object, each as important as each other.

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > In a competitive marketplace, why would I choose to buy DRMed software if > there is a non-DRMed equivalent with the same functionality and equivalent > cost? The only explanation I can think of is, their marketing must be AWEsome!-) Alex -- http://

[ANNOUNCE] gmpy 1.1 beta released

2005-11-13 Thread Alex Martelli
See http://gmpy.sourceforge.net/ for details. What is it: a wrapper for the GMP 4 library (http://swox.com/gmp/), to provide multi-precision arithmetic for Python. Multi-precision floats, and unbounded-precision rationals, are not present in stock Python; multi-precision integers ('long') are, b

Re: Copyright [was Re: Python Obfuscation]

2005-11-13 Thread Alex Martelli
David T <[EMAIL PROTECTED]> wrote: ... > Tom Edison moved to California so _he_ could skirt copyright laws of I'm not aware of any move to California for either the better-known Thomas Alva Edison, or his lesser-known and less successful son of the same name. Could you clarify? The movie indu

gmpy 1.01 binaries for the mac

2005-11-13 Thread Alex Martelli
I've added to gmpy.sf.net two binary packages of gmpy for Mac OS X 10.4, one for the Python 2.3.5 that comes with the system and one for Bob Ippolito's build of 2.4.1. They still need GMP to be previously installed (I'm told the one that comes with fink works; I installed my own from sources, from

gmpy/decimal interoperation

2005-11-13 Thread Alex Martelli
As things stand now (gmpy 1.01), an instance d of decimal.Decimal cannot transparently become an instance of any of gmpy.{mpz, mpq, mpf}, nor vice versa (the conversions are all possible, but a bit laborious, e.g. by explicitly going through string-forms). I'm thinking about possible ways to fix t

Re: gmpy/decimal interoperation

2005-11-14 Thread Alex Martelli
Raymond L. Buvel <[EMAIL PROTECTED]> wrote: ... > This is a bit off topic but I would like to know how you would go about > doing an implicit operation with an mpz and Decimal becoming a Decimal. I would tweak Decimal.__new__ to accept an mpz and perform an int() on it before proceeding as it d

best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is indeed fixed. Being in a hurry, I originally used a q&d hack...: if sys.platform in ('linux2', 'da

Re: compare list

2005-11-14 Thread Alex Martelli
Brian van den Broek <[EMAIL PROTECTED]> wrote: > Ben Bush said unto the world upon 2005-11-14 05:51: > > I have four lists: > > lisA=[1,2,3,4,5,6,9] > > lisB=[1,6,5] > > lisC=[5,6,3] > > lisD=[11,14,12,15] > > how can I write a function to compare lisB, lisC and lisD with lisA, if they > > share t

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Not sure if I should start a new thread or not, but > since this is closely related, I'll just leave it as is. > > Alex Martelli wrote: > > > Having fixed a memory leak (not the leak of a Python reference, s

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
Neal Norwitz <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > > So, I thought I'd turn to the "wisdom of crowds"... how would YOU guys > > go about adding to your automated regression tests one that checks that > > a certain memory leak

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
MrJean1 <[EMAIL PROTECTED]> wrote: > My suggestion would also be to use sbrk() as it provides a high-water > mark for the memory usage of the process. That's definitely what I would have used in the '70s -- nowadays, alas, it ain't that easy. > Below is the function hiwm() I used on Linux (RedHa

Re: Default method arguments

2005-11-15 Thread Alex Martelli
Gregory Petrosyan <[EMAIL PROTECTED]> wrote: ... > def f(self, x = self.data) (*) ... > So I think (*) is the best variant, but it doesn't work :( It DOES work -- it just does not work the way you _expect_ it to work, but rather, it works the way it's _defined_ to w

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
matt <[EMAIL PROTECTED]> wrote: > Perhaps you could extend Valgrind (http://www.valgrind.org) so it works > with python C extensions? (x86 only) Alas, if it's x86 only I won't even look into the task (which does sound quite daunting as the way to solve the apparently-elementary question "how muc

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
MrJean1 <[EMAIL PROTECTED]> wrote: > This may work on MacOS X. An initial, simple test does yield credible > values. Definitely looks promising, thanks for the pointer. > However, I am not a MacOS X expert. It is unclear which field of the > malloc_statistics_t struct to use and how malloc_zon

Re: is parameter an iterable?

2005-11-15 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: ... > TypeError: iteration over non-sequence > > I was kind of hoping for a more specific exception than TypeError. > You can't tell the difference between: > > try: > for i in 5: > print i + 1 > except TypeError: > print "non-iterable" > > and >

Re: So what are __slots__ and when should I use them?

2005-11-15 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I see some programs declaring the names of class variables in > "__slots__". I've looked this up and the docs say something about old > and new style classes, whatever that means. Can someone give me a > simple, brief explanation of what __slots__ are and when I should

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-16 Thread Alex Martelli
Paul Boddie <[EMAIL PROTECTED]> wrote: > Neal Norwitz wrote: > > Valgrind actually runs on PPC (32 only?) and amd64, but I don't think > > that's the way to go for this problem. > > +1 for understatement of the week. > > > Here's a really screwy thought that I think should be portable to all > >

Re: AJAX => APAX? Or: is there support for python in browsers?

2005-11-16 Thread Alex Martelli
Tim Roberts <[EMAIL PROTECTED]> wrote: ... > Internet Explorer will allow any registered ActiveScript language to be > used in a web page. Python qualifies. In the latest Win32 extensions, > there is a script in win32comext/axscript/client/pyscript.py that will > register Python as an ActiveSc

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-16 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > Neal Norwitz wrote: > > Here's a really screwy thought that I think should be portable to all > > Unixes which have dynamic linking. LD_PRELOAD. > > > > You can create your own version of malloc (and friends) and free. You > > intercept each

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