[issue33185] Python 3.7.0b3 fails in pydoc where b2 did not.

2018-03-30 Thread Ned Batchelder
Ned Batchelder <n...@nedbatchelder.com> added the comment: Turns out it's even simpler: $ pydoc itertools No module named 'ast' # !!! -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33185] Python 3.7.0b3 fails in pydoc where b2 did not.

2018-03-30 Thread Ned Batchelder
New submission from Ned Batchelder <n...@nedbatchelder.com>: "pydoc coverage" worked with 3.7b2, but fails with a surprising ModuleNotFoundError for configparser with b3. The configparser is importable in the Python interpreter. I tried with -v to what import

Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-26 Thread Ned Batchelder
On 3/26/18 7:10 PM, Python wrote: Humans are already good enough at making mistakes that they require no additional encouragement, such as what is provided by allowing such syntactical horrors. Agreed. And that's why we must respect and follow the code styling wisdom which has been passed down

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 12:39 PM, Malcolm Greene wrote: Perhaps it doesn't need to be said, but just to be sure: don't use eval if you don't trust the people writing the configuration file. They can do nearly unlimited damage to your environment.  They are writing code that you are running. Of course!

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 4:30 AM, Malcolm Greene wrote: Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following

Re: [OT] Re: Thank you Python community!

2018-03-20 Thread Ned Batchelder
On 3/20/18 12:08 PM, Rick Johnson wrote: On Tuesday, March 20, 2018 at 7:03:11 AM UTC-5, Adriaan Renting wrote: (on the subject of the opioid epidemic) The [OT] in the subject line is right: let's not get off on a political tangent. --Ned. --

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Ned Batchelder
On 3/19/18 1:04 PM, Irv Kalb wrote: I am building some classes for use in future curriculum. I am using PyCharm for my development. On the right hand edge of the PyCharm editor window, you get some little bars indicating warnings or errors in your code. I like this feature and try to clean

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 12:35 PM, Peter Otten wrote: Ned Batchelder wrote: On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski <arek.bul...@gmail.com>: I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a list comprehension over individual

[issue32305] Namespace packages have inconsistent __file__ and __spec__.origin

2018-03-05 Thread Ned Batchelder
Ned Batchelder <n...@nedbatchelder.com> added the comment: As is usual for me, I am here because some coverage.py code broke due to this change. A diff between b1 and b2 found me the code change (thanks for the comment, btw!), but a What's New doesn't seem out of

[issue32305] Namespace packages have inconsistent __file__ and __spec__.origin

2018-03-05 Thread Ned Batchelder
Ned Batchelder <n...@nedbatchelder.com> added the comment: Should this get an entry in the What's New? -- nosy: +nedbat ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 5:25 PM, Ooomzay wrote: On Sunday, 4 March 2018 14:37:30 UTC, Ned Batchelder wrote: Are you including cyclic references in your assertion that CPython behaves as you want? Yes. Because the only behaviour required for RAII is to detect and debug such cycles in order to eliminate

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 9:11 AM, Ooomzay wrote: I am well aware of what it will mean for interpreters. For some interpreters it will have zero impact (e.g. CPython) ... There's no point continuing this if you are just going to insist on falsehoods like this.  CPython doesn't currently do what you want,

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 7:37 AM, Ooomzay wrote: On Sunday, 4 March 2018 04:23:07 UTC, Steven D'Aprano wrote: [...] [This PEP] imposes enormous burdens on the maintainers of at least five interpreters (CPython, Stackless, Jython, IronPython, PyPy) all of which will need to be re-written to have RAII

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 8:26 AM, Ooomzay wrote: On Sunday, 4 March 2018 03:16:31 UTC, Paul Rubin wrote: Chris Angelico writes: Yep, cool. Now do that with all of your smart pointers being on the heap too. You are not allowed to use ANY stack objects. ANY. Got it? That's both

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-03 Thread Ned Batchelder
On 2/28/18 6:53 PM, ooom...@gmail.com wrote: On Wednesday, February 28, 2018 at 11:45:24 PM UTC, ooo...@gmail.com wrote: On Wednesday, February 28, 2018 at 11:02:17 PM UTC, Chris Angelico wrote: On Thu, Mar 1, 2018 at 9:51 AM, ooomzay wrote: [snip] Taking a really simple situation: class

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-03 Thread Ned Batchelder
On 3/2/18 10:36 AM, Paul Moore wrote: Or (real Python): def fn(): for i in range(1): with open(f"file{i}.txt", "w") as f: f.write("Some text") How would you write this in your RAII style - without leaving 10,000 file descriptors open until the

