Re: What the Pythons docs means by container ?

2015-02-18 Thread Terry Reedy
On 2/18/2015 2:43 PM, Ethan Furman wrote: Whether a contained object exists before it is accessed is irrelevant, is an implementation detail, and is a level of optimization. Is in not irrelevant in that virtual collections can be infinite. -- Terry Jan Reedy --

Re: What the Pythons docs means by container ?

2015-02-17 Thread Terry Reedy
On 2/17/2015 4:21 PM, candide wrote: Official Python documentation very frequently invokes a mysterious *container* data structure. The PLR manual explains : I use 'collection' rather than 'container'. -- Some objects contain references to other objects; these are

Re: Python discussed in Nature

2015-02-12 Thread Terry Reedy
On 2/12/2015 11:07 PM, Rustom Mody wrote: On Thursday, February 12, 2015 at 11:59:55 PM UTC+5:30, John Ladasky wrote: On Thursday, February 12, 2015 at 3:08:10 AM UTC-8, Fabien wrote: ... what a coincidence then that a huge majority of scientists (including me) dont care AT ALL about unicode.

Re: Bad text appearance in IDLE

2015-02-12 Thread Terry Reedy
On 2/12/2015 7:26 AM, ast wrote: Hello Here is how text appears in IDLE window http://www.cjoint.com/data/0BmnEIcxVAx.htm Do you get anything similar when running the console interpreter? Yesterday evening I had not this trouble. It appears this morning. I restarted my computer with no

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-02-11 Thread Terry Reedy
On 2/11/2015 8:04 AM, Albert van der Horst wrote: It is not until we assign the object to a name (which becomes thereby a function) that the __name__ thingy comes into play, like so. But __name__ would not come into play. f = x-x**2 This would mean to create an anonymous function object

Re: idle feature request

2015-02-11 Thread Terry Reedy
On 2/11/2015 1:00 PM, Mark Lawrence wrote: On 11/02/2015 13:11, Rustom Mody wrote: Context: I am using idle for taking python classes. Teaching or taking? Finish the class and run out usually in a hurry and forget to save the idle interaction window. Do you mean the shell window? Would

Re: warnings building 3.5 on Windows

2015-02-11 Thread Terry Reedy
On 2/11/2015 5:17 PM, Mark Lawrence wrote: There are loads of possible loss of data warnings such as. 15..\Modules\_tkinter.c(640): warning C4267: '+=' : conversion from 'size_t' to 'int', possible loss of data 15..\Modules\_tkinter.c(892): warning C4244: 'function' : conversion from

Re: idle feature request

