Re: One line command line filter

2011-09-05 Thread Terry Reedy
On 9/5/2011 5:32 PM, Jon Redgrave wrote: Am I missing something obvious? ls | python -c "for line in __import__('sys').stdin: print (line.upper())" Ah, so I am missing something - it is possible - but 'obvious'? Do people think it should be more accessible __import__ is well-documented and

Re: One line command line filter

2011-09-05 Thread Terry Reedy
On 9/5/2011 7:18 PM, Steven D'Aprano wrote: Terry Reedy wrote: The doc says "-c Execute the Python code in command. command can be one or more statements separated by newlines," However, I have no idea how to put newlines into a command-line string. I imagine that it depen

Re: Relative seeks on string IO

2011-09-06 Thread Terry Reedy
On 9/6/2011 3:18 AM, Pierre Quentel wrote: I am wondering why relative seeks fail on string IO in Python 3.2 Good question. from io import StringIO txt = StringIO('Favourite Worst Nightmare') txt.seek(8) # no problem with absolute seek Please post code without non-code inden

Re: Floating point multiplication in python

2011-09-07 Thread Terry Reedy
On 9/7/2011 12:51 AM, Steven D'Aprano wrote: So given a float x, when you square it you get this: Exact values: a*a = a**2 Float values: x*x = (a+e)(a+e) = a**2 + 2*a*e + e**2 So the error term has increased from e to (2*a*e+e**2). It is usual to assume that e**2 is small e

Re: Best way to check that you are at the beginning (the end) of an iterable?

2011-09-07 Thread Terry Reedy
On 9/7/2011 8:23 PM, Cameron Simpson wrote: On 07Sep2011 16:22, Laurent wrote: | I totally understand the performance issue that an hypothetical | "istail" would bring, even if I think it would just be the programmer's | responsibility not to use it when it's not certain that an end can | be det

Re: 2to3 chokes on bad character

2011-02-24 Thread Terry Reedy
On 2/24/2011 8:11 AM, Frank Millman wrote: future I will run some tests when betas are released, just in case I come up with something. Please do, perhaps more than once. The test suite coverage is being improved but is not 100%. The day *after* 3.2.0 was released, someone reported an unplea

Re: Why this difference?

