Re: is python 3 better than python 2?

2011-04-05 Thread Terry Reedy
On 4/5/2011 4:42 PM, John Nagle wrote: Well, actually Unicode support went in back around Python 2.4. Even earlier, I think, but there were and still are problems with unicode in 2.x. Some were and will only be fixed in 3.x. In 3.x, ASCII strings went away, but that was more of a removal.

Re: is python 3 better than python 2?

2011-04-06 Thread Terry Reedy
On 4/6/2011 12:31 PM, MRAB wrote: On 06/04/2011 07:06, Dan Stromberg wrote: I suspect not all string methods were kept for the bytes type: Doc says "Bytes and bytearray objects, being “strings of bytes”, have all methods found on strings, with the exception of encode(), format() and isiden

Re: TypeError: iterable argument required

2011-04-06 Thread Terry Reedy
On 4/6/2011 6:06 AM, Νικόλαος Κούρας wrote: Now it works like i wanted but i want to ask you if i wrote it correctly, especially when i check against `""` and None One important note: there is one and one one None object; there can be multiple strings with value ''. So, testing against each i

Re: Is the function filter deprecated?

2011-04-06 Thread Terry Reedy
On 4/6/2011 7:20 PM, Jabba Laci wrote: Hi, I tried Pylint today and it gave me a warning for the function "filter". That is a bug in PyLint. Do not take any code checker as gospel truth. Is it deprecated? No. One can look in the source code for a deprecation warning statement or run 3.2 w

Re: Trapping the segfault of a subprocess.Popen

