Re: Py 3.3, unicode / upper()

2012-12-20 Thread Terry Reedy
On 12/20/2012 2:19 PM, wxjmfa...@gmail.com wrote: My feeling is that most of the people are defending this FSR simply because it exists, not because of its intrisic quality. The fact, contrary to your feeling, is that I was initially dubious that is could be made to work as well as it does. I

Re: Brython - Python in the browser

2012-12-20 Thread Terry Reedy
On Thu, Dec 20, 2012 at 8:37 PM, Pierre Quentel wrote: I'm afraid I am going to disagree. The document is a tree structure, and today Python doesn't have a syntax for easily manipulating trees. What Python does have is 11 versions of the augmented assignment statement: +=, -=, *=, /=, //=,

Re: Strange effect with import

2012-12-20 Thread Terry Reedy
On 12/20/2012 5:52 PM, Jens Thoms Toerring wrote: You are rather likely right and I probably should have written: "I don't see any way to pass that variable to the object that is supposed to use it". Perhaps you have an idea how it could be done correctly when I explain the complete picture: I'm

Re: Brython - Python in the browser

2012-12-21 Thread Terry Reedy
On 12/21/2012 3:31 AM, Rouslan Korneychuk wrote: Although I'm not really in favor of using an operator for this sort of thing either way, I can't help but notice the discussion seems to be limited to Python's operators. If you're implementing Python yourself, can't you define a new operator that

Re: Second try: non-blocking subprocess pipe and Tkinter in 2.7

2012-12-21 Thread Terry Reedy
On 12/21/2012 10:52 AM, Kevin Walzer wrote: Yesterday I posted a question about keeping a Tkinter GUI during a long-running process, i.e. reading data from a pipe via the subprocess module. I think that question did not quite get at the heart of the issue because it assumed that Python, like Tcl

Re: redirect standard output problem

2012-12-22 Thread Terry Reedy
On 12/22/2012 10:15 AM, Chris Angelico wrote: On Sun, Dec 23, 2012 at 2:07 AM, iMath wrote: when I run it through command line ,it works ok ,but when I run it through IDLE , only print A but leave out 888 so why ? Because IDLE has to fiddle with stdin/stdout a bit to function. Try adopting D

Re: Plz Suggest... How can i install the pure python package py-bidi in WIndows.

2012-12-22 Thread Terry Reedy
On 12/22/2012 10:02 AM, David Robinow wrote: On Sat, Dec 22, 2012 at 9:10 AM, Arsalan Khan wrote: I tried installing but it gives error.. Can anyone guide the procedure of configuring/Installing a python package in windows ??? What did you do to try to install? What error(s) did you get?

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Terry Reedy
On 12/22/2012 7:45 AM, prilisa...@googlemail.com wrote: Am Samstag, 22. Dezember 2012 13:38:11 UTC+1 schrieb prili...@googlemail.com: Am Samstag, 22. Dezember 2012 12:43:54 UTC+1 schrieb Peter Otten: wrote: Hello, to all, And my mail reader text window is fille

Re: Python, email temperature

2012-12-23 Thread Terry Reedy
On 12/23/2012 12:23 PM, Mitya Sirenef wrote: On 12/23/2012 08:46 AM, KarlE wrote: On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote: from __future__ import division Depending on the linux installed, you should be able to run 3.2 or 3.3 instead of 2.7. Though there are still 2.x

Re: Parsing files in python