Re: Functions unnecessarily called in Python/pylifecycle.c:_Py_InitializeCore() ?

2018-03-01 Thread Ned Batchelder
On 3/1/18 7:40 AM, Thomas Nyberg wrote: On 03/01/2018 12:46 PM, bartc wrote: If they're only called once, then it probably doesn't matter too much in terms of harming performance. Oh yeah there's no way this has any affect on performance. A smart compiler might even be able optimize the call

Re: Detection of ultrasonic side channels in mobile devices with Python?

2018-02-28 Thread Ned Batchelder
On 2/28/18 7:01 PM, Etienne Robillard wrote:  What do rats find rewarding in play fighting? This is well outside the topics for this list. --Ned. Le 2018-02-28 à 18:29, Chris Angelico a écrit : On Thu, Mar 1, 2018 at 10:23 AM, Steven D'Aprano wrote:

Re: Detection of ultrasonic side channels in mobile devices with Python?

2018-02-28 Thread Ned Batchelder
On 2/28/18 4:13 PM, Etienne Robillard wrote: I want to know why this question is being silently ignored by this group. If no one has any information about your topic, then no one will say anything.  Python on Android is very specialized as it is, and I have no idea what ultrasonic side

Re: Questions about `locals` builtin

2018-02-27 Thread Ned Batchelder
On 2/27/18 3:52 AM, Kirill Balunov wrote: a. Is this restriction for locals desirable in the implementation of CPython in Python 3? b. Or is it the result of temporary fixes for Python 2? My understanding is that the behavior of locals() is determined mostly by what is convenient for the

Re: How to make Python run as fast (or faster) than Julia

2018-02-26 Thread Ned Batchelder
On 2/26/18 10:09 AM, Chris Angelico wrote: On Tue, Feb 27, 2018 at 2:02 AM, bartc <b...@freeuk.com> wrote: On 26/02/2018 14:04, bartc wrote: On 26/02/2018 13:42, Ned Batchelder wrote: Well, once you notice that the Python code had N=1e5, and the C code had N=1e9 :) If yo

Re: How to make Python run as fast (or faster) than Julia