2011-04-06 Thread Terry Reedy
On 4/6/2011 7:58 PM, Nobody wrote: On Wed, 06 Apr 2011 02:20:22 -0700, Pierre GM wrote: I need to run a third-party binary from a python script and retrieve its output (and its error messages). I use something like process = subprocess.Popen(options, stdout=subprocess.PIPE, stderr=subprocess.

Re: Generators and propagation of exceptions

2011-04-08 Thread Terry Reedy
On 4/8/2011 11:55 AM, r wrote: I had a problem for which I've already found a "satisfactory" work-around, but I'd like to ask you if there is a better/nicer looking solution. Perhaps I'm missing something obvious. The code looks like this: stream-of-tokens = token-generator(stream-of-characters

Re: Retrieving Python Keywords

2011-04-09 Thread Terry Reedy
On 4/9/2011 9:28 PM, candide wrote: Python is very good at introspection, so I was wondering if Python (2.7) provides any feature to retrieve the list of its keywords (and, as, assert, break, ...). Yes. (Look in the manuals, or try the obvious imports ;-) -- Terry Jan Reedy -- http://mail.pyt

Re: Retrieving Python Keywords

2011-04-10 Thread Terry Reedy
On 4/10/2011 5:12 AM, candide wrote: Le 10/04/2011 04:01, Terry Reedy a écrit : Yes. (Look in the manuals, I did : my main reference book is the Martelli's /Python in a Nutshell/ You should only use that as a supplement. and the index doesn't refer to the keyword import a

Re: Feature suggestion: math.zod for painlessly avoiding ZeroDivisionError

2011-04-11 Thread Terry Reedy
On 4/11/2011 10:10 AM, Natan Yellin wrote: Hey everyone, This is my first posting to python-list, so be gentle. I propose the following function for the math module (which can, of course, be rewritten in C): zod = lambda a, b: b and a / b This is way too trivial to add. zod, the zero

Re: Dump interpreter history?

2011-04-11 Thread Terry Reedy
On 4/11/2011 11:54 AM, Aahz wrote: In article, Ken D'Ambrosio wrote: Hey, all. A co-worker asked me a question, and I've got no idea how (or if) it can be done. Bottom line: he'd like to save off the text from an interpreter session, his thinking being that you've already tried to get what y

Re: Free software versus software idea patents

2011-04-12 Thread Terry Reedy
On 4/11/2011 4:36 AM, rusi wrote: http://www.cse.uconn.edu/~dqg/papers/cie05.pdf may be of interest (and also other papers of Peter Wegner questioning the universality of Turing machines lambda calculus etc) Thank you for that reference. In summary, it says that while Turing machine are univ

Re: [OT] Free software versus software idea patents

2011-04-12 Thread Terry Reedy
On 4/12/2011 4:15 AM, harrismh777 wrote: Anyone here who does not understand how absurd software patents can get should contemplate the following (based on a real patent from about 20 years ago, when CDroms were new. A Methods for Ensuring that the Correct CDROM is in the CDROM drive. While

Re: Dump interpreter history?

2011-04-12 Thread Terry Reedy
On 4/12/2011 12:12 PM, Aahz wrote: In article, Terry Reedy wrote: Idle will save the contents of the shell window, including opening slash line and prompts. The problem is that normally you *don't* want the prompts. I believe IPython handles that. I have already had in mind that

Re: Feature suggestion -- return if true

2011-04-12 Thread Terry Reedy
On 4/12/2011 2:25 PM, zildjohn01 wrote: Wow. Two dozen replies, the majority of which are arguing over whether the end of my snippet is reachable. I thought the behavior of if statements was well-established by this point. Regardless of James Mills's coding prowess, I suppose I should follow his

Re: Free software versus software idea patents

2011-04-12 Thread Terry Reedy
On 4/12/2011 2:44 PM, Dan Stromberg wrote: On Tue, Apr 12, 2011 at 10:32 AM, Terry Reedy wrote: On 4/11/2011 4:36 AM, rusi wrote: http://www.cse.uconn.edu/~dqg/papers/cie05.pdf may be of interest (and also other papers of Peter Wegner questioning the universality of Turing machines lambda

Re: Testing changes to Python code on the fly: reload() + alternatives?

2011-04-12 Thread Terry Reedy
On 4/12/2011 3:26 PM, Keith wrote: 1) Is it possible to reload a class using the reload() method? Yes, but instances of the old version will remain instances of the old version, which will not go away until all its instances and other references go away. So reload is deceptive, which is why

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Terry Reedy
On 4/13/2011 11:12 PM, Steven D'Aprano wrote: Personally, I'm glad that most of Python Dev don't hang around here. We are far better off if Python Dev, you know, actually Devs Python, rather than answering (mostly) easy questions and getting stuck in tar-pits. Since 3.2 was released 45 days ag

Re: memory usage multi value hash

2011-04-14 Thread Terry Reedy
On 4/14/2011 12:55 PM, Peter Otten wrote: I don't expect that it matters much, but you don't need to sort your data if you use a dictionary anyway: Which means that one can build the dict line by line, as each is read, instead of reading the entire file into memory. So it does matter for int

Re: [Q] ipython: Multiple commands on the same line and newlines

2011-04-16 Thread Terry Reedy
On 4/16/2011 9:55 AM, Phil Winder wrote: Hi, I'm having a go at using ipython as a command prompt for data analysis. Coming from Matlab, I'm used to typing multiple commands on the same line then using the up arrow to go through my history. How can I write multiple python commands on the same lin

Re: Python IDE/text-editor

2011-04-16 Thread Terry Reedy
On 4/16/2011 3:03 AM, Alec Taylor wrote: IDLE loses syntax highlighting annoyingly often Could you exlain? When does it do that with a file labelled .py? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] Python 2.5.6 Release Candidate 1

2011-04-18 Thread Terry Reedy
On 4/18/2011 7:33 PM, Brendan Simon (eTRIX) wrote: If there is an official release of source (e.g. 2.5.5 and 2.5.6) why aren't binaries produced (other than to make it really hard for users and force them to upgrade to a later major revision -- 2.6, 2.7, etc) ?? Unofficial answer: A. Binaries

Re: IDLE bug

2011-04-19 Thread Terry Reedy
On 4/19/2011 12:05 AM, harrismh777 wrote: Are bug reports wanted here, or just in issue tracker? If one is somewhat experienced with Python and is sure about having identified a bug, and is willing to search the tracker for existing reports and respond to questions, then report on the tracker

3.2 test failures on Centos 5.6 (was Re: Noob Question)

2011-04-19 Thread Terry Reedy
On 4/19/2011 10:55 AM, Rob McGillivray wrote: I'm new to Python, and trying to get python 3.2 installed on Centos 5.6. When I run 'make test', I receive several errors. Welcome to Python. Newbie lesson 1: write an informative subject line that will catch the attention of people who can answe

Re: Namespaces in functions vs classes

2011-04-19 Thread Terry Reedy
On 4/19/2011 10:58 AM, Gerald Britton wrote: serve method unless it is qualified. I now understand the Python does not consider a class definition as a separate namespace as it does for function definitions. Class namespaces are separate namespaces but not in the same way as for functions. C

Re: What breaks if I remove lib/python2.7/test/* ?

2011-04-19 Thread Terry Reedy
On 4/19/2011 1:06 PM, cjblaine wrote: What breaks if I remove lib/python2.7/test/* ? What purpose does it serve? It allows you to run the test suite. Some people like to run it when they install. Or they may run a module test if they have a problem with a specific module or edit the Python c

Re: 3.2 test failures on Centos 5.6 (was Re: Noob Question)

2011-04-19 Thread Terry Reedy
On 4/19/2011 1:33 PM, Rob McGillivray wrote: I am trying to install from an RPM downloaded from python.org. That puzzles me. For *nix, I do not see .rpm, just tarballs, on http://python.org/download/releases/3.2/ -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE bug

2011-04-19 Thread Terry Reedy
On 4/19/2011 11:39 PM, harrismh777 wrote: Terry Reedy wrote: If one is new to Python and perhaps not sure, or should not be sure, then I prefer that one ask here for a second opinion. Thanks Terry. I am not new to Python, but I am new to Python3, and I'm also relatively new to IDLE. Typi

Re: Teaching Python

2011-04-20 Thread Terry Reedy
On 4/20/2011 6:17 AM, Steven D'Aprano wrote: It's hardly just the press. "Hack" is a fine old English word: "The jungle explorer hacked at the undergrowth with his machete." "I was so hungry, I didn't take the time to neatly slice up the meat, but just hacked off a chunk and stuffed it in my m

Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Terry Reedy
On 4/20/2011 1:15 PM, Ron wrote: I've written an online interactive Python tutorial atop Google App Engine: http://www.learnpython.org. Currently giving 500 server error. Hope something clears up. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.2 on CentOS 5.6 & compatibility concerns

2011-04-21 Thread Terry Reedy
On 4/21/2011 8:02 AM, Rob McGillivray wrote: Hi All, Does anyone know if it is ‘safe’ to install Python 3.2 on CentOS? By ‘safe’ I mean not breaking the existing base Python 2.4.x installation upon which various CentOS/RHEL services (like yum) depend. Will the ‘make install’ install 3.2 in paral

Re: A question about Python Classes

2011-04-21 Thread Terry Reedy
On 4/21/2011 11:43 AM, chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an ins

Re: Snowball to Python compiler

2011-04-21 Thread Terry Reedy
On 4/21/2011 8:25 PM, Paul Rubin wrote: Matt Chaput writes: I'm looking for some code that will take a Snowball program and compile it into a Python script. Or, less ideally, a Snowball interpreter written in Python. (http://snowball.tartarus.org/) Anyone heard of such a thing? I never saw

Re: Closing generators

2011-04-21 Thread Terry Reedy
On 4/21/2011 9:14 PM, Thomas Rachel wrote: Hi folks, it is possible to close a generator. That is (among others) for the following case: I run a for loop over the iterator, but then I break it. Now I can leave the generator to the GC (which is AFAI have been told a thing which I should not do),

Re: Closing generators

2011-04-22 Thread Terry Reedy
On 4/22/2011 4:01 AM, Thomas Rachel wrote: Am 22.04.2011 09:01, schrieb Wolfgang Rohdewald: On Freitag 22 April 2011, Terry Reedy wrote: When returning from the function, g, if local, should disappear. yes - it disappears in the sense that it no longer accessible, but AFAIK python makes

Re: Function __defaults__

2011-04-24 Thread Terry Reedy
On 4/24/2011 5:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? Interesting que

Re: Function __defaults__

2011-04-24 Thread Terry Reedy
On 4/24/2011 5:21 PM, Ken Seehart wrote: Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure features against all potential target platforms. In this case, I would argue that**Benjamin's test demonstrates a bu

Re: learnpython.org - an online interactive Python tutorial

2011-04-25 Thread Terry Reedy
On 4/25/2011 2:20 AM, harrismh777 wrote: Steven D'Aprano wrote: It seems to me that weak typing is a Do What I Mean function, and DWIM is a notoriously bad anti-pattern that causes far more trouble than it is worth. I'm even a little suspicious of numeric coercions between integer and float. (Bu

Re: How to concatenate unicode strings ???

2011-04-26 Thread Terry Reedy
On 4/26/2011 12:07 PM, Chris Rebert wrote: On Tue, Apr 26, 2011 at 8:58 AM, Ariel wrote: Hi everybody, how could I concatenate unicode strings ??? What I want to do is this: unicode('this an example language ') + unicode('español') but I get an: Traceback (most recent call last): File "",

Re: Terrible FPU performance

2011-04-26 Thread Terry Reedy
On 4/26/2011 3:27 PM, Dan Stromberg wrote: for 0<= i< 1000: x *= 0.8 #x += 0.01 print x In my WinXP (Athlon), 3.2 standard install x=1.0 print(x) for i in range(1000): x *= 0.8 x += 0.01 print(x) takes about 3 1/2 secs with addition comment

Re: Have you read the Python docs lately?

2011-04-28 Thread Terry Reedy
On 4/27/2011 7:40 PM, Ben Finney wrote: http://docs.python.org/dev/howto/logging.html This one in particular was sorely needed, especially its early if-then discussion of whether to use ‘logging’ at all. Thanks very much to Vinay Sajip. Yes, he has been working pretty steadily for some months

Re: IDLE lost from Windows menu !

2011-04-28 Thread Terry Reedy
On 4/28/2011 12:28 PM, Uncle Ben wrote: I have lost the convenient feature that to edit a .py file I could right-click on the file name and reach the menu item "Edit with IDLE". The workaround is not hard, but it wouild be nice to get this feature back. It happened when I was mungeing around an

Re: NaN

2011-04-28 Thread Terry Reedy
On 4/28/2011 2:59 PM, Steven D'Aprano wrote: Still, it could be worse... I've seen a programs use to represent missing values, on the basis that nobody could ever have more than (say) 5000 invoices in the database... (I wish I was exaggerating.) All 9s in a field for missing was once sta

Re: Python 3.2 Tkinter and TTK

2011-04-28 Thread Terry Reedy
On 4/28/2011 1:33 PM, steven.oldner wrote: Just downloaded Python3.2 from python's site and attempted to run some of the examples in the 24.2.10 Tk Styling. The button worked, I found 4 examples, none of which *do* anything. Perhaps they are only meant to show syntax. I am running WinXP. You?

Re: Python wide-python-build unicode for Windows

2011-04-29 Thread Terry Reedy
On 4/29/2011 7:52 AM, sathe...@e-ndicus.com wrote: How could i increase the unicode range beyond 1 ? Use Python3, which, after renaming unichar to chr, changed it to always accept the full range of codepoints, even when that means returning a two-char string on narrow builds, like window

Re: Python competitions and learnings

2011-04-30 Thread Terry Reedy
On 4/30/2011 3:22 PM, Alexander Lyabah wrote: I spend a lot of time in writing a new service checkio.org It's all about python, learn python, find the best solution in python. And Im looking for feedback from peoples who best in python. Here I make some video tutorial about this service http:/

Re: What other languages use the same data model as Python?

2011-05-01 Thread Terry Reedy
On 5/1/2011 4:45 AM, Steven D'Aprano wrote: Python uses a data model of "name binding" and "call by object" (also known as "call by sharing"). I trust I don't need to define my terms, but just in case: http://effbot.org/zone/call-by-object.htm http://effbot.org/zone/python-objects.htm Now, thi

Re: Fibonacci series recursion error

2011-05-01 Thread Terry Reedy
On 5/1/2011 5:27 AM, Hans Georg Schaathun wrote: Of course you do, but you are still only saying that there might be an application where this might happen because of excessive although logically correct recursion. You have not given a single example where it actually happened. I will. Stack

Re: Python competitions and learnings

2011-05-01 Thread Terry Reedy
On 5/1/2011 12:49 PM, Alexander Lyabah wrote: And what do you think about Score Games and competitions? The rules of the first score game were not clear to me. I could not figure out how to play it interactively myself so I could see how it actually played. -- Terry Jan Reedy -- http://mai

Re: What other languages use the same data model as Python?

2011-05-01 Thread Terry Reedy
On 5/1/2011 6:33 PM, Gregory Ewing wrote: Steven D'Aprano wrote: Python uses a data model of "name binding" and "call by object" (also known as "call by sharing"). It can be summed up in a less jargony way by saying that all data is stored in heap-allocated objects, This is incomprehensible

Re: Fibonacci series recursion error

2011-05-01 Thread Terry Reedy
On 5/1/2011 7:16 PM, BartC wrote: Yes, it generates lots of calls. About 22000 for fib(20), and 330 million for fib(40). Using the standard double recursion implementation of fib, ncf(n) (number of calls to fib() for fib(n)) requires ncf(n-2) + ncf(n+1) + 1 calls. The +1 is for the call to

Re: PIL Question

2011-05-01 Thread Terry Reedy
On 5/1/2011 9:00 PM, Chris Rebert wrote: I would think to a file named "screen_capture.jpg" in the current working directory. What that is for IDLE, I don't know. At least on windows with 3.2, if one just starts up the shell, it is in the Pythonxy directory. If one runs a file from an edit wi

Re: Fibonacci series recursion error

2011-05-02 Thread Terry Reedy
On 5/2/2011 9:14 AM, Hans Georg Schaathun wrote: On Sun, 01 May 2011 18:24:30 -0400, Terry Reedy : Python does not do this automatically because 1) it can be a semantic : change under some circumstances; 2) one who wants the iterative version : can just as easily write it directly; That&#

Re: Coolest Python recipe of all time

2011-05-02 Thread Terry Reedy
On 5/3/2011 1:04 AM, Stefan Behnel wrote: The bad thing about this recipe is that it requires quite a bit of background knowledge in order to infer that the code the developer is looking at is actually correct. The main math knowledge needed is the trivial fact that if a*x + b = 0, then x = -

Re: Coolest Python recipe of all time

2011-05-03 Thread Terry Reedy
On 5/3/2011 2:29 AM, Gregory Ewing wrote: Terry Reedy wrote: The trick is that replacing x with j and evaluating therefore causes (in Python) all the coefficients of x (now j) to be added together separately from all the constant terms to reduce the linear equation to a*x+b (= 0 implied

Re: Why do directly imported variables behave differently than those attached to imported module?

2011-05-03 Thread Terry Reedy
Your problem is reveal in the subject line. As discussed in many other threads, including a current one, Python does not have 'variables' in the way that many understand the term. Python binds names to objects. Binding statements (assignment, augmented assignment, import, def, class, and others

Re: A very minute correction on PDF

2011-05-04 Thread Terry Reedy
On 5/4/2011 3:45 AM, Mehta, Pratik wrote: For tutorialPython.pdf Page 17 of the ebook (i.e. page 23 of pdf) under topic *3.2 First Steps towards programming* Under while loop, there should be a “,” after print b Print b, (a comma after ‘b’ is missing) [You should mention versions when posting

Re: [ann] pyjamas 0.8alpha1 release

2011-05-04 Thread Terry Reedy
On 5/4/2011 10:06 AM, Luke Kenneth Casson Leighton wrote: after a long delay the pyjamas project - http://pyjs.org - has begun the 0.8 series of releases, beginning with alpha1: https://sourceforge.net/projects/pyjamas/files/pyjamas/0.8/ pyjamas is a suite of projects, including a python-to-jav

Re: Hooking into Python's memory management

2011-05-04 Thread Terry Reedy
On 5/4/2011 12:51 PM, Daniel Neilson wrote: Hello, I'm hoping that there will be someone here with sufficient expertise to answer a question on Python 3 for me. I work in the Computer Science department at a large Canadian University. We are currently doing a feasibility analysis for switching

Re: Basic interaction with another program

2011-05-04 Thread Terry Reedy
On 5/4/2011 12:34 PM, ETP wrote: I have a dos program (run in a window) that I would like to control with a script. Look at the subprocess module. You may have to (and be able to) have it start up the window program with the dos program as an argument. It needs only text input. For exampl

Re: Today's fun and educational Python recipe

2011-05-04 Thread Terry Reedy
On 5/4/2011 2:17 PM, Raymond Hettinger wrote: Here's a 22-line beauty for a classic and amazing algorithm: http://bit.ly/bloom_filter The wiki article on the algorithm is brief and well-written: http://en.wikipedia.org/wiki/Bloom_filter As I understand the article, the array of num_bits should

Re: Today's fun and educational Python recipe

2011-05-04 Thread Terry Reedy
On 5/4/2011 5:39 PM, Raymond Hettinger wrote: The 512 bits in h are progressively eaten-up between iterations. So each pass yields a different (array index, bit_mask) pair. Yeh, obvious now that I see it. It's easy to use the interactive prompt to show that different probes are produced on

Re: What other languages use the same data model as Python?

2011-05-05 Thread Terry Reedy
On 5/5/2011 9:19 AM, Neil Cerutti wrote: On 2011-05-04, John Nagle wrote: That's a quirk of CPython's boxed number implementation. All integers are boxed, but there's a set of canned objects for small integers. CPython's range for this is -5 to +256, incidentally. That's visible through the

Re: checking if a list is empty

2011-05-06 Thread Terry Reedy
On 5/6/2011 7:34 AM, James Mills wrote: On Fri, May 6, 2011 at 4:36 PM, Jabba Laci wrote: If I want to check if a list is empty, which is the more pythonic way? [...] (2) if not li: This is fine. This is the intended way. Anything in addition is extra noise and wasted calculation. In o

Re: string formatting

2011-05-06 Thread Terry Reedy
On 5/6/2011 3:22 PM, harrismh777 wrote: I don't really like the old style, not because there is anything wrong with it, There is in that it special cases tuples. For instance, a message function like def emsg(x): print("The following object caused a proplem: %s" % x) raises "TypeError: n

Re: string formatting

2011-05-07 Thread Terry Reedy
On 5/6/2011 8:09 PM, Chris Angelico wrote: On Sat, May 7, 2011 at 6:54 AM, Terry Reedy wrote: def emsg(x): if isinstance(x,tuple): x = (x,) print(The following object caused a proplem: %s" % x) Couldn't you just do that unconditionally? print(The following object caused

Re: checking if a list is empty

2011-05-08 Thread Terry Reedy
On 5/8/2011 10:07 AM, Steven D'Aprano wrote: Because the test of "is this nothing, or something?" is a common, useful test: Because inductive algorithms commonly branch on 'input is something' (not done, change args toward 'nothing'and recurse or iterate) versus 'input is nothing (done, retu

Re: scipy

2011-05-08 Thread Terry Reedy
On 5/8/2011 6:44 AM, pb wrote: Hi, I', having trouble with scipy. If you do not get an answer here, try the scipy list where scipy experts hang out. You might also try searching the archives of that list or the scipy bug tracker. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinf

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Terry Reedy
On 5/9/2011 4:25 AM, Antonio CHESSA wrote: apple = [["a","b","c"],[1,2,3,4,5,6],["antony","max","sandra","sebastian"]] apple[0] = ["a","b","c"] apple[1] = [1,2,3,4,5,6] apple[2] = ["antony","max","sandra","sebastian"] apple[0][1] = "b" apple[2][3] = "sebastian" to view all videos in a loop so

Re: What other languages use the same data model as Python?

2011-05-09 Thread Terry Reedy
On 5/9/2011 10:29 AM, Steven D'Aprano wrote: If people then ask, how does the interpreter know the names?, I can add more detail: names are actually strings in a namespace, which is usually nothing more than a dict. Oh, and inside functions, it's a bit more complicated still. And so on. Which

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Terry Reedy
On 5/9/2011 2:10 PM, James Wright wrote: Hello, I have been using a script on several boxes that have been around for a while, and everything works just fine. I am finding though, that on some new OS installs the script fails with: Traceback (most recent call last): File "render4.py", line

Re: checking if a list is empty

2011-05-09 Thread Terry Reedy
On 5/8/2011 7:36 PM, Dan Stromberg wrote: On Sun, May 8, 2011 at 3:41 PM, Terry Reedy mailto:tjre...@udel.edu>> wrote: Because inductive algorithms commonly branch on 'input is something' (not done, change args toward 'nothing'and recurse or iterate)

Re: Custom string joining

2011-05-09 Thread Terry Reedy
On 5/9/2011 4:25 PM, Claudiu Popa wrote: I already told in the first post that I've implemented __str__ function, > but it doesn't seems to be automatically called. No, Python does not auto-coerce to strings (only between numbers). You have to be explicit by calling str. Karim's statement "Yo

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Terry Reedy
On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used. But how to enable the "standard" matrix notation a[i, j] in Python 3.2 in the manner of numpy (and other matrix packa

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Terry Reedy
On 5/10/2011 3:22 AM, Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: > class listwrap: > def __init__(self, lis): > self._list = lis > def __getitem__(self, dex): > i,j = dex > return self._list[i][j] > # __setitem__: exerci

Re: What other languages use the same data model as Python?

2011-05-10 Thread Terry Reedy
On 5/10/2011 3:41 AM, Gregory Ewing wrote: Actually, you're right. What I've presented is a paper-and-pencil implementation of the Python data model. Together with a set of rules for manipulating the diagram under the direction of Python code, you have a complete implementation of Python that yo

Re: Non Programming in python

2011-05-10 Thread Terry Reedy
On 5/10/2011 12:41 PM, rusi wrote: Sorry for a silly subject change: A better one will be welcome -- cant think of a name myself. Associated tools. I might separate them into development tools (up to the production of python.exe) and usage tools (everything thereafter). On Windows, this is a

Re: Py3k,email header handling

2011-05-11 Thread Terry Reedy
On 5/11/2011 12:27 PM, TheSaint wrote: Steven D'Aprano wrote: Before you re-write it, you should run 2to3 over it and see how much it can do automatically: Widely done, only the results from some query has radically changed on favour of unicode. Errors raising about results which are not stri

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Terry Reedy
On 5/11/2011 12:27 PM, Genstein wrote: In py3k is it necessary to flush() a file between read/write calls in order to see consistent results? I ask because I have a case under Python 3.2 (r32:88445) where it does appear to be, on both Gentoo Linux and Windows Vista. I've naturally read http://

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Terry Reedy
On 5/11/2011 3:08 PM, Genstein wrote: On 11/05/2011 19:24, Terry Reedy wrote: writing and reading. If you want others to look at this more, you should 1) produce a minimal* example that demonstrates the questionable behavior, and 2) show the comparative outputs that raise your question

Re: unicode by default

2011-05-11 Thread Terry Reedy
On 5/11/2011 11:44 PM, harrismh777 wrote: Steven D'Aprano wrote: You need to understand the difference between characters and bytes. http://www.joelonsoftware.com/articles/Unicode.html is also a good resource. Thanks for being patient guys, here's what I've done: astr="pound sign" asym="

Re: checking if a list is empty

2011-05-12 Thread Terry Reedy
On 5/11/2011 8:26 AM, Roy Smith wrote: I conclude that li == [] should have returned False. Either I'm not understanding things correctly, or this is a bug. The doc is wrong (and not only on this). I am working on a report with suggested fixes. Will post number when finish. -- Terry Jan Re

Re: py3k buffered IO - flush() required between read/write?

2011-05-12 Thread Terry Reedy
On 5/12/2011 9:30 AM, Genstein wrote: With 3.2 on winxp, that is what I get with StringIO, text file, and bytes file (the first two with b's removed). I would expect the same on any system. If you get anything different, I would consider it a bug Thanks Terry, you're entirely right there; I tri

Re: generate properties code in class dynamically

2011-05-12 Thread Terry Reedy
On 5/12/2011 9:11 AM, JamesEM wrote: I would prefer to generate the properties code dynamically from the keys of the dictionaries. What I am looking for is something like: class MyClass(object): def __init__(self): self.d = {} d['field1'] = 1.0 d['field2'] = 'A'

Re: unicode by default

2011-05-12 Thread Terry Reedy
On 5/12/2011 12:17 PM, Ian Kelly wrote: On Thu, May 12, 2011 at 1:58 AM, John Machin wrote: On Thu, May 12, 2011 4:31 pm, harrismh777 wrote: So, the UTF-16 UTF-32 is INTERNAL only, for Python NO. See one of my previous messages. UTF-16 and UTF-32, like UTF-8 are encodings for the EXTERNAL

Re: checking if a list is empty

2011-05-12 Thread Terry Reedy
On 5/12/2011 3:37 PM, Terry Reedy wrote: On 5/11/2011 8:26 AM, Roy Smith wrote: I conclude that li == [] should have returned False. Either I'm not understanding things correctly, or this is a bug. The doc is wrong (and not only on this). I am working on a report with suggested fixes.

Re: unicode by default

2011-05-13 Thread Terry Reedy
On 5/13/2011 3:53 PM, harrismh777 wrote: The unicode consortium is very careful to make sure that thousands of symbols have a unique code point (that's great !) but how do these thousands of symbols actually get displayed if there is no font consortium? Are there collections of 'standard' fonts

Re: turn monitor off and on

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:20 AM, harrismh777 wrote: harrismh777 wrote: def turnOnMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) I've never tried turning my monitor on/off without using my finger... The computer cannot tur

Re: How best to convert a string "list" to a python list

2011-05-14 Thread Terry Reedy
On 5/14/2011 4:41 AM, Nobody wrote: On Fri, 13 May 2011 10:15:29 -0700, noydb wrote: I want some code to take the items in a semi-colon-delimted string "list" and places each in a python list. I came up with below. In the name of learning how to do things properly, do you experts have a bette

Re: unicode by default

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:41 AM, harrismh777 wrote: Terry Reedy wrote: Easy, practical use of unicode is still a work in progress. Apparently... the good news for me is that SBL provides their unicode font here: http://www.sbl-site.org/educational/biblicalfonts.aspx I'm getting much closer here

Re: Question about available python lib for a task

2011-05-14 Thread Terry Reedy
On 5/14/2011 11:11 AM, cesium5...@yahoo.ca wrote: I would like to build a database of all the MS-Excel file on a LAN. I would like to get the files metadata : filename, summary, location, size, etc. You subject line is about a non-specific as can be, which means that the person who can answer

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:39 AM, Steven D'Aprano wrote: Th money-quote as regards using arbitrary objects in truth tests: [quote] All this changed with the introduction of the two-element boolean domain {true, false} which provides the vocabulary needed to assign values to boolean expr

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:45 AM, rusi wrote: (True = True) is False is a syntax error ;-) and 'True = True' is a (useless) statement, and statements do not have boolean values, and 'True == True' *is* True, which is to say, ((True == True) is False) is False. -- Terry Jan Reedy -- http://mail.python.o

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 1:43 PM, rusi wrote: But it seems you did not get the moral? Spelt out: "Beware of lossy compression!" [Which is also the moral of my 'proof'] I get it now. As I suggested in response to Stephen, [] and [1] spell False and True only in boolean contexts (if/while headers) where th

Re: dict: retrieve the original key by key

2011-05-15 Thread Terry Reedy
On 5/15/2011 6:46 AM, Christoph Groth wrote: Steven D'Aprano writes: On Sun, 15 May 2011 11:11:41 +0200, Christoph Groth wrote: I would like to avoid having _multiple_ objects which are equal (a == b) but not the same (a is not b). This would save a lot of memory. Python hashed collection

Re: checking if a list is empty

2011-05-15 Thread Terry Reedy
On 5/15/2011 1:33 PM, rusi wrote: On May 15, 10:07 am, Steven D'Aprano wrote: I'm afraid I don't understand what you mean. Can you explain please, what properties of "first class booleans" do you think are missing from Python? Given the usual CS definition of 'first class object', all Python

Re: checking if a list is empty

2011-05-15 Thread Terry Reedy
On 5/15/2011 5:36 PM, Terry Reedy wrote: On 5/15/2011 1:33 PM, rusi wrote: Dijkstra's writings I alluded to, at http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1070.html "Acquiring that familiarity requires what in these financial times is known as "intellec

Re: pyjamas 0.8alpha1 release

2011-05-17 Thread Terry Reedy
On 5/17/2011 12:07 PM, lkcl wrote: On May 4, 7:37 pm, Terry Reedy wrote: On 5/4/2011 10:06 AM, Luke Kenneth Casson Leighton wrote: pyjamasis a suite of projects, including a python-to-javascript compiler As you well know, there is no such thing as 'python' when it comes to compil

Re: [ann] pyjamas 0.8alpha1 release

2011-05-17 Thread Terry Reedy
On 5/17/2011 12:38 PM, harrismh777 wrote: Terry Reedy wrote: Like it or not, Python 3 is the future of Python. It is the Python that many Python newcomers learn first, and perhaps ever will. Yes, no doubt, and I'm genuine about that... ... but there is something else to consider, as I&#

Re: in search of graceful co-routines

2011-05-17 Thread Terry Reedy
On 5/17/2011 1:04 PM, Chris Withers wrote: Hi All, I'm looking for a graceful pattern for the situation where I have a provider of a sequence, the consumer of a sequence and code to moderate the two, and where I'd like to consumer to be able to signal to the provider that it hasn't succeeded in

Re: Python 3.x and bytes

2011-05-17 Thread Terry Reedy
On 5/17/2011 3:39 PM, MRAB wrote: On 17/05/2011 19:47, Ethan Furman wrote: In Python 3 one can say --> huh = bytes(5) BTW, help(bytes) doesn't seem to mention it! I believe I mentioned that on some tracker issue. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

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