2015-02-11 Thread Terry Reedy
On 2/11/2015 9:48 PM, Rustom Mody wrote: On Thursday, February 12, 2015 at 7:57:48 AM UTC+5:30, Terry Reedy wrote: If one saves the shell with 'save as', the filename is added to the title bar. If one does something more, the name in bracketed with *s to indicate the the memory buffer has

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Terry Reedy
On 2/9/2015 6:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input(What's your favourite takeaway?Pizza, Chinease or Indian?) if restraunt == (Pizza): fav = (1) As a style note, putting parentheses around strings is worse than

Re: [RELEASE] Python 3.4.3rc1 is now available

2015-02-08 Thread Terry Reedy
On 2/8/2015 5:06 PM, Mark Lawrence wrote: On 08/02/2015 22:00, Larry Hastings wrote: On behalf of the Python development community and the Python 3.4 release team, I'm happy to announce the availability of Python 3.4.3rc1. Python 3.4.3rc1 has many bugfixes and other small improvements over

Re: Indentation issues with python

2015-02-04 Thread Terry Reedy
class EventHubClient(object): ... def sendMessage(self,body,partition): ... ^ IndentationError: expected an indented block *** and 'def' is not indented as it must be. This must be covered in the tutorial. -- Terry

Re: __pycache__

2015-02-03 Thread Terry Reedy
On 2/2/2015 6:26 PM, Luke Lloyd wrote: I am in school and there is a problem with my code: When I try to run my code in the python code in the python shell it waits about 10 seconds then shows an error that says “IDLE’s subprocess didn’t make connection. Either IDLE can’t start a subprocess or

Re: Python tracker manual password reset

2015-01-31 Thread Terry Reedy
On 1/30/2015 10:46 AM, Ian Kelly wrote: I just tried to use the password recovery tool for the Python tracker. I entered my personal email. It sent me the confirmation email with the password reset link, which I followed. It then reset my password and sent an email to a different address, an old

Re: help() function screen output

2015-01-31 Thread Terry Reedy
On 1/31/2015 4:13 AM, Steven D'Aprano wrote: Jacob Kruger wrote: Using python 3.4 32 bit on windows 7 64 bit machine, and when, for example, type in something like the following in interpreter window: help(str) It will populate the screen with one full screen of information, with a prompt of

Re: unicode question

2015-01-27 Thread Terry Reedy
On 1/27/2015 12:17 AM, Rehab Habeeb wrote: Hi there python staff does python support arabic language for texts ? and what to do if it support it? i wrote hello in Arabic using codeskulptor and the powershell just for testing and the same error appeared( a sytanx error in unicode)!! I do not

Re: __bases__ misleading error message

2015-01-25 Thread Terry Reedy
On 1/25/2015 7:00 AM, Steven D'Aprano wrote: What happens inside the dictionary? Dictionaries are hash tables, so they are basically a big array of cells, and each cell is a pair of pointers, one for the key and one for the value: [dictionary header] [blank] [blank] [ptr to

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error: This is an anomalous situation.

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:14 PM, Mario Figueiredo wrote: In article 54c39366$0$13006$c3e8da3$54964...@news.astraweb.com, steve+comp.lang.pyt...@pearwood.info says... AttributeError: 'Sub' instance has no attribute '__bases__', AttributeError: 'foo' object has no attribute '__bases__'

Re: Hello World in Python

2015-01-24 Thread Terry Reedy
On 1/24/2015 6:53 PM, Christopher J. Pisz wrote: I am trying to help a buddy out. I am a C++ on Windows guy. This buddy of mine is learning Python at work on a Mac. I figured I could contribute with non language specific questions and such. When learning any new language, I said, the first step

Re: Python simple Code

2015-01-24 Thread Terry Reedy
On 1/24/2015 7:16 PM, Salem Alqahtani wrote: Hi Guys, I just joined the group and I hope that I can help and be active. I have a question about python. I wrote a code on python 2.7 and I want to choose from the list of names that I provide n!. I execute the code but the result or output is

Re: Delegation in Python

2015-01-24 Thread Terry Reedy
On 1/24/2015 5:57 PM, Brian Gladman wrote: I would appreciate advice on how to set up delgation in Python. I am continuously implementing a function to test whether a Python Fraction is an integer Since Fractions are reduced to lowest terms, from fractions import Fraction as F F(4, 2)

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:51 PM, Marco Buttu wrote: On 24/01/2015 20:24, Terry Reedy wrote: On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last

Re: Random ALL CAPS posts on this group

2015-01-23 Thread Terry Reedy
On 1/23/2015 5:40 PM, sohcahto...@gmail.com wrote: On Monday, January 19, 2015 at 4:16:13 PM UTC-8, Luke Tomaneng wrote: Has anyone noticed these? There have been about three of them recently and they don't seem to have anything to do with Python at all. Does anyone know if there is a good

Re: Comparisons and sorting of a numeric class....

2015-01-23 Thread Terry Reedy
On 1/23/2015 6:46 AM, Andrew Robinson wrote: -- because people seem to have a very wrong idea about bool's nature as a dualton being somehow justified solely by the fact that there are only two values in Boolean logic; For, singletons style programming is not justified by the number of values

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-22 Thread Terry Reedy
On 1/22/2015 8:15 PM, Rick Johnson wrote: Okay, i have found a solution to the type hinting problem that will appease both sides. On one side we have those who are proposing type hinting annotations within function sigs, and on the other side, we have those who oppose the implementation of type

Re: Python is DOOMED! Again!

2015-01-22 Thread Terry Reedy
On 1/22/2015 7:40 PM, Sturla Molden wrote: On 22/01/15 21:03, Mario Figueiredo wrote: That is fine. But then the problem isn't type hinting, is it? Neither I think you are suggesting we don't introduce language because there are bad project managers out there. The problem is then bad project

Re: Python is DOOMED! Again!

2015-01-22 Thread Terry Reedy
On 1/22/2015 3:44 PM, Rick Johnson wrote: On Thursday, January 22, 2015 at 12:28:47 PM UTC-6, Mark Lawrence wrote: Evidence in completely the opposite direction if I'm reading this correctly [snip link] The main use case of type hinting is static analysis using an external tool without

Re: Python is DOOMED! Again!

2015-01-22 Thread Terry Reedy
On 1/22/2015 8:06 PM, Rick Johnson wrote: On Thursday, January 22, 2015 at 4:25:37 PM UTC-6, Mario Figueiredo wrote: 1. Annotations where created exactly for this purpose. So there's some preassure to put them to work on what they were always meant to be used for. Yes, i whole heartily

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-22 Thread Terry Reedy
On 1/22/2015 10:59 PM, Chris Angelico wrote: On Fri, Jan 23, 2015 at 2:22 PM, Terry Reedy tjre...@udel.edu wrote: This idea is so brilliant that it is already an option in mypy and is part of the new type-hint proposal. The separate type-hint files are called 'stub files'. It's worth

Re: Python is DOOMED! Again!

2015-01-22 Thread Terry Reedy
On 1/22/2015 3:24 AM, Rick Johnson wrote: Yes, YES, *YES* That would be my first choice, or docstrings as a secondary. But to introduce new syntax into the method signatures is SUICIDE! What the hell is this man thinking? You are years late for complaining about new signature syntax. The

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Terry Reedy
On 1/21/2015 7:16 PM, Mario Figueiredo wrote: In article 873873ae91@jester.gateway.sonic.net, no.email@nospam.invalid says... Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: In 2009, Robert Martin gave a talk at RailsConf titled What Killed Smalltalk Could Kill Ruby...

Re: Trees

2015-01-20 Thread Terry Reedy
On 1/20/2015 4:47 PM, Mario wrote: In article d34dbfbe-fe82-47dc-8bc3-c8773e2b7...@googlegroups.com, rustompm...@gmail.com says... Yeah python has trees alright. Heres' some simple tree-code Didn't you just demonstrate that Python has no trees and instead you have to implement them yourself

Re: Trees

2015-01-19 Thread Terry Reedy
On 1/19/2015 5:06 PM, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Sequences nested withing sequences can be regarded as trees, and Python has these. I regard Lisp as a tree processing languages, as it must be to manipulate, for example, code with nested

Re: Comparisons and sorting of a numeric class....

2015-01-13 Thread Terry Reedy
On 1/13/2015 1:13 AM, Chris Angelico wrote: On Tue, Jan 13, 2015 at 4:32 PM, Steven D'Aprano st...@pearwood.info wrote: Crashing the interpreter from pure Python code is *absolutely not allowed*, so anything which would allow that is forbidden. Except when you willingly shoot yourself in the

Re: Why do the URLs of posts here change?

2015-01-10 Thread Terry Reedy
On 1/9/2015 7:04 AM, Skip Montanaro wrote: Posts on this newsgroup/mailing list are archived on the web, but the URLs seem to change, which leaves dead links if you search for things. Steven, It's a known issue, but one which appears to be somewhat unavoidable, at least in Mailman 2.x. The

Re: Non-unique dirs in sys.path

2015-01-10 Thread Terry Reedy
On 1/9/2015 8:14 AM, Gisle Vanem wrote: I'm having some trouble understanding why my Python 2.7.9 has the '%PYTHONHOME%\lib\site-packages' listed multiple times. I cooked up this .bat file to demonstrate the issue: @echo off setlocal set PYTHONPATH= python -c import sys;

Re: Playing with threads

2015-01-07 Thread Terry Reedy
On 1/7/2015 9:00 PM, Ganesh Pal wrote: Hi friends, I'm trying to use threads to achieve the below work flow 1. Start a process , while its running grep for a string 1 2. Apply the string 1 to the command in step 1 and exit step 2 3. Monitor the stdout of step1 and print success if the is

Re: Comparisons and sorting of a numeric class....

2015-01-06 Thread Terry Reedy
On 1/6/2015 9:01 PM, Andrew Robinson wrote: [snip] There are very few (about 4) builtin classes that cannot be subclassed. bool is one of those few, float is not. Go ahead and subclass it. class F(float): pass F class '__main__.F' F(2.3) + F(3.3) 5.6 -- Terry Jan Reedy --

Re: Help with map python 2

2015-01-05 Thread Terry Reedy
On 1/5/2015 6:33 AM, flebber wrote: You could do what mathematicians do when they deal with alternating signs: they raise -1 to the power of the index to get an appropriate multiplier. [ n * (-1) ** n for n in range(10) ] [0, -1, 2, -3, 4, -5, 6, -7, 8, -9] Mathematicians operating

Re: Python Tk Tix GUI documentation builder overview and tips

2015-01-04 Thread Terry Reedy
On 1/4/2015 3:23 AM, Christian Gollwitzer wrote: Am 03.01.15 um 22:57 schrieb Terry Reedy: The current doc is wrong in any case. I opened http://bugs.python.org/issue23156 Tix is a compiled extension, so this tix8.4.3.dll is needed as well as a couple of .tcl file including pkgIndex.tcl

Re: Help with map python 2

2015-01-04 Thread Terry Reedy
On 1/4/2015 6:34 AM, flebber wrote: In repsonse to this question: Write a program that prints the first 100 members of the sequence 2, -3, 4, -5, 6, -7, 8. This is my solution it works but ugly. series = range(2,100) # answer = [(x,(y* -1)) for x, y in series[::2]] # print(answer) answer = []

Re: Python Tk Tix GUI documentation builder overview and tips

2015-01-03 Thread Terry Reedy
On 1/3/2015 1:30 PM, aba...@gmail.com wrote: Hi, I have had issues running Tix on python 2.7.6 and 3.4.2: More details on the issue here. http://stackoverflow.com/questions/27751923/tix-widgets-installation-issue Has anyone had similar issues with Tix? The current doc is wrong in any case.

Re: list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread Terry Reedy
On 1/3/2015 6:19 PM, austin aigbe wrote: I am currently implementing the LTE physical layer in Python (ver 2.7.7). For the qpsk, 16qam and 64qam modulation I would like to know which is more efficient to use, between an integer comparison and a list comparison: Integer comparison: bit_pair as

Re: Drag and Drop Images in Python (NEED HELP!)

2015-01-01 Thread Terry Reedy
On 1/1/2015 7:36 PM, lucas mvm wrote: a different introduction to the same code posted 6 hours earlier. Read and study both of the answers already given about an hour after the first post. Ignoring them and reposting, with 'NEED HELP!' no less, is rude. I strongly suggest you do the exercise

Re: Python 3.4.2 64-bit Installer

2014-12-30 Thread Terry Reedy
On 12/30/2014 7:21 PM, MRAB wrote: On 2014-12-30 22:45, Toni Bajer wrote: When I try to run the Python 3.4.2 64-bit Installer on Windows 7 it gets about 90% through and then a new box pops up with the following message... There is a problem with this Windows Installer package. A program

Re: Searching through more than one file.

2014-12-28 Thread Terry Reedy
On 12/28/2014 12:27 PM, Seymore4Head wrote: I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through a directory of files that have different

Configuring code editors (was Re: IDLE ...)

2014-12-23 Thread Terry Reedy
On 12/23/2014 10:24 AM, pypythotho wrote: In Command Prompt, 'python -m idlelib' helped me to dicover the problem source. An explicit message told that an indentation was insconsistant in the file ntpath.py I modified previously with notepad++. I replaced a tab by 4 spaces and IDLE run again

Re: [Distutils] Release: pip 6.0 and virtualenv 12.0

2014-12-23 Thread Terry Reedy
On 12/23/2014 12:27 PM, Mark Lawrence wrote: I chanced upon this https://mail.python.org/pipermail/distutils-sig/2014-December/025450.html via twitter and thought it would be of interest here. I'll assume that by the time I hit 'Send' it'll have arrived on the announcements mailing list :)

Re: learning to use iterators

2014-12-23 Thread Terry Reedy
On 12/23/2014 1:55 PM, Seb wrote: def n_grams(a, n): ... z = (islice(a, i, None) for i in range(n)) ... return zip(*z) I'm impressed at how succinctly this islice helps to build a list of tuples with indices for all the required windows. However, I'm not quite following what goes

Re: learning to use iterators

2014-12-23 Thread Terry Reedy
On 12/23/2014 4:25 PM, Ben Finney wrote: Ian Kelly ian.g.ke...@gmail.com writes: On Tue, Dec 23, 2014 at 11:55 AM, Seb splu...@gmail.com wrote: Particulary, what do the parentheses do there? The parentheses enclose a generator expression, which is similar to a list comprehension [1] but

Re: what is wrong with d.clear()?

2014-12-22 Thread Terry Reedy
On 12/21/2014 2:28 AM, shawool wrote: where am i going wrong ? You clear sys.modules, which apparently CPython uses in its normal function. Python 3.2.5 (default, Oct 2 2013, 22:58:11) d = {} import sys d = sys.modules type(d) class 'dict' dir(d) ['__class__', '__contains__',

Re: List Comprehensions

2014-12-22 Thread Terry Reedy
On 12/22/2014 12:10 PM, Chris Angelico wrote: On Tue, Dec 23, 2014 at 2:18 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Chris Angelico wrote: On Mon, Dec 22, 2014 at 8:21 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: If the called function has

Re: Hello World

2014-12-20 Thread Terry Reedy
On 12/21/2014 12:31 AM, Chris Angelico wrote: On Sun, Dec 21, 2014 at 4:14 PM, CM cmpyt...@gmail.com wrote: I ran it in IDLE with Python 2.7.8 and got: Traceback (most recent call last): File C:/Python27/helloworld.py, line 39, in module lambda _, __, ___, , _, __, ___,

Re: Bug? Feature? setattr(foo, '3', 4) works!

2014-12-19 Thread Terry Reedy
On 12/19/2014 6:40 AM, Cem Karan wrote: I'm bringing this discussion over from the python-ideas mailing list to see what people think. I accidentally discovered that the following works, at least in Python 3.4.2: class foo(object): ... pass ... setattr(foo, '3', 4) dir(foo) ['3',

Re: problems with Methods in Python 3.4.2

2014-12-18 Thread Terry Reedy
On 12/18/2014 12:27 PM, Marcus Lütolf wrote: Learn to use dir to fine valid names. 1)I am trying to do this: dir(_builtins_) I am getting this: Traceback (most recent call last): File pyshell#0, line 1, in module dir(_builtins_) NameError: name '_builtins_' is not defined dir()

Re: Is there a way to schedule my script?

2014-12-18 Thread Terry Reedy
On 12/18/2014 8:55 PM, Juan Christian wrote: On Thu Dec 18 2014 at 11:35:11 PM Chris Angelico ros...@gmail.com mailto:ros...@gmail.com wrote: Why does this matter to you? Why am I getting the feeling that I should not be helping you? Because that's what my project is all about, I need to fake

Re: Classes - converting external function to class's method.

2014-12-14 Thread Terry Reedy
On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: Ivan Evstegneev wrote: I have stuck a bit with this example(took this one from the book). Here are a description steps of what I've done till now: Step 1 - creating an empty namespace: class rec: pass IMHO that is not actually

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Terry Reedy
On 12/10/2014 5:04 PM, Bruno Cauet wrote: I hesitated a while before deciding not to include it! Apart from python core development what would be the reasons to work mostly on this version ? where 'This version' == 3.5. A possible reason: one is developing an app expected to be released fall

Re: Extension of while syntax

2014-12-11 Thread Terry Reedy
On 12/11/2014 9:21 PM, Nelson Crosby wrote: I was thinking a bit about the following pattern: value = get_some_value() while value in undesired_values: value = get_some_value() This is do_while or do_until. In Python, write it as do_until in this form. while True: value =

Re: Python Iterables struggling using map() built-in

2014-12-10 Thread Terry Reedy
On 12/10/2014 11:46 AM, Ian Kelly wrote: I don't particularly have a problem with functions having attributes, e.g. I think itertools.chain.from_iterable is just peachy. There is a downside though, which is that making those functions attributes of another function rather than of the module

Re: Python Iterables struggling using map() built-in

2014-12-10 Thread Terry Reedy
On 12/10/2014 3:32 PM, Ian Kelly wrote: So Idle gets it right. At least for static methods of classes, which isn't very surprising. Does it complete a function attribute of a function? def f(): pass f.a='attr' f. box with 'a' as possible completion. Having used Komodo IDE for a number

Re: Python Iterables struggling using map() built-in

2014-12-09 Thread Terry Reedy
On 12/9/2014 12:03 AM, Terry Reedy wrote: Roy Smith wrote: Chris Angelico wrote: def myzip(*args): iters = map(iter, args) while iters: res = [next(i) for i in iters] yield tuple(res) Ugh. When I see while foo, my brain says, OK, you're about to see a loop

Re: Nested loops is strangely slow, totally at a loss.

2014-12-09 Thread Terry Reedy
On 12/10/2014 1:53 AM, Chris Angelico wrote: On Wed, Dec 10, 2014 at 5:44 PM, Steven D'Aprano st...@pearwood.info wrote: It would be nice if product iterators behaved like xrange() objects and could perform in tests without exhausting the iterator, but they don't. That's sad. It'd be very

Re: When do default parameters get their values set?

2014-12-08 Thread Terry Reedy
def f(a=default +arg value): return a f.__defaults__ ('default arg value',) Before any calls, the expression has be evaluated. When f() is called with no arg, the local name 'a' is associated with 'default arg value'. Then code execution begins. Use dir(f), for instance, to invesigate

Re: Question on lambdas

2014-12-08 Thread Terry Reedy
On 12/8/2014 8:53 PM, Chris Angelico wrote: On Tue, Dec 9, 2014 at 12:44 PM, Christoph Becker cmbecke...@gmx.de wrote: Ben Finney wrote: It's best to remember that ‘lambda’ is syntactic sugar for creating a function; the things it creates are not special in any way, they are normal functions,

Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Terry Reedy
On 12/8/2014 9:50 PM, Steven D'Aprano wrote: Roy Smith wrote: Chris Angelico wrote: def myzip(*args): iters = map(iter, args) while iters: res = [next(i) for i in iters] yield tuple(res) Ugh. When I see while foo, my brain says, OK, you're about to see a loop

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Terry Reedy
On 12/5/2014 3:51 PM, John J Posner wrote: The defaultdict documentation is confusing on this point. A *long* time ago, I filed Bug 9536 to improve the doc, but the fix hasn't bubbled to the surface yet. Untrue. Your patch 'bubbled to the surface' and got provisionally rejected in 5 hours

Re: Tuple of lists concatenation - function vs comprehension

2014-12-07 Thread Terry Reedy
On 12/7/2014 10:28 AM, Ivan Evstegneev wrote: Hi Shiyao, Now I see, that it was kind of dumb question... x = ([1, 2], [3, 4], [5, 6]) L = [] [L.extend(i) for i in x] [None, None, None] Using a list comprehension for the expression side-effect, when you do not actually want the list

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Terry Reedy
On 12/7/2014 7:12 PM, Roy Smith wrote: Chris Angelico wrote: I'm actually glad PEP 479 will break this kind of code. Gives a good excuse for rewriting it to be more readable. Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What kind of code is that? Short, simple, Pythonic and

Re: Reasons for source code line length limits

2014-12-07 Thread Terry Reedy
On 12/7/2014 11:44 PM, Ben Finney wrote: Much more relevant is the ability to have two or even three code windows side-by-side, for comparison during a merge operation. For this purpose, a 75–80 column limit is a great help. Or Idle Shell | Idle editor1 | Idle editor2 Editor 1 has file being

Re: jitpy - Library to embed PyPy into CPython

2014-12-05 Thread Terry Reedy
On 12/5/2014 2:54 PM, Mark Lawrence wrote: For those who haven't heard thought this might be of interest https://github.com/fijal/jitpy So the old cpython module psyco which became the pypy jit is back as jitpy. Nice. -- Terry Jan Reedy --

Re: How is max supposed to work, especially key.

2014-12-04 Thread Terry Reedy
On 12/4/2014 5:35 AM, Albert van der Horst wrote: I agree that it is a useful function and that it is doing the right thing. What is wrong is the name. I refer to the fact that it is not returning the maximum. It returns the iterator value that leads to the maximum. A function that doesn't

Re: Is Python installer/un-installer buggy on Windows?

2014-12-04 Thread Terry Reedy
On 12/4/2014 11:46 AM, Aseem Bansal wrote: Yeah, the problem seems to be with registry as every solution seems to be fiddling with registry. One can edit the registry directly with regedit. If you try it, follow the instruction to first make a backup. Look for a regedit tutorial on the

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Terry Reedy
On 12/3/2014 6:02 AM, Chris Angelico wrote: When importing a module from a subpackage, it's sometimes convenient to refer to it throughout the code with a one-part name rather than two. I'm going to use 'os.path' for the examples, but my actual use-case is a custom package where the package name

Re: Is Python installer/un-installer buggy on Windows?

2014-12-03 Thread Terry Reedy
On 12/3/2014 10:16 PM, Aseem Bansal wrote: I am using 32-bit Python on a 64-bit Windows. Edit with IDLE is missing from the context menu. I am working on Windows 7. I have searched on google a lot and have tried everything said in superuser, stackoverflow etc. I have even tried re-installing

Re: tabs with tkinter

2014-11-29 Thread Terry Reedy
On 11/29/2014 2:50 AM, Peter Otten wrote: Terry Reedy wrote: On 11/28/2014 10:52 AM, Peter Otten wrote: ast wrote: I have been using tkinter for few weeks now and I didn't found how to make some tabs on a window. see this picture for a window with tabs http://www.computerhope.com/jargon/t

Re: tabs with tkinter

2014-11-28 Thread Terry Reedy
On 11/28/2014 10:52 AM, Peter Otten wrote: ast wrote: I have been using tkinter for few weeks now and I didn't found how to make some tabs on a window. see this picture for a window with tabs http://www.computerhope.com/jargon/t/tabs.gif Isn't it feasible with tkinter ? See

Re: bug or feature in enum34 py2.7 backport?

2014-11-26 Thread Terry Reedy
On 11/26/2014 10:32 AM, random...@fastmail.us wrote: It seems like if it is a bug to reject long where int is accepted, I do not believe that is universally true is 2.7. But even if it is... Short ints were, value-wise, a subset of longs. Thus, for example, binary operations could always

Re: Infinitely nested containers

2014-11-22 Thread Terry Reedy
On 11/21/2014 2:30 PM, Zachary Ware wrote: On Fri, Nov 21, 2014 at 12:37 PM, Ian Kelly ian.g.ke...@gmail.com wrote: Here's a nice crash. I thought this might similarly produce a recursion depth error, but no, it's a seg fault! $ cat test.py import itertools l = [] it =

Re: Is StopIteration a singleton?

2014-11-20 Thread Terry Reedy
On 11/20/2014 12:09 AM, Steven D'Aprano wrote: No idea. But you can marshal StopIteration itself, but not StopIteration instances: py marshal.dumps(StopIteration) 'S' py marshal.dumps(StopIteration()) Traceback (most recent call last): File stdin, line 1, in module ValueError:

Re: GUI toolkit(s) status

2014-11-20 Thread Terry Reedy
On 11/20/2014 4:04 AM, Christian Gollwitzer wrote: Tcl nor Tk support Unicode outside the BMP. Full Unicode support is a big todo item on the wishlist for Tcl 9, for Tk nobody really knows. We are lacking manpower and people with specialized knowledge. Tcl/Tk currently use UCS-2, which only

Re: Is StopIteration a singleton?

2014-11-20 Thread Terry Reedy
On 11/20/2014 11:23 PM, Chris Angelico wrote: On Fri, Nov 21, 2014 at 2:40 PM, Terry Reedy tjre...@udel.edu wrote: On 11/20/2014 12:09 AM, Steven D'Aprano wrote: No idea. But you can marshal StopIteration itself, but not StopIteration instances: py marshal.dumps(StopIteration) 'S' py

Re: tkinter mainloop

2014-11-19 Thread Terry Reedy
On 11/19/2014 3:46 AM, ast wrote: Hello mainloop() is a window method which starts the event manager which tracks for events (mouse, keyboard ...) to be send to the window. But if I forget the root.mainloop() in my program, it works well anyway, I cant see any failure. Why ? Second question,

Re: I dont understand root['bg'] = 'red' where root is a tkinter.Tk object

2014-11-17 Thread Terry Reedy
On 11/17/2014 8:32 AM, ast wrote: Hello, import tkinter root = tkinter.Tk() Let's see all attributes of root: root.__dict__ {'master': None, 'children': {}, '_tclCommands': ['tkerror', 'exit', '13825848destroy'], 'tk': tkapp object at 0x02949C28, '_tkloaded': 1} Now we change the

Re: isiter builtin

2014-11-16 Thread Terry Reedy
On 11/16/2014 2:57 AM, Garrett Berg wrote: (how often have you iterated over a string?) Often enough, but perhaps more often have written functions for which a string is as valid an input as many other iterables. def cross(iterable, reiterable): for a in iterable: for b in

Re: import graphics library; causes error

2014-11-16 Thread Terry Reedy
On 11/16/2014 3:39 PM, ryguy7272 wrote: These libraries drive me totally nuts. Sorry, just had to get it out there. Anyway, I open the cmd window, and typed this: 'easy_install python graphics'. In what directory? So, it starts up and runs/downloads the appropriate library from the web. I

Re: Using map()

2014-11-16 Thread Terry Reedy
On 11/16/2014 8:01 AM, Pavel Volkov wrote: I checked my modules with pylint and saw the following warning: W: 25,29: Used builtin function 'map' (bad-builtin) Why is the use of map() discouraged? It' such a useful thing. I consider that to be a bug in pylint. It misstates a careless 'bad'

Re: Error when trying to open an image

2014-11-16 Thread Terry Reedy
On 11/16/2014 2:37 PM, Abdul Abdul wrote: Hello, I'm trying to open an image using the `Python Imaging Library` as follows: from PIL import Image img = Image.open('xyz.jpg') But, got the following error: File C:/Users/abc/PycharmProjects/untitled/open_image.py, line 2, in module from

Re: A Freudian slip of *EPIC PROPORTIONS*!

2014-11-15 Thread Terry Reedy
On 11/15/2014 7:28 AM, Steven D'Aprano wrote: Terry Reedy wrote: On 11/13/2014 6:11 PM, Rick Johnson wrote: # The parse functions have no idea what to do with # Unicode, so replace all Unicode characters with x. # This is safe so long as the only characters germane

Re: Decorators

2014-11-15 Thread Terry Reedy
On 11/15/2014 8:24 AM, Marko Rauhamaa wrote: I'd take top-posting if I were enlightened about how decorators could be valuable. Here is part of the original rationale. @deco(arg) def f: suite is (for this discussion) equivalent to def f: suite f = deco(arg)(f) The latter requires writing

Re: Two locations for module struct ?

2014-11-14 Thread Terry Reedy
On 11/14/2014 10:11 AM, ast wrote: Hello In module wave there is a sub module struct. struct is not a documented part of the wave module. You can call function pack() with: import wave val = wave.struct.pack(...) wave imports several other stdlib modules. All are accessible the same

Re: Array of Functions

2014-11-14 Thread Terry Reedy
On 11/14/2014 5:17 PM, Richard Riehle wrote: In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like

Re: help please: tkinter grid layout is very slow

2014-11-13 Thread Terry Reedy
On 11/13/2014 3:45 PM, Rich Cook wrote: Hi, I'm trying to toss together an image browser in tkinter, and it is so slow it is unworkable. Here is my code. Can someone point out why it's so slw? :-) Thanks root = Tkinter.Tk() root.geometry(1000x280+300+300) label = Tkinter.Button(root,

Re: A Freudian slip of *EPIC PROPORTIONS*!

2014-11-13 Thread Terry Reedy
On 11/13/2014 6:11 PM, Rick Johnson wrote: # The parse functions have no idea what to do with # Unicode, so replace all Unicode characters with x. # This is safe so long as the only characters germane # to parsing the structure of Python are 7-bit ASCII. # It's

A new Help Vampire? (was Re: (too many threads)

2014-11-13 Thread Terry Reedy
On 11/13/2014 7:51 PM, satishmlm...@gmail.com wrote: in 4 different threads How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? fileno() in not supported. Is it only in 3.1? What is the workaround? io.UnsupportedOperation: fileno How to give a file descriptor number to this

Re: I love assert

2014-11-12 Thread Terry Reedy
On 11/11/2014 5:52 PM, Ben Finney wrote: Terry Reedy tjre...@udel.edu writes: We love 'assert' so much that we have 20-30 'assertXYZ' variations in unittest. A function will not be disabled by a run-time option to the Python interpreter. The statement 'assert expression' is almost

Re: Moving a window on the screen

2014-11-12 Thread Terry Reedy
On 11/8/2014 3:31 PM, Akira Li wrote: Terry Reedy tjre...@udel.edu writes: On my Win7 machine, your complicated code is much worse as it causes the window to jump about every half second After cutting and pasting again, I do not see the jumps. I do not have the code I ran before to compare

Re: How about some syntactic sugar for __name__ == '__main__' ?

2014-11-12 Thread Terry Reedy
On 11/12/2014 4:02 PM, John Ladasky wrote: I have taught Python to several students over the past few years. As I have worked with my students, I find myself bothered by the programming idiom that we use to determine whether a module is being executed or merely imported: if __name__ ==

Re: How about some syntactic sugar for __name__ == '__main__' ?

2014-11-12 Thread Terry Reedy
On 11/12/2014 6:26 PM, Chris Angelico wrote: On Thu, Nov 13, 2014 at 10:19 AM, Terry Reedy tjre...@udel.edu wrote: Functions have an implicit 'return None' at the end (which, in CPython, become an explicit pair of bytecodes, even when the function already ends with return something

Re: I love assert

2014-11-11 Thread Terry Reedy
On 11/11/2014 2:40 PM, Peter Cacioppi wrote: I get the impression that most Pythonistas aren't as habituated with assert statements as I am. Is that just a misimpression on my part? If not, is there a good reason to assert less with Python than other languages? We love 'assert' so much that we

<    11   12   13   14   15   16   17   18   19   20   >