2012-12-23 Thread Terry Reedy
On 12/23/2012 12:19 PM, Kene Meniru wrote: Hello: I am writing a program that is made up of a collection of POV-Ray macros. POV-Ray is available at povray.org. It is a ray-tracing program that reads a scene description language (SDL) to create photo-realistic images. At this time my program (for

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Terry Reedy
On 12/23/2012 4:32 AM, prilisa...@googlemail.com wrote: By the way, I think I have found the correct "wording". for my understood, the "handover" of objects to imported modules doesn't work because, e.g. trying to hand-over an SQLite connection into a imported module, can't work because the "attr

Re: Parsing files in python

2012-12-24 Thread Terry Reedy
On 12/23/2012 11:05 PM, Chris Angelico wrote: But other than that, yes, Python's a good choice for this. (I find it amusing how I said "yeah, good idea to make a DSL, I wonder if you can capitalize on Python" and you said "don't make a DSL, maybe you can capitalize on Python" - opposite opening

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Terry Reedy
On 12/27/2012 3:01 PM, mogul wrote: 'Aloha! I'm new to python, got 10-20 years perl and C experience, all gained on unix alike machines hacking happily in vi, and later on in vim. Now it's python, and currently mainly on my kubuntu desktop. Do I really need a real IDE, as the windows guys arou

Re: pickle module doens't work

2012-12-27 Thread Terry Reedy
On 12/27/2012 7:34 AM, Dave Angel wrote: Perhaps you'd rather see it in the Python docs. http://docs.python.org/2/library/pickle.html http://docs.python.org/3.3/library/pickle.html pickle can save and restore class instances transpare

Re: Custom alphabetical sort

2012-12-27 Thread Terry Reedy
On 12/27/2012 1:17 PM, wxjmfa...@gmail.com wrote: Le lundi 24 décembre 2012 16:32:56 UTC+1, Pander Musubi a écrit : I would like to sort according to this order: (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', '

Re: learning curve

2012-12-28 Thread Terry Reedy
On 12/27/2012 8:20 PM, Verde Denim wrote: Just getting into Py coding and not understanding why this code doesn't seem to do anything - Part of your 'learning curve' should be learning to write informative subjects lines. The above says almost nothing. For this I suggest "Problem with classes

Re: email.message.Message - as_string fails

2012-12-28 Thread Terry Reedy
On 12/28/2012 7:22 AM, Helmut Jarausch wrote: Hi, I'm trying to filter an mbox file by removing some messages. For that I use Parser= FeedParser(policy=policy.SMTP) and 'feed' any lines to it. If the mbox file contains a white line followed by '^From ', I do Msg= Parser.close() (lateron I dele

Re: learning curve

2012-12-28 Thread Terry Reedy
On 12/28/2012 1:29 PM, Verde Denim wrote: On 12/27/2012 09:32 PM, alex23 wrote: On Dec 28, 11:20 am, Verde Denim wrote: Just getting into Py coding and not understanding why this code doesn't seem to do anything - Is that the sum total of your code? You're not showing any instantiation of yo

Re: dict comprehension question.

2012-12-29 Thread Terry Reedy
On 12/29/2012 4:40 PM, Mitya Sirenef wrote: On 12/29/2012 03:15 PM, Joel Goldstick wrote: Would this help: >>> w = [1,2,3,1,2,4,4,5,6,1] >>> s = set(w) >>> s set([1, 2, 3, 4, 5, 6]) >>> {x:w.count(x) for x in s} {1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1} >>> Indeed,

Re: dict comprehension question.

2012-12-29 Thread Terry Reedy
On 12/29/2012 2:48 PM, Quint Rankid wrote: Given a list like: w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1] I would like to be able to do the following as a dict comprehension. a = {} for x in w: a[x] = a.get(x,0) + 1 results in a having the value: {1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1} Let me paraphr

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Terry Reedy
On 12/29/2012 8:48 AM, Roy Smith wrote: In article <50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: In Python 3.2 and 3.3, the message about no handlers is not printed, which is an interesting difference. (Somebody who knows more about the logging package than I

Re: Python 3.3, gettext and Unicode problems

2012-12-30 Thread Terry Reedy
On 12/30/2012 7:39 PM, Marcel Rodrigues wrote: I'm using Python 3.3 (CPython) and am having trouble getting the standard gettext module to handle Unicode messages. I have never even looked at the doc before, but I will take a look. My problem can be isolated as follows: I have 3 files in a f

Re: Python 3.3, gettext and Unicode problems

2012-12-30 Thread Terry Reedy
On 12/30/2012 8:48 PM, Terry Reedy wrote: On 12/30/2012 7:39 PM, Marcel Rodrigues wrote: I'm using Python 3.3 (CPython) and am having trouble getting the standard gettext module to handle Unicode messages. Addition to previous response. import gettext t = gettext.translation(&quo

Re: pylint, was Re: pygame - importing GL - very bad...

2013-01-02 Thread Terry Reedy
On 1/2/2013 9:24 PM, someone wrote: What pylint says is: 1) class somethingWork: Invalid name "somethingWork" (should match [A-Z_][a-zA-Z0-9]+$), I'm not that good at regular exps, but I suppose it wants my class name to start with a capital letter ? Yes 2) self.lightDone: Invalid name "lig

Re: pylint, was Re: pygame - importing GL - very bad...

2013-01-03 Thread Terry Reedy
On 1/3/2013 9:19 AM, Mike C. Fletcher wrote: On 13-01-02 09:48 PM, Terry Reedy wrote: ... 2) self.lightDone: Invalid name "lightDone" (should match [a-z_][a-z0-9_]{2,30}$) So I can now understand that pylint doesn't like my naming convention with a capital letter in the middle