2011-02-24 Thread Terry Reedy
On 2/24/2011 7:19 AM, n00m wrote: file my.txt: === 0 beb 1 qwe 2 asd 3 hyu 4 zed 5 asd 6 oth = py script: === import sys sys.stdin = open('88.txt', 'r') t = sys.stdin.readlines() t = map(lambda rec: rec.split()

Re: py3k: converting int to bytes

2011-02-24 Thread Terry Reedy
On 2/24/2011 11:19 AM, s...@uce.gov wrote: Is there a better way to convert int to bytes then going through strings: x=5 str(x).encode() (This being Py3) If 0 <= x <= 9, bytes((ord('0')+n,)) will work. Otherwise, no. You would have to do the same thing str(int) does, which is to reverse the

Re: py3k: converting int to bytes

2011-02-24 Thread Terry Reedy
On 2/24/2011 9:25 PM, John Machin wrote: On Feb 25, 4:39 am, Terry Reedy wrote: Note: an as yet undocumented feature of bytes (at least in Py3) is that bytes(count) == bytes()*count == b'\x00'*count. Python 3.1.3 docs for bytes() say same constructor args as for bytearray(); this

Re: backwards-compatibility

2011-02-26 Thread Terry Reedy
On 2/26/2011 11:32 AM, Benjamin Kaplan wrote: On Sat, Feb 26, 2011 at 8:11 AM, Jason Swails wrote: Hello, I have a question I was having a difficult time finding with a quick google search, so I figured someone on here might know. For the sake of backwards compatibility (and supporting system

Re: come back and find python 3

2011-02-26 Thread Terry Reedy
On 2/26/2011 2:36 PM, pipehappy wrote: To answer your questions, as I understand them. 1. Print was not removed, just changed to a function: a. gets rid of special-case hackish syntax like >> and trailing comma by using keyword args instead, becoming more flexible as a result; b. function can

Re: urlopen returns forbidden

2011-02-28 Thread Terry Reedy
On 2/28/2011 10:21 AM, Grant Edwards wrote: As somebody else has already said, if the site provides an API that they want you to use you should do so rather than hammering their web server with a screen-scraper. If there any generic method for finding out 'if the site provides an API" and spe

Re: Problems with read_eager and Telnet

2011-02-28 Thread Terry Reedy
On 2/28/2011 10:54 AM, Robi wrote: Hi everybody, I'm totally new to Python but well motivated :-) I'm fooling around with Python in order to interface with FlightGear using a telnet connection. Given that FlightGear is a graphical flight simulator http://www.flightgear.org/ https://secure.wi

Re: Problems with read_eager and Telnet

2011-02-28 Thread Terry Reedy
On 2/28/2011 3:46 PM, Robi wrote: unless using it just to get/set configuration, in which case, speed should hardly seem an issue. Right, I'm using it that way, I get/set properties changing them in real time (I whish!). ... My conclusion being, fgfs cannot answer back quicker than this: 20H

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Terry Reedy
On 2/28/2011 3:51 PM, Ethan Furman wrote: Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> import base64 --> base64.encodestring(b'this is a test') __main__:1: DeprecationWarning: encod

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Terry Reedy
On 3/3/2011 10:39 AM, Jean-Paul Calderone wrote: C and C++ have standards, and the standards describe what they don't define. Python has implementations. Python also has standards, the language and library manuals. The defined behavior is whatever the implementation does. No, the defined

Re: Pure python standard library and License

2011-03-03 Thread Terry Reedy
On 3/3/2011 11:39 AM, Markus Schaber wrote: Hi, We want to include IronPython in one of our products, including the pure Python part of the python standard library. It seems that the IronPython installer packagers simply copied the pure python part of the standard library (the directory tree of

Re: how to read the last line of a huge file???

2011-03-05 Thread Terry Reedy
On 3/5/2011 1:21 PM, tkp...@hotmail.com wrote: Thanks for the pointer. Yes, it is a text file, but the mystery runs deeper: I later found that it works perfectly as written when I run it from IDLE or the Python shell, but it fails reliably when I run it from PyScripter 2.4.1 (an open source Pytho

Re: 下载 below Download, in python.org site menu

2011-03-06 Thread Terry Reedy
On 3/6/2011 6:42 AM, Martin v. Loewis wrote: > Am 06.03.2011 12:18, schrieb Alex Willmer: >> On the English version of http://python.org I'm seeing 下载 as a menu >> item between Download and Community. AFAICT it's Simplified Chinese >> for 'download'. Is it's appearance intentional, or a leak throug

Re: Fun with 'str' and 'bytes'

2011-03-06 Thread Terry Reedy
On 3/6/2011 4:55 PM, Nicholas Devenish wrote: On 04/03/2011 16:40, nn wrote: As far as I know, that is pretty much it. Also see: http://bugs.python.org/issue3982 That is a depressing bug report, and really comes across as people who don't use networking commenting on the requirements of peopl

Re: encoding hell - any chance of salvation ?

2011-03-07 Thread Terry Reedy
On 3/7/2011 6:24 AM, southof40 wrote: Hi - I've got some code which uses array (http://docs.python.org/ library/array.html) to store charcters read from a file (it's not my code it comes from here http://sourceforge.net/projects/pygold/) The read is done, in GrammarReader.py, like this ...

Re: my computer is allergic to pickles

2011-03-07 Thread Terry Reedy
On 3/7/2011 4:50 AM, Bob Fnord wrote: I want a portable data file (can be moved around the filesystem or copied to another machine and used), Used only by Python or by other software? Would a database in a file have any advantages over a file made by marshal or shelve? If you have read the

Re: strange behaviour with while-else statement

2011-03-07 Thread Terry Reedy
On 3/7/2011 11:43 AM, Victor Paraschiv wrote: Hi and please help me understand if it is a bug, or..,as someone said, there's a 'bug' in my understanding: (Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32) (windows vista, the regular windows python installer) It's

Re: Problem with Python GUI checklist, Tkinter

2011-03-07 Thread Terry Reedy
On 3/7/2011 12:49 PM, Mathew Coyle wrote: Everything seems to roll along fine, a few tweaks are still needed, but an issue I cannot resolve has come up. It seems that the checklist items are being selected and added twice to the list, once for a mouse button click, and again for a mouse button r

Re: Absolutely Insane Problem with Gmail

2011-03-07 Thread Terry Reedy
On 3/7/2011 1:26 PM, Ian wrote: On 06/03/2011 13:56, Victor Subervi wrote: gmail, for whatever reason, filters out emails send to the same address from which they are sent. Its possibly a protection against circular forwarding. Or spam. Many spam messages sent to me have me as sender. -- Ter

Re: changing to function what works like a function

2011-03-07 Thread Terry Reedy
On 3/7/2011 1:12 PM, Victor Paraschiv wrote: Well, thank you all for being honest ☺ What I conclude is that you, the programmers, don’t really care about those who are new to programming: Whereas you exhibit your care for humanity by casually slandering those who offer you a gift. Grow up. Se

Re: Numerical representation

2011-03-07 Thread Terry Reedy
On 3/7/2011 1:59 PM, Jon Herman wrote: And for the sake of completeness, the derivative function I am calling from my integrator (this is the 3 body problem in astrodynamics): def F(mu, X, ti): r1= pow((pow(X[0]+mu,2)+pow(X[1],2)+pow(X[2],2)),0.5) x0 = X[0]; x1 = X[1]; x2 = X[2]

Re: embedded python 2.7.1 slow startup

2011-03-08 Thread Terry Reedy
On 3/8/2011 4:06 AM, bruce bushby wrote: Hi I've been playing with running python on embedded linux. I thought I would run some "straces" to see how the install went when I noticed python attempts to "open" loads of files that don't exist.is there a way to prevent these "open" attemptsth

Re: Finding keywords

2011-03-08 Thread Terry Reedy
On 3/8/2011 2:00 PM, Matt Chaput wrote: On 08/03/2011 8:58 AM, Cross wrote: I know meta tags contain keywords but they are not always reliable. I can parse xhtml to obtain keywords from meta tags; but how do I verify them. To obtain reliable keywords, I have to parse the plain text obtained from

Re: Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Terry Reedy
On 3/8/2011 4:39 PM, Larry Hastings wrote: I'm doing a talk at PyCon about changes to the Python language. I'm wondering: are there any Python language changes that first shipped in an implementation of Python besides CPython? The sort of answer I'm looking for: "set literals first shipped in J

Re: Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Terry Reedy
On 3/8/2011 4:39 PM, Larry Hastings wrote: Adding to my previous response, extended slices and ellipses were added for numerical python, but that is cpython extension, not alternative. The 3.x memoryview came from there too, I believe. -- Terry Jan Reedy -- http://mail.python.org/mailman/list

Re: I found some very odd behaviour in Python's very basic types

2011-03-09 Thread Terry Reedy
On 3/10/2011 12:47 AM, Sunjay Varma wrote: For some reason, sub-classing and overwriting a built-in type does not change the behavior of the literal. Logically speaking, overwriting a name, such as str, should delete the basic str type, and replace it with the new class or object put in its place

Re: Compile time evaluation of dictionaries

2011-03-10 Thread Terry Reedy
On 3/10/2011 11:23 AM, Gerald Britton wrote: Today I noticed that an expression like this: "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": "can be as bad as one"} could be evaluated at compile time, but is not: In fact, it could be evaluated at writing time ;-). This wou

Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Terry Reedy
On 3/10/2011 5:51 PM, Patty wrote: Thanks so much for this reference - and the detailed further explanation! I have a Windows 7 system and recently installed Visual Studio 2010 for the SQL Server, Visual C/C++ and Visual Basic. I would love to have this Python tool installed under Visual Studio

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Terry Reedy
On 3/10/2011 8:58 PM, n00m wrote: http://docs.python.org/py3k/whatsnew/3.0.html What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I understand). I even liked print as a function **more** than print as a stmt Now I think that Py3k is better than all prev pythons and cobras. I a

Re: Use-cases for alternative iterator

2011-03-11 Thread Terry Reedy
On 3/11/2011 1:43 AM, Steven D'Aprano wrote: The iter() built-in takes two different forms, the familiar iter(iterable) we all know and love, and an alternative form: iter(callable, sentinel) E.g.: T = -1 def func(): ... global T ... T += 1 ... return T ... it = iter(func, 3)

Re: IDLE doesn't start

2011-03-11 Thread Terry Reedy
On 3/11/2011 12:58 PM, Ceonn Bobst wrote: Someone told me: “You certainly have a TCL_LIBRARY environment variable set on your system, it should be removed”. Someone else posted this week about the same problem (though from a different cause) and solution. How do I remove TCL_LIBRARY, or do

Re: Calling C++ Modules in Python

2011-03-11 Thread Terry Reedy
On 3/11/2011 4:15 PM, Patrick wrote: Hi, I saw in the Beginner document that "•Is easily extended by adding new modules implemented in a compiled language such as C or C++. ". While to my investigation, it seems not that easy or did I miss something? boost python (C++ libraries need to be re-c

Re: Changing class name causes process to 'hang'

2011-03-12 Thread Terry Reedy
On 3/12/2011 2:53 PM, Tim Johnson wrote: I'm using Python 2.6.5 on ubuntu 10.04 32-bit. My issue however, is with a code base that goes back to 2002, which at that time was 1.5~ or so. I have been since that time using my own cgi module which in turn, uses the python standard `cgi' module. The

Re: Changing class name causes process to 'hang'

2011-03-12 Thread Terry Reedy
On 3/12/2011 7:18 PM, Tim Johnson wrote: * Terry Reedy [110312 13:28]: On 3/12/2011 2:53 PM, Tim Johnson wrote: Is 'cgilib' *your* wrapper of the cgi module, or from a third party. cgilib is my module. I use the cgi module as follows: ## code below import cgi

Re: Changing class name causes process to 'hang'

2011-03-13 Thread Terry Reedy
On 3/13/2011 3:17 PM, Tim Johnson wrote: * Tim Johnson [110313 08:27]: One other thing I just realized: The process stops inside of a function call to another object method, if that method call is removed, the process teminates. :) I may have a solution later today, and will relay i

Re: organizing many python scripts, in a large corporate environment.

2011-03-13 Thread Terry Reedy
On 3/13/2011 7:27 PM, bukzor wrote: I think this touches on my core problem. It's dead simple (and natural) to use .py files simultaneously as both scripts and libraries, as long as they're in a flat organization (all piled into a single directory). Because of this, I never expected it to be so

Re: Compile time evaluation of dictionaries

2011-03-14 Thread Terry Reedy
On 3/14/2011 10:21 AM, Gerald Britton wrote: Any idea why Python works this way? I see that, in 3.2, an optimization was done for sets (See "Optimizations" at http://docs.python.org/py3k/whatsnew/3.2.html) though I do not see anything similar for dictionaries. 1/ because no one would ever s

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread Terry Reedy
On 3/14/2011 4:31 PM, bruce bushby wrote: but has anybody seen any efforts to allow python to "import modules via a socket" I do not remember any such thing. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: possible to run a python script without installing python?

2011-03-15 Thread Terry Reedy
On 3/15/2011 4:58 PM, davidj411 wrote: it seems that if I copy the python.exe binary and the folders associated with it to a server without python, i can run python. does anyone know which files are important to copy and which can be omitted? For the 3.2 Windows installation, you should be able

Re: Memory Usage of Strings

2011-03-16 Thread Terry Reedy
On 3/16/2011 3:51 PM, Santoso Wijaya wrote: ?? Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> L = [] >>> for i in xrange(10): ... L.append(str(i) * (1000 / len(

Re: Fitting polynomial curve

2011-03-16 Thread Terry Reedy
On 3/17/2011 1:42 AM, Astan Chee wrote: Hi, I have 2 points in 3D space and a bunch of points in-between them. I'm trying to fit a polynomial curve on it. Currently I'm looking through numpy but I don't think the function exists to fit a function like this: y = ax**4 + bx**3 + cx**2 + dx + e (I'm

Re: Python 3.2 Debug build

2011-03-17 Thread Terry Reedy
On 3/17/2011 6:54 PM, Willis Cheung wrote: Hi all, I'm trying to build the debug version of Python 3.2. I downloaded the py3k folder from the python SVN. Just so you know, Python SVN is now a read-only historical arifact. Development now happens in the hg repository. If you build x.y docs, yo

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-17 Thread Terry Reedy
On 3/17/2011 8:24 PM, J Peyret wrote: This gives a particularly nasty abend in Windows - "Python.exe has stopped working", rather than a regular exception stack error. I've fixed it, after I figured out the cause, which took a while, but maybe someone will benefit from this. Python 2.6.5 on Win

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-17 Thread Terry Reedy
On 3/17/2011 10:00 PM, Terry Reedy wrote: On 3/17/2011 8:24 PM, J Peyret wrote: This gives a particularly nasty abend in Windows - "Python.exe has stopped working", rather than a regular exception stack error. I've fixed it, after I figured out the cause, which took a while, bu

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-18 Thread Terry Reedy
On 3/18/2011 5:15 PM, Carl Banks wrote: Multiple people reproduce a Python hang/crash yet it looks like no one bothered to submit a bug report I did not because I did not initially see a problem... I observed the same behavior (2.6 and 3.2 on Linux, hangs) and went ahead and submitted a

Re: class error

2011-03-18 Thread Terry Reedy
On 3/18/2011 5:27 PM, monkeys paw wrote: TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) OK, i overlooked that and the error was not very enlightening. A detailed explanation: every module is an instance of a class we will call Module. E

Re: Bounds checking

2011-03-18 Thread Terry Reedy
On 3/18/2011 10:24 AM, Martin De Kauwe wrote: def bounds_check(state): """ check state values are> 0 """ for attr in dir(state): if not attr.startswith('__') and getattr(state, attr)< 0.0: print "Error state values< 0: %s" % (attr) dir() has to do a bit a com

Re: Syntax Error

2011-03-18 Thread Terry Reedy
On 3/19/2011 1:03 AM, Vlastimil Brom wrote: 2011/3/19 Manatee: I hope this is the place to post this question. Yes. Lesson 1. Report Python version used, as things change. For anything that seems like it might by os/system specific, include that too. Lesson 2. Always include tracebacks when

Re: Syntax Error

2011-03-19 Thread Terry Reedy
On 3/19/2011 2:07 PM, Manatee wrote: C:\Users\Rivetmr\MyPythonScripts>Python Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] onI win32 Type "help", "copyright", "credits" or "license" for more information. I guess I have to go to an earlier version; maybe 2.6?

Re: Pyserial

2011-03-20 Thread Terry Reedy
On 3/20/2011 8:46 PM, Manatee wrote: The windows msi install fails saying there is no python install found in the registry. Is there a workaround for this? Can I edit the registry and manually enter the information? I am running Python 2.71 There is no traceback, the installation fails immediat

Re: Regex in if statement.

2011-03-20 Thread Terry Reedy
On 3/20/2011 8:46 PM, Ken D'Ambrosio wrote: Hey, all -- I know how to match and return stuff from a regex, but I'd like to do an if, something like (from Perl, sorry): if (/MatchTextHere/){DoSomething();} How do I accomplish this in Python? Look at the doc to see what are the possible return

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 9:48 AM, Andrea Crotti wrote: def fib_iter(n): ls = {0: 1, 1:1} Storing a linear array in a dict is a bit bizarre for i in range(2, n+1): ls[i] = ls[i-1] + ls[i-2] return ls[max(ls)] So is using max(keys) to find the highest index, which you

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 9:48 AM, Andrea Crotti wrote: I was showing a nice memoize decorator to a friend using the classic fibonacci problem. --8<---cut here---start->8--- def memoize(f, cache={}): def g(*args, **kwargs): # first must create a key to

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 8:26 PM, Fons Adriaensen wrote: On Thu, Mar 24, 2011 at 08:12:22PM -0400, Terry Reedy wrote: The irony of this is that memoizing 'recursive' functions with a decorator depends on the fact the Python does not have truly recursive functions. A function cannot call itsel

Re: why memoizing is faster

2011-03-25 Thread Terry Reedy
On 3/25/2011 4:49 AM, Andrea Crotti wrote: Terry Reedy writes: def fib_iter(n, _cache = [1,1]): k = len(_cache) if n>= k: for i in range(k, n+1): _cache.append(_cache[i-2] + _cache[i-1]) return _cache[n] I just realized that the signature really ought to be

Re: why memoizing is faster

2011-03-25 Thread Terry Reedy
On 3/25/2011 5:16 AM, Stefan Behnel wrote: Terry's version is playing with the fact that default arguments are only instantiated once, i.e. (unless overridden by passing an explicit argument) the "_cache" is shared over all calls to the function. This is similar to what your memoization decorato

Re: python 2.7.1 "serial" vs "pyserial"

2011-03-25 Thread Terry Reedy
On 3/25/2011 7:27 AM, bruce bushby wrote: Hi Is there any difference between the "serial" module in Python 2.7.1 and "pyserial 2.5" ? When asking about 3rd party modules, it may help to give a reference to the site or download page on pypi. (And one should also check to package specific list

Re: why memoizing is faster

2011-03-25 Thread Terry Reedy
On 3/26/2011 12:17 AM, Stefan Behnel wrote: Not "restarted" in the sense that it gets cleaned up, though. The above simply passes an explicit value for it that will be used for the single call. Which satisfies the time test need, but... > Future calls won't be affected. Good point. If one do

Re: why memoizing is faster

2011-03-26 Thread Terry Reedy
On 3/26/2011 5:55 AM, Lie wrote: On Mar 26, 5:10 pm, Terry Reedy wrote: On 3/26/2011 12:17 AM, Stefan Behnel wrote: Not "restarted" in the sense that it gets cleaned up, though. The above simply passes an explicit value for it that will be used for the single call. Which satisfie

Re: why memoizing is faster

2011-03-26 Thread Terry Reedy
On 3/26/2011 7:06 AM, Andrea Crotti wrote: Stefan Behnel writes: Not "restarted" in the sense that it gets cleaned up, though. The above simply passes an explicit value for it that will be used for the single call. Future calls won't be affected. Stefan About this global caching thing I tho

Re: Guido rethinking removal of cmp from sort method

2011-03-26 Thread Terry Reedy
On 3/26/2011 4:49 AM, Steven D'Aprano wrote: On Fri, 25 Mar 2011 16:04:02 -0700, Carl Banks wrote: Call me crazy, I would call you a bit ungrateful. Steven could have stayed silent instead of making himself a target by informing interested people on this list about the pydev post by Guido.

Re: why memoizing is faster

2011-03-26 Thread Terry Reedy
On 3/26/2011 11:49 AM, Steven D'Aprano wrote: On Sat, 26 Mar 2011 07:14:17 -0700, eryksun () wrote: Yikes! I know this thread is about caching the output of a function, but in the example of Fibonacci numbers, we're blessed with an easily derived closed form expression (via Z transform, etc):

Re: Guido rethinking removal of cmp from sort method

2011-03-29 Thread Terry Reedy
For anyone interested, the tracker discussion on removing cmp is at http://bugs.python.org/issue1771 There may have been more on the old py3k list and pydev list. One point made there is that removing cmp= made list.sort consistent with all the other comparision functions, min/max/nsmallest/nla

Re: Python3 Tkinter difficulty

2011-03-29 Thread Terry Reedy
On 3/29/2011 1:52 PM, harrismh777 wrote: Thanks. You're right... I don't have tk-dev installed. duh. And I have choices to make... it looks like setup.py is looking for 8.4 headers; I 3.2 (which you should definitely be starting with) should, I think, be looking for 8.5, which I believe is ye

Re: Fun python 3.2 one-liner

2011-03-29 Thread Terry Reedy
On 3/29/2011 5:50 AM, Raymond Hettinger wrote: from collections import Counter from itertools import product print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items( The line break makes that hard to read; the axis is not labeled (and labels he

Re: delete namespaces

2011-03-29 Thread Terry Reedy
On 3/29/2011 9:14 PM, monkeys paw wrote: How do i delete a module namespace once it has been imported? I use import banner Then i make a modification to banner.py. When i import it again, the new changes are not reflected. The best thing, if possible, is to restart the program. If you develo

Re: delete namespaces

2011-03-30 Thread Terry Reedy
On 3/30/2011 5:10 AM, Jean-Michel Pichavant wrote: 3/ if you want to do the 2/ but require a painful long prologue to your test, then you may want to use the builtin reload. Use it with care, because any existing object created from the previous module will not be affected, they'll still hold th

Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Terry Reedy
On 3/30/2011 7:58 PM, Gnarlodious wrote: On Mar 30, 9:28 am, Peter Otten wrote: You are trying to run your 3.x code with Python 2.x... You're right. Exactly why this started happening I don't know. I believe recent Mac OSX comes with some 2.x installed as the default Python. -- Terry Jan

Re: Guido rethinking removal of cmp from sort method

2011-03-31 Thread Terry Reedy
On 3/31/2011 2:34 AM, harrismh777 wrote: breaking a fundamental law of object oriented programming... don't break and advertised interface (particularly if it is useful and people are actually making use of it!). This is insane folks. Each x.y version (starting with 2.3) is feature stable: jus

Re: a basic bytecode to machine code compiler

2011-03-31 Thread Terry Reedy
On 3/31/2011 6:33 PM, Rouslan Korneychuk wrote: I was looking at the list of bytecode instructions that Python uses and I noticed how much it looked like assembly. So I figured it can't be to hard to convert this to actual machine code, to get at least a small boost in speed. And so I whipped up

Re: Extracting subsequences composed of the same character

2011-03-31 Thread Terry Reedy
On 3/31/2011 10:20 PM, Tim Chase wrote: On 03/31/2011 07:43 PM, candide wrote: "pyyythhooonnn ---> " and you search for the subquences composed of the same character, here you get : 'yyy', 'hh', 'ooo', 'nnn', '---', '' Or, if you want to do it with itertools instead of the "re" modul

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 3:45 AM, Paul Rubin wrote: Removing cmp certainly isn't the most disruptive change of Python 3, That was almost certainly the ascii to unicode switch for strings. It is still not quite complete in 3.2 but should be pretty well ironed out in 3.3. but it seems like the one with t

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 2:13 AM, harrismh777 wrote: When I speak of implementation vs interface I am speaking from a strictly object oriented philosophy, as pedigree, from Grady Booch, whom I consider to be the father of Object Oriented Analysis and Design (Booch, OO A&D with apps, 1994). Python is object

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 3:45 AM, Paul Rubin wrote: What happens then is you define a new interface. Like key= versus cmp= In Microsoft-speak if the IWhatever interface needs an incompatible extension like new parameters, they introduce IWhatever2 which supports the new parameters. They change the imple

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 2:44 AM, harrismh777 wrote: Terry Reedy wrote: Python 3 was announced and as a mildly code breaking version at least 5 years before it came out. I appreciate the spirit of your arguments overall, and I do not necessarily disagree with much of what you are saying. I would like to

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 3:45 AM, Paul Rubin wrote: What happens then is you define a new interface. In Microsoft-speak if the IWhatever interface needs an incompatible extension like new parameters, they introduce IWhatever2 which supports the new parameters. They change the implementation of IWhatever so

Re: Compiling python without ssl?

2011-04-01 Thread Terry Reedy
On 4/1/2011 7:36 AM, Austin Bingham wrote: Is there any way to compile python (3.1.3, in case it matters) without ssl support? OpenSSL is on my system, and configure finds it, Can you temporarily disguise (rename) it? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Mathematical Operations on Array

2011-04-01 Thread Terry Reedy
On 4/1/2011 8:56 AM, Fodness, Bryan C - GS wrote: I am loading text into an array and would like to convert the values. from math import * from numpy import * from pylab import * data=loadtxt('raw.dat') mincos=degrees(acos(data[:,0])) minazi=degrees(data[:,1]) minthick=data[:,2]/0.006858 I am no

Re: Mathematical Operations on Array

2011-04-01 Thread Terry Reedy
On 4/1/2011 9:35 AM, bryan.fodn...@gmail.com wrote: Can anyone tell me what I am doing wrong? Posting the same question twice is a bad idea, as it splits answers and may lead to duplication. I answered your first post without seeing Peter's response to you second post, which is further down

Re: The Magick of __call__ (Or, Digging Deeper Than I Ought To)

2011-04-01 Thread Terry Reedy
On 4/1/2011 11:07 AM, Corey Richardson wrote: All callables (things you can foo(bar)) are really just objects that implement the __call__ method, as far as I understand. > Well then, that would appear to make methods themselves callable, Method are just function objects that are class attribute

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Terry Reedy
On 4/1/2011 3:22 PM, Paul Rubin wrote: 2to3 could probably gain a fixer to change .sort(cmp=f) # to import functools import cmp_to_key .sort(key=functools.cmp_to_key(f)) I know some would not like this because interface change is not their real concern. Looks like a good idea. There is an e

Re: Guido rethinking removal of cmp from sort method

2011-04-02 Thread Terry Reedy
On 4/2/2011 4:29 AM, harrismh777 wrote: I am responding to both this and a previous post of yours. Python is not a thing, but an abstraction of multiple parts. It is a name, a trademark of the Python Software Foundation. It is a Platonic ideal in the mind of Guido and others. It is a series* o

Re: proposal to allow to set the delimiter in str.format to something other than curly bracket

2011-04-03 Thread Terry Reedy
On 4/3/2011 6:07 AM, Alia Khouri wrote: Hi folks, I've been using ironpython2.7 in a project, and I was generating some csharp code when i discovered that I couldn't use use str.format because the interference with the brackets-aplenty situation in csharp. In [1]: code = "class {0}Model { publi

Re: Guido rethinking removal of cmp from sort method

2011-04-03 Thread Terry Reedy
On 4/3/2011 1:26 AM, harrismh777 wrote: Very interesting. Your explanations (and other excellent contributions here) have shown an intense variation of diversity of viewpoint within at least the comp.lang. community with regard to the Python language. If you really want to see variation of opi

Re: integer multiplication

2011-04-04 Thread Terry Reedy
On 4/4/2011 1:51 AM, Paul Rubin wrote: I didn't realize Python used Karatsuba. The main issue is probably that Python uses a straightforward portable C implementation that's not terribly efficient, but relatively easy for a couple of people to maintain. For (C)Python 3, which no longer has a

Re: Python CPU

2011-04-04 Thread Terry Reedy
On 4/4/2011 5:23 AM, Paul Rubin wrote: Gregory Ewing writes: What might help more is having bytecodes that operate on arrays of unboxed types -- numpy acceleration in hardware. That is an interesting idea as an array or functools module patch. Basically a way to map or fold arbitrary function

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Terry Reedy
On 4/4/2011 5:34 AM, Antoon Pardon wrote: On Fri, Apr 01, 2011 at 10:21:33PM -0400, Terry Reedy wrote: rewriting cmp_to_key in C is underway http://bugs.python.org/issue11707 Nice to know! Any chance this wil get into 2.7.x? I posted the question to the issue. -- Terry Jan Reedy -- http

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Terry Reedy
On 4/4/2011 9:35 AM, Lie Ryan wrote: On 04/04/11 19:34, Antoon Pardon wrote: On Fri, Apr 01, 2011 at 10:21:33PM -0400, Terry Reedy wrote: rewriting cmp_to_key in C is underway http://bugs.python.org/issue11707 Nice to know! Any chance this wil get into 2.7.x? Python 2.7 still have

Re: Python CPU

2011-04-04 Thread Terry Reedy
On 4/4/2011 1:14 PM, Terry Reedy wrote: On 4/4/2011 5:23 AM, Paul Rubin wrote: Gregory Ewing writes: What might help more is having bytecodes that operate on arrays of unboxed types -- numpy acceleration in hardware. That is an interesting idea as an array or functools module patch

Re: integer multiplication

2011-04-04 Thread Terry Reedy
On 4/4/2011 1:20 PM, geremy condra wrote: On Mon, Apr 4, 2011 at 9:41 AM, Terry Reedy wrote: (I believe that retaining two implementations internally was considered but rejected. Could be wrong.) There are two implementations, grade school multiplication and karatsuba, which kicks in after

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Terry Reedy
O fix exactly, and there is always worry that permanance enhancements may have unforseen side effects. I will let Raymond make the call on this. /permanance/performance/, /unforseen/unforeseen/ -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Terry Reedy
On 4/4/2011 9:16 PM, harrismh777 wrote: Another item that would be nice as an IDLE enhancement would be a menu option that applies the fixers (either direction depending on version 2.7 <--> 3.2) right in the IDE. Entries that could not be fixed could be flagged for manual update. I have had th

Re: is python 3 better than python 2?

2011-04-05 Thread Terry Reedy
On 4/5/2011 8:42 AM, neil wrote: what are the advantages? Py3 complete many transitions begun in Py2. In some cases, that means deleting old obsolete stuff, such as old-style classes. if it wasn't for python 3 breaking backwards compatibility would it be the better choice? Assuming equal

Re: Suggest some exercises on Python

2011-04-05 Thread Terry Reedy
On 4/5/2011 9:13 AM, Jins Thomas wrote: I'm a new bie. I have just started learning Python (3.0), Please download, install, and use 3.2. finished with official tutorial. > I would like to have your opinion on some 1. Good books (for an intermediate in programming) with lot's of ... 2. O

<    5   6   7   8   9   10   11   12   13   14   >