RE: Using namedtuples field names for column indices in a list of lists

2017-01-10 Thread Steven D'Aprano
On Tuesday 10 January 2017 18:14, Deborah Swanson wrote: > I'm guessing that you (and those who > see things like you do) might not be used to working with quick learners > who make mistakes at first but catch up with them real fast, or you're > very judgemental about people who make mistakes, per

Re: Question about abstract base classes and abstract properties -- Python 2.7

2017-01-10 Thread Steven D'Aprano
On Wednesday 11 January 2017 12:26, Gerald Britton wrote: > I was rereading the 2.7 docs about abstract base classes the other day. I > found this line in the usage section of the abc.abstractproperty function: > > "This defines a read-only property; you can also define a read-write > abstract

Re: The hardest problem in computer science...

2017-01-10 Thread Ethan Furman
On 01/10/2017 08:06 AM, Paul Moore wrote: On Tuesday, 10 January 2017 15:47:20 UTC, Paul Moore wrote: On Saturday, 7 January 2017 19:14:43 UTC, Ethan Furman wrote: Ya know, that looks an /awful/ lot like a collection! Maybe even an Enum? ;) -- 8<

Re: Question about abstract base classes and abstract properties -- Python 2.7

2017-01-10 Thread Gerald Britton
I was rereading the 2.7 docs about abstract base classes the other day. I found this line in the usage section of the abc.abstractproperty function: "This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:" along with

Re: Temporary variables in list comprehensions

2017-01-10 Thread Steven D'Aprano
On Tuesday 10 January 2017 00:12, Antoon Pardon wrote: > Op 09-01-17 om 04:53 schreef Steven D'Aprano: >> Suppose you have an expensive calculation that gets used two or more times >> in a loop. The obvious way to avoid calculating it twice in an ordinary loop >> is with a temporary variable: [...

Re: Work between multiple processes

2017-01-10 Thread Patrick Zhou
Hi Irmen, I have successfully got it to work with both side as python but so far having trouble with pyrolite.jar which is downloaded from https://mvnrepository.com/artifact/net.razorvine/pyrolite/4.4 Having simple codes as: public static void main(String[] args) { //System.out.pr

Re: Help with this code

2017-01-10 Thread jladasky
On Monday, January 9, 2017 at 12:50:11 PM UTC-8, Joaquin Alzola wrote: > >> elements. For example, if we have a list_a=["a","b","c","d"] and > >> list_b=["a","b"] I want to obtain a new list_c containing elements that > >> match between these lists (a and b here), > > >Perhaps this might work: >

Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-10 Thread Irmen de Jong
On 10-1-2017 16:01, Donald Stufft wrote: >> TypeError: the JSON object must be str, not ‘bytes' > Huh, just tested, my original snippet works on Python 3.6 but fails on Python > 3.5. My guess is that is due to an improvement in 3.6 mentioned here: https://docs.python.org/3/whatsnew/3.6.html#jso

Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-10 Thread Donald Stufft
> On Jan 10, 2017, at 9:59 AM, Oleg Broytman wrote: > > On Tue, Jan 10, 2017 at 08:27:21AM -0500, Donald Stufft > wrote: >>python3 -c "import urllib.request,json; >> print(json.loads(urllib.request.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])" > > Traceback (most

Re: The hardest problem in computer science...

2017-01-10 Thread Paul Moore
On Tuesday, 10 January 2017 15:47:20 UTC, Paul Moore wrote: > On Saturday, 7 January 2017 19:14:43 UTC, Ethan Furman wrote: > > Ya know, that looks an /awful/ lot like a collection! Maybe even an Enum? > > ;) > > > > -- 8< --- > > from aenu

Re: The hardest problem in computer science...

2017-01-10 Thread Paul Moore
On Saturday, 7 January 2017 19:14:43 UTC, Ethan Furman wrote: > Ya know, that looks an /awful/ lot like a collection! Maybe even an Enum? ;) > > -- 8< --- > from aenum import Enum # note the 'a' before the 'enum' :) > > class Theme(Enum, i

Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-10 Thread Oleg Broytman
On Tue, Jan 10, 2017 at 08:27:21AM -0500, Donald Stufft wrote: > python3 -c "import urllib.request,json; > print(json.loads(urllib.request.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])" Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3

Re: Temporary variables in list comprehensions

2017-01-10 Thread Paul Moore
On Monday, 9 January 2017 03:53:37 UTC, Steven D'Aprano wrote: > Suppose you have an expensive calculation that gets used two or more times > in a loop. [...] > [(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]] > > I can't decide whether that's an awesome trick or a horrible

Re: Temporary variables in list comprehensions

2017-01-10 Thread jmp
On 01/09/2017 04:53 AM, Steven D'Aprano wrote: Suppose you have an expensive calculation that gets used two or more times in a loop. The obvious way to avoid calculating it twice in an ordinary loop is with a temporary variable: result = [] for x in data: tmp = expensive_calculation(x)

Re: Enum with only a single member

2017-01-10 Thread Peter Otten
Steven D'Aprano wrote: > Is it silly to create an enumeration with only a single member? That is, a > singleton enum? > > from enum import Enum > > class Unique(Enum): > FOO = auto() > > > The reason I ask is that I have two functions that take an enum argument. > The first takes one of th

Re: Enum with only a single member

2017-01-10 Thread jmp
On 01/10/2017 05:43 AM, Steven D'Aprano wrote: Is it silly to create an enumeration with only a single member? That is, a singleton enum? Don't think so, for the same reason that lists with one element make sense. def ham(arg): if isinstance(arg, MarxBros) or arg is Unique.FOO:

Re: Enum with only a single member

2017-01-10 Thread Ethan Furman
On 01/10/2017 12:37 AM, Chris Angelico wrote: On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote: That is, a singleton enum? Why stop there? You can make empty ones too. (Zerotons?) Sure you *can*, but I can't think of any time they'd be useful. Can you give an example? Sure. Any time

Re: Using namedtuples field names for column indices in a list of lists

2017-01-10 Thread Ethan Furman
On 01/09/2017 11:14 PM, Deborah Swanson wrote: So I guess you should just do your thing and I'll do mine. As you say. Takes all kinds, and I think in the end what will count is the quality of my finished work (which has always been excellent), and not the messy process to get there. Agreed

Re: Is enum iteration order guaranteed?

2017-01-10 Thread Ethan Furman
On 01/09/2017 10:22 PM, Steven D'Aprano wrote: On Tuesday 10 January 2017 16:55, Ethan Furman wrote: On 01/09/2017 09:18 PM, Steven D'Aprano wrote: The docs say that enums can be iterated over, but it isn't clear to me whether they are iterated over in definition order or value order. If I ha

Re: Enum with only a single member

2017-01-10 Thread Chris Angelico
On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote: >> That is, a singleton enum? > > Why stop there? You can make empty ones too. (Zerotons?) Sure you *can*, but I can't think of any time they'd be useful. Can you give an example? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Enum with only a single member

2017-01-10 Thread Paul Rubin
Steven D'Aprano writes: > Is it silly to create an enumeration with only a single member? No. > That is, a singleton enum? Why stop there? You can make empty ones too. (Zerotons?) > The reason I ask is that I have two functions that take an enum > argument. Sounds like a good reason. >