Re: On Numbers

2006-01-16 Thread Alex Martelli
Terry Hancock <[EMAIL PROTECTED]> wrote: ... > I'm bothered by the fact that "int" can be coerced into > either "decimal" or "float". In practice, you should > have to choose one or the other. Practically speaking, Why ever?! You're indicating "is a subset of", and int IS a subset of both (ne

Re: Arithmetic sequences in Python

2006-01-16 Thread Alex Martelli
Paul Rubin wrote: ... > while the traditional > > xrange(f(n)-1, -1, -1) > > only evaluates it once but is IMO repulsive. Yep, reversed(range(f(n))) is MUCH better. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Arithmetic sequences in Python

2006-01-16 Thread Alex Martelli
Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > > For finite sequences, your proposal adds nothing new to existing > > solutions like range and xrange. > > Oh come on, [5,4,..0] is much easier to read than range(5,-1,-1). But not easier than reversed(

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Alex Martelli
Charles Krug <[EMAIL PROTECTED]> wrote: ... > I'm trying to create a list of all of C's subclasses: There's a class method for that very purpose: >>> class C(object): pass ... >>> class D(C): pass ... >>> class E(C): pass ... >>> C.__subclasses__() [, ] >>> Alex -- http://mail.python.or

Re: Arithmetic sequences in Python

2006-01-16 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 16 Jan 2006 12:51:58 +0100, Xavier Morel wrote: > > > For those who'd need the (0..n-1) behavior, Ruby features something that > > I find quite elegant (if not perfectly obvious at first), (first..last) > > provides a range from first to last w

Re: Arithmetic sequences in Python

2006-01-16 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: > Alex Martelli <[EMAIL PROTECTED]> wrote: > >Agreed. *IF* we truly needed an occasional "up to X *INCLUDED*" > >sequence, it should be in a syntax that can't FAIL to be noticed, such > >as range(X, endinclu

Re: embedding python: simulating sequence get item / set item methods

2006-01-16 Thread Alex Martelli
Johannes Zellner <[EMAIL PROTECTED]> wrote: > Hello, > > when embedding python: how can I create a type which simulates item > getters and setters? Something like this: > > void setter(PyObject* self, int i, PyObject new_value) > { > // do something > } > > PyObject* getter(PyObject* self,

Re: OT: excellent book on information theory

2006-01-17 Thread Alex Martelli
Terry Hancock <[EMAIL PROTECTED]> wrote: ... > due to the Evil Conspiracy of region-coding, I couldn't > watch the British DVD even if I were to import it (Well, > yeah I could, but it would be painful, and probably illegal, I have a region-free DVD player here in CA -- considering that I broug

Re: Arithmetic sequences in Python

2006-01-17 Thread Alex Martelli
Tom Anderson <[EMAIL PROTECTED]> wrote: ... > Sounds good. More generally, i'd be more than happy to get rid of list > comprehensions, letting people use list(genexp) instead. That would > obviously be a Py3k thing, though. I fully agree, but the BDFL has already (tentatively, I hope) Pronounc

Re: OT: excellent book on information theory

2006-01-18 Thread Alex Martelli
Rocco Moretti <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > Terry Hancock <[EMAIL PROTECTED]> wrote: > >... > >>due to the Evil Conspiracy of region-coding, I couldn't > >>watch the British DVD even if I were to import it (Well, >

Re: Arithmetic sequences in Python

2006-01-18 Thread Alex Martelli
Paul Rubin wrote: ... > Well, [...] notation for regular lists (as opposed to list > comprehensions) is also unnecessary since we could use "list((a,b,c))". Indeed, there's no reason list couldn't accept multiple arguments as an alternative to one sequence argument, j

Re: OT: excellent book on information theory

2006-01-18 Thread Alex Martelli
Terry Hancock <[EMAIL PROTECTED]> wrote: ... > > Nothing at all. But I still prefer tales of people who > > have hacked their DVD players to be multi-region :-) > > It isn't illegal in Canada anyway. And yes, it would be > possible for me to pay a very high price to get a > region-free player

Re: Arithmetic sequences in Python

2006-01-18 Thread Alex Martelli
Paul Rubin wrote: ... > What should the output of "print list(1,2,3)" be? Is there a really > good reason to make it different from the input syntax? If we assume that str and repr must keep coinciding for lists (and why not), no reason -- just like, say, today: >>>

Re: OT: excellent book on information theory

2006-01-18 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > I mean, when you read "He sat on the chair" do you need > to look up the dictionary to discover that chairs can > have arm rests or not, they can be made of wood or > steel or uphostered springs, be on legs or coasters, > fixed or movable? If

Re: web crawling.

2006-01-18 Thread Alex Martelli
S Borg <[EMAIL PROTECTED]> wrote: > Hello, > > I have been writing very simple Python programs that parse HTML and > such, mainly just to get > a better feel for the language. Here is my question: If I parsed an > HTML page into all of the image > files listed on that page, how could I request

Re: "Dynamic" website content

2006-01-21 Thread Alex Martelli
Christoph Haas <[EMAIL PROTECTED]> wrote: > On Saturday 21 January 2006 20:42, sophie_newbie wrote: > > To give you a better explaination of what I want, you could visit > > www.pat2pdf.org. > > > > Type in 123456 as the patent number, you see what it does? It tells the > > user that it is request

Re: new.instancemethod as a form of partial()

2006-01-21 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > So it seems that instancemethod() don't like "None" as the instance. "bound methods" and "unbound methods" are instance of the same type, distinguished by one thing: the im_self of an unbound method is None, the im_self of a bound method is anything else. So, w

Re: new.instancemethod as a form of partial()

2006-01-22 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > thanks. So in this special case, None is being treated as a "flag" > rather than just an instance(I just read the doc) like any other > instance and the behaviour is intended. Is there any reason why it is > designed this way ? I didn't yet know Python back when

Re: Some thougts on cartesian products

2006-01-22 Thread Alex Martelli
Kay Schluehr <[EMAIL PROTECTED]> wrote: ... > > >> range(3)**2 > > [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)] ... > But why isn't this interpreted as [0, 1, 4] like it is in Mathematica? Since range(3)*2 is [0, 1, 2, 0, 1, 2], it would be horribly, painfully inconsistent

Re: Catching very specific exceptions

2006-01-22 Thread Alex Martelli
Harlin Seritt <[EMAIL PROTECTED]> wrote: > except socket.error: > code goes here... > > Of course, though, these are two separate error messages under the same > error handler though. I've tried: > > except socket.error, (10061, 'Connection refused'): > and > except (socket.error, 10061, 'Co

Re: Some thougts on cartesian products

2006-01-22 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: ... > given length. You could get a 6/49 lotto tip with something like: > > choice(set(range(49)).powerset(6)) And that would be better than the current random.sample(range(49),6) in WHAT ways, exactly...? Alex -- http://mail.python.org/mailman

Re: Some thougts on cartesian products

2006-01-22 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > What advantage is there to creating a "list with cartesian product" > subclass of list? Essentially, syntax sugar -- for some people, being able to code a*b rather than product(a,b) takes on a huge significance; Python chooses to support this syn

Re: Some thougts on cartesian products

2006-01-22 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Alex Martelli schrieb: > > Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > >... > >> given length. You could get a 6/49 lotto tip with something like: > >> > >> choice(set(range(49))

Re: Sets and Membership Tests

2006-07-12 Thread Alex Martelli
JKPeck <[EMAIL PROTECTED]> wrote: > Thanks for the advice. Once assured that __hash__ etc was the right > route, I found that using hash() instead of object.__hash__() gave me > stable hash valules. (I am hashing strings that I know to be unique.) > > The "no luck" situation was that a set woul

Re: testing array of logicals

2006-07-12 Thread Alex Martelli
John Henry <[EMAIL PROTECTED]> wrote: > Hi list, > > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: >test = test and x > print test test = sum(bool(x) for x in logflags)==len(logflags) is yet another possibility (without t

Re: Accessors in Python (getters and setters)

2006-07-12 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: ... > I'm not sure about which languages you are talking (pretty much all that > allow public methods also allow public attributes), but in general I think Smalltalk is a very well known object-oriented language that behaves otherwise, just as one exam

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: > On 2006-07-13 01:50:18, Alex Martelli wrote: > > >> I'm not sure about which languages you are talking (pretty much all that > >> allow public methods also allow public attributes), [...] > > > >

Re: Number combinations

2006-07-19 Thread Alex Martelli
placid <[EMAIL PROTECTED]> wrote: > Hi all, > > Just wondering if there is a better way of generating a 4 digit number > (that gets converted to a string), ive got the following code which > generates strings between -. > > > > for a in range(0,10): > for b in range(0,10): >

Re: range() is not the best way to check range?

2006-07-20 Thread Alex Martelli
Paul Boddie <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > > > range() and xrange() are functions. You are suggesting that 2 > > *functions* should acquire a __contains__ method each? I trust not. > > Well, range is a function in the current implementation, although its > usage is similar to

Re: Python linker

2006-07-20 Thread Alex Martelli
Ben Sizer <[EMAIL PROTECTED]> wrote: > Sion Arrowsmith wrote: > > Er, what? How are you generating your standalone executables? What > > size is "acceptable"? python24.dll is only 1.8M -- surely on any > > non-embedded platform these days 1.8M isn't worth bothering about. > > And since you mention

Re: Python linker

2006-07-20 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I develop shareware applications that need to be extremely slim (less > than 1 MB is preferable). > > Delphi applications easily meet this requirement and I can expect end > users to download the .NET framework (if they don't already have it!). > > However, I cannot

Re: range() is not the best way to check range?

2006-07-20 Thread Alex Martelli
Paul Boddie <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > Paul Boddie <[EMAIL PROTECTED]> wrote: > > > > > > Well, range is a function in the current implementation, although its > > > usage is similar to that one would get if it were a cla

Re: function v. method

2006-07-20 Thread Alex Martelli
danielx <[EMAIL PROTECTED]> wrote: > > ...and source code... > > *shudders* What happened to all the goodness of abstraction? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Need a compelling argument to use Django instead of Rails

2006-08-02 Thread Alex Martelli
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: ... > >>And of course import hooks. > > > > Python?? Where? > > RTFM: > http://www.python.org/doc/2.3.5/lib/built-in-funcs.html Perhaps a better reference is . Alex -- http://mail.python.org/mailman/li

Re: Need a compelling argument to use Django instead of Rails

2006-08-02 Thread Alex Martelli
Ray <[EMAIL PROTECTED]> wrote: > Damjan wrote: > > BTW I'd choose TurboGears for it's flexibility, but I guess Django could be > > nice when more rapid results are needed (and the problem doesn't fall too > > far from the Django sweet spot). > > Well actually I was thinking of exaclty the same th

Re: Windows vs. Linux

2006-08-02 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: ... a few fine points of computing history...: > >> (URLs probably use the slash because the internet protocols have been > >> developed largely on Unix-type systems for use with Unix-type systems?) > > > > It wasn't designed specifically for Unix-ty

Re: Windows vs. Linux

2006-08-02 Thread Alex Martelli
jean-michel bain-cornu <[EMAIL PROTECTED]> wrote: > Andy Dingley a écrit : > > I'd never recommend dual-boot for anything! > Don't agree man, it's good for testing... It's bothersome for testing: virtualization is much handier in most cases. Alex -- http://mail.python.org/mailman/listinfo/pyth

Re: Windows vs. Linux

2006-08-02 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: ... > > Part of the CP/M compatibility did include the use of / as flag-indicator > > (the use of \r+\n as line ending also comes from CP/M -- in turn, CP/M > > had aped these traits from some DEC minicomputer operating systems). > > At the time, proba

Re: Windows vs. Linux

2006-08-02 Thread Alex Martelli
Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Gerhard Fiedler enlightened us with: > > I don't know how many reasons you need besides backward > > compatibility, but all the DOS (still around!) and Windows apps that > > would break... ?!? I think breaking that compatibility would be > > more expensi

Re: function v. method

2006-08-02 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: > On 2006-07-25 05:16:04, Wesley Brooks wrote: > > >> prefix your names with _ or __. Both are ommited from autogenerated > >> docuementation and both are OFFICALLY not supposed to be used. > >> > > > > Could you elaborate on that a little or point me i

Re: How to force a thread to stop

2006-08-02 Thread Alex Martelli
H J van Rooyen <[EMAIL PROTECTED]> wrote: > "Paul Rubin" Writes: > > | "H J van Rooyen" <[EMAIL PROTECTED]> writes: > | > *grin* - Yes of course - if the WDT was enabled - its something that > | > I have not seen on PC's yet... > | > | They are available for PC's, as pl

Re: Python open a named pipe == hanging?

2006-08-03 Thread Alex Martelli
Rochester <[EMAIL PROTECTED]> wrote: > Hi, > > I just found out that the general open file mechanism doesn't work > for named pipes (fifo). Say I wrote something like this and it > simply hangs python: ...just as it would "hang" any other language...!-). Looks like you may not b

Re: Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions!

2006-08-03 Thread Alex Martelli
Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Casey Hawthorne napisa?(a): > > > Can Your Programming Language Do This? > > > > Joel on functional programming and briefly on anonymous functions! > > > > http://www.joelonsoftware.com/items/2006/08/01.html > > Ridiculos. That's how single-programming-

Re: E' possibile integrare ironpython con visual studio 2005?

2006-08-03 Thread Alex Martelli
LaGuna <[EMAIL PROTECTED]> wrote: > Se si come? > > Ciao by Enzo Questo newsgroup preferisce l'inglese -- per favore, chiedi su it.comp.lang.python invece che qui. This newsgroup prefers English -- please ask on it.comp.lang.python rather than here. Alex -- http://mail.python.org/mailman/lis

Re: Python open a named pipe == hanging?

2006-08-04 Thread Alex Martelli
Rochester <[EMAIL PROTECTED]> wrote: > Thank you for your advise. So, it turns out that fifos are quite useless > in Python programming then, which is quite disappointing to me :-( Uh? How so? They're exactly as useful (or useless) as in any other language: if you want the open-for-writing to

Re: Python open a named pipe == hanging?

2006-08-04 Thread Alex Martelli
Donn Cave <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Rochester <[EMAIL PROTECTED]> wrote: > > > I just found out that the general open file mechanism doesn't work > > for named pipes (fifo). Say I wrote something like this and it > > simply hangs python: > >

Re: Design Patterns in Python

2006-08-05 Thread Alex Martelli
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > Hello > > Most authors talk about Java/C++, and describe patterns used as a > workaround to their static class model; the dynamic nature of Python > allows for trivial implementations in some cases. > I've seen some design patterns examples on the

Re: Open letter to BDFL begging forgiveness.

2006-08-06 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > "The Eternal Squire" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I tried to send you a private response but Comcast rejected it ('not a > customer'). As a Comcast customer, I can confirm that Comcast's email system is a mess (which

Re: Python open a named pipe == hanging?

2006-08-07 Thread Alex Martelli
Donn Cave <[EMAIL PROTECTED]> wrote: ... > > > I believe your problem is that, by the time you open the > > > pipe for read, it has already been closed by its writer. > > > > Hmmm, no: the problem is, he never opens the pipe for write, because the > > open blocks (will not proceed until somebod

Re: do people really complain about significant whitespace?

2006-08-08 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > infidel wrote: > > Where are they-who-hate-us-for-our-whitespace? Are "they" really that > > stupid/petty? Are "they" really out there at all? "They" almost sound > > like a mythical caste of tasteless heathens that "we" have invented. > > It just sounds like so muc

Re: Python open a named pipe == hanging?

2006-08-08 Thread Alex Martelli
Donn Cave <[EMAIL PROTECTED]> wrote: ... > > You forgot to add os.mkfifo(f) here -- so you're writing and reading a > > perfectly ordinary file... of course *that* gives no problems!-) > > Of course you're right about that, and with that fixed we > see that you're right, the open blocks. In or

Re: How to change the path for python binary?

2006-08-10 Thread Alex Martelli
Nico Grubert <[EMAIL PROTECTED]> wrote: > Hi there, > > I have installed Python 2.3.5 on Suse Linux 10. > If I enter "python" in the shell, the Python 2.3.5 interpreter is called. > > After I installed Python 2.4.3. the Python 2.4.3 interpreter is called > which is the default behaviour I guess.

Re: __contains__ vs. __getitem__

2006-08-10 Thread Alex Martelli
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > David Isaac wrote: > >> Alan Isaac wrote: > >>> I have a subclass of dict where __getitem__ returns None rather than > >>> raising KeyError for missing keys. (The why of that is not important > > for > >>> this question.) > > > > "Bruno Desthuilli

Re: __contains__ vs. __getitem__

2006-08-10 Thread Alex Martelli
Pedro Werneck <[EMAIL PROTECTED]> wrote: > On Wed, 09 Aug 2006 16:51:23 GMT > "David Isaac" <[EMAIL PROTECTED]> wrote: > > > Looking forward: > > Can I count on this independence of __getitem__ and __contains__? > > I would like to understand whether it will be safe to count on this > > behavior.

Re: Using a dictionary to pass data to/from embedded python functions

2006-08-12 Thread Alex Martelli
wardm <[EMAIL PROTECTED]> wrote: > I have created a Dict object in a C++ App that calls (embedded) Python > functions. [[snip snip]] > This python code throws an exception when it attempts to access the > "VarDictionary". > Does anyone know why this fails ? It fails due to some code of yours t

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Alex Martelli
Tim Peters <[EMAIL PROTECTED]> wrote: ... > It has a much better chance of working from .pyc in Python 2.5. > Michael Hudson put considerable effort into figuring out whether the > platform uses a recognizable IEEE double storage format, and, if so, > marshal and pickle take different paths that

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Alex Martelli
Tim Peters <[EMAIL PROTECTED]> wrote: [snip] thanks for an exhaustively satisfying explanation! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Using a dictionary to pass data to/from embedded python functions

2006-08-12 Thread Alex Martelli
wardm <[EMAIL PROTECTED]> wrote: > Thanks Alex for your help, (and advice on focusing the point of my > question). > > I was able to compile and run your example OK, but when I try to use the > "VarDictionary" in the > MyScriptModule.py code, I get an exception. > > I added the following code

Re: Make $1000's Monthly!

2006-08-12 Thread Alex Martelli
AlbaClause <[EMAIL PROTECTED]> wrote: ... > Just to bring this thread back on topic, you could also make thousands of > dollars monthly by becoming a professional Python coder or consultant. ;-) Yes, easily -- according to SD Magazine's yearly surveys, Python programmers have been the best-pai

Re: Using a dictionary to pass data to/from embedded python functions

2006-08-12 Thread Alex Martelli
wardm <[EMAIL PROTECTED]> wrote: > Thanks again for your help, I agree, it seems I need to read a good book on > Python. > > One last question, will Python allow me to add new items to > InterfaceModule.VarDictionary > from the Python functions I call ? Yes, no problem with that. Alex -- htt

Re: Using a dictionary to pass data to/from embedded python functions

2006-08-13 Thread Alex Martelli
Bill Pursell <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > > I wrote the following file za.c: > > > > > and proceeded to compile and execute as follows: [[Note: it does not > > matter that I'm using 2.5, the code is just as fine with pr

Re: yet another noob question

2006-08-13 Thread Alex Martelli
mike_wilson1333 <[EMAIL PROTECTED]> wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do t

Re: hide python code !

2006-08-15 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: > On 2006-08-14 20:48:45, Damjan wrote: > > > I think you increase your chances of Microsoft not even being in the same > > room with your software 100-fold if you release it under.. say GPL. > > ... and have the money to run a law suit? Patents, licens

Re: modifying __new__ of list subclass

2006-08-15 Thread Alex Martelli
Ken Schutte <[EMAIL PROTECTED]> wrote: > Steven Bethard wrote: > > > > The __new__ method is for immutable types. So things like str and int > > do their initialization in __new__. But for regular mutable types, you > > should do your initialization in __init__:: > > I see... So, is there a us

Re: hide python code !

2006-08-15 Thread Alex Martelli
Gerhard Fiedler <[EMAIL PROTECTED]> wrote: > On 2006-08-15 12:04:18, Alex Martelli wrote: > > > It just isn't worth Microsoft's while to take the public-relations hit > > of such a fight: much cheaper for them to re-implement your ideas than > > to c

Re: what is the keyword "is" for?

2006-08-16 Thread Alex Martelli
Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Dan Bishop enlightened us with: > a = b = 1e1000 / 1e1000 > a is b > > True > a == b > > False > > If "a is b" then they refer to the same object, hence a == b. It > cannot be otherwise, unless Python starts to defy logic. I copied your P

Re: sum and strings

2006-08-20 Thread Alex Martelli
Rhamphoryncus <[EMAIL PROTECTED]> wrote: ... > > > I believe the prefered method to flatten a list of lists is this: > > > > > > shallow = [] > > > for i in deep: > > > shallow.extend(i) > > > > > > Yes, it's three lines. It's also very easy to read. reduce() and > > > sum() are not. > > >

Re: write eof without closing

2006-08-20 Thread Alex Martelli
Grant Edwards <[EMAIL PROTECTED]> wrote: ... > IIRC, ctrl-Z is not used _in_files_ to represent EOF. Only > when text is being entered at the console. Easy to test, if you have Windows: >>> n='foo.txt' >>> s='ba\r\n'+chr(26)+'bo\r\r' >>> open(n,'wb').write(s) >>> ss=open(n).read() >>> ss 'ba\

Re: What do you want in a new web framework?

2006-08-22 Thread Alex Martelli
Tim Roberts <[EMAIL PROTECTED]> wrote: ... > themselves. However, in the case of web frameworks, I believe Marc is > fundamentally correct: the web framework proliferation in Python is > actually doing the language a huge disservice. Indeed, it has been truthfully observed that Python's the on

Re: Finding the type of indexing supported by an object?

2006-08-23 Thread Alex Martelli
Derek Peschel <[EMAIL PROTECTED]> wrote: > Here are two functions. > > def invert_dict_to_lists(dict): > lists = {} > for key in dict: > value = dict[key] > if not value in lists: > lists[value] = [key] > else: > lists[value].append(key) >

Re: itertools.count() as built-in

2006-05-28 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I have a project of around 6000 lines where I used count() 20 times. It > has 14 modules, 10 of which I needed an explicit import. > > Many of the usages are of the form: > > for item, n in zip(items, count(N)): > dostuff > > Around half of these

Re: itertools.count() as built-in

2006-05-29 Thread Alex Martelli
Duncan Smith <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Zipping an xrange? I'm having trouble visualizing how you do that to > > avoid x*i+y. > > > > -Janto > > > > Something like, > > >>> lis = ['a', 'b', 'c', 'd'] > >>> y = 3 > >>> i = 7 > >>> for n, item in zip(xrange(y, len

Re: Ricerca Programmatore Python

2006-05-29 Thread Alex Martelli
Edward Elliott <[EMAIL PROTECTED]> wrote: > Scott David Daniels wrote: > > > I understand there is an Italian-language Python group, but _here_ > > the language is English, even if you begin by an apology in English. > > ... In consideration for such people, please limit yourself to English. > >

Re: shuffling elements of a list

2006-06-01 Thread Alex Martelli
Peter Otten <[EMAIL PROTECTED]> wrote: > Gerard Flanagan wrote: > > Ben Finney wrote: > > >> pile_index = 0 > >> for card in deck: > >> piles[pile_index].append(card) > >> pile_index = (pile_index + 1) % numpiles > > > > no need to maintain an index ;-) >

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > operations. I think what must be going on is that the 'b' list > contains replicated references instead of copies of [range(1,3)]*2 . Right. > IMO, python's == operator should detect this difference in list > structure since it leads to different behavior unde

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Hi Alex, > With all due respect to your well-deserved standing in the Python > community, I'm not convinced that equality shouldn't imply invariance > under identical operations. So, why aren't you satisfying my request? Provide a simple concrete definition of what y

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I agree with Alex that checking for this type of inequality is not a > trivial programming exercise. It requires (at least) a parallel I'm not asking for ANY programming: I'm asking for a *straightforward operational definition*. If the concept which you hanke

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Thu, 01 Jun 2006 13:40:34 -0700 > [EMAIL PROTECTED] wrote: > > #> Scott David Daniels wrote: > #> > Would you say that envelope containing five $100 bills is equal to > #> > an envelope containing five $100 bills with different serial numbers? >

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Thu, 01 Jun 2006 15:12:23 -0700 > [EMAIL PROTECTED] wrote: > > #> I believe that 'is' tests equality of reference, such that > #> > #> >>> a = range(1,3) > #> >>> b = range(1,3) > #> >>> a is b > #> False > #> > #> The 'is' operator tells you wh

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > (As an aside, may I point out that Python In A Nutshell states on page > 46 "The result of S*n or n*S is the concatenation of n copies of S". It > might be well to put a warning in a future edition that this is not > strictly the case.) Can you give me an exampl

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > (As an aside, may I point out that Python In A Nutshell states on page > > 46 "The result of S*n or n*S is the concatenation of n copies of S". > > It would be more exact to say that S*n is

Re: An oddity in list comparison and element assignment

2006-06-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > [snip] > > Can somebody please shut down this bot? I think it's running out of Much as you might love for somebody to "shut me down", that (unfortunately, no doubt, from your viewpoint) is quite u

Re: carshing the interpreter in two lines

2006-06-03 Thread Alex Martelli
sam <[EMAIL PROTECTED]> wrote: > tomer: > > It is my opinion that you would loose performance if the Python > interpreter had the additional task of verifying byte code. It might be > more appropriate to have a preprocessor that did the verifying as it > compiled the byte code. But in this case,

Re: An oddity in list comparison and element assignment

2006-06-03 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > > it's EXACTLY the > > concatenation of three copies of that string -- no more, no less. > > Depends what one means by 'copy'. See below for your alternate wording. Please give me a reasonable definition of the unadorned word "copy" which would make this

Re: Using print instead of file.write(str)

2006-06-03 Thread Alex Martelli
Tim Roberts <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > >Sion Arrowsmith a écrit : > >> A.M <[EMAIL PROTECTED]> wrote: > >> > >>>I found print much more flexible that write method. > >> > >> "more flexible"? More convenient, yes. More powerful, maybe. But I >

Re: Python less error-prone than Java

2006-06-03 Thread Alex Martelli
Simon Percivall <[EMAIL PROTECTED]> wrote: ... > with static typing. The equivalent in Python would have been if an > overflow exception was raised when the int got too big. It might have > been that way, typing or no typing. Indeed, it _used_ to be that way --

Re: An oddity in list comparison and element assignment

2006-06-05 Thread Alex Martelli
Slawomir Nowaczyk <[EMAIL PROTECTED]> wrote: > On Sat, 03 Jun 2006 17:03:00 -0700 > [EMAIL PROTECTED] (Alex Martelli) wrote: > > #> Terry Reedy <[EMAIL PROTECTED]> wrote: > #> > #> > Depends what one means by 'copy'. See below for your alter

Re: what are you using python language for?

2006-06-06 Thread Alex Martelli
hacker1017 <[EMAIL PROTECTED]> wrote: > im just asking out of curiosity. At work, since about 16 months ago, mostly for maintaining and enhancing many programs that control, monitor, and ensure the smooth working of, many large clusters of servers (plus, all the persnickety extra little things th

Re: __getattr__ question

2006-06-09 Thread Alex Martelli
Andrew Robert <[EMAIL PROTECTED]> wrote: > If I remember correctly, this behavior depends on how the class is > created (classic mode versus modern). > > Modern > > class foo(object): > pass > > Classic ( pre python 2.2 I believe ) > > class foo(): No parentheses all

Re: Get my airlines boarding pass

2006-06-09 Thread Alex Martelli
Ken <[EMAIL PROTECTED]> wrote: > rh0dium wrote: > > Hi all, > > > > Has any of you fine geniuses figured out a nice python script to go to > > the Southwest airlines website and check in, and retrieve your boarding > > pass - automatically 24 hours in advance > > I just wrote such a script in py

Re: Get my airlines boarding pass

2006-06-10 Thread Alex Martelli
KenAggie <[EMAIL PROTECTED]> wrote: > Good idea - I just bought the 2nd edition of the book and it is very > good. Will check it out. I'm happy that you liked the book, but I meant the online site, sorry if that wasn't clear!-) Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: import hook

2006-06-11 Thread Alex Martelli
Jeremy Sanders <[EMAIL PROTECTED]> wrote: > Hi - Is it possible to override the import process so that if in my program > I do > > import foo.bar > > Python will look for bar in a directory which isn't called foo? > > I want my module/program to be able to be run without being installed in > si

Re: "groupby" is brilliant!

2006-06-14 Thread Alex Martelli
Frank Millman <[EMAIL PROTECTED]> wrote: > Benji York wrote: > > Frank Millman wrote: > > > reader = csv.reader(open('trans.csv', 'rb')) > > > rows = [] > > > for row in reader: > > > rows.append(row) > > > > Why do you create a list of rows instead of just iterating over the > > reader direct

Re: "groupby" is brilliant!

2006-06-14 Thread Alex Martelli
James Stroud <[EMAIL PROTECTED]> wrote: ... > def doit(rows, doers, i=0): >for r, alist in groupby(rows, itemgetter(i)): > if len(doers) > 1: >doit(alist, doers[1:], i+1) > doers[0](r) Isn't this making N useless slices (thus copies, for most kinds of sequences) for a doer

Re: numeric/numpy/numarray

2006-06-14 Thread Alex Martelli
Bryan <[EMAIL PROTECTED]> wrote: ... > so, was Numarray written *before* NumPY, or was it a reimplementation of > NumPy which implies it came *after* NumPy? it seems clear that Numeric is > the old one and i read is not being worked on anymore. so that leaves > Numarray and numpy. which of the

Re: convert floats to their 4 byte representation

2006-06-14 Thread Alex Martelli
godavemon <[EMAIL PROTECTED]> wrote: > I need to take floats and dump out their 4 byte hex representation. > This is easy with ints with the built in hex function or even better > for my purpose > > def hex( number, size ): > s = "%"+str(size) + "X" > return (s % number).replace(' ',

Re: Extending Python - Understanding Flags...

2006-06-14 Thread Alex Martelli
John Machin <[EMAIL PROTECTED]> wrote: ... > > If it is any consolation I hope to take what I learn and put together > > a tutorial on expanding Python for those that only have a little > > experience with C programming, like myself. I plan to explain > > everything like I was teaching a 6-year

Re: "groupby" is brilliant!

2006-06-14 Thread Alex Martelli
James Stroud <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > James Stroud <[EMAIL PROTECTED]> wrote: > >... > > > >>def doit(rows, doers, i=0): > >> for r, alist in groupby(rows, itemgetter(i)): > >> if len(doers) >

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread Alex Martelli
Dave Opstad <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > John Salerno <[EMAIL PROTECTED]> wrote: > > I had retired from Apple in 2001 after 33 years in the business, feeling > completely burned out. Didn't want to even look at another line of code. > After resting and recuperat

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread Alex Martelli
BartlebyScrivener <[EMAIL PROTECTED]> wrote: ... > Especially the Python Cookbook, as I don't normally 'get it' when > someone just describes theory or an abstraction, I also must see an > example. The examples in the Cookbook are useful and also come with > explanations about how they work. Sam

<    3   4   5   6   7   8   9   10   11   12   >