Re: ``if var'' and ``if var is not None''

2019-09-01 Thread Ian Kelly
On Sun, Sep 1, 2019, 8:58 AM Terry Reedy wrote: > On 9/1/2019 2:12 AM, Hongyi Zhao wrote: > > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > > Aside from the fact that this is false, why would you post such a thing? > Trolling? Did you hit [Send]

Re: itertools cycle() docs question

2019-08-21 Thread Ian Kelly
On Wed, Aug 21, 2019 at 12:36 PM Calvin Spealman wrote: > > The point is to demonstrate the effect, not the specific implementation. But still yes, that's pretty much exactly what it does. The main difference between the "roughly equivalent to" code and the actual implementation is that the

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Ian Kelly
Or use the "pairwise" recipe from the itertools docs: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b) for num1, num2 in pairwise(a): print(num1, num2) On Tue, Aug 20, 2019 at 7:42

Re: Remote/Pair-Programming in-the-cloud

2019-08-04 Thread Ian Kelly
On Sat, Aug 3, 2019, 9:25 AM Bryon Tjanaka wrote: > Depending on how often you need to run the code, you could use a google doc > and copy the code over when you need to run. Of course, if you need linters > and other tools to run frequently this would not work. > I've conducted a number of

Re: if bytes != str:

2019-08-04 Thread Ian Kelly
On Sun, Aug 4, 2019, 9:02 AM Hongyi Zhao wrote: > Hi, > > I read and learn the the following code now: > > https://github.com/shadowsocksr-backup/shadowsocksr-libev/blob/master/src/ > ssrlink.py > > > In this

Re: super or not super?

2019-07-16 Thread Ian Kelly
On Tue, Jul 16, 2019 at 1:21 AM Chris Angelico wrote: > > On Tue, Jul 16, 2019 at 3:32 PM Ian Kelly wrote: > > > > Just using super() is not enough. You need to take steps if you want to > > ensure that you class plays nicely with MI. For example, consider the > &g

Re: super or not super?

2019-07-15 Thread Ian Kelly
On Sun, Jul 14, 2019 at 7:14 PM Chris Angelico wrote: > > On Mon, Jul 15, 2019 at 10:51 AM Paulo da Silva > wrote: > > > > Às 15:30 de 12/07/19, Thomas Jollans escreveu: > > > On 12/07/2019 16.12, Paulo da Silva wrote: > > >> Hi all! > > >> > > >> Is there any difference between using the base

Re: How Do You Replace Variables With Their Values?

2019-07-14 Thread Ian Kelly
On Thu, Jul 11, 2019 at 11:10 PM Chris Angelico wrote: > > On Fri, Jul 12, 2019 at 2:30 PM Aldwin Pollefeyt > wrote: > > > > Wow, I'm so sorry I answered on the question : "How do you replace a > > variable with its value". For what i understood with the example values, > > CrazyVideoGamez wants

Re: Conway's game of Life, just because.

2019-05-07 Thread Ian Kelly
On Tue, May 7, 2019 at 1:00 PM MRAB wrote: > > On 2019-05-07 19:29, Eli the Bearded wrote: > > In comp.lang.python, Paul Rubin wrote: > > > > Thanks for posting this. I'm learning python and am very familiar with > > this "game". > > > >> #!/usr/bin/python3 > >> from itertools import chain > >>

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Tue, Apr 2, 2019 at 1:43 AM Alexey Muranov wrote: > > > On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov > gmail.com> > > wrote: > > > > > > I only see a superficial analogy with `super()`, but perhaps it is > > > because you did not give much details of you suggestion. > > > > No, it's because

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov wrote: > > I only see a superficial analogy with `super()`, but perhaps it is > because you did not give much details of you suggestion. No, it's because the analogy was not meant to be anything more than superficial. Both are constructs of syntactic

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Ian Kelly
On Sun, Mar 31, 2019 at 1:09 PM Alexey Muranov wrote: > > On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote: > > On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov > > > > wrote: > > > >> > >> On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org > >> wrote: > >> > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-30 Thread Ian Kelly
On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov wrote: > > On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org wrote: > > > > There could perhaps be a special case for lambda expressions such > > that, > > when they are directly assigned to a variable, Python would use the > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Thu, Mar 28, 2019 at 2:30 PM Alexey Muranov wrote: > > On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: > > Throwing the name away is foolish. Testing functions is another > > situation in which function names are needed for proper report. > > My idea however was to have it as an exact

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Wed, Mar 27, 2019 at 3:13 AM Paul Moore wrote: > > On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: > > > > Whey you need a simple function in Python, there is a choice between a > > normal function declaration and an assignment of a anonymous function > > (defined by a lambda-expression)