Re: Yet another attempt at a safe eval() call

2013-01-04 Thread Terry Reedy
On 1/3/2013 6:25 PM, Grant Edwards wrote: I've written a small assembler in Python 2.[67], and it needs to evaluate integer-valued arithmetic expressions in the context of a symbol table that defines integer values for a set of names. The "right" thing is probably an expression parser/evaluator

Re: import of ttk

2013-01-04 Thread Terry Reedy
On 1/4/2013 11:02 PM, Verde Denim wrote: In reading through one of the learning articles, I have a bit of code that imports ttk, but I apparently don't have this installed. I've looked up the svn checkout for python-tk, and have checked it out (read-only), but still get the same error. I'm runnin

Re: reduce expression to test sublist

2013-01-05 Thread Terry Reedy
On 1/5/2013 1:58 PM, Dave Angel wrote: If you're trying to make a faster loop, then I suggest you look into set differences. Turn both lists into sets, and subtract them. Something like (untested): result = not bool( set(lst1) - set(lst2) ) This does not return False as soon as an ite

Re: reduce expression to test sublist

2013-01-05 Thread Terry Reedy
On 1/5/2013 1:25 PM, Asim wrote: Hi All The following reduce expression checks if every element of list lst1 is present in list lst2. It works as expected for integer lists but for lists of strings, it always returns False. reduce( lambda x,y: (x in lst2) and (y in lst2), lst1) reduce(lambda

Re: python wiki gone?

2013-01-05 Thread Terry Reedy
On 1/5/2013 2:59 PM, Andrew Berg wrote: On 2013.01.05 13:07, Lee Harr wrote: When I go to wiki.python.org I get redirected to http://wiki.python.org/moin/ which is 404 Not Found. There's a security issue with moinmoin. The Python wiki is not the only wiki offline for this reason. For anyone d

Re: import of ttk

2013-01-05 Thread Terry Reedy
On 1/5/2013 2:21 PM, Verde Denim wrote: On 01/04/2013 11:39 PM, Terry Reedy wrote: On 1/4/2013 11:02 PM, Verde Denim wrote: In reading through one of the learning articles, I have a bit of code that imports ttk, but I apparently don't have this installed. I've looked up the svn ch

Re: Ubuntu Python -dbg packages

2013-01-06 Thread Terry Reedy
On 1/6/2013 8:42 AM, Lee Harr wrote: I am using: Ubuntu 12.10 Python 3.2.3 import has been considerably redone, and hopefully upgraded, in 3.3. Qt 4.8.2 PyQt 4.9.3 I also have the ubuntu -dbg packages: python3-dbg python3-pyqt4-dbg I don't understand why python3-dbg cannot import the PyQ

Re: Over 30 types of variables available in python ?

2013-01-06 Thread Terry Reedy
On 1/6/2013 6:12 PM, chaouche yacine wrote: booleans ints, floats, longs, complexes strings, unicode strings lists, tuples, dictionaries, dictionary views, sets, frozensets, buffers, bytearrays, slices functions, methods, code objects,modules,classes, instances, types, nulls (there is exactly on

Re: Ubuntu Python -dbg packages

2013-01-06 Thread Terry Reedy
On 1/6/2013 3:21 PM, Lee Harr wrote: On 1/6/2013 8:42 AM, Lee Harr wrote: I am using: Ubuntu 12.10 Python 3.2.3 import has been considerably redone, and hopefully upgraded, in 3.3. Ok, so now I tried python3.3-dbg but I don't think the pyqt modules are compiled for 3.3 and that may be pr

Re: Problem with Unicode char in Python 3.3.0

2013-01-07 Thread Terry Reedy
On 1/7/2013 7:57 AM, Franck Ditter wrote: <<< print('\U0001d11e') Traceback (most recent call last): File "", line 1, in print('\U0001d11e') UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e' in position 0: Non-BMP character not supported in Tk The message comes fro

Re: Vigil, the eternal morally vigilant programming language

2013-01-08 Thread Terry Reedy
On 1/7/2013 11:01 AM, Alain Ketterlin wrote: I just came across Vigil, an extension to python for serious software engineers, I hope that last part comes from a sense of humor. at https://github.com/munificent/vigil and thought everybody in this group would be interested (sorry if it has bee

Re: Problem with Unicode char in Python 3.3.0

2013-01-08 Thread Terry Reedy
On 1/7/2013 8:12 AM, Terry Reedy wrote: On 1/7/2013 7:57 AM, Franck Ditter wrote: <<< print('\U0001d11e') Traceback (most recent call last): File "", line 1, in print('\U0001d11e') UnicodeEncodeError: 'UCS-2' codec can't encode c

Re: test failed: test_urlwithfrag

2013-01-08 Thread Terry Reedy
On 1/7/2013 1:26 PM, Elli Lola wrote: $ ./python -m test -v test_urlwithfrag == CPython 3.3.0 (default, Jan 4 2013, 23:08:00) [GCC 4.6.3] == Linux-3.2.0-35-generic-pae-i686-with-debian-wheezy-sid little-endian == /home/me/Programme/Python/Python-3.3.0/build/test_python_30744 Testing with fl

Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-08 Thread Terry Reedy
On 1/7/2013 8:23 PM, Steven D'Aprano wrote: On Mon, 07 Jan 2013 22:32:54 +, Oscar Benjamin wrote: An example: Earlier today I was looking at some experimental data. A simple model of the process underlying the experiment suggests that two variables x and y will vary in direct proportion to

Re: socket.makefile raises ValueError when mode = 'rt'

2013-01-09 Thread Terry Reedy
On 1/9/2013 9:14 AM, Antoon Pardon wrote: Op 01/09/13 14:54, Dave Angel schreef: On 01/09/2013 08:22 AM, Antoon Pardon wrote: This is using python 3.2. ... But the documentation states: socket.makefile(mode='r', buffering=None, *, encoding=None, errors=None, newline=None) Return a file o

Re: Why BOM in logging message?

2013-01-10 Thread Terry Reedy
On 1/10/2013 11:06 AM, Roy Smith wrote: Well, this is fascinating. It turns out that while all of our machines report that they're running 2.7.3, they have two different versions of /usr/lib/python2.7/logging/handlers.py! -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/han

Re: PyWart: Import resolution order

2013-01-11 Thread Terry Reedy
On 1/11/2013 1:13 AM, Rick Johnson wrote: Python's import resolution order is terrible.[1] The fact that Python looks in the stdlib _first_ is not a good idea. And the fact is that it does not do so. The order depends on sys.path, and '' is the first entry. It would seem more intuitive fo

Re: pylint or similar to test version-specific language constructs?

2013-01-11 Thread Terry Reedy
On 1/11/2013 3:29 AM, The Night Tripper wrote: Gisle Vanem wrote: "jkn" wrote: I have to write python code which must run on an old version of python (v2.4) as well as a newer (v2.7). I am using pylint and would like to check if is possible to check with pylint the use of operators etc.

Re: Problem with importing in Python

2013-01-11 Thread Terry Reedy
On 1/11/2013 5:17 PM, su29090 wrote: Circle.py import math class circle: By current convention, you should call the file 'circle.py' and the class 'Circle'. Using all lower case for module filenames is the sanest thing to do in a world where different filesystems do different things with

Re: String concatenation benchmarking weirdness

2013-01-12 Thread Terry Reedy
On 1/12/2013 3:38 AM, wxjmfa...@gmail.com wrote: from timeit import timeit, repeat size = 1000 r = repeat("y = x + 'a'", setup = "x = 'a' * %i" % size) print('1:', r) r = repeat("y = x + 'é'", setup = "x = 'a' * %i" % size) print('2:', r) r = repeat("y = x + 'œ'", setup = "x = 'a' * %i" % size)

Re: stringbench (was Re: String concatenation benchmarking weirdness)

2013-01-12 Thread Terry Reedy
On 1/12/2013 6:42 AM, Chris Angelico wrote: On Sat, Jan 12, 2013 at 10:31 PM, Terry Reedy wrote: 0.410.4395.2("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower() Why does stringbench misspell the name Carmen Sandiego? Copyright avoidance? Or ignorance. Perhaps I w

Re: ANN: Python training "text movies"

2013-01-12 Thread Terry Reedy
On 1/13/2013 2:08 AM, Mitya Sirenef wrote: On 01/13/2013 01:35 AM, Steven D'Aprano wrote: On Sun, 13 Jan 2013 00:11:53 -0500, AK wrote: > >> I don't know what to call these, so for now I'll call them "training >> text movies" until I come up with a better name.. >> >> I hope these will be

Re: Finding the variables (read or write)

2013-01-14 Thread Terry Reedy
On 1/14/2013 4:28 PM, Chris Angelico wrote: On Tue, Jan 15, 2013 at 6:48 AM, wrote: I'd like to develop a small debugging tool for python programs.In Dynamic Slicing How can I find the variables that are accessed in a statement? And find the type of access (read or write) for those variables

Re: code explanation

2013-01-14 Thread Terry Reedy
On 1/14/2013 11:00 PM, Rodrick Brown wrote: Can someone explain what's going on here. def _build_magic_dispatcher(method): def inner(self, *args, **kwargs): return self.__dict__[method](*args, **kwargs) inner.__name__ = method return inner Nothing, until you run that wi

Re: atexit handler in IDLE?

2013-01-15 Thread Terry Reedy
On 1/15/2013 7:25 AM, Steve Spicklemire wrote: import atexit print "This is my program" def exit_func(): print "OK.. that's all folks!" atexit.register(exit_func) print "Program is ending..." If you put () around the strings, it will run the same *and* work in 3.x. When I run this on

Re: cymbalic reference?

2013-01-15 Thread Terry Reedy
On 1/15/2013 11:56 PM, rh wrote: I have this working and I am curious to know how others do same. class Abc(object): def __init__(self): pass def good(self): print "Abc good" def better(self): print "Abc better" urls = {'Abc':'http://example.com'} strin

Re: PyWart: Exception error paths far too verbose

2013-01-16 Thread Terry Reedy
On 1/16/2013 12:59 AM, Rick Johnson wrote: Python needs to trim the path to the source file from which the exception was caught and only display the relative path starting from your personal library folder. For example. Say your personal library exists in: C:\users\user\documents\python\lib .

Re: cymbalic reference?

2013-01-16 Thread Terry Reedy
On 1/16/2013 4:06 PM, rh wrote: My final product uses your suggestions along with one from the other post. I like the idea of storing the class name as the key. Then no call to globals() is needed. But I still have to test how that object behaves when it's a key. i.e. Is it deeply bound? Shall

Re: PyWart: Exception error paths far too verbose

2013-01-16 Thread Terry Reedy
On 1/16/2013 11:43 AM, Rick Johnson wrote: On Wednesday, January 16, 2013 3:53:55 AM UTC-6, Terry Reedy wrote: I agree with the complaint and you may have the germ of a good idea. The problem is that for some tracebacks, paths jump all over the place rather than having a common prefix. Dealing

Re: iterating over the lines of a file - difference between Python 2.7 and 3?

2013-01-17 Thread Terry Reedy
On 1/17/2013 7:04 AM, Peter Otten wrote: Wolfgang Maier wrote: I just came across an unexpected behavior in Python 3.3, which has to do with file iterators and their interplay with other methods of file/IO class methods, like readline() and tell(): Basically, I got used to the fact that it is a

Re: Thorough Python 2.7.3 Windows Build Documentation?

2013-01-17 Thread Terry Reedy
On 1/17/2013 10:29 AM, Leonard, Arah wrote: Hello fellow Python programmers, I’m building a 32-bit CPython 2.7.3 distro for Windows using the MS Visual Studio Professional 2008 SP1 (and all hotfixes) MSVC 9 compiler. My build works, technically, but it also happens to benchmark over 30% slower t

Re: Any built-in ishashable method ?

2013-01-18 Thread Terry Reedy
On 1/18/2013 5:36 AM, Jean-Michel Pichavant wrote: Hello people, Is there any built-in way to know if an object is a valid dictionary key ? For the instances of a class to be properly useable as set members or dict keys, __eq__ must return bool, __hash__ must return int, the __eq__ and __has

Re: Any built-in ishashable method ?

2013-01-18 Thread Terry Reedy
On 1/18/2013 6:56 AM, Jean-Michel Pichavant wrote: is there any valid test case You mean use case? where key1 != key2 and hash(key1) == hash(key2) ? This is the normal case. There are many unequal items that have the same hash. The point of using hash is to quickly find items in the set/di

Re: Question related to multiprocessing.Process

2013-01-19 Thread Terry Reedy
On 1/19/2013 12:05 AM, Chris Angelico wrote: On Sat, Jan 19, 2013 at 3:50 PM, Cen Wang wrote: Hi, when I use multiprocessing.Process in this way: from multiprocessing import Process class MyProcess(Process): def __init__(self): Process.__init__(self) def run(self):

Re: Messing with the GC

2013-01-19 Thread Terry Reedy
On 1/19/2013 9:47 AM, Jens Thoms Toerring wrote: The code comments mostly answer your questions about what happens or does not happen and when. The comments after add more detail. import sys class X( object ) : def __init__( self, parent, cnt ) : print( "In constructor for {0}

Re: PyWart: Exception error paths far too verbose

2013-01-20 Thread Terry Reedy
On 1/20/2013 1:08 AM, Steven D'Aprano wrote: On Sat, 19 Jan 2013 19:15:55 -0800, Ramchandra Apte wrote: [snip dozens of irrelevant quoted lines] Right-click the file in the traceback and there is an "Go to file/line" option. Please trim your replies so that the reader doesn't have to scroll

Re: Messing with the GC

2013-01-20 Thread Terry Reedy
On 1/20/2013 3:09 PM, Jens Thoms Toerring wrote: thank you for the explanations. I had overlooked the cyclic nature of what I had produced here and, of course, the GC can't be blamed for not collecting objects that are part of a cycle. The other question about the last refe- rence to an obj

Re: RE Help splitting CVS data

2013-01-20 Thread Terry Reedy
On 1/20/2013 5:04 PM, Garry wrote: I'm trying to manipulate family tree data using Python. I'm using linux and Python 2.7.3 and have data files saved as Linux formatted cvs files ... I'm stuck, comments and solutions greatly appreciated. Why are you not using the cvs module? -- Terry Jan Re

Re: Windows subprocess.call problem

2013-01-21 Thread Terry Reedy
On 1/21/2013 6:22 PM, Tom Borkin wrote: nob...@nowhere.com had an excellent suggestion that worked right off the bat and achieved exactly what I was after. Thanks all! And what was it? On Mon, Jan 21, 2013 at 9:04 AM, Dave Angel mailto:d...@davea.name>> wrote:

Re: pycache directories

2013-01-21 Thread Terry Reedy
On 1/21/2013 11:55 PM, monosij.for...@gmail.com wrote: I am doing some OO python3 where I am using multiple dirs/sub-dirs. So everything works fine, however when I run code __pycache__ directories are being created in every directory touched by the execution. This is much better than having mu

Re: Retrieving the full command line

2013-01-22 Thread Terry Reedy
On 1/22/2013 4:24 AM, Tim Golden wrote: [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, though]. I use the python -mpackage incantation to run a package which has a __main__.py module and which uses relative imports internally. I'm developing under cherrypy which includes

Understanding while...else...

2013-01-22 Thread Terry Reedy
Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if n > 0: n -= 1 else: n = None The else clause is executed if and when the condition is

Re: Understanding while...else...

2013-01-22 Thread Terry Reedy
On 1/22/2013 3:09 PM, Ethan Furman wrote: On 01/22/2013 09:44 AM, Terry Reedy wrote: Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if

Re: Understanding while...else...

2013-01-23 Thread Terry Reedy
On 1/22/2013 1:15 PM, Jean-Michel Pichavant wrote: - Original Message - Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple agreed on the last part. [snip long story] Did you just try to make it simple by showing the comp

Re: Understanding while...else...

2013-01-23 Thread Terry Reedy
On 1/22/2013 7:39 PM, Oscar Benjamin wrote: On 22 January 2013 23:41, Terry Reedy wrote: On 1/22/2013 3:09 PM, Ethan Furman wrote: On 01/22/2013 09:44 AM, Terry Reedy wrote: [SNIP] The else clause is executed if and when the condition is false. Now use a real Python while statement to do

Re: Arent these snippets equivalent?

2013-01-23 Thread Terry Reedy
On 1/23/2013 6:29 PM, Tim Chase wrote: On 01/23/13 16:47, Roy Smith wrote: while getchar() as c: putchar(c) That would give people (including me) the use case they're after most of the time (call a function, assign the return value, and test it). It's way less klunky than: while True:

Re: Galry, a high-performance interactive visualization package in Python

2013-01-29 Thread Terry Reedy
On 1/29/2013 1:23 PM, Cyrille Rossant wrote: The goal of this beta pre-release is to ensure that Galry can work on the widest possible range of systems and graphics cards (OpenGL v2+ is required). > From that site: "Mandatory dependencies include Python 2.7,"

Re: numpy array operation

2013-01-29 Thread Terry Reedy
On 1/29/2013 1:49 PM, Alok Singhal wrote: On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote: Is there a numpy operation that does the following to the array? 1 2 ==> 4 3 3 4 2 1 Thanks in advance. How about: import numpy as np a = np.array([[1,2],[3,4]]) a array([[1, 2], [3, 4]])

Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread Terry Reedy
On 1/30/2013 1:11 PM, MRAB wrote: On 2013-01-30 17:15, noydb wrote: I am looking for some guidance on using subprocess to execute an EXE with arguments and an output. The below code works in that it returns a 0 exit code, but no output file is created. I have tried a few different versions of

Re: (any)dbm module lacks a context manager

2013-01-31 Thread Terry Reedy
On 1/31/2013 2:03 PM, python.l...@tim.thechases.com wrote: I don't know if this has been remedied in a more recent version than I've got on my box (Debian Stable), but it seems like it should work out of the box: Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) [GCC 4.4.5] on linux2 Type "help",

Re: Help the visibility of Python in computational science

2013-01-31 Thread Terry Reedy
On 1/31/2013 8:05 PM, dg.google.gro...@thesamovar.net wrote: Hi everyone, There is currently a competition running that could help give Python in computational science a bit of visibility. The competition is for the most popular recently published article on the Scholarpedia website, one of whic

Re: Using an object inside a class

2012-01-23 Thread Terry Reedy
On 1/23/2012 2:44 PM, Jonno wrote: I have a pretty complicated bit of code that I'm trying to convert to more clean OOP. Without getting too heavy into the details I have an object which I am trying to make available inside another class. The reference to the object is rather long and convoluted

Re: String interning in Python 3 - missing or moved?

2012-01-23 Thread Terry Reedy
On 1/23/2012 9:25 PM, Chris Rebert wrote: On Mon, Jan 23, 2012 at 4:38 PM, Chris Angelico wrote: Python 2 can intern 'str' (bytes) strings (with the eponymous builtin, and with C API functions), though not unicode. Python 3 does not have that builtin, nor the C API; I can't find any support for

Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Terry Reedy
On 1/25/2012 11:02 AM, Adam Mercer wrote: Is this possible at all? If you are not willing to tell Debian Squeeze users to install 2.7, or that they cannot run your program, ask the bug reporter to tell you what version of OpenSSL the system comes with and code it into your program. Or poss

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Terry Reedy
On 1/25/2012 12:16 PM, Rick Johnson wrote: (?...) # Base Extension Syntax All extensions are wrapped in parenthesis and start with a question mark, but i believe the question mark was a very bad choice, since the I think that syntax came either from Perl or the pcre library used by several o

Re: to express unicode string

2012-01-28 Thread Terry Reedy
On 1/28/2012 2:58 PM, Michael Torrie wrote: On 01/28/2012 12:21 AM, contro opinion wrote: s='你好' On my computer, s is a byte string that contains the utf-8 formatted encoding of 你好. On mine, s is a (unicode) string containing those two characters. That is because I pasted the above into IDL

Re: object aware of others

2012-01-28 Thread Terry Reedy
On 1/28/2012 11:02 PM, Chris Angelico wrote: On Sun, Jan 29, 2012 at 2:48 PM, Lee Chaplin wrote: I am trying to create an object that is aware of other objects created before itself, and when found, then copy some attributes from them, something like: If you're looking only at other objects o

Re: Questions about "compiled" Python (beginner)

2012-01-29 Thread Terry Reedy
On 1/29/2012 12:57 PM, HoneyMonster wrote: I am new to Python (Python 2.7 on Linux). Research indicates that: a) "Compiling" Python modules into intermediate bytecode marginally improves load time. The improvement is larger the larger the file. You may notice that .pyc files are only created

Re: IDLE not setting current directory in its path

2012-01-30 Thread Terry Reedy
On 1/30/2012 10:06 AM, gujax wrote: Hi, When I open python shell and change to any directory, the sys.path always shows ' '. It actually shows '' (without a space). When I do the same with IDLE, it shows the name of the current directory i.e., ['name1', other paths...] instead of showing ['

Re: Disable use of pyc file with no matching py file

2012-01-30 Thread Terry Reedy
On 1/30/2012 4:30 PM, Roy Smith wrote: Every so often (typically when refactoring), I'll remove a .py file and forget to remove the corresponding .pyc file. If I then import the module, python finds the orphaned .pyc and happily imports it. Usually leading to confusing and hard to debug failures

Re: IDLE not setting current directory in its path

2012-01-30 Thread Terry Reedy
On 1/30/2012 3:15 PM, Terry Reedy wrote: This issue is under consideration at http://bugs.python.org/issue13506 It should be fixed before the next Python releases. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE not setting current directory in its path

2012-01-31 Thread Terry Reedy
On 1/31/2012 11:27 AM, gujax wrote: Thanks Terry, I see that the issue has been closed by you. However, I do not know how to run the patch on my Windows. Do I reinstall IDLE? Please suggest. I am using Python2.7 Choices: 1. Wait for the next 2.7 release, which should be within a month. Easiest

Re: Disable use of pyc file with no matching py file

2012-01-31 Thread Terry Reedy
On 1/31/2012 3:20 PM, John Roth wrote: On Jan 30, 3:43 pm, Terry Reedy wrote: On 1/30/2012 4:30 PM, Roy Smith wrote: Every so often (typically when refactoring), I'll remove a .py file and forget to remove the corresponding .pyc file. If I then import the module, python finds the orp

Re: Disable use of pyc file with no matching py file

2012-01-31 Thread Terry Reedy
On 1/31/2012 9:19 AM, Jean-Michel Pichavant wrote: A: "My wheel is flat" B: "Buy a new car" A better analogy would be Q. "How do I make my old model car do something (it cannot do)?" A. "Get the free new model that has that feature added." Of course, there is a cost to giving up the old and

Re: except clause syntax question

2012-01-31 Thread Terry Reedy
On 1/31/2012 8:57 AM, Charles Yeomans wrote: In any case, though I appreciate your attempt at a post hoc justification, > I was hoping for a positive explanation. I think the best you are going to get is that Python somewhat consistently*, for both practical and historical reasons#, uses tupl

Re: configobj

2012-01-31 Thread Terry Reedy
On 1/31/2012 11:06 AM, Andrea Crotti wrote: I have a couple of questions about configobj, which I'm happily trying to use for this project. When asking about 3rd party modules, please include a url, so we can be sure of what you mean and even take a look. Is www.voidspace.org.uk/python/config

Re: How can I verify if the content of a variable is a list or a string?

2012-01-31 Thread Terry Reedy
On 1/31/2012 7:44 PM, Andres Soto wrote: Hi, I'm writing a function which receive a list which elements are strings or new lists (sublists) containing strings. How can I verify if sone element of the list (which is contained in a variable) is a list or a string? I found the method isinstance(obje

Re: Disable use of pyc file with no matching py file

2012-02-01 Thread Terry Reedy
On 1/31/2012 11:14 PM, Roy Smith wrote: We would love to move to 3.x, for the better unicode support, if nothing else. What's keeping us from doing so is the host of third-party modules and tools we depend on that don't yet support 3.x. Tell that to the authors of packages you use so they no

Re: Disable use of pyc file with no matching py file

2012-02-01 Thread Terry Reedy
On 2/1/2012 6:14 AM, Devin Jeanpierre wrote: It really bothers me that you imagine that there are no other problems than the newness. And it bothers me that you imput such ignorance to me. You made what I think was a bad analogy and I made a better one of the same type, though still imperfec

Re: Disable use of pyc file with no matching py file

2012-02-01 Thread Terry Reedy
On 2/1/2012 8:11 AM, John Roth wrote: One other point: I'm unclear if a compiled module in the source directory would be named spam.pyc or spam.cpython-32.pyc. I'd think the latter to allow two versions of a compiled-only distribution. By test, it has to be spam.pyc, as before. -- Terry Jan R

Re: Buffering in Wing and IDLE 3

2012-02-01 Thread Terry Reedy
On 2/1/2012 10:17 AM, Franck Ditter wrote: I would prefer to use IDLE but as we are in France, the Python team does not seem to be aware that the ~ and others are not available on MacOS-X here (probably the same in Europe)... We are quite aware of the problem but cannot directly do anything ab

Re: Disable use of pyc file with no matching py file

2012-02-02 Thread Terry Reedy
On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: And it bothers me that you imput such ignorance to me. You made what I think was a bad analogy and I made a better one of the same type, though still imperfect. I acknowledged that the transition

Re: copy on write

2012-02-02 Thread Terry Reedy
On 2/2/2012 9:17 AM, John O'Hagan wrote: It's not so much about the type of x but that of x[1]. Wouldn't it be possible to omit the assignment simply if the object referred to by x[1] uses "+=" without creating a new object? That way, some_tuple[i] += y will succeed if some_tuple[i] is a list bu

Re: Python embeded in c++ application. Can't load python module if application is placed in folder with unicode chars.

2012-02-02 Thread Terry Reedy
On 2/2/2012 6:37 PM, Сергей Владимирович wrote: Hello. Please help me to import python module in my application that has python 2.7.2 embeded. I tried example from this link http://docs.python.org/extending/embedding.html#embedding-python-in-c paragraph 5.3. If i place program in folder D:\temp\t

Re: multiple constructor __init__

2012-02-02 Thread Terry Reedy
On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote: Hello all, I would like to instantiate my class as follow QObject(, ) QObject() an example would be http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html How can I do this without have to specify parent= in the second version (I al

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