2018-02-26 Thread Ned Batchelder
On 2/26/18 7:13 AM, bartc wrote: On 26/02/2018 11:40, Chris Angelico wrote: On Mon, Feb 26, 2018 at 10:13 PM, bartc wrote: Below is the first draft of a Python port of a program to do with random numbers. (Ported from my language, which in turned ported it from a C program

Re: How to only get \n for newline without the single quotes?

2018-02-24 Thread Ned Batchelder
On 2/24/18 2:08 PM, Peng Yu wrote: On Sat, Feb 24, 2018 at 12:45 PM, Wildman via Python-list wrote: On Sat, 24 Feb 2018 11:41:32 -0600, Peng Yu wrote: I would like to just get the escaped string without the single quotes. Is there a way to do so? Thanks. x='\n'

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Ned Batchelder
On 2/23/18 3:02 PM, bartc wrote: On 23/02/2018 19:47, Chris Angelico wrote: On Sat, Feb 24, 2018 at 6:25 AM, bartc wrote: The difference between Python and another dynamic language might be a magnitude, yet you say it doesn't matter. Thanks, that makes me feel much better

Re: How to make Python run as fast (or faster) than Julia

2018-02-22 Thread Ned Batchelder
On 2/22/18 11:00 AM, bartc wrote: On 22/02/2018 12:03, bartc wrote: On the fib(20) test, it suggests using this to get a 30,000 times speed-up: BTW while doing my tests, I found you could redefine the same function with no error: def fred(): pass def fred(): pass def fred():

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Ned Batchelder
On 2/20/18 5:47 AM, Antoon Pardon wrote: On 19-02-18 16:18, Ned Batchelder wrote: On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't answer, is "Do you mean that v

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 1:01 PM, Paul Moore wrote: On 19 February 2018 at 17:11, Ned Batchelder <n...@nedbatchelder.com> wrote: On 2/19/18 10:39 AM, Paul Moore wrote: I'm curious - How would you explain Python's "variables" to someone who knows how C variables work, in a way that ensures

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 10:39 AM, Paul Moore wrote: On 19 February 2018 at 15:18, Ned Batchelder <n...@nedbatchelder.com> wrote: On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't answer, is "Do you mean that values are strongly typed, or that names are? Or did you mean that variables are, because if so

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-18 Thread Ned Batchelder
On 2/18/18 6:57 AM, bartc wrote: On 18/02/2018 11:45, Ned Batchelder wrote: Let's not go down this path yet again. We've heard it all before. Bart: stop it.  Everyone else: stop it. :) Well, this was a rare instance of someone admitting that a simple and smaller codebase has benefits

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-18 Thread Ned Batchelder
On 2/18/18 6:33 AM, bartc wrote: On 18/02/2018 01:39, Chris Angelico wrote: On Sun, Feb 18, 2018 at 12:31 PM, bartc wrote: On 18/02/2018 00:45, Chris Angelico wrote: On Sun, Feb 18, 2018 at 11:13 AM, bartc wrote: It's text, but it is an intermediate or

Re: Python GIL vs CAS

2018-02-15 Thread Ned Batchelder
On 2/15/18 9:35 AM, Chris Angelico wrote: On Thu, Feb 15, 2018 at 2:40 PM, Oleg Korsak wrote: Hi. While hearing about GIL every time... is there any real reason why CAS doesn't help to solve this problem? https://en.wikipedia.org/wiki/Compare-and-swap

Re: Django-hotsauce 1.0 commercial edition looking for beta testers!

2018-02-13 Thread Ned Batchelder
On 2/13/18 6:41 PM, Etienne Robillard wrote: Hello everyone, Django-hotsauce 1.0 commercial edition (LTS) is now available for preorder :) Checkout: https://www.livestore.ca/product/django-hotsauce/ I'm also looking for expert Django and Python programmers to test and review the design and

Re: PyPy support breaking CPython compatibility?

2018-01-31 Thread Ned Batchelder
On 1/30/18 3:58 PM, Etienne Robillard wrote: Hi Ned, Le 2018-01-30 à 15:14, Ned Batchelder a écrit : I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) Please take a look at the changesets: https://bitbucket.org/tkadm30/libschevo/commits

Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder
On 1/30/18 4:08 PM, Chris Angelico wrote: On Wed, Jan 31, 2018 at 7:58 AM, Etienne Robillard<tkad...@yandex.com> wrote: Hi Ned, Le 2018-01-30 à 15:14, Ned Batchelder a écrit : I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) Please take

Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder
On 1/30/18 2:35 PM, Etienne Robillard wrote: Hi, I managed to patch Schevo and Durus to run under PyPy 5.9. However, I'm afraid the changes is breaking Python 2.7 compatibility. I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) I'm not sure how

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Ned Batchelder
On 1/27/18 3:15 PM, Jason Qian via Python-list wrote: HI I am a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like it print as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet It looks like

Re: exec and traceback

2018-01-25 Thread Ned Batchelder
On 1/22/18 3:22 AM, ken...@gameofy.com wrote: I'm using exec() to run a (multi-line) string of python code. If an exception occurs, I get a traceback containing a stack frame for the string. I've labeled the code object with a "file name" so I can identify it easily, and when I debug, I

[issue32551] Zipfile & directory execution in 3.5.4 also adds the parent directory to sys.path

2018-01-23 Thread Ned Batchelder
Ned Batchelder <n...@nedbatchelder.com> added the comment: I can confirm that 3.5.5rc1 fixes the problem I had. -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