Re: array of characters?

2019-03-22 Thread Ian Kelly
I don't know the answer, and PEP 393 doesn't talk about the array('u') deprecation directly. But it seems to me that with Py_UNICODE going away this array type code would have to be completely reimplemented, and also at that point array('u') is just equivalent to array('L') with some extra

Re: Potential Security Bug

2019-03-20 Thread Ian Kelly
On Wed, Mar 20, 2019 at 5:14 AM Laish, Amit (GE Digital) wrote: > > Hello, > I’m Amit Laish, a security researcher from GE Digital. > During one of our assessments we discovered something that we consider a bug with security implications which can cause a denial of service by disk exhausting, and

Re: Determining latest stable version for download

2019-03-20 Thread Ian Kelly
1) https://www.python.org/downloads/ has release information. Based on that you would currently want 3.7.2. Make sure you actually download 3.7.2 and not 3.7.2rc1. 2) The tarfiles are not distro-specific. For Linux there are really only two options: Python-3.7.2.tar.xz and Python-3.7.2.tgz. The

Re: Why can't access the property setter using the super?

2019-03-19 Thread Ian Kelly
Here's the thing: the result of calling super() is not an instance of the base class. It's just a proxy object with a __getattribute__ implementation that looks up class attributes in the base class, and knows how to pass self to methods to simulate calling base class methods on an instance. This

Re: Generator question

2019-03-13 Thread Ian Kelly
You're basically running into this: https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result To see why, let's try disassembling your function. I'm using Python 3.5 here, but it shouldn't make much of a difference. py>

Re: The slash "/" as used in the documentation

2019-02-11 Thread Ian Kelly
On Mon, Feb 11, 2019 at 1:56 PM boB Stepp wrote: > > On Mon, Feb 11, 2019 at 2:34 PM Chris Angelico wrote: > > > Calling on the D'Aprano Collection of Ancient Pythons for confirmation > > here, but I strongly suspect that positional arguments with defaults > > go back all the way to 1.x. > > Has

Re: The slash "/" as used in the documentation

2019-02-11 Thread Ian Kelly
On Mon, Feb 11, 2019 at 1:35 PM Chris Angelico wrote: > > On Tue, Feb 12, 2019 at 7:26 AM Avi Gross wrote: > > If you want to talk about recent or planned changes, fine. But make that > > clear. I was talking about how in the past positional arguments did not have > > defaults available at the

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Mon, Feb 11, 2019 at 12:19 AM Terry Reedy wrote: > The pass-by-position limitation is not in CPython, it is the behavior of > C functions, which is the behavior of function calls in probably every > assembly and machine language. Allowing the flexibility of Python > function calls take extra

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sun, Feb 10, 2019 at 2:18 PM Avi Gross wrote: > I am not sure how python implements some of the functionality it does as > compared to other languages with similar features. But I note that there are > rules, presumably some for efficiency, such as requiring all keyword > arguments to be

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sun, Feb 10, 2019 at 9:34 AM Chris Angelico wrote: > > On Mon, Feb 11, 2019 at 2:49 AM Ian Kelly wrote: > > > > On Sat, Feb 9, 2019 at 1:19 PM Terry Reedy wrote: > > > > > > This is the result of Python being a project of mostly unpaid volunteers. > &

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sat, Feb 9, 2019 at 1:19 PM Terry Reedy wrote: > > This is the result of Python being a project of mostly unpaid volunteers. > > See my response in this thread explaining how '/' appears in help output > and IDLE calltips. '/' only appears for CPython C-coded functions that > have been

Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-23 Thread Ian Kelly
On Wed, Jan 23, 2019 at 1:36 PM Stefan Behnel wrote: > > Cameron Simpson schrieb am 23.01.19 um 00:21: > > from __future__ import absolute_imports, print_function > > > > gets you a long way. > > ... and: division. All right, but apart from absolute imports, the print function, and true

Re: Pythonic Y2K

2019-01-17 Thread Ian Kelly
On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote: > > The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number

Re: the python name

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > declaimed the following: > > > >language, Formula Translator? (I recall using the What For version). > > WATFOR => WATerloo FORtran And then there was WATFIV, which stands for

Re: Type hinting of Python is just a toy ?

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 10:44 AM iamybj--- via Python-list wrote: > > { id: 1, name:’abc’, age:99, address:{province:’CA’, city:’SA’}} Those are nested dicts, not tuples, which leaves your argument really unclear. A dict is essentially a hash map. Java and C# (it's unclear what language you're

Re: Type hinting of Python is just a toy ?

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 1:20 AM Chris Angelico wrote: > > Pep484 is too complex. Typle should not a seperate type, in fact it should > > be just a class. Like this in other programming language > > Python: Tuple(id: int, name: string, age: int) > > Other: class someClass { > > public int

Re: Question about slight deviations when using integer division with large integers.

2018-12-30 Thread Ian Kelly
On Sun, Dec 30, 2018 at 10:18 PM Christian Seberino wrote: > > What is simplest way to make both those > prints give same values? Any slicker way > than an if statement? Stack Overflow has a few suggestions:

Re: Question about slight deviations when using integer division with large integers.

2018-12-30 Thread Ian Kelly
On Sun, Dec 30, 2018 at 10:27 PM Cameron Simpson wrote: > > On 30Dec2018 21:14, Christian Seberino wrote: > >What is simplest way to make both those > >prints give same values? Any slicker way > >than an if statement? > > If your post had an attachment, be aware that the python-list list drops

Re: Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-27 Thread Ian Kelly
On Wed, Dec 26, 2018 at 11:21 PM Chris Angelico wrote: > > On Thu, Dec 27, 2018 at 1:56 PM wrote: > > > > I saw the code below at stackoverflow. I have a little idea about the scope > > of a class, and list comprehension and generator expressions, but still > > can't figure out why Z4 works

Re: Why do data descriptors (e.g. properties) take priority over instance attributes?

2018-12-18 Thread Ian Kelly
On Mon, Dec 17, 2018, 12:09 PM Paul Baker When Python looks up an attribute on an object (i.e. when it executes > `o.a`), it uses an interesting priority order [1]. It looks for: > > 1. A class attribute that is a data-descriptor (most commonly a property) > 2. An instance attribute > 3. Any

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Sat, Dec 8, 2018 at 7:57 PM wrote: > > Grant Edwards於 2018年12月9日星期日 UTC+8上午12時52分04秒寫道: > > Just to be clear: you do _not_ want to use eval on the string. > > > > If you're not the one who created the string, it might wipe your hard > > drive or empty your bank account. If you _are_ the one

Re: Program to keep track of success percentage

2018-12-08 Thread Ian Kelly
On Sat, Dec 8, 2018 at 1:22 PM Alister via Python-list wrote: > > On Sat, 08 Dec 2018 10:02:41 -0800, Musatov wrote: > > > I am thinking about a program where the only user input is win/loss. The > > program let's you know if you have won more than 31% of the time or not. > > Any suggestions

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Fri, Dec 7, 2018 at 11:56 PM Henrik Bengtsson wrote: > > A comment from the sideline: one could imagine extending the Python syntax > with a (optional) 0d prefix that allows for explicit specification of > decimal values. They would "complete" the family: > > * 0b: binary number > * 0o: octal

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Ian Kelly
On Fri, Dec 7, 2018 at 7:47 PM wrote: > > MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > > Before Python 3, a leading 0 in an integer literal would indicate an > > octal (base 8) number. > > So, the reason is historical. > > > The old form is now invalid in order to reduce the chance of bugs. > > I

Re: Question on difference between LambdaType and FunctionType

2018-11-26 Thread Ian Kelly
On Sun, Nov 25, 2018 at 2:00 PM Chris Angelico wrote: > > On Mon, Nov 26, 2018 at 7:55 AM Iwo Herka wrote: > > > > > class Foo: > > >def setup(self): ... > > >__init__ = lambda self: self.setup() > > > > Sorry, didn't address this. This is fine too, since I'm assuming that > > only

Re: Odd truth result with in and ==

2018-11-21 Thread Ian Kelly
On Wed, Nov 21, 2018 at 2:53 PM Serhiy Storchaka wrote: > > 21.11.18 22:17, Cameron Simpson пише: > > Can someone show me a real world, or failing that - sane looking, > > chained comparison using "in"? > > s[0] == s[-1] in '\'"' > > Tests that string s starts and ends with a single or

Re: on the prng behind random.random()

2018-11-19 Thread Ian Kelly
On Mon, Nov 19, 2018 at 2:12 PM Robert Girault wrote: > > Chris Angelico writes: > > > On Tue, Nov 20, 2018 at 7:31 AM Robert Girault wrote: > >> Nice. So Python's random.random() does indeed use mt19937. Since it's > >> been broken for years, why isn't it replaced by something newer like >

Re: Generators, generator expressions, and loops

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: > > I have looked at generators, generator expressions, and iterators and > I try to get more familiar with these. > > 1. How would I loop over all (with no upper bound) integers or all > powers of two, for example? > > In C it would be > >

Re: Iterators of iterators

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 8:01 AM Steve Keller wrote: > > I wonder why iterators do have an __iter__() method? I thought > iterable objects would have an __iter__() method (but no __next__()) > to create an iterator for it, and that would have the __next__() > method but no __iter__(). > > $

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
On Tue, Nov 6, 2018 at 3:39 PM Ian Kelly wrote: > > n Mon, Nov 5, 2018 at 8:43 PM wrote: > > What I meant was, the error message is specific to futures in the > > 'PENDING' state. Which should be set to 'RUNNING' before any actions > > occur. So it appears the task

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
n Mon, Nov 5, 2018 at 8:43 PM wrote: > > On Mon, Nov 05, 2018 at 07:15:04PM -0700, Ian Kelly wrote: > > > For context: > > > https://github.com/ldo/dbussy/issues/13 > > > https://gist.github.com/tu500/3232fe03bd1d85b1529c558f920b8e43 > > > > >

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
On Mon, Nov 5, 2018 at 6:20 PM wrote: > Again sorry for the confusion, but I don't think this is an issue with > restarting loops, as this isn't happening in my application. Sure, I wasn't talking about restarting loops so much as strategies for making sure that everything has completed in the

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
On Mon, Nov 5, 2018 at 8:41 AM wrote: > > > But anyway, I highly recommend you to use the "await other_coroutine()" > > > syntax I talked about earlier. It may even fix the issue (90% chance). > > > > This should indeed fix the issue, but this is definitely not what one is > > looking for if one

Re: Asyncio tasks getting cancelled

2018-11-04 Thread Ian Kelly
On Sun, Nov 4, 2018 at 3:58 PM Léo El Amri via Python-list wrote: > > On 04/11/2018 20:25, i...@koeln.ccc.de wrote: > > I'm having trouble with asyncio. Apparently tasks (asyncio.create_task) > > are not kept referenced by asyncio itself, causing the task to be > > cancelled when the creating

Re: Observations on the List - "Be More Kind"

2018-10-11 Thread Ian Kelly
On Thu, Oct 11, 2018 at 9:28 AM Dan Purgert wrote: > > Larry Martell wrote: > > On Fri, Oct 5, 2018 at 6:54 AM Bruce Coram wrote: > > [...] > > We don't like you. We don't want you here. We never will. Save us all > > the trouble and go away. > > That's the best code of conduct I've ever read

Re: How to use Python's built-in Logging with Asyncio (Permission Error)

2018-10-08 Thread Ian Kelly
I'm spit-balling here, but I suspect the problem is that TimedRotatingFileHandler was probably not designed to have multiple instances of it in different processes all trying to rotate the same file. Yet that's the situation you have since each subprocess in your process pool creates its own

Re: asyncio await different coroutines on the same socket?

2018-10-03 Thread Ian Kelly
On Wed, Oct 3, 2018 at 7:47 AM Russell Owen wrote: > Using asyncio I am looking for a simple way to await multiple events where > notification comes over the same socket (or other serial stream) in arbitrary > order. For example, suppose I am communicating with a remote device that can > run

Re: This thread is closed [an actual new thread]

2018-10-02 Thread Ian Kelly
On Tue, Oct 2, 2018 at 4:50 AM Rhodri James wrote: > > On what grounds are you suppressing debate? It is exactly and precisely > not irrelevant to Python, since it's discussing a Python-specific change > to known and understood computing terminology, and frankly the statement > "Continued

Re: [OT] master/slave debate in Python

2018-10-01 Thread Ian Kelly
On Wed, Sep 26, 2018 at 3:18 PM Chris Angelico wrote: > > On Thu, Sep 27, 2018 at 7:05 AM Ian Kelly wrote: > > > > You're objecting to people trying to do *something* positive on the > > grounds that they're not doing *more* while you yourself are doing > > *nothin

Re: Re[2]: [OT] master/slave debate in Python

2018-09-26 Thread Ian Kelly
On Wed, Sep 26, 2018 at 3:10 PM Brian Grawburg wrote: > > This is right next to the objection of the use male and female to describe > the two parts of a connector. I lament that snowflakes and such are trying > desperately to enforce their quest for radical egalitarianism and see hidden >

Re: [OT] master/slave debate in Python

2018-09-26 Thread Ian Kelly
On Tue, Sep 25, 2018 at 10:48 PM Chris Angelico wrote: > > On Wed, Sep 26, 2018 at 2:36 PM Ian Kelly wrote: > > So, Chris, what have *you personally* done about real slavery where it > > still happens? > > > > If, as I'm guessing, the answer is "nothing"

Re: [OT] master/slave debate in Python

2018-09-26 Thread Ian Kelly
On Wed, Sep 26, 2018 at 7:49 AM Chris Angelico wrote: > > On Wed, Sep 26, 2018 at 11:33 PM Ian Kelly wrote: > > > > Care to give an example? The distinctive part of the definition of > > "slave" is that it refers to someone who is owned and/or held capti

Re: [OT] master/slave debate in Python

2018-09-26 Thread Ian Kelly
On Wed, Sep 26, 2018 at 2:01 AM David Palao wrote: > > Hello, > My opinion is that the terms "master/slave" describe well some situations. > They could be seen by some people as offensive (although unfortunately > sometimes true, even today) when applied to persons. But it is not > offensive when

Re: [OT] master/slave debate in Python

2018-09-25 Thread Ian Kelly
Chris Angelico wrote: > > I was neither rude, nor personally attacking anyone. Actually, the "SJW brigade" remark was quite rude, and a clear attack on anybody who supports this change. > Yes, it's an insult. It's the people who believe that they can cure > social problems by making demands,

Re: [OT] master/slave debate in Python

2018-09-25 Thread Ian Kelly
On Mon, Sep 24, 2018 at 6:55 AM Robin Becker wrote: > > On 23/09/2018 15:45, Albert-Jan Roskam wrote: > > *sigh*. I'm with Hettinger on this. > > > > https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ > > > I am as well. Don't fix what is not broken. The

Re: Generating a specific list of intsgers

2018-08-24 Thread Ian Kelly
On Fri, Aug 24, 2018 at 3:47 PM wrote: > > I am looking for a program able to output a set of integers meeting the > following requirement: > > a(n) is the minimum k > 0 such that n*2^k - 3 is prime, or 0 if no such k > exists > > Could anyone get me started? (I am an amateur) Is there some

Re: Connection refused when tryign to run bottle/flask web framweworks

2018-08-19 Thread Ian Kelly
On Sun, Aug 19, 2018, 1:47 PM Νίκος wrote: > Hello, > > i just installed bottle and flask web frameworks in my CentOS environment > but i canno get it working even with the simpleste xample. The coonection > is refused always. > > from bottle import route, run, template > > @route('/hello/') >

Re: Good reason not to obfuscate URLs (was: Fishing from PyPI ?)

2018-08-14 Thread Ian Kelly
On Tue, Aug 14, 2018 at 1:41 PM Peter J. Holzer wrote: > > On 2018-08-08 05:18:21 +, Gilmeh Serda wrote: > > And if you read email in blasted HTML, chances are they also have an > > image that they serve to you on their "beautiful" page you receive, an > > image whose link which may or may

Re: Checking whether type is None

2018-07-27 Thread Ian Kelly
On Thu, Jul 26, 2018, 10:00 AM Stephan Houben wrote: > Op 2018-07-25, Ian Kelly schreef : > > > Is there a reason for using singledispatch here rather than a simpler and > > more readable "if color is None" check? > > Yes, the other 20 cases I didn't show. >

Re: Checking whether type is None

2018-07-25 Thread Ian Kelly
On Wed, Jul 25, 2018, 8:27 AM Stephan Houben wrote: > Op 2018-07-24, Chris Angelico schreef : > > On Wed, Jul 25, 2018 at 9:18 AM, Rob Gaddi > > wrote: > >> On 07/24/2018 01:07 PM, Chris Angelico wrote: > >> I suppose one valid usage would be this sort of thing: > >> > >> fn = { > >> int:

Re: What is the pattern for this number set?

2018-07-18 Thread Ian Kelly
Rather than go to the effort of reverse-engineering the chart, I wonder if it would be simpler to just run OCR over it and dump it into a spreadsheet. On Wed, Jul 18, 2018 at 4:01 PM Thomas Jollans wrote: > > On 18/07/18 23:43, Chris Angelico wrote: > > On Thu, Jul 19, 2018 at 7:16 AM, wrote: >

Re: Cult-like behaviour [was Re: Kindness]

2018-07-16 Thread Ian Kelly
On Mon, Jul 16, 2018 at 12:02 PM Terry Reedy wrote: > > On 7/15/2018 5:28 PM, Marko Rauhamaa wrote: > > > if your new system used Python3's UTF-32 strings as a foundation, > > Since 3.3, Python's strings are not (always) UFT-32 strings. Nor are > they always UCS-2 (or partly UTF-16) strings.

Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Ian Kelly
On Sat, Jul 14, 2018 at 3:12 AM Christian Gollwitzer wrote: > Typical conversation on this list / newsgroup: > > Q: "I could need a ?: operator just like in C. Is there something like > that in Python?" > > A1: "No. You don't want it. It makes the code confusing. You said, you > have a problem,

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Ian Kelly
On Fri, Jul 6, 2018 at 11:56 AM INADA Naoki wrote: > > D.setdefault('c', None) Not guaranteed to be atomic. I think the only safe way to do it is with a Lock. -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Ian Kelly
On Sat, Jul 7, 2018 at 8:03 AM Stefan Behnel wrote: > > Marko Rauhamaa schrieb am 07.07.2018 um 15:41: > > Steven D'Aprano : > >> On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: > >>> D.setdefault('c', None) > >> > >> Oh that's clever! > > > > Is that guaranteed to be thread-safe? The

Re: Congrats to Chris for breaking his PEP curse

2018-07-04 Thread Ian Kelly
On Wed, Jul 4, 2018 at 1:11 AM Steven D'Aprano wrote: > > On Tue, 03 Jul 2018 23:05:01 -0600, Ian Kelly wrote: > > > Now that I've actually read the PEP (sorry, I just assumed it would > > never fly), I have a couple of (tongue-in-cheek) observations about it: > >

Re: PEP 526 - var annotations and the spirit of python

2018-07-04 Thread Ian Kelly
On Wed, Jul 4, 2018, 9:36 AM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Wed, 04 Jul 2018 13:48:26 +0100, Bart wrote: > >> A better example would be: > >> > >> x: int = None > >> > >> which ought to be read as "x is an int, or None, and it's currently > >> None". > >

Re: Congrats to Chris for breaking his PEP curse

2018-07-03 Thread Ian Kelly
Now that I've actually read the PEP (sorry, I just assumed it would never fly), I have a couple of (tongue-in-cheek) observations about it: > group = re.match(data).group(1) if re.match(data) else None The only problem with this example of doing more work to save a line of code is that

Re: PEP 526 - var annotations and the spirit of python

2018-07-02 Thread Ian Kelly
On Sun, Jul 1, 2018 at 10:53 PM Jim Lee wrote: > I did get one epiphany out of that. He's right - there are orders of > magnitude more programmers today than there were a couple of decades ago > - and they ARE almost all entry level, in that they are fluent in only > one (maybe two) languages.

Re: PEP 526 - var annotations and the spirit of python

2018-07-01 Thread Ian Kelly
On Sun, Jul 1, 2018 at 11:09 AM Abdur-Rahmaan Janhangeer wrote: > > was viewing pep526, so, finally, python cannot do without hinting the type > as other languages? Python certainly can do without it. That's why it's an optional feature with no runtime effect beyond making the annotations

Re: Should nested classes in an Enum be Enum members?

2018-06-29 Thread Ian Kelly
On Thu, Jun 28, 2018 at 10:06 PM Ben Finney wrote: > > Ethan Furman writes: > > > On 06/28/2018 05:58 PM, Ben Finney wrote: > > > > > So I remain dumbfounded as to why anyone would want a class to *both* be > > > an enumerated type, *and* have callable attributes in its API. > > > > Perhaps I am

Re: Should nested classes in an Enum be Enum members?

2018-06-29 Thread Ian Kelly
On Thu, Jun 28, 2018 at 7:01 PM Ben Finney wrote: > > Ian Kelly writes: > > > On Thu, Jun 28, 2018 at 4:38 AM Ben Finney > > wrote: > > > > > > Ethan Furman writes: > > > > > > Specifically, I can't make sense of why someone would w

Re: Should nested classes in an Enum be Enum members?

2018-06-28 Thread Ian Kelly
On Thu, Jun 28, 2018 at 4:38 AM Ben Finney wrote: > > Ethan Furman writes: > > > Consider the following Enum definition: > > > > class Color(Enum): > > RED = 1 > > GREEN = 2 > > BLUE = 3 > > @property > > def lower(self): > > return self.name.lower() > >

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Tue, Jun 19, 2018 at 1:42 PM Rick Johnson wrote: > > On Tuesday, June 19, 2018 at 1:02:52 PM UTC-5, Ian wrote: > > On Mon, Jun 18, 2018 at 2:57 PM Rick Johnson > > It's a "burden" (actually, a helpful tool) to the > > programmer either way: whether it's in a comment or an > > annotation, it's

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Mon, Jun 18, 2018 at 2:57 PM Rick Johnson wrote: > > On Monday, June 18, 2018 at 2:48:58 PM UTC-5, Ian wrote: > > I would also note that none of this applies to type hinting > > in any case. Type hints don't require the programmer to be > > able to explain anything in natural language, nor are

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Tue, Jun 19, 2018 at 3:14 AM Steven D'Aprano wrote: > > On Mon, 18 Jun 2018 10:01:58 -0700, Rick Johnson wrote: > > > Steven D'Aprano wrote: > > [...] > >> particular at DropBox, which is (I believe) funding a lot of Guido's > >> time on this, because they need it. > > > > And now we get to

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 10:19 AM Rick Johnson wrote: > And even from the POV of a programmer, comments can be more > useful if they are ignored than if they are not. Some > programmers lack the skill required to properly explain the > workings of an algorithm in natural language, and thus, the >

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 11:27 AM Rick Johnson wrote: > > Ian wrote: > > > Uh, yes, they do. They're defined in PEP 484, and Mypy uses them for > > type-checking Python 2 code, where the annotations don't exist. > > So when will the interleaved type-hints be removed from the language >

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 11:39 AM Jim Lee wrote: > On 06/18/2018 07:03 AM, Steven D'Aprano wrote: > > As a human programmer, you surely perform your own ad hoc type checking > > when you write and debug code. > Of course. And, I use linting tools and other forms of static type > checking. What I

Re: syntax difference (type hints)

2018-06-18 Thread Ian Kelly
FYI, Python type hints aren't "proposed"; they're already here. The function annotation syntax was added in 3.0, without any imposition of semantic meaning or requirements on it, and allowed to simmer for several years for third-party frameworks to find uses for. Python 3.5 added the typing module

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 9:17 AM Rick Johnson wrote: > > Chris Angelico wrote: > [...] > > What was the quote before that? > > > > > "Type-hint comments" would allow: > > > (3) and those who utterly *HATE* them, to write a simpl[e] > > > little function which will strip them from any and all >

Re: OFF-TOPIC Good sig [was Re: What is the "Unpacking Arguments List" rule?]

2018-06-13 Thread Ian Kelly
On Wed, Jun 13, 2018 at 10:10 AM Steven D'Aprano wrote: > > On Wed, 13 Jun 2018 12:43:12 +, Alister via Python-list wrote: > > > I have a theory that it's impossible to prove anything, but I can't > > prove it. > > Heh, that reminds me of Stephen Pinker's comment from "Enlightenment Now": > >

Re: a Python bug report

2018-05-29 Thread Ian Kelly
On Tue, May 29, 2018 at 7:07 PM, Ruifeng Guo wrote: > Hello, > We encountered a bug in Python recently, we checked the behavior for Python > version 2.7.12, and 3.1.1, both version show the same behavior. Please see > below the unexpected behavior in "red text". > > Thanks, > Ruifeng Guo > >

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Ian Kelly
On Sat, May 26, 2018 at 9:17 AM, Paul St George wrote: > Thank you. > You are very right. The show() method is intended for debugging purposes and > is useful for that, but what method should I be using and is PIL the best > imaging library for my purposes? I do not want to manipulate images, I

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-29 Thread Ian Kelly
On Tue, May 29, 2018 at 3:19 AM, Peter J. Holzer wrote: > On 2018-05-23 11:08:48 -0600, Ian Kelly wrote: >> >> How about we instead just use the rules from PEP 257 so that there >> aren't two different sets of multi-line string indentation rules to >> ha

Re: Enums: making a single enum

2018-05-25 Thread Ian Kelly
On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote: > On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano > wrote: >> Am I silly for wanting to make a single enum? >> >> I have a three-state flag, True, False or Maybe. Is is confusing or

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 10:25 AM, Peter J. Holzer wrote: > How about this? > > x = > Here is a multi-line string > with > indentation. > > > This would be equivalent to > > x = 'Here is a multi-line string\nwith\n

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 12:49 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > On Tue, 22 May 2018 09:43:55 -0600, Ian Kelly wrote: > >> In other words, the rule is not really as simple as "commas make >> tuples". I stand by what I

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 12:01 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, May 22, 2018 at 11:32 PM, Christian Gollwitzer <aurio...@gmx.de> > wrote: >> Am 23.05.18 um 07:22 schrieb Chris Angelico: >>> >>> On Wed, May 23, 2018 at 9:51 AM, bart

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Ian Kelly
On Tue, May 22, 2018 at 11:32 PM, Christian Gollwitzer wrote: > Am 23.05.18 um 07:22 schrieb Chris Angelico: >> >> On Wed, May 23, 2018 at 9:51 AM, bartc wrote: >>> >>> Sorry, but I don't think you're right at all. unless the official >>> references >>> for the

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 9:34 AM, Chris Angelico <ros...@gmail.com> wrote: > On Wed, May 23, 2018 at 1:22 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: >> On Tue, May 22, 2018 at 8:25 AM, Chris Angelico <ros...@gmail.com> wrote: >>> On Tue, May 22, 2018 at 8:

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 9:22 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, May 22, 2018 at 8:25 AM, Chris Angelico <ros...@gmail.com> wrote: >> On Tue, May 22, 2018 at 8:25 PM, bartc <b...@freeuk.com> wrote: >>> Note that Python tup

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 8:25 AM, Chris Angelico wrote: > On Tue, May 22, 2018 at 8:25 PM, bartc wrote: >> Note that Python tuples don't always need a start symbol: >> >>a = 10,20,30 >> >> assigns a tuple to a. > > The tuple has nothing to do with the

Re: "Data blocks" syntax specification draft

2018-05-20 Thread Ian Kelly
On Sun, May 20, 2018 at 4:28 PM, Mikhail V wrote: > "Markdown" is too vague - there dozens of markdown styles and > also they include subsets of HTML. It is just plain text with tags The whole point of Markdown is that it's readable as plain text precisely because it

Re: what does := means simply?

2018-05-17 Thread Ian Kelly
On Thu, May 17, 2018, 7:50 PM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > If you want to *really* see code that is hard to port, you should try > porting an Inform 7 program to another language. Any other language. > How about Z-code? *ducks* > --

  1   2   3   4   5   6   7   8   9   10   >