Re: python to C code generator

2018-01-23 Thread Ned Batchelder
On 1/23/18 8:48 AM, kushal bhattacharya wrote: On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote: On 23/01/2018 13:23, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as

Re: exec and traceback

2018-01-22 Thread Ned Batchelder
On 1/22/18 3:22 AM, ken...@gameofy.com wrote: (BTW, I've written a simple secure eval()) You have accurately guessed our interest!  Would you mind starting a new thread to show us your simple secure eval? --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread Ned Batchelder
On 1/17/18 2:45 PM, Chris Angelico wrote: On Thu, Jan 18, 2018 at 6:28 AM, Ned Batchelder <n...@nedbatchelder.com> wrote: You'll have to replace random.choice() with random.choice(list(...)), since you can't random.choice from a set. Side point: why can't you? You can random.sample from

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread Ned Batchelder
On 1/17/18 9:29 AM, leutrim.kal...@gmail.com wrote: Hello everyone, I am implementing a time-dependent Recommender System which applies BPR (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to learn the parameters of the model. Such that, one iteration involves

Re: documentation on read.encode

2018-01-16 Thread Ned Batchelder
On 1/16/18 2:19 PM, Larry Martell wrote: On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell wrote: Looking for 2.7 docs on read.encode - googling did not turn up anything. Specifically, looking for the supported options for base64, and how to specify them, e.g.

Re: Where is the usage of (list comprehension) documented?

2018-01-15 Thread Ned Batchelder
On 1/14/18 9:57 PM, Dan Stromberg wrote: On Sun, Jan 14, 2018 at 3:01 PM, Peng Yu wrote: Hi, I see the following usage of list comprehension can generate a generator. Does anybody know where this is documented? Thanks. Here's the (a?) generator expression PEP:

[issue32551] 3.5.4 has a regression that was fixed in 3.6.1rc1

2018-01-14 Thread Ned Batchelder
Ned Batchelder <n...@nedbatchelder.com> added the comment: (For clarity) The problem is that 3.5.4 adds the current directory to sys.path when running a subdirectory's __main__.py. No other version of Python does this. -- ___ Python tracke

[issue32551] 3.5.4 has a regression that was fixed in 3.6.1rc1

2018-01-14 Thread Ned Batchelder
New submission from Ned Batchelder <n...@nedbatchelder.com>: The issue that I reported in https://bugs.python.org/issue29723 is now affecting 3.5.4: ``` $ pwd /Users/ned/foo $ tree syspathmain syspathmain └── __main__.py 0 directories, 1 file $ cat syspathmain/__main__.py import sys

Re: Simple graphic library for beginners

2018-01-11 Thread Ned Batchelder
On 1/11/18 8:21 PM, bartc wrote: On 11/01/2018 23:23, Chris Angelico wrote: On Fri, Jan 12, 2018 at 10:11 AM, bartc wrote: I'm almost ready to plonk you, but I think there is still SOME value in your posts. But please, stop denigrating what you don't understand. And

Re: Simple graphic library for beginners

2018-01-11 Thread Ned Batchelder
On 1/11/18 10:23 AM, Chris Angelico wrote: On Fri, Jan 12, 2018 at 12:38 AM, bartc wrote: On 11/01/2018 05:16, Michael Torrie wrote: On 01/10/2018 01:13 PM, bartc wrote: Yes the link didn't have the simple examples I hoped for. How's this: -

Re: Copy-on-write friendly Python garbage collection (Posting On Python-List Prohibited)

2018-01-01 Thread Ned Batchelder
On 1/1/18 1:49 PM, Niles Rogoff wrote: On Mon, 01 Jan 2018 10:42:58 -0800, breamoreboy wrote: On Monday, January 1, 2018 at 10:14:59 AM UTC, wxjm...@gmail.com wrote: Le lundi 1 janvier 2018 08:35:53 UTC+1, Lawrence D’Oliveiro a écrit : On Monday, January 1, 2018 at 7:52:48 AM UTC+13, Paul

Re: you shortened it, but you broke it too... ;-)

2018-01-01 Thread Ned Batchelder
On 12/31/17 8:15 PM, Wu Xi wrote: def neighbours(point): x,y = point yield x + 1 , y yield x - 1 , y yield x , y + 1 yield x , y - 1 #this is proof that life can emerge inside of computers and cellular automatons, yield x + 1 , y + 1

Re: Python goto

2017-12-28 Thread Ned Batchelder
On 12/28/17 6:43 AM, jorge.conr...@cptec.inpe.br wrote: Hi, I would like to know if there is a goto command or something similar that I can use in Python. Python does not have a goto statement. You have to use structured statements: for, while, try/except, yield, return, etc. If you

Re: What is wrong with this regex for matching emails?

2017-12-17 Thread Ned Batchelder
On 12/17/17 10:29 AM, Peng Yu wrote: Hi, I would like to extract "a...@efg.hij.xyz". But it only shows ".hij". Does anybody see what is wrong with it? Thanks. $ cat main.py #!/usr/bin/env python # vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8: import re

Re: Automated distribution building tools to support SpamBayes

2017-12-15 Thread Ned Batchelder
On 12/15/17 2:03 PM, Skip Montanaro wrote: SpamBayes (http://www.spambayes.org/) has languished for quite awhile, in part because nobody is around who can put together a Windows installer. Unfortunately, most users are on Windows and have to work around problems caused by the march of time and

Re: f-string

2017-12-08 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: > compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Octâ 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: > Perhaps it's not politically correct for me to say this, but > i've never been one who cared much about political > correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.â His messages are famous for their

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line. What would be the best way

Re: why won't slicing lists raise IndexError?

2017-12-08 Thread Ned Batchelder
On 12/7/17 9:02 PM, Python wrote: Can you please explain to me Really, you just have to ignore him. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 2:41 PM, Ethan Furman wrote: On 12/07/2017 11:23 AM, Ned Batchelder wrote: On 12/7/17 1:28 PM, Ethan Furman wrote: --> identity('spam', 'eggs', 7) ('spam', 'eggs', 7) I don't see why this last case should hold.  Why does the function take more than one argument?  And if it d

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 1:28 PM, Ethan Furman wrote: The simple answer is No, and all the answers agree on that point. It does beg the question of what an identity function is, though. My contention is that an identity function is a do-nothing function that simply returns what it was given: -->

Re: why won't slicing lists raise IndexError?

2017-12-06 Thread Ned Batchelder
After a certain point, the only thing you can do with a troll is ignore them. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: f-string

2017-12-05 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Oct  4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

Re: why won't slicing lists raise IndexError?

2017-12-05 Thread Ned Batchelder
On 12/4/17 10:41 PM, Rick Johnson wrote: I think we've demonstrated the slicing semantics well. Indeed. And i never questioned this aspect. I merely wanted to inform the lurkers that the else-clause was handling a non-action, and therefore, could be omitted. Your original statement sounded

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:31 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote: [...] Here are details filled in: $ python3.6 Python 3.6.3 (default, Oct 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 8:03 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 6:13:19 PM UTC-6, Chris Angelico wrote: [...] Ahhh, I see how it is. You didn't run the code, ergo you don't understand it. Makes perfect sense. :) Being that Terry didn't offer any declarations or defintions for his

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.  His messages are famous for their

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to

Re: connect four (game)

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 1:57 PM, bartc wrote: > On 27/11/2017 17:41, Chris Angelico wrote: >> On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote: >>> JPEG uses lossy compression. The resulting recovered data is an >>> approximation of the original. >> >> Ah but it is a perfect representation of

Re: I have framework on python with pyunit, facing below issue while

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote: > Please let me know anyone aware about the issue > > > Traceback (most recent call last): > File "testrunner.py", line 447, in > testrunner_obj.main() > File "testrunner.py", line 433, in main > self.result() > File "testrunner.py", line 310, in

Re: While, If, Count Statements

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: > Input : > > count = 0 > > if count < 5: >print "Hello, I am an if statement and count is", count > > while count < 10: >print "Hello, I am a while and count is", count >count += 1 > > Output : > > Hello, I am an if statement and count is 0 >

Re: connect four (game)

2017-11-27 Thread Ned Batchelder
On 11/27/17 1:57 PM, bartc wrote: On 27/11/2017 17:41, Chris Angelico wrote: On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote: JPEG uses lossy compression. The resulting recovered data is an approximation of the original. Ah but it is a perfect representation of the JPEG

Re: While, If, Count Statements

2017-11-27 Thread Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and

Re: I have framework on python with pyunit, facing below issue while executing test case

2017-11-27 Thread Ned Batchelder
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote: Please let me know anyone aware about the issue Traceback (most recent call last): File "testrunner.py", line 447, in testrunner_obj.main() File "testrunner.py", line 433, in main self.result() File "testrunner.py", line 310, in result result

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . nospam . Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: > Hi, my goal is to obtain an interpreter that internally > uses UCS-2. Such a simple code should print 65535: > >import sys >print sys.maxunicode > > This is enabled in Windows, but I want the same in Linux. > What options have I pass to

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: > Hi, my goal is to obtain an interpreter that internally > uses UCS-2. Such a simple code should print 65535: > >import sys >print sys.maxunicode > > This is enabled in Windows, but I want the same in Linux. > What options have I pass to

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-25 Thread Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure

Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-24 Thread Ned Batchelder
On 11/24/17 5:26 PM, Richard Damon wrote: Have you tried using U+2010 (HYPHEN) ‐. It is in the class XID_CONTINUE (in fact it is in XID_START) so should be available. U+2010 isn't allowed in Python 3 identifiers. The rules for identifiers are here:

Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Ned Batchelder
On 11/20/17 9:50 AM, Stefan Ram wrote: Ned Batchelder <n...@nedbatchelder.com> writes: Also, why set headers that prevent the Python-List mailing list from archiving your messages? I am posting to a Usenet newsgroup. I am not aware of any "Python-List mailing list".

Re: How to Generate dynamic HTML Report using Python

2017-11-19 Thread Ned Batchelder
On 11/19/17 8:40 PM, Stefan Ram wrote: mradul dhakad writes: I am new to python . I am trying to generate Dynamic HTML report using Pyhton based on number of rows selected from query .Do any one can suggest some thing for it. main.py import sqlite3 conn =

Re: Should constants be introduced to Python?

2017-11-16 Thread Ned Batchelder
On 11/16/17 1:16 AM, Saeed Baig wrote: Hey guys I am thinking of perhaps writing a PEP to introduce constants to Python. Something along the lines of Swift’s “let” syntax (e.g. “let pi = 3.14”). Since I’m sort of new to this, I just wanted to ask: - Has a PEP for this already been written? If

Re: from xx import yy

2017-11-12 Thread Ned Batchelder
On 11/12/17 9:17 PM, bvdp wrote: I'm having a conceptual mind-fart today. I just modified a bunch of code to use "from xx import variable" when variable is a global in xx.py. But, when I change/read 'variable' it doesn't appear to change. I've written a bit of code to show the problem:

Re: How to modify this from Python 2.x to v3.4?

2017-11-11 Thread Ned Batchelder
On 11/11/17 6:56 AM, jf...@ms4.hinet.net wrote: I learned python start from using v3.4 and never has any v2.x experience. There is a Pypi project "ctypesgen" I like to use, but it seems is for v2.x. (un)Fortunately I found one of its branch on github which announced is for Python3, but

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/10/17 6:03 PM, Ben Finney wrote: Ned Batchelder <n...@nedbatchelder.com> writes: On 11/8/17 10:18 PM, Ben Finney wrote: What has been made clear to me is that we have a long way to go in pursuit of allowing ideas to be held at arm's length, discussed and criticised, with r

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/8/17 10:18 PM, Ben Finney wrote: How many paragraphs of close parsing are we going to twist ourselves through, just to avoid saying, "Yeah, sorry, that went a bit far.  I didn't want to alienate you in the pursuit of a demonstration of my own correctness." I don't have any aim of avoiding

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/8/17 3:05 PM, Marko Rauhamaa wrote: Jon Ribbens : It is my experience of this group/list that if one disagrees with any of you, Steve and Chris, you all rally round and gang up on that person to insult and belittle them. This makes the atmosphere quite hostile,

Re: Ideas about how software should behave

2017-11-08 Thread Ned Batchelder
On 11/8/17 5:22 PM, Ben Finney wrote: Jon Ribbens writes: On 2017-11-08, Ben Finney wrote: I also think Jon had cause to bristle somewhat at the characterisation. I don't think Jon was attacked by Steve's remark, but I do sympathise

Re: Ideas about how software should behave

2017-11-07 Thread Ned Batchelder
On 11/7/17 5:48 PM, Ben Finney wrote: Ian Kelly writes: Nowadays I realize and accept that this is preposterous. You cannot criticize an idea without also criticizing the people who are attached to that idea. Maybe so. Does that mean we must not criticise ideas? Later

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Ned Batchelder
On 11/6/17 8:05 AM, Jon Ribbens wrote: On 2017-11-06, Chris Angelico wrote: If you start with the assumption that "intuitively obvious" doesn't actually mean "intuitively obvious" but actually means something completely different, then your statement definitely means

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:29 PM, Chris Angelico wrote: On Thu, Nov 2, 2017 at 8:23 AM, Ned Batchelder <n...@nedbatchelder.com> wrote: On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for`

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that it should be rather "then" than "else." Compare also "try ... then ... finally" with "try ... else ... finally".

Re: String changing size on failure?

2017-11-01 Thread Ned Batchelder
On 11/1/17 4:17 PM, MRAB wrote: On 2017-11-01 19:26, Ned Batchelder wrote:   From David Beazley (https://twitter.com/dabeaz/status/925787482515533830):   >>> a = 'n'   >>> b = 'ñ'   >>> sys.getsizeof(a) 50   >>> sys.getsizeof(b)

String changing size on failure?

2017-11-01 Thread Ned Batchelder
From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): >>> a = 'n' >>> b = 'ñ' >>> sys.getsizeof(a) 50 >>> sys.getsizeof(b) 74 >>> float(b) Traceback (most recent call last):   File "", line 1, in ValueError: could not convert string to

Re: Report on non-breaking spaces in posts

2017-11-01 Thread Ned Batchelder
On 10/31/17 1:23 PM, Stefan Ram wrote: Ok, here's a report on me seing non-breaking spaces in posts in this NG. I have written this report so that you can see that it's not my newsreader that is converting something, because there is no newsreader involved. You've worded this as if

Re: Code Snippets

2017-11-01 Thread Ned Batchelder
On 11/1/17 1:25 PM, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on. You get the idea. However,

Re: The syntax of replacement fields in format strings

2017-11-01 Thread Ned Batchelder
On 10/31/17 12:45 PM, John Smith wrote: If we keep the current implementation as is, perhaps the documentation should at least be altered ? John, it looks like you are responding to a Python-Dev message, but on this list, somehow... --Ned. --

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder
On 10/31/17 12:29 PM, Stefan Ram wrote: Ned Batchelder <n...@nedbatchelder.com> writes: However you solve it, do yourself a favor and write a function to encapsulate it: It is always a good solution to encapsulate a pattern into a function. So I agree that this is a good sugg

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder
On 10/31/17 11:29 AM, Neil Cerutti wrote: On 2017-10-31, Ganesh Pal wrote: Here is my solution values = '||' + '||'.join(map(str, value_list)) + '||' values '||1||2||3||4||56||s||' I am joining the elements at the beginning and end of the list using '+' operator any

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 3:09 PM, Alberto Riva wrote: On 10/29/2017 02:13 PM, Rick Johnson wrote: Alberto Riva wrote: Rick Johnson wrote: Alberto Riva wrote: [...] In a language like Lisp Python is nothing like Lisp, and for good reason! I would disagree with this. Actually, it's the most Lisp-

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 10:18 AM, Alberto Riva wrote: Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my function if a dict does not contain a given key. I could write: def

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