From Alister.ware at ntlworld.com Mon Oct 1 04:15:19 2018 From: Alister.ware at ntlworld.com (Alister ware) Date: Mon, 01 Oct 2018 08:15:19 GMT Subject: How to change '\\' to '\' References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> Message-ID: On Sun, 30 Sep 2018 17:45:52 -0700, Rick Johnson wrote: > Jach Fong wrote: >> I get a string item, for example path[0], from path = >> os.get_exec_path() >> It's something like "\\Borland\\Bcc55\\Include", a Python string. >> I want to use this "string" in a subprocess command as a parameter. >> Obviously this command can only recognize "\Borland\Bcc55\Include". >> I know there must have an easy way to convert it, but just can't figure >> it out :-( > > I would suggest substituting all backslashes with forward slashes, that > way, the printed version and the internal escaped version won't be > confusing to you. And besides, which is easier to read? > > This? > > "\\Borland\\Bcc55\\Include" > > Or this? > > "/Borland/Bcc55/Include" > > ??? > > Practicality Beats Purity -- ???????????????? -- ?????? From jfong at ms4.hinet.net Mon Oct 1 05:19:25 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Mon, 1 Oct 2018 17:19:25 +0800 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> Message-ID: <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> Hmmm...strange, I didn't see Rick's mail:-( Sure the forward slash is better, not to cause this confusion. But I am curious, since when, I mean, since which version Windows start to accept forward slash? --Jach Alister ware via Python-list at 2018/10/1 PM 04:15 wrote: > On Sun, 30 Sep 2018 17:45:52 -0700, Rick Johnson wrote: > >> Jach Fong wrote: >>> I get a string item, for example path[0], from path = >>> os.get_exec_path() >>> It's something like "\\Borland\\Bcc55\\Include", a Python string. >>> I want to use this "string" in a subprocess command as a parameter. >>> Obviously this command can only recognize "\Borland\Bcc55\Include". >>> I know there must have an easy way to convert it, but just can't figure >>> it out :-( >> >> I would suggest substituting all backslashes with forward slashes, that >> way, the printed version and the internal escaped version won't be >> confusing to you. And besides, which is easier to read? >> >> This? >> >> "\\Borland\\Bcc55\\Include" >> >> Or this? >> >> "/Borland/Bcc55/Include" >> >> ??? >> >> > > Practicality Beats Purity > > > > --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From tjol at tjol.eu Mon Oct 1 05:28:36 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 1 Oct 2018 11:28:36 +0200 Subject: How to change '\\' to '\' In-Reply-To: <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> Message-ID: <3c982573-7fa0-efdc-2638-1b56a818c372@tjol.eu> On 2018-10-01 11:19, Jach Fong wrote: > Hmmm...strange, I didn't see Rick's mail:-( That's because he's banned from the list, but still around on the newsgroup > Sure the forward slash is better, not to cause this confusion. > But I am curious, since when, I mean, since which version > Windows start to accept forward slash? Windows has always supported forward slashes in most contexts for compatibility with UNIX software. (just not in cmd.exe IIRC) > > --Jach > > Alister ware via Python-list at 2018/10/1 PM 04:15 wrote: >> On Sun, 30 Sep 2018 17:45:52 -0700, Rick Johnson wrote: >> >>> Jach Fong wrote: >>>> I get a string item, for example path[0], from path = >>>> os.get_exec_path() >>>> It's something like "\\Borland\\Bcc55\\Include", a Python string. >>>> I want to use this "string" in a subprocess command as a parameter. >>>> Obviously this command can only recognize "\Borland\Bcc55\Include". >>>> I know there must have an easy way to convert it, but just can't figure >>>> it out :-( >>> >>> I would suggest substituting all backslashes with forward slashes, that >>> way, the printed version and the internal escaped version won't be >>> confusing to you. And besides, which is easier to read? >>> >>> This? >>> >>> ?? "\\Borland\\Bcc55\\Include" >>> >>> Or this? >>> >>> ?? "/Borland/Bcc55/Include" >>> >>> ??? >>> >>> >> >> Practicality Beats Purity >> >> >> >> > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > -- Thomas Jollans m ? +31 (6) 42630259 e ? tjol at tjol.eu From hjp-python at hjp.at Mon Oct 1 05:28:50 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 1 Oct 2018 11:28:50 +0200 Subject: How to change '\\' to '\' In-Reply-To: <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> Message-ID: <20181001092850.h2dkeiannhckkdcz@hjp.at> On 2018-10-01 17:19:25 +0800, Jach Fong wrote: > Sure the forward slash is better, not to cause this confusion. > But I am curious, since when, I mean, since which version > Windows start to accept forward slash? Since MS-DOS 2.0, i.e., before Windows even existed. Note that this is only true for system call paraeters[1], not for command line parameters. So for your use case: > > > > I want to use this "string" in a subprocess command as a parameter. you probably need to use backslashes, not forward slashes (it depends on the program you are calling). hp [1] And even there not always, as I've learned from the resident Windows expert on this list. -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From ethan at stoneleaf.us Mon Oct 1 13:43:32 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 1 Oct 2018 10:43:32 -0700 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> On 09/30/2018 09:30 AM, Steven D'Aprano wrote: > Notwithstanding Ethan's comment about having posted the suspension notice > on the list, I see no sign that he actually did so. My apologies to you and the list. I did indeed only send the notice to the other moderators. Contrary to what you and others may believe, banning/suspending people is not a gleeful, stress-free activity. None of us like to do it. Also contrary to what you and others seem to believe, I did not make those decisions by myself. As far as challenging the ban, I think the first step would be talking to the CoC working group: conduct-wg at python.org If you don't like that answer, the next (and final, as far as I'm aware) stop would be the PSF. I have updated the filter that should be catching your posts, so hopefully the suspension is now working properly. Since you did choose to ignore the ban, the two-month period restarts now. -- ~Ethan~ Python List Moderator From nanman3012 at gmail.com Mon Oct 1 13:49:02 2018 From: nanman3012 at gmail.com (nanman3012 at gmail.com) Date: Mon, 1 Oct 2018 10:49:02 -0700 (PDT) Subject: regex string matching python3 Message-ID: I have a string like this: b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' And I would like to extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this: [ '89.9', '4.4', '1.7', '4.0'] Any help would be appreciated! From ethan at stoneleaf.us Mon Oct 1 13:53:45 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 1 Oct 2018 10:53:45 -0700 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: <931b9e9b-d687-f9ba-74c5-644956717ef7@stoneleaf.us> This thread is closed. -- ~Ethan~ Python List Moderator From rosuav at gmail.com Mon Oct 1 14:05:36 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Oct 2018 04:05:36 +1000 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On Tue, Oct 2, 2018 at 3:49 AM Mark Lawrence wrote: > > Personally I think Ethan Furman should be removed from his position as a > moderator as he's less than useless at the job. If you mean how he sent an email to the mods instead of to the list, that's a simple administrative error that anyone could make (and I have myself made similar errors - sending Python emails to a Gilbert & Sullivan list, and vice versa). If you mean the decision to put Steve on moderation, that was not Ethan's decision alone. ChrisA From jkn_gg at nicorp.f9.co.uk Mon Oct 1 14:25:11 2018 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Mon, 1 Oct 2018 11:25:11 -0700 (PDT) Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: On Monday, October 1, 2018 at 6:57:30 PM UTC+1, Ethan Furman wrote: > On 09/30/2018 09:30 AM, Steven D'Aprano wrote: > > > Notwithstanding Ethan's comment about having posted the suspension notice > > on the list, I see no sign that he actually did so. > > My apologies to you and the list. I did indeed only send the notice to > the other moderators. > > Contrary to what you and others may believe, banning/suspending people > is not a gleeful, stress-free activity. None of us like to do it. Also > contrary to what you and others seem to believe, I did not make those > decisions by myself. > > As far as challenging the ban, I think the first step would be talking > to the CoC working group: > > conduct-wg at python.org > > If you don't like that answer, the next (and final, as far as I'm aware) > stop would be the PSF. > > I have updated the filter that should be catching your posts, so > hopefully the suspension is now working properly. Since you did choose > to ignore the ban, the two-month period restarts now. > > -- > ~Ethan~ > Python List Moderator As a reader of /occasional contributor to, this newsgroup (via GG, admittedly) since around the year 2000, I for one am mightily unimpressed with this. There's a lot of heavy-handedness going around. And then ... you make a mistake, and then restart the ban?? Sheesh, where has happened to the the grown-up behaviour that c.l.python has always had? That has been one of its hallmarks for the past nearly twenty years. I'm not going to go as far as to agree with anything RR says on the matter - but c'mon guys, lighten up. Jon N From breamoreboy at gmail.com Mon Oct 1 15:08:35 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Mon, 1 Oct 2018 20:08:35 +0100 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On 01/10/18 19:05, Chris Angelico wrote: > On Tue, Oct 2, 2018 at 3:49 AM Mark Lawrence wrote: >> >> Personally I think Ethan Furman should be removed from his position as a >> moderator as he's less than useless at the job. > > If you mean how he sent an email to the mods instead of to the list, > that's a simple administrative error that anyone could make (and I > have myself made similar errors - sending Python emails to a Gilbert & > Sullivan list, and vice versa). If you mean the decision to put Steve > on moderation, that was not Ethan's decision alone. > > ChrisA > I mean that I have always thought that Ethan Furman was useless as a moderator. Having said that with this latest disgraceful decision regarding Steven I believe all moderators should stand down as they all appear to be clueless, especially I don't recall getting asked who I wanted in the job. If their defence is that they're applying the CoC to the letter then that should be rewritten be back the people who have in the long term supported Python, not the lazy, bone idle types who provide no data, no code, no nothing when asking their question, and the well known trolls who get away with blue murder who months or even years before they get kicked into touch. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From python at mrabarnett.plus.com Mon Oct 1 15:14:59 2018 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 1 Oct 2018 20:14:59 +0100 Subject: regex string matching python3 In-Reply-To: References: Message-ID: <3b08e88c-a0e0-0ce0-3e0f-0aa3dc608d49@mrabarnett.plus.com> On 2018-10-01 18:49, nanman3012 at gmail.com wrote: > I have a string like this: > > b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' > > And I would like to extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this: > > [ '89.9', '4.4', '1.7', '4.0'] > > Any help would be appreciated! > Try this: re.findall(r'\b[SDFM]:(\d+\.\d+)', data.decode('ascii')) From roel at roelschroeven.net Mon Oct 1 15:22:55 2018 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 1 Oct 2018 21:22:55 +0200 Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: jkn schreef op 1/10/2018 om 20:25: > On Monday, October 1, 2018 at 6:57:30 PM UTC+1, Ethan Furman wrote: >> On 09/30/2018 09:30 AM, Steven D'Aprano wrote: >> >>> Notwithstanding Ethan's comment about having posted the suspension notice >>> on the list, I see no sign that he actually did so. >> >> My apologies to you and the list. I did indeed only send the notice to >> the other moderators. >> >> I have updated the filter that should be catching your posts, so >> hopefully the suspension is now working properly. Since you did choose >> to ignore the ban, the two-month period restarts now. >> > > As a reader of /occasional contributor to, this newsgroup (via GG, admittedly) > since around the year 2000, I for one am mightily unimpressed with this. > There's a lot of heavy-handedness going around. > > And then ... you make a mistake, and then restart the ban?? Sheesh, where has > happened to the the grown-up behaviour that c.l.python has always had? > That has been one of its hallmarks for the past nearly twenty years. > > I'm not going to go as far as to agree with anything RR says on the matter - > but c'mon guys, lighten up. Yeah I don't understand this neither. I'm not very active here, but I've been lurking for years. In my eyes Steven has always been active and helpful. Now he has *once* been a *tiny bit* rude, and he's banned for that? As far as I can see the moderators do a pretty good job overall, but this decision is ... weird. -- "Honest criticism is hard to take, particularly from a relative, a friend, an acquaintance, or a stranger." -- Franklin P. Jones Roel Schroeven From fetchinson at googlemail.com Mon Oct 1 15:58:42 2018 From: fetchinson at googlemail.com (Fetchinson .) Date: Mon, 1 Oct 2018 21:58:42 +0200 Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: On 10/1/18, Roel Schroeven wrote: > jkn schreef op 1/10/2018 om 20:25: >> On Monday, October 1, 2018 at 6:57:30 PM UTC+1, Ethan Furman wrote: >>> On 09/30/2018 09:30 AM, Steven D'Aprano wrote: >>> >>>> Notwithstanding Ethan's comment about having posted the suspension >>>> notice >>>> on the list, I see no sign that he actually did so. >>> >>> My apologies to you and the list. I did indeed only send the notice to >>> the other moderators. >>> >>> I have updated the filter that should be catching your posts, so >>> hopefully the suspension is now working properly. Since you did choose >>> to ignore the ban, the two-month period restarts now. >>> >> >> As a reader of /occasional contributor to, this newsgroup (via GG, >> admittedly) >> since around the year 2000, I for one am mightily unimpressed with this. >> There's a lot of heavy-handedness going around. >> >> And then ... you make a mistake, and then restart the ban?? Sheesh, where >> has >> happened to the the grown-up behaviour that c.l.python has always had? >> That has been one of its hallmarks for the past nearly twenty years. >> >> I'm not going to go as far as to agree with anything RR says on the matter >> - >> but c'mon guys, lighten up. > > Yeah I don't understand this neither. > > I'm not very active here, but I've been lurking for years. In my eyes > Steven has always been active and helpful. Now he has *once* been a > *tiny bit* rude, and he's banned for that? > > As far as I can see the moderators do a pretty good job overall, but > this decision is ... weird. +1 Steven has been around for a long time, after a quick search it seems for at least 15 years, I mean on python-list. He has consistently been helpful and has dedicated an amazing number of man hours to altruistic help of fellow python users, beginners, experts, etc. I'm totally amazed by this decision to ban him. The official explanation has referenced 2 potentially mildly problematic posts. I guess the moderators do have and should have the power to ban people but we all have the right to criticise these bans on a case by case basis. I'm not implying that Ethan and the moderators who were involved in the ban are doing a bad job in general, but in this particular case it does seem hyper excessive. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From none at invalid.com Mon Oct 1 17:05:31 2018 From: none at invalid.com (mm0fmf) Date: Mon, 01 Oct 2018 22:05:31 +0100 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> Message-ID: On 01/10/2018 10:19, Jach Fong wrote: > Hmmm...strange, I didn't see Rick's mail:-( > > Sure the forward slash is better, not to cause this confusion. > But I am curious, since when, I mean, since which version > Windows start to accept forward slash? > First, stop top posting. Second, ISTR that all Windows NT versions and versions derived from the NT codebase support forward slash in pathnames given to functions. It may go back further, but anything derived from NT works. I can't remember which Windows command shells support it, probably PowerShell does. From brian.j.oney at googlemail.com Mon Oct 1 17:39:51 2018 From: brian.j.oney at googlemail.com (Brian J. Oney) Date: Mon, 01 Oct 2018 23:39:51 +0200 Subject: regex string matching python3 In-Reply-To: References: Message-ID: <1538429991.12274.2.camel@gmail.com> On Mon, 2018-10-01 at 10:49 -0700, nanman3012 at gmail.com wrote: > I have a string like this:? >? > b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' >? > And I would like to??extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this:? >? > [ '89.9', '4.4', '1.7', '4.0'] >? > Any help would be appreciated!? Hi there, import re s = b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' pattern = re.compile('S:([0-9.]+)%,D:([0-9.]+)%\],F:([0-9.]+)%,M:([0-9.]+)') stuff = [x for x in re.findall(pattern, s)[0]] You may consider just getting everthing out of your string and then munging it to what ever you like. I mean: pattern = re.compile('([A-Za-z]):([0-9.]+)') {x: float(y) for x, y in re.findall(pattern, s) Then you could read what ever and put it in a handy format wherein it is clear what it was. I mean: stuff = [] for s in iostream: ????stuff.append({x: float(y) for x, y in re.findall(pattern, s)}) HTH From jon+usenet at unequivocal.eu Mon Oct 1 19:20:26 2018 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 1 Oct 2018 23:20:26 -0000 (UTC) Subject: So apparently I've been banned from this list References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: On 2018-10-01, Roel Schroeven wrote: > I'm not very active here, but I've been lurking for years. In my eyes > Steven has always been active and helpful. Now he has *once* been a > *tiny bit* rude, and he's banned for that? It's not "once", it's a long-standing pattern of behaviour. > As far as I can see the moderators do a pretty good job overall, but > this decision is ... weird. It's not "weird" so much as it is "long overdue", but even I would say that two months seems a little excessive. From ben+python at benfinney.id.au Mon Oct 1 19:26:36 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 02 Oct 2018 09:26:36 +1000 Subject: This thread is closed (was: [OT] master/slave debate in Python) References: <931b9e9b-d687-f9ba-74c5-644956717ef7@stoneleaf.us> Message-ID: <86pnwt45ar.fsf_-_@benfinney.id.au> Ethan Furman writes: > This thread is closed. Coming from a moderator of this forum, I don't know how that statement is to be interpreted. Is that a statement that it is *impossible* (mechanically) to post replies in this thread? Across the different technologies that propogate this forum? If not impossible, is that a statement that it is *strictly prohibited*, by a forum moderator, to post replies in this thread? If prohibited, what are we to expect are the consequences of breaching that prohibition, knowingly or unknowingly? How is any of the above affected by posting in the same thread but on a different metter, as I have done? How is any of the above affected by changing the Subject field, as I have done? If there is some specific formal meaning to the above statement, I don't know where it's documented. If it's not a specific formal statement, that is itself troubling, because it's not clear what would constitute a violation nor what the consequences are. Ethan, I thank you for doing the fraught work of a moderator of this forum. Hopefully we can get clarity on this and future thread-closing actions, separate from the thread which prompted this instance. -- \ ?Truth would quickly cease to become stranger than fiction, | `\ once we got as used to it.? ?Henry L. Mencken | _o__) | Ben Finney From ethan at stoneleaf.us Mon Oct 1 20:02:48 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 1 Oct 2018 17:02:48 -0700 Subject: This thread is closed [an actual new thread] Message-ID: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> On 10/01/2018 04:26 PM, Ben Finney wrote: > Ethan Furman writes: >> This thread is closed. > > Coming from a moderator of this forum, I don't know how that statement > is to be interpreted. It should be interpreted as: - No further discussion should take place on this thread. - I've done what I can with the primitive tools at hand to block any further discussion. - Continued considerate posts will be discarded. - Continued flame-bait/inconsiderate posts will be met with warnings or stronger as warranted. > Is that a statement that it is *impossible* (mechanically) to post > replies in this thread? Across the different technologies that > propogate this forum? Not impossible, no. > If not impossible, is that a statement that it is *strictly prohibited*, by a forum moderator, to post replies in this thread? If one tries to get around moderators' efforts to shut down a thread we will interpret that harshly. > If prohibited, what are we to expect are the consequences of breaching > that prohibition, knowingly or unknowingly? Two factors come into play: 1) do we think the post was done knowingly or unknowingly; and 2) the content of the post. > How is any of the above affected by posting in the same thread but on > a different matter, as I have done? At this point the blocks are entirely based on subject lines (like I said, primitive). If the new subject line still matches the relevant regex, then it will get held and we will decide what to do with it (I allowed this one as it had good questions -- in general, just start a new thread if the subject is different, as I did in this reply). > How is any of the above affected by changing the Subject field, as I > have done? If the subject is different enough it will get by the block. If the content is still on the old subject we will consider that as willfully ignoring the thread closure. > If there is some specific formal meaning to the above statement, I > don't know where it's documented. If it's not a specific formal > statement, that is itself troubling, because it's not clear what would > constitute a violation nor what the consequences are. Consider it now documented, at least on Python List. I imagine Python Ideas may also implement this framework (assuming we stay on Mail Man and don't migrate to some web-based forum). > Ethan, I thank you for doing the fraught work of a moderator of this > forum. Hopefully we can get clarity on this and future thread-closing > actions, separate from the thread which prompted this instance. Let me know if anything is still unclear. -- ~Ethan~ From chandana.pattanayak at patterneffectslabs.com Mon Oct 1 21:29:05 2018 From: chandana.pattanayak at patterneffectslabs.com (Chandana Pattanayak) Date: Tue, 2 Oct 2018 06:59:05 +0530 Subject: How to achieve pyc only deployment for module in python3.6 Message-ID: Hi, I have a requirement to provide basic code protection for a module in our product suite. With python 3.6 the .pyc files are created under pycache , so if i remove the py file the module is not found anymore. Thank you, Chandana From jfong at ms4.hinet.net Mon Oct 1 22:17:27 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Tue, 2 Oct 2018 10:17:27 +0800 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> Message-ID: <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> Thanks for your info about how Windows supports the forward slash. I don't quit sure what is the meaning of "top posting" in your mail. If its meaning (forgive me if I was wrong) is where the reply was put in mail, I have reason of standing on the opposite side. It was supposed that most discussant want to see the reply message instantly when they open the mail. They already know what is going on and no need to pass through all those previous message. "top posting" seems more reasonable to me:-) --Jach mm0fmf at 2018/10/2 AM 05:05 wrote: > On 01/10/2018 10:19, Jach Fong wrote: >> Hmmm...strange, I didn't see Rick's mail:-( >> >> Sure the forward slash is better, not to cause this confusion. >> But I am curious, since when, I mean, since which version >> Windows start to accept forward slash? >> > > First, stop top posting. > > Second, ISTR that all Windows NT versions and versions derived from the > NT codebase support forward slash in pathnames given to functions. It > may go back further, but anything derived from NT works.? I can't > remember which Windows command shells support it, probably PowerShell does. > --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From wrw at mac.com Tue Oct 2 00:22:24 2018 From: wrw at mac.com (William Ray Wing) Date: Tue, 02 Oct 2018 00:22:24 -0400 Subject: How to change '\\' to '\' In-Reply-To: <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> Message-ID: <8BFAE333-44FA-41E0-8243-57082FF984FB@mac.com> > On Oct 1, 2018, at 10:17 PM, Jach Fong wrote: > > Thanks for your info about how Windows supports the forward slash. > > I don't quit sure what is the meaning of "top posting" in your mail. > If its meaning (forgive me if I was wrong) is where the reply was put > in mail, I have reason of standing on the opposite side. > Yes, exactly correct > It was supposed that most discussant want to see the reply message > instantly when they open the mail. They already know what is going on > and no need to pass through all those previous message. "top posting" > seems more reasonable to me:-) > The problem is that it is comparatively rare for there to be a singleton Q and immediate A. Even seemingly simple questions frequently trigger fairly long discussions, which assume familiarity with the earlier discussion. AND this list is pretty much the place of record for people researching python IFAQs (infrequently asked questions). So, six months from now a Google search that turns up a relevant thread will make sense only if it can be read as in-lined comments like this. > --Jach > > mm0fmf at 2018/10/2 AM 05:05 wrote: >>> On 01/10/2018 10:19, Jach Fong wrote: >>> Hmmm...strange, I didn't see Rick's mail:-( >>> >>> Sure the forward slash is better, not to cause this confusion. >>> But I am curious, since when, I mean, since which version >>> Windows start to accept forward slash? >>> >> First, stop top posting. >> Second, ISTR that all Windows NT versions and versions derived from the NT codebase support forward slash in pathnames given to functions. It may go back further, but anything derived from NT works. I can't remember which Windows command shells support it, probably PowerShell does. > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > -- > https://mail.python.org/mailman/listinfo/python-list From dieter at handshake.de Tue Oct 2 01:23:08 2018 From: dieter at handshake.de (dieter) Date: Tue, 02 Oct 2018 07:23:08 +0200 Subject: How to achieve pyc only deployment for module in python3.6 References: Message-ID: <87h8i4exc3.fsf@handshake.de> Chandana Pattanayak writes: > I have a requirement to provide basic code protection for a module in our > product suite. With python 3.6 the .pyc files are created under pycache , > so if i remove the py file the module is not found anymore. One approach could be to define and register your own import hook, similar to the "zipimporter". Such import hooks allow to find modules in non standard places, such as in a zip archive. Of course, you would need to implement the import hook in a standard place (accessible with the standard Python import mechanism). Another approach could be, that you move the created "*.pyc" files to standard import places for deployment. Note that you can disassemble "*.pyc" files and gain quite some insight by this. Thus, the protection provided by not deploying the source files is basic indeed. From rosuav at gmail.com Tue Oct 2 01:41:02 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Oct 2018 15:41:02 +1000 Subject: How to achieve pyc only deployment for module in python3.6 In-Reply-To: References: Message-ID: On Tue, Oct 2, 2018 at 12:01 PM Chandana Pattanayak wrote: > > Hi, > > I have a requirement to provide basic code protection for a module in our > product suite. With python 3.6 the .pyc files are created under pycache , > so if i remove the py file the module is not found anymore. If you want code protection, the ONLY reliable way to do it is to not provide the code *at all*, in any form. That generally means hosting your application on some sort of server and granting access that way (eg through a web browser interface). Shipping only .pyc files does not protect your code - it merely obscures it a little. I suggest changing the requirement. Otherwise, you're running a huge risk that someone will decompile your pyc files, word will get back to your company, and you'll get in trouble for having deceived people into thinking that the code was protected when it actually wasn't. ChrisA From dieter at handshake.de Tue Oct 2 01:50:51 2018 From: dieter at handshake.de (dieter) Date: Tue, 02 Oct 2018 07:50:51 +0200 Subject: How to achieve pyc only deployment for module in python3.6 References: <87h8i4exc3.fsf@handshake.de> Message-ID: <87d0ssew1w.fsf@handshake.de> dieter writes: > Chandana Pattanayak writes: >> I have a requirement to provide basic code protection for a module in our >> product suite. With python 3.6 the .pyc files are created under pycache , >> so if i remove the py file the module is not found anymore. > ... > Note that you can disassemble "*.pyc" files and gain > quite some insight by this. Thus, the protection provided > by not deploying the source files is basic indeed. You should also read "https://www.python.org/dev/peps/pep-3147/". It mainly explains why "pycache" has been introduced but as a side effect, it points out a bondage between the "*.pyc" files and the major Python version: it is very likely, that a major Python version will not accept "*.pyc" files created by another major Python version. From auriocus at gmx.de Tue Oct 2 02:10:28 2018 From: auriocus at gmx.de (Christian Gollwitzer) Date: Tue, 2 Oct 2018 08:10:28 +0200 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> Message-ID: Am 02.10.18 um 04:17 schrieb Jach Fong: > It was supposed that most discussant want to see the reply message > instantly when they open the mail. They already know what is going on > and no need to pass through all those previous message. "top posting" > seems more reasonable to me:-) You assume that everybody who reads it has already read all the previous discussion. That may be true in a private discussion, but on Usenet often people scan over the postings and don't recall all the details. Also, "intermixed posting" makes it easier to reply to several points individually. You should shorten the quote to the releveant bit that your reply belongs to. Classic quote: A: Because it reverses the logical flow of conversation. Q: Why is top posting frowned upon? A: Top-posting. Q: What is the most annoying thing on usenet and in email? Christian From chandana.pattanayak at patterneffectslabs.com Tue Oct 2 02:40:48 2018 From: chandana.pattanayak at patterneffectslabs.com (Chandana Pattanayak) Date: Tue, 2 Oct 2018 12:10:48 +0530 Subject: How to achieve pyc only deployment for module in python3.6 In-Reply-To: <87d0ssew1w.fsf@handshake.de> References: <87h8i4exc3.fsf@handshake.de> <87d0ssew1w.fsf@handshake.de> Message-ID: Thank you all. I will go for containers. Will ask for more time based on all your inputs.. Thanks, Chandana On Tue, 2 Oct 2018, 11:22 dieter, wrote: > dieter writes: > > Chandana Pattanayak writes: > >> I have a requirement to provide basic code protection for a module in > our > >> product suite. With python 3.6 the .pyc files are created under pycache > , > >> so if i remove the py file the module is not found anymore. > > ... > > Note that you can disassemble "*.pyc" files and gain > > quite some insight by this. Thus, the protection provided > > by not deploying the source files is basic indeed. > > You should also read "https://www.python.org/dev/peps/pep-3147/". > It mainly explains why "pycache" has been introduced > but as a side effect, it points out a bondage between > the "*.pyc" files and the major Python version: it is very likely, > that a major Python version will not accept "*.pyc" files created > by another major Python version. > > -- > https://mail.python.org/mailman/listinfo/python-list > From ethan at stoneleaf.us Tue Oct 2 02:48:32 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 1 Oct 2018 23:48:32 -0700 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> Message-ID: On 10/01/2018 11:10 PM, Christian Gollwitzer wrote: > Am 02.10.18 um 04:17 schrieb Jach Fong: >> It was supposed that most discussant want to see the reply message >> instantly when they open the mail. They already know what is going on >> and no need to pass through all those previous message. "top posting" >> seems more reasonable to me:-) > > You assume that everybody who reads it has already read all the previous > discussion. That may be true in a private discussion, but on Usenet > often people scan over the postings and don't recall all the details. Even for two-person, private email discussions I prefer the interleaved replies -- in a week when I have to remind myself what was discussed it is much easier to comprehend. > Also, "intermixed posting" makes it easier to reply to several points > individually. You should shorten the quote to the releveant bit that > your reply belongs to. Yes. It is extremely annoying when someone top posts and leaves the entire rest of the discussion still attached at the bottom. -- ~Ethan~ From kirillbalunov at gmail.com Tue Oct 2 05:11:37 2018 From: kirillbalunov at gmail.com (Kirill Balunov) Date: Tue, 2 Oct 2018 12:11:37 +0300 Subject: How to achieve pyc only deployment for module in python3.6 In-Reply-To: References: Message-ID: On Tue, Oct 2, 2018, 08:42 Chris Angelico wrote: > On Tue, Oct 2, 2018 at 12:01 PM Chandana Pattanayak > wrote: > > > > Hi, > > > > I have a requirement to provide basic code protection for a module in our > > product suite. With python 3.6 the .pyc files are created under pycache , > > so if i remove the py file the module is not found anymore. > > If you want code protection, the ONLY reliable way to do it is to not > provide the code *at all*, in any form. > I think Cython is a rather reliable way to do it. There is a nice post to start with ?Protecting Python Sources With Cython? @2parrots https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e With kind regards, -gdg > From anthony.flury at btinternet.com Tue Oct 2 06:10:08 2018 From: anthony.flury at btinternet.com (Anthony Flury) Date: Tue, 2 Oct 2018 11:10:08 +0100 Subject: Question about Multi-processing Message-ID: <64ba533c-28d9-ab4a-75ef-2fdd4b616dd1@btinternet.com> I decided to spend this morning to get my head around multi-processing, and decided to try to experiment initially in the command line interpreter, using the Python 3 documentation I fired up Python 3.6 and ran this : Python 3.6.6 (default, Sep 12 2018, 18:26:19) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from multiprocessing import Pool >>> def f(x): ...???? return x*2 + 1 ... >>> with Pool(10) as p: ...????? print(p.map(f, range(1,100))) ... [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199] As you can see - it clearly worked as expected - queue a happy dance. I continued to read the documentation and came to this quote : /Functionality within this package requires that the //|__main__|//module be importable by the children. This is covered in //Programming guidelines //however it is worth pointing out here. This means that some examples, such as the //|multiprocessing.pool.Pool| //examples will not work in the interactive interpreter./ The Documentation then gives a clear example very similar to mine : >>> from multiprocessing import Pool >>> p = Pool(5) >>> def f(x): ... return x*x ... >>> p.map(f, [1,2,3]) Process PoolWorker-1: Process PoolWorker-2: Process PoolWorker-3: Traceback (most recent call last): AttributeError: 'module' object has no attribute 'f' AttributeError: 'module' object has no attribute 'f' AttributeError: 'module' object has no attribute 'f' But when I run this exact example in the command line interpreter it works fine : >>> p = Pool(5) >>> def f(x): ...???? return x*x ... >>> p.map(f,[1,2,3]) [3, 5, 7] Is the documentation wrong ? is something weird going on ? -- Anthony Flury *Email* : anthony.flury at btinternet.com *Twitter* : @TonyFlury From rhodri at kynesim.co.uk Tue Oct 2 06:46:18 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 2 Oct 2018 11:46:18 +0100 Subject: This thread is closed [an actual new thread] In-Reply-To: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: On 02/10/18 01:02, Ethan Furman wrote: > On 10/01/2018 04:26 PM, Ben Finney wrote: > > Ethan Furman writes: > > >> This thread is closed. > > > > Coming from a moderator of this forum, I don't know how that statement > > is to be interpreted. > > It should be interpreted as: > > - No further discussion should take place on this thread. > - I've done what I can with the primitive tools at hand to block > ? any further discussion. > - Continued considerate posts will be discarded. > - Continued flame-bait/inconsiderate posts will be met with warnings > ? or stronger as warranted. 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 considerate posts will be discarded" is outrageous. I have been unimpressed with the moderation team for some weeks now, but this is just not acceptable. -- Rhodri James *-* Kynesim Ltd From vinay_sajip at yahoo.co.uk Tue Oct 2 06:51:05 2018 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 2 Oct 2018 10:51:05 +0000 (UTC) Subject: ANN: distlib 0.2.8 released on PyPI References: <1396803138.3606424.1538477465897.ref@mail.yahoo.com> Message-ID: <1396803138.3606424.1538477465897@mail.yahoo.com> I've recently released version 0.2.8 of distlib on PyPI [1]. For newcomers,distlib is a library of packaging functionality which is intended to beusable as the basis for third-party packaging tools. The main changes in this release are as follows: * Fixed #107: Updated documentation on testing to include information on? setting PYTHONHASHSEED. * Fixed #108: Updated metadata scan to look for the METADATA file as well as the? JSON formats. * Fixed #109: Removed existing files (which might have been symlinks) before? overwriting. * Fixed #111: Avoided unnecessary newlines in script preambles, which caused? problems with detecting encoding declarations. Thanks to Wim Glenn for the? report and patch. * Fixed #112: Handled wheel tags and platform-dependent downloads correctly in? SimpleScrapingLocator. A more detailed change log is available at [2]. Please try it out, and if you find any problems or have any suggestions for improvements,please give some feedback using the issue tracker! [3] Regards, Vinay Sajip [1] https://pypi.org/project/distlib/0.2.8/[2] https://goo.gl/tVzKUc[3] https://bitbucket.org/pypa/distlib/issues/new From robin at reportlab.com Tue Oct 2 07:14:47 2018 From: robin at reportlab.com (Robin Becker) Date: Tue, 2 Oct 2018 12:14:47 +0100 Subject: This thread is closed [an actual new thread] In-Reply-To: References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: <0f4ba882-ba3f-30fd-c15a-a82a3396215f@chamonix.reportlab.co.uk> On 02/10/2018 11:46, Rhodri James wrote: > On 02/10/18 01:02, Ethan Furman wrote: >> On 10/01/2018 04:26 PM, Ben Finney wrote: >> ?> Ethan Furman writes: >> >> ?>> This thread is closed. >> ?> >> ?> Coming from a moderator of this forum, I don't know how that statement >> ?> is to be interpreted. >> >> It should be interpreted as: >> >> - No further discussion should take place on this thread. >> - I've done what I can with the primitive tools at hand to block >> ?? any further discussion. >> - Continued considerate posts will be discarded. >> - Continued flame-bait/inconsiderate posts will be met with warnings >> ?? or stronger as warranted. > > 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 considerate posts will > be discarded" is outrageous. > > I have been unimpressed with the moderation team for some weeks now, but this is just not acceptable. > +1 from me there seems to be a considerable humour deficit in some quarters. The language is called python and is named after Monty Python's Flying Circus (https://docs.python.org/2/faq/general.html#why-is-it-called-python). Apparently we now also have the Spanish Inquisition :) -- Robin Becker From zljubisic at gmail.com Tue Oct 2 08:33:47 2018 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Tue, 2 Oct 2018 05:33:47 -0700 (PDT) Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word Message-ID: Hi, if I have a string: sql = """ where 1 = 1 and field = :value and field2 in (:list) """ I would like to replace every word that starts with ":" in the following way: 1. replace ":" with "${" 2. at the end of the word add "}" An example should look like this: where 1 = 1 and field = ${value} and field2 in (${list}) How to do that? Regards. From rosuav at gmail.com Tue Oct 2 08:41:53 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Oct 2018 22:41:53 +1000 Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word In-Reply-To: References: Message-ID: On Tue, Oct 2, 2018 at 10:36 PM wrote: > > Hi, > > if I have a string: > > sql = """ > where 1 = 1 > and field = :value > and field2 in (:list) > """ > > I would like to replace every word that starts with ":" in the following way: > 1. replace ":" with "${" > 2. at the end of the word add "}" > > > An example should look like this: > > where 1 = 1 > and field = ${value} > and field2 in (${list}) > > How to do that? First off: WHY? Are you then planning to do a naive interpolation? Are you trying to recognize syntactic elements in SQL? If so, you'll need an SQL parser. Or are you prepared to handle just a few basics, like making sure the colon isn't inside quotes? And if so, which basics? And what constitutes a word? I strongly recommend *not doing this* unless you have an extremely good reason to. ChrisA From zljubisic at gmail.com Tue Oct 2 09:04:35 2018 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Tue, 2 Oct 2018 06:04:35 -0700 (PDT) Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word In-Reply-To: References: Message-ID: I have to execute the same sql in two different programs. Each of them marks parameters differently. Anyway, I have found the solution. cnv_sel = re.sub(r"(:(.+?)\b)", r"${\2}", sel) Reagards. From mchathuranga4 at gmail.com Tue Oct 2 09:59:26 2018 From: mchathuranga4 at gmail.com (mchathuranga4 at gmail.com) Date: Tue, 2 Oct 2018 06:59:26 -0700 (PDT) Subject: python not working on RHEL6 Message-ID: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Hi All, I'm a beginner on this. I was trying to install a new python version which is 2.7.5. My OS(RHEL6) had already installed version 2.6. so I downloaded the tar and unzipped it then executed ./configure --prefix=/usr \ --enable-shared \ --with-system-expat \ --with-system-ffi \ --enable-unicode=ucs4 && make afterwards sudo make install && sudo chmod -v 755 /usr/lib/libpython2.7.so.1.0 http://www.linuxfromscratch.org/blfs/view/7.4/general/python2.html This is what I followed and which got me here. everything was successfully finished. afterwards when I type python in the terminal I get below error: python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory I guess from the little knowledge I have I should have executed altinstall instead of install. Anyone know how to resolve this? Thanks. From mchathuranga4 at gmail.com Tue Oct 2 10:05:08 2018 From: mchathuranga4 at gmail.com (Madushan Chathuranga) Date: Tue, 2 Oct 2018 07:05:08 -0700 (PDT) Subject: Error after installing python 2.7.5 on rhel6 Message-ID: <1b84b04a-3a19-4e9f-b7b0-fd43f0fb68f8@googlegroups.com> Hi All, I'm a beginner on this. I tried to install python 2.7.5 on my rhel6 os. It already had installed 2.6.6. I downloaded the tar and unzipped it the executed below command. ./configure --prefix=/usr \ --enable-shared \ --with-system-expat \ --with-system-ffi \ --enable-unicode=ucs4 && make afterwards, sudo make install && sudo chmod -v 755 /usr/lib/libpython2.7.so.1.0 everything executed successfully. but after the installation I'm getting an error when I type python or python --version in the terminal.Below is the error I get. Does Anyone here know how to solve this? python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory >From my little knowledge I know instead of executing make install I should have executed make altinstall From rosuav at gmail.com Tue Oct 2 10:05:53 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 00:05:53 +1000 Subject: python not working on RHEL6 In-Reply-To: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: On Wed, Oct 3, 2018 at 12:01 AM wrote: > > Hi All, > > I'm a beginner on this. I was trying to install a new python version which is 2.7.5. My OS(RHEL6) had already installed version 2.6. so I downloaded the tar and unzipped it then executed > > ./configure --prefix=/usr \ > --enable-shared \ > --with-system-expat \ > --with-system-ffi \ > --enable-unicode=ucs4 && > make > > afterwards > sudo make install && > sudo chmod -v 755 /usr/lib/libpython2.7.so.1.0 Not sure what the point of the chmod is, but whatever. I don't think it's breaking anything. > http://www.linuxfromscratch.org/blfs/view/7.4/general/python2.html This is what I followed and which got me here. > > everything was successfully finished. > > afterwards when I type python in the terminal I get below error: > > python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory What happens if you type "python2.6" or "python2.7"? ChrisA From rosuav at gmail.com Tue Oct 2 10:07:20 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 00:07:20 +1000 Subject: How to change '\\' to '\' In-Reply-To: <26u6rd5nn8snl8m2fqvicfn1mnpnk7f3tr@4ax.com> References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> <26u6rd5nn8snl8m2fqvicfn1mnpnk7f3tr@4ax.com> Message-ID: On Wed, Oct 3, 2018 at 12:05 AM Dennis Lee Bieber wrote: > > On Tue, 2 Oct 2018 10:17:27 +0800, Jach Fong > declaimed the following: > > > >It was supposed that most discussant want to see the reply message > >instantly when they open the mail. They already know what is going on > >and no need to pass through all those previous message. "top posting" > >seems more reasonable to me:-) > > > > Such behavior reflects > 1) personal (1 to 1) replies, where the recipient should already know the > subject of the matter (having written it in the first place); Which assumes that the recipient of your message has sent few enough messages that s/he remembers the content of all of them. I don't know about you, but that certainly isn't true of me. If you're replying to anything more than a week old, I'm going to be looking at the quoted context to see what I said. ChrisA From mchathuranga4 at gmail.com Tue Oct 2 10:09:59 2018 From: mchathuranga4 at gmail.com (Madushan Chathuranga) Date: Tue, 2 Oct 2018 07:09:59 -0700 (PDT) Subject: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: Hi, when I type python2.6 terminal opens for python. So no issue on that. but when I type python2.7, python or any yum command It gives the error, python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory Thanks From grant.b.edwards at gmail.com Tue Oct 2 10:10:10 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 2 Oct 2018 14:10:10 +0000 (UTC) Subject: This thread is closed [an actual new thread] References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: On 2018-10-02, Rhodri James wrote: > On 02/10/18 01:02, Ethan Furman 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 Agreed. > "Continued considerate posts will be discarded" is outrageous. Agreed. > I have been unimpressed with the moderation team for some weeks now, but > this is just not acceptable. Agreed. -- Grant Edwards grant.b.edwards Yow! The SAME WAVE keeps at coming in and COLLAPSING gmail.com like a rayon MUU-MUU ... From rosuav at gmail.com Tue Oct 2 10:24:52 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 00:24:52 +1000 Subject: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: On Wed, Oct 3, 2018 at 12:20 AM Madushan Chathuranga wrote: > > Hi, > > when I type python2.6 terminal opens for python. So no issue on that. but when I type python2.7, python or any yum command It gives the error, > python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory Okay. Check what "which python" and "which python2.6" do, and if "which python2.7" is different. You may be able to manually recreate your original /usr/bin/python (or whatever it is) from python2.6. That would effectively undo the non-alt part of your install, and then you can proceed to fix the actual installation. Hopefully. ChrisA From tjol at tjol.eu Tue Oct 2 10:26:40 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 2 Oct 2018 16:26:40 +0200 Subject: python not working on RHEL6 In-Reply-To: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> On 2018-10-02 15:59, mchathuranga4 at gmail.com wrote: > Hi All, > > I'm a beginner on this. I was trying to install a new python version which is 2.7.5. My OS(RHEL6) had already installed version 2.6. so I downloaded the tar and unzipped it then executed > > ./configure --prefix=/usr \ > --enable-shared \ > --with-system-expat \ > --with-system-ffi \ > --enable-unicode=ucs4 && > make > > afterwards > sudo make install && > sudo chmod -v 755 /usr/lib/libpython2.7.so.1.0 > > http://www.linuxfromscratch.org/blfs/view/7.4/general/python2.html This is what I followed and which got me here. > > everything was successfully finished. > > afterwards when I type python in the terminal I get below error: > > python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory I have no idea what's going on, but in any case you should make sure your /usr/bin/python works and points to the system python2.6. Maybe "sudo yum reinstall python" is the way to go. Then perhaps you should delete all Python2.7 files and try again (preferably, not in /usr - that's for OS-installed files only. /usr/local is a nice place to put things you installed from source) The in some sense "official" way to get Python 2.7 on an EL6 system is to install it through the software collections mechanism: https://www.softwarecollections.org/en/scls/rhscl/python27/ Better yet, forget about Python 2.7 and use Python 3.7 (or 3.6, which is available as an SCL) > > I guess from the little knowledge I have I should have executed altinstall instead of install. Anyone know how to resolve this? > > Thanks. > -- Thomas Jollans m ? +31 (6) 42630259 e ? tjol at tjol.eu From ian.g.kelly at gmail.com Tue Oct 2 10:35:27 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 2 Oct 2018 08:35:27 -0600 Subject: This thread is closed [an actual new thread] In-Reply-To: References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: 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 considerate posts will be discarded" is outrageous. To be fair, it went four days without any posts before being closed, so I'd say it was already dead at that point anyway. > I have been unimpressed with the moderation team for some weeks now, but > this is just not acceptable. Note I'm not expressing an opinion on any specific decision by the moderators, but I for one would like to welcome the more proactive moderation being employed recently. This group, which was originally unmoderated, at one time had a reputation for having a respectful and welcoming community. To my experience, that has not been the case for years now. Self-policing is no longer working when the self-appointed police are among the greatest offenders, at the ready to declare somebody a troll and therefore fair game at the slightest disagreement. The archives contain piles upon pile of centithreads of inane bickering on topics like "what is a variable, precisely" that are no different than arguing about the number of angels that can dance on the head of a pin. And while I haven't actually done it yet, I can't count on one hand the number of times I've been disgusted by the toxic tone so prevalent here and nearly unsubscribed. Whether or not you think the moderators are doing a good job, there's no doubt in my mind that moderation is sorely needed here and long overdue. From michael.stemper at gmail.com Tue Oct 2 10:59:20 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Tue, 2 Oct 2018 09:59:20 -0500 Subject: How to achieve pyc only deployment for module in python3.6 In-Reply-To: References: Message-ID: On 2018-10-02 00:41, Chris Angelico wrote: > On Tue, Oct 2, 2018 at 12:01 PM Chandana Pattanayak > wrote: >> I have a requirement to provide basic code protection for a module in our >> product suite. With python 3.6 the .pyc files are created under pycache , >> so if i remove the py file the module is not found anymore. > > If you want code protection, the ONLY reliable way to do it is to not > provide the code *at all*, in any form. That generally means hosting > your application on some sort of server and granting access that way > (eg through a web browser interface). Shipping only .pyc files does > not protect your code - it merely obscures it a little. I can support that. Before retiring, I worked for a vendor of SCADA/EMS for large electric utilities. Since our systems were responsible for operating their critical infrastructure, NERC CIP[1] standards required them to only obtain systems that underwent regular security audits. We sent one of our systems to the NSTB[2] for such an audit. It included only executables, no source code. Yet, when the NSTB sent us their report, they were able to say things like "Lines x-y of zzzz.c have the following vulnerability." Those guys were (are) *sharp*. [1] [2] -- Michael F. Stemper Outside of a dog, a book is man's best friend. Inside of a dog, it's too dark to read. From lists at vanderhoff.org Tue Oct 2 11:14:45 2018 From: lists at vanderhoff.org (Tony van der Hoff) Date: Tue, 2 Oct 2018 16:14:45 +0100 Subject: Querying MariaDB from python Message-ID: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> I'm writing a database application, in python 3,5 under Debian9. My code: ??? def get_albums(self, parent_id = 0 ): ??????? cursor = self.cnx.cursor() ??????? sql =(? "select" ??????????????? "??? id" ??????????????? ",?? parent_id" ??????????????? ",?? title" ??????????????? ",?? ifnull( description, '' )" ??????????????? ",?? path" ??????????????? ",?? date( from_unixtime( date_created ) ) as date" ??????????????? " from album" ??????????????? " where parent_id = %(parent_id)s" ??????????????? " order by date_created" ???????????? ) ??????? cursor.execute( sql, {'parent_id': parent_id } )??????????????? ??????? rows = cursor.fetchall() ??????? # return result as a list of dicts ??????? result = [] ??????? for row in rows: ??????????? result.append({ 'id':row[0], ??????????????????????????? 'parent_id':row[1], ??????????????????????????? 'title':row[2], ??????????????????????????? 'description':row[3], ??????????????????????????? 'path':row[4], ??????????????????????????? 'date':row[5], ??????????????????????????? } ??????????????????????? ) ??????? return result This works OK, but looks inelegant. Having to iterate through the returned data to get it into a dictionary is error-prone if the query changes. I would have expected the connector to be able to return a dictionary. Can anyone suggest a better way of doing this? ? -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From larry.martell at gmail.com Tue Oct 2 11:37:25 2018 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 2 Oct 2018 11:37:25 -0400 Subject: Querying MariaDB from python In-Reply-To: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> Message-ID: On Tue, Oct 2, 2018 at 11:34 AM Tony van der Hoff wrote: > > I'm writing a database application, in python 3,5 under Debian9. > > My code: > > def get_albums(self, parent_id = 0 ): > cursor = self.cnx.cursor() > sql =( "select" > " id" > ", parent_id" > ", title" > ", ifnull( description, '' )" > ", path" > ", date( from_unixtime( date_created ) ) as date" > " from album" > " where parent_id = %(parent_id)s" > " order by date_created" > ) > cursor.execute( sql, {'parent_id': parent_id } ) > rows = cursor.fetchall() > > # return result as a list of dicts > result = [] > > for row in rows: > result.append({ 'id':row[0], > 'parent_id':row[1], > 'title':row[2], > 'description':row[3], > 'path':row[4], > 'date':row[5], > } > ) > return result > > This works OK, but looks inelegant. Having to iterate through the > returned data to get it into a dictionary is error-prone if the query > changes. I would have expected the connector to be able to return a > dictionary. > > Can anyone suggest a better way of doing this? https://pymysql.readthedocs.io/en/latest/modules/cursors.html#pymysql.cursors.DictCursor From torriem at gmail.com Tue Oct 2 11:38:50 2018 From: torriem at gmail.com (Michael Torrie) Date: Tue, 2 Oct 2018 09:38:50 -0600 Subject: How to change '\\' to '\' In-Reply-To: References: <30a9280d-5602-4ff1-998d-accbc165de09@googlegroups.com> <2e51b0f0-ad15-14a3-7719-fb58b2e49c55@ms4.hinet.net> <7873ccf6-d669-0d7c-1b94-31aefff1385e@ms4.hinet.net> Message-ID: <692eceaa-70c8-1e83-ec49-75f4ddb8a42b@gmail.com> On 10/02/2018 12:48 AM, Ethan Furman wrote: > Even for two-person, private email discussions I prefer the interleaved > replies -- in a week when I have to remind myself what was discussed it > is much easier to comprehend. Absolutely. I've been saved from embarrassment countless times because while editing the quote so I could respond to it point by point, I realized I had misread the the original poster. Top posting usually indicates that the person replying to my email never really read it, and is just replying to what he thought I said or asked. Frustrating to no end. This problem is endemic in corporate communication. Corporate email is completely nonfunctional as a means of communication, largely because of the top posting culture. Well communication is a problem in general in corporations because of the personalities that tend to gravitate towards the management end of things. Top posting just makes the communication that much worse! > Yes. It is extremely annoying when someone top posts and leaves the > entire rest of the discussion still attached at the bottom. Or when they bottom post without trimming, or even when they interleave their responses without trimming. From airween at gmail.com Tue Oct 2 11:47:27 2018 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 2 Oct 2018 17:47:27 +0200 Subject: Querying MariaDB from python In-Reply-To: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> Message-ID: <20181002154727.GA1197@arxnet.hu> hi, On Tue, Oct 02, 2018 at 04:14:45PM +0100, Tony van der Hoff wrote: > I'm writing a database application, in python 3,5 under Debian9. > > My code: > > ??? def get_albums(self, parent_id = 0 ): > ??????? cursor = self.cnx.cursor() cursor = self.cnx.cursor(pymysql.cursors.DictCursor) > ??????? sql =(? "select" > ??????????????? "??? id" > ??????????????? ",?? parent_id" > ??????????????? ",?? title" > ??????????????? ",?? ifnull( description, '' )" > ??????????????? ",?? path" > ??????????????? ",?? date( from_unixtime( date_created ) ) as date" > ??????????????? " from album" > ??????????????? " where parent_id = %(parent_id)s" > ??????????????? " order by date_created" > ???????????? ) sql = ("""SELECT id, parent_id, ... """) > ??????? cursor.execute( sql, {'parent_id': parent_id } )??????????????? > ??????? rows = cursor.fetchall() now rows will looks like this: ({'id':...,...},{'id':...,}...) a. From lists at vanderhoff.org Tue Oct 2 11:51:29 2018 From: lists at vanderhoff.org (Tony van der Hoff) Date: Tue, 2 Oct 2018 16:51:29 +0100 Subject: Querying MariaDB from python In-Reply-To: References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> Message-ID: <1aa1185c-2dfe-1d27-4f69-e54d6ed431e0@vanderhoff.org> On 02/10/18 16:37, Larry Martell wrote: > On Tue, Oct 2, 2018 at 11:34 AM Tony van der Hoff wrote: >>I would have expected the connector to be able to return a >> dictionary. >> >> Can anyone suggest a better way of doing this? > > https://pymysql.readthedocs.io/en/latest/modules/cursors.html#pymysql.cursors.DictCursor > Well, thanks, Larry, for taking the trouble to reply, but I can't see how that solves the issue. -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From lists at vanderhoff.org Tue Oct 2 12:07:38 2018 From: lists at vanderhoff.org (Tony van der Hoff) Date: Tue, 2 Oct 2018 17:07:38 +0100 Subject: Querying MariaDB from python In-Reply-To: <20181002154727.GA1197@arxnet.hu> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> <20181002154727.GA1197@arxnet.hu> Message-ID: <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> On 02/10/18 16:47, Ervin Heged?s wrote: > hi, > > now rows will looks like this: > ({'id':...,...},{'id':...,}...) Thanks Ervin, but: cursor = cnx.cursor(pymysql.cursors.DictCursor) NameError: name 'pymysql' is not defined I have been using the mysql.connector module, which seems to be the "official" python interface. I hadn't spotted the pymysql module. Is the consensus here that pymysql is the preferred connector? Cheers, -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From larry.martell at gmail.com Tue Oct 2 12:13:26 2018 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 2 Oct 2018 12:13:26 -0400 Subject: Querying MariaDB from python In-Reply-To: <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> <20181002154727.GA1197@arxnet.hu> <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> Message-ID: On Tue, Oct 2, 2018 at 12:09 PM Tony van der Hoff wrote: > > On 02/10/18 16:47, Ervin Heged?s wrote: > > hi, > > > > now rows will looks like this: > > ({'id':...,...},{'id':...,}...) > > Thanks Ervin, but: > > cursor = cnx.cursor(pymysql.cursors.DictCursor) > NameError: name 'pymysql' is not defined > > I have been using the mysql.connector module, which seems to be the > "official" python interface. That also supports the cursordict: https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursordict.html From tjol at tjol.eu Tue Oct 2 12:13:36 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 2 Oct 2018 18:13:36 +0200 Subject: Querying MariaDB from python In-Reply-To: <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> <20181002154727.GA1197@arxnet.hu> <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> Message-ID: <935504ca-afc9-ed79-00b5-9b5ab95e88e1@tjol.eu> On 2018-10-02 18:07, Tony van der Hoff wrote: > On 02/10/18 16:47, Ervin Heged?s wrote: >> hi, >> >> now rows will looks like this: >> ({'id':...,...},{'id':...,}...) > > Thanks Ervin, but: > > cursor = cnx.cursor(pymysql.cursors.DictCursor) > NameError: name 'pymysql' is not defined > > I have been using the mysql.connector module, which seems to be the > "official" python interface. I hadn't spotted the pymysql module. Is the > consensus here that pymysql is the preferred connector? I don't know, but it appears to be (the?) one that solves your problem. From airween at gmail.com Tue Oct 2 12:14:13 2018 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 2 Oct 2018 18:14:13 +0200 Subject: Querying MariaDB from python In-Reply-To: <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> <20181002154727.GA1197@arxnet.hu> <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> Message-ID: <20181002161413.GA7276@arxnet.hu> Hi Tony, On Tue, Oct 02, 2018 at 05:07:38PM +0100, Tony van der Hoff wrote: > On 02/10/18 16:47, Ervin Heged?s wrote: > > hi, > > > > now rows will looks like this: > > ({'id':...,...},{'id':...,}...) > > Thanks Ervin, but: > > cursor = cnx.cursor(pymysql.cursors.DictCursor) > NameError: name 'pymysql' is not defined > > I have been using the mysql.connector module, which seems to be the > "official" python interface. I hadn't spotted the pymysql module. Is the > consensus here that pymysql is the preferred connector? well, since I'm using Python3, I didn't use "old" MySQLdb python module, I switched to pymysql - but as I know they are compatible, so you can use: cnx.cursor(MySQLdb.cursors.DictCursor) I don't know about "mysql.connector" module yet - but it doesn't mean that it doesn't existst :) hth, a. From lists at vanderhoff.org Tue Oct 2 12:30:38 2018 From: lists at vanderhoff.org (Tony van der Hoff) Date: Tue, 2 Oct 2018 17:30:38 +0100 Subject: [SOLVED] Re: Querying MariaDB from python In-Reply-To: References: <217b93cd-2102-58c3-36d7-6c66a200eaf6@vanderhoff.org> <20181002154727.GA1197@arxnet.hu> <1529e87e-7fb1-ebfe-b3d3-a7ac3d2f4894@vanderhoff.org> Message-ID: <9b1b6dd8-f0b6-bc6b-9edf-45fd7bedf203@vanderhoff.org> On 02/10/18 17:13, Larry Martell wrote: > On Tue, Oct 2, 2018 at 12:09 PM Tony van der Hoff wrote: >> >> On 02/10/18 16:47, Ervin Heged?s wrote: >>> hi, >>> >>> now rows will looks like this: >>> ({'id':...,...},{'id':...,}...) >> >> Thanks Ervin, but: >> >> cursor = cnx.cursor(pymysql.cursors.DictCursor) >> NameError: name 'pymysql' is not defined >> >> I have been using the mysql.connector module, which seems to be the >> "official" python interface. > > That also supports the cursordict: > > https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursordict.html > Great, thanks Larry, that sorts it. -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From rosuav at gmail.com Tue Oct 2 12:49:43 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 02:49:43 +1000 Subject: Question about Multi-processing In-Reply-To: <64ba533c-28d9-ab4a-75ef-2fdd4b616dd1@btinternet.com> References: <64ba533c-28d9-ab4a-75ef-2fdd4b616dd1@btinternet.com> Message-ID: On Wed, Oct 3, 2018 at 2:13 AM Anthony Flury via Python-list wrote: > I continued to read the documentation and came to this quote : > > /Functionality within this package requires that the > //|__main__|//module be importable by the children. This is covered > in //Programming guidelines > //however > it is worth pointing out here. This means that some examples, such > as the //|multiprocessing.pool.Pool| > //examples > will not work in the interactive interpreter./ > > The Documentation then gives a clear example very similar to mine : > > But when I run this exact example in the command line interpreter it > works fine : > > Is the documentation wrong ? is something weird going on ? > You're running it on Linux, and it can fork to create child processes. If you were to run that on Windows, where forking isn't an option[1], the creation of child processes would involve spinning up a new Python process, importing main, and invoking the appropriate function from there. ChrisA [1] AIUI, forking technically is possible on Windows, but it's not the way things are done From ethan at stoneleaf.us Tue Oct 2 13:16:33 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 2 Oct 2018 10:16:33 -0700 Subject: This thread is closed [an actual new thread] In-Reply-To: References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: <86076e8f-426e-a983-d744-a82e9f0b99bd@stoneleaf.us> On 10/02/2018 03:46 AM, Rhodri James wrote: > On 02/10/18 01:02, Ethan Furman wrote: >> It should be interpreted as: >> >> - No further discussion should take place on this thread. >> - I've done what I can with the primitive tools at hand to block >> ?? any further discussion. >> - Continued considerate posts will be discarded. >> - Continued flame-bait/inconsiderate posts will be met with warnings >> ?? or stronger as warranted. > > 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 considerate posts will be discarded" is outrageous. As soon as personal or group attacks start taking place (at least, as soon as such posts are noticed), that thread will be shut down. As I said, the tools are primitive and more precise actions are not available. > I have been unimpressed with the moderation team for some weeks now, but > this is just not acceptable. I'm sorry you feel that way. The goal is to have an environment where we can all help/be helped by others, primarily with Python. Attacks on others do not help that [1]. -- ~Ethan~ Python List Moderator From dan at djph.net Tue Oct 2 13:22:34 2018 From: dan at djph.net (Dan Purgert) Date: Tue, 2 Oct 2018 17:22:34 -0000 (UTC) Subject: python not working on RHEL6 References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> Message-ID: Thomas Jollans wrote: > [...] (preferably, not in /usr - that's for OS-installed files only. > /usr/local is a nice place to put things you installed from source). While I agree that /usr(/bin) is incorrect, I believe that "for OS-installed files only" is taking it a bit far. My (admittedly, dim) recollection of the FHS is that the /usr hierarchy is for static[1] "user" binaries, libraries, and so on; while being OS-agnostic (so long as that OS followed the FHS). [1] "Static" in terms of the relevant filesystem being able to be mounted RO and not cause any undue headaches. I don't believe that the FHS writers ever meant to imply that executables and symlinks thereto were to be immutable such that installation of new / upgrading of existing software is rendered impossible. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From python at mrabarnett.plus.com Tue Oct 2 13:35:31 2018 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 2 Oct 2018 18:35:31 +0100 Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word In-Reply-To: References: Message-ID: <10477faf-48f6-aeb9-ff66-a8bf1f17a0f8@mrabarnett.plus.com> On 2018-10-02 14:04, zljubisic at gmail.com wrote: > I have to execute the same sql in two different programs. > Each of them marks parameters differently. > > Anyway, I have found the solution. > > cnv_sel = re.sub(r"(:(.+?)\b)", r"${\2}", sel) > A slightly better solution would be: cnv_sel = re.sub(r":(\w+)", r"${\1}", sel) From tjol at tjol.eu Tue Oct 2 13:52:32 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 2 Oct 2018 19:52:32 +0200 Subject: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> Message-ID: <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> On 02/10/2018 19:22, Dan Purgert wrote: > Thomas Jollans wrote: >> [...] (preferably, not in /usr - that's for OS-installed files only. >> /usr/local is a nice place to put things you installed from source). > > While I agree that /usr(/bin) is incorrect, I believe that "for > OS-installed files only" is taking it a bit far. > > My (admittedly, dim) recollection of the FHS is that the /usr hierarchy > is for static[1] "user" binaries, libraries, and so on; while being > OS-agnostic (so long as that OS followed the FHS). > > [1] "Static" in terms of the relevant filesystem being able to be > mounted RO and not cause any undue headaches. I don't believe that the > FHS writers ever meant to imply that executables and symlinks thereto > were to be immutable such that installation of new / upgrading of > existing software is rendered impossible. > You're not wrong, but there's still a fairly strong convention that /usr/{bin,lib*,share,include} are only populated by (in some sense) non-essential components of the OS only, with varying definitions of "the OS". On Linux, this tends to mean "everything managed by the package manager", while on *BSD, it tends to exclude extra packages and ports collection. Whether we agree on the terminology here or not, of course we can agree that you have to be bloody careful if you *do* decide to put things in /usr/bin yourself :-) -- Thomas From roel at roelschroeven.net Tue Oct 2 14:11:35 2018 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 2 Oct 2018 20:11:35 +0200 Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: Jon Ribbens schreef op 2/10/2018 om 1:20: > On 2018-10-01, Roel Schroeven wrote: >> I'm not very active here, but I've been lurking for years. In my eyes >> Steven has always been active and helpful. Now he has *once* been a >> *tiny bit* rude, and he's banned for that? > > It's not "once", it's a long-standing pattern of behaviour. Are we talking about the same Steven D'Aprano? I must have somehow selectively missed a lot of posts, because from the posts I have seen, I can see nothing wrong with Steven's behaviour. -- "Honest criticism is hard to take, particularly from a relative, a friend, an acquaintance, or a stranger." -- Franklin P. Jones Roel Schroeven From john at doe.com Tue Oct 2 15:03:42 2018 From: john at doe.com (John Doe) Date: Tue, 2 Oct 2018 19:03:42 -0000 (UTC) Subject: Creating Win .exe file from *.py on Linux Message-ID: Hello World Is it possible to create on Linux win .exe file from *.py file? From rosuav at gmail.com Tue Oct 2 15:32:52 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 05:32:52 +1000 Subject: python not working on RHEL6 In-Reply-To: <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> Message-ID: On Wed, Oct 3, 2018 at 5:17 AM Thomas Jollans wrote: > > On 02/10/2018 19:22, Dan Purgert wrote: > > Thomas Jollans wrote: > >> [...] (preferably, not in /usr - that's for OS-installed files only. > >> /usr/local is a nice place to put things you installed from source). > > > > While I agree that /usr(/bin) is incorrect, I believe that "for > > OS-installed files only" is taking it a bit far. > > > > My (admittedly, dim) recollection of the FHS is that the /usr hierarchy > > is for static[1] "user" binaries, libraries, and so on; while being > > OS-agnostic (so long as that OS followed the FHS). > > > > [1] "Static" in terms of the relevant filesystem being able to be > > mounted RO and not cause any undue headaches. I don't believe that the > > FHS writers ever meant to imply that executables and symlinks thereto > > were to be immutable such that installation of new / upgrading of > > existing software is rendered impossible. > > > > You're not wrong, but there's still a fairly strong convention that > /usr/{bin,lib*,share,include} are only populated by (in some sense) > non-essential components of the OS only, with varying definitions of > "the OS". On Linux, this tends to mean "everything managed by the > package manager", while on *BSD, it tends to exclude extra packages and > ports collection. > > Whether we agree on the terminology here or not, of course we can agree > that you have to be bloody careful if you *do* decide to put things in > /usr/bin yourself :-) As a general rule, it's safe to get a *different* version of Python and do a "make altinstall" (which the OP agrees was the original intention). Whether that lands in /usr/bin or /usr/local/bin doesn't actually make a difference - what matters is the $PATH and which command you get when you type "python" or "python2" or "python3". On my system (Debian GNU/Linux), /usr/local/bin is ahead of /usr/bin in $PATH, so even installing into local isn't going to protect you. It will quite probably protect system tools (since they should be explicitly calling on /usr/bin/python2.6 or similar), but could well mess up manual usage from the shell. ChrisA From grant.b.edwards at gmail.com Tue Oct 2 15:58:49 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 2 Oct 2018 19:58:49 +0000 (UTC) Subject: Creating Win .exe file from *.py on Linux References: Message-ID: On 2018-10-02, John Doe wrote: > Hello World > > Is it possible to create on Linux win .exe file from *.py file? Yes... if you run on Linux a VM instance that's running Windows? -- Grant Edwards grant.b.edwards Yow! Do you guys know we at just passed thru a BLACK gmail.com HOLE in space? From tomusatov at gmail.com Tue Oct 2 16:23:07 2018 From: tomusatov at gmail.com (Musatov) Date: Tue, 2 Oct 2018 13:23:07 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. Message-ID: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. DATA 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 EXAMPLE 7*5 - 3 - 1 = 31 11*7 - 5 - 1 = 71 11*7 - 5 + 1 = 73 13*11 - 7 + 1 = 137 Can someone put this in a Python program and post? From breamoreboy at gmail.com Tue Oct 2 17:24:37 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Tue, 2 Oct 2018 22:24:37 +0100 Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: On 02/10/18 19:11, Roel Schroeven wrote: > Jon Ribbens schreef op 2/10/2018 om 1:20: >> On 2018-10-01, Roel Schroeven wrote: >>> I'm not very active here, but I've been lurking for years. In my eyes >>> Steven has always been active and helpful. Now he has *once* been a >>> *tiny bit* rude, and he's banned for that? >> >> It's not "once", it's a long-standing pattern of behaviour. > > Are we talking about the same Steven D'Aprano? I must have somehow > selectively missed a lot of posts, because from the posts I have seen, I > can see nothing wrong with Steven's behaviour. > > I fully support Steven D'Aprano. This disgraceful behaviour by the moderators has been perpetuated by Ethan Thurman who doesn't have the guts to say things online but has instead sent me a message to my personal inbox. Please can we get rid of this useless moron? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ethan at stoneleaf.us Tue Oct 2 17:39:31 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 2 Oct 2018 14:39:31 -0700 Subject: So apparently I've been banned from this list In-Reply-To: References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> Message-ID: On 10/02/2018 02:24 PM, Mark Lawrence wrote: > I fully support Steven D'Aprano.? This disgraceful behaviour by the > moderators has been perpetuated by Ethan Thurman who doesn't have the > guts to say things online but has instead sent me a message to my > personal inbox.? Please can we get rid of this useless moron? Personal attacks will not be tolerated against anybody, myself included. Your posts will be barred from Python List for the rest of the year. After that you may petition the moderators to regain access. -- ~Ethan~ Python List Moderator From gherron at digipen.edu Tue Oct 2 17:45:43 2018 From: gherron at digipen.edu (Gary Herron) Date: Tue, 2 Oct 2018 14:45:43 -0700 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: <7f44b090-61ef-589c-1041-98bc8605df61@digipen.edu> On 10/02/2018 01:23 PM, tomusatov at gmail.com wrote: > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > DATA > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > EXAMPLE > > 7*5 - 3 - 1 = 31 > > 11*7 - 5 - 1 = 71 > > 11*7 - 5 + 1 = 73 > > 13*11 - 7 + 1 = 137 > > Can someone put this in a Python program and post? No, sorry, but that's not how this works.? We're not here to do your homework for you, and you won't learn anything if we do.? You make an attempt at solving this, asking any specific Python related questions you need help with, and you'll find this to be prompt, friendly, and helpful group. Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From bgailer at gmail.com Tue Oct 2 17:48:38 2018 From: bgailer at gmail.com (Bob Gailer) Date: Tue, 2 Oct 2018 17:48:38 -0400 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: On Oct 2, 2018 4:59 PM, "Musatov" wrote: > > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > DATA > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > EXAMPLE > > 7*5 - 3 - 1 = 31 > > 11*7 - 5 - 1 = 71 > > 11*7 - 5 + 1 = 73 > > 13*11 - 7 + 1 = 137 > > Can someone put this in a Python program and post? It is our policy to not write code at others requests. We are glad to help if you've started writing a program and are stuck. Out of curiosity where does this request come from? If you want to hire one of us to write the program, in other words pay us for our time and expertise, that's a different matter. We would be happy to comply. > -- > https://mail.python.org/mailman/listinfo/python-list From tomusatov at gmail.com Tue Oct 2 17:53:03 2018 From: tomusatov at gmail.com (Martin Musatov) Date: Tue, 2 Oct 2018 16:53:03 -0500 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: I am drafting a sequence for OEIS. I was told Python was most accesible for beginners. On Tue, Oct 2, 2018, 4:48 PM Bob Gailer wrote: > On Oct 2, 2018 4:59 PM, "Musatov" wrote: > > > > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > > DATA > > > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, > 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, > 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, > 70489, 74797, 89669, 98909, 98911 > > > > EXAMPLE > > > > 7*5 - 3 - 1 = 31 > > > > 11*7 - 5 - 1 = 71 > > > > 11*7 - 5 + 1 = 73 > > > > 13*11 - 7 + 1 = 137 > > > > Can someone put this in a Python program and post? > > It is our policy to not write code at others requests. We are glad to help > if you've started writing a program and are stuck. > > Out of curiosity where does this request come from? > > If you want to hire one of us to write the program, in other words pay us > for our time and expertise, that's a different matter. We would be happy to > comply. > > -- > > https://mail.python.org/mailman/listinfo/python-list > From max at zettlmeissl.de Tue Oct 2 18:01:28 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Wed, 3 Oct 2018 00:01:28 +0200 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: On Tue, Oct 2, 2018 at 10:23 PM, Musatov wrote: > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > DATA > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > EXAMPLE > > 7*5 - 3 - 1 = 31 > > 11*7 - 5 - 1 = 71 > > 11*7 - 5 + 1 = 73 > > 13*11 - 7 + 1 = 137 > > Can someone put this in a Python program and post? > Here you go, my friend: #!/usr/bin/env python3 primes = """Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. DATA 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 35\ 47, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 3\ 7831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 989\ 09, 98911 EXAMPLE 7*5 - 3 - 1 = 31 11*7 - 5 - 1 = 71 11*7 - 5 + 1 = 73 13*11 - 7 + 1 = 137 """ if __name__ == "__main__": print(primes) As soon as you start showing more effort yourself in the form of your honest attempts to create a program or at least in the form of some serious ideas, you might get replies which better fit what you attempted to receive. From cs at cskk.id.au Tue Oct 2 18:18:13 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 3 Oct 2018 08:18:13 +1000 Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word In-Reply-To: References: Message-ID: <20181002221813.GA91679@cskk.homeip.net> On 02Oct2018 06:04, zljubisic at gmail.com wrote: >I have to execute the same sql in two different programs. >Each of them marks parameters differently. Then you are MUCH better off assembling the SQL using come kind of query constructor, which correctly inserts parameter placeholders is the correct dialogue. >Anyway, I have found the solution. >cnv_sel = re.sub(r"(:(.+?)\b)", r"${\2}", sel) That is a recipe for making unsafe SQL. It does not honour quotes. It does not ensure parameter names are identifiers (which may be vital). Please look into a library for constructing SQL. My favourite general purpose one is SQLAlchemy, which lets you write very nice Python expressions which get turned safely into dialect specific SQL. Cheers, Cameron Simpson From ethan at stoneleaf.us Tue Oct 2 18:52:50 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 2 Oct 2018 15:52:50 -0700 Subject: =?UTF-8?Q?Re:_Re=c2=a0:_So_apparently_I've_been_banned_from_this_li?= =?UTF-8?Q?st?= In-Reply-To: <20181002224032.00D581204E1@zproxy130.enst.fr> References: <0d336830-b8f1-b6e3-b71c-6fb321368e99@stoneleaf.us> <20181002224032.00D581204E1@zproxy130.enst.fr> Message-ID: <26f8c6d5-92c6-29c6-f0c4-02d3afab96e3@stoneleaf.us> On 10/02/2018 03:40 PM, armand.foucault at telecom-bretagne.eu wrote: > Hello there, I'm quite new here. Welcome! > I'm sorry to interfere, but this thread is only creating noise on this list. You are correct. This thread is now closed. > Is there a place where such topics can be debated, other than the common ML? > On StackOverflow, we would take this to Meta; do we have our Meta? Sadly, there is not, and we do not. -- ~Ethan~ Python List Moderator From ben+python at benfinney.id.au Tue Oct 2 20:51:21 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 03 Oct 2018 10:51:21 +1000 Subject: This thread is closed [an actual new thread] References: <5d4fc1bf-fda7-3d39-438b-dd82cd31fee8@stoneleaf.us> Message-ID: <86lg7f4zue.fsf@benfinney.id.au> Ethan Furman writes: > On 10/01/2018 04:26 PM, Ben Finney wrote: > > If there is some specific formal meaning to the above statement, I > > don't know where it's documented. If it's not a specific formal > > statement, that is itself troubling, because it's not clear what > > would constitute a violation nor what the consequences are. > > Consider it now documented, at least on Python List. I imagine Python > Ideas may also implement this framework (assuming we stay on Mail Man > and don't migrate to some web-based forum). Thank you. I don't want to imply an obligation for others, but I suggest it will be (beyond the short term) less painful for future thread-closing actions if that is documented in an official document at a known web page URL. So every time a moderator closes a thread, the message announcing that action can simply say "see for what this means". -- \ ?Drop your trousers here for best results.? ?dry cleaner, | `\ Bangkok | _o__) | Ben Finney From wrw at mac.com Tue Oct 2 22:29:40 2018 From: wrw at mac.com (William Ray Wing) Date: Tue, 02 Oct 2018 22:29:40 -0400 Subject: Creating Win .exe file from *.py on Linux In-Reply-To: References: Message-ID: > On Oct 2, 2018, at 3:03 PM, John Doe wrote: > > Hello World > > Is it possible to create on Linux win .exe file from *.py file? > -- > https://mail.python.org/mailman/listinfo/python-list As was pointed out here a day or so ago, the answer is yes, but it is a two step process. First step is to use Cython to compile the python file to C source, then compile that to a binary executable. The link given was: https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e Where the focus is keeping the python source away from prying eyes, but it generates exactly what you want. Bill From tjcowell at aol.com Wed Oct 3 03:34:48 2018 From: tjcowell at aol.com (Timothy Cowell) Date: Wed, 3 Oct 2018 03:34:48 -0400 Subject: Help please installing Python on Windows 10 Message-ID: <16638d9c626-1ec1-1eed@webjasstg-vaa11.srv.aolmail.net> Hi, Could I please ask for help installing Python on Windows 10 - I've tried twice (Version 3.7 for windows) selecting the install now option. After first attempt I uninstalled and tried again. Each time it has put 4 items in the programs list from the windows start button, all under heading Python 3.7, but the first time they said 64 bit and the second time only 32 bit - I guess I must have clicked on different versions. Both times there was IDLE, Python 3.7, Manuals, and Module Docs. The last two of these worked when clicked on, but the first two just put up a small window of which first was white, and second was black, but I couldn't make them do anything. Could you please tell me what I'm doing wrong? Many thanks, Tim. From dan at djph.net Wed Oct 3 06:59:55 2018 From: dan at djph.net (Dan Purgert) Date: Wed, 3 Oct 2018 10:59:55 -0000 (UTC) Subject: python not working on RHEL6 References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> Message-ID: Thomas Jollans wrote: > On 02/10/2018 19:22, Dan Purgert wrote: >> Thomas Jollans wrote: >>> [...] (preferably, not in /usr - that's for OS-installed files only. >>> /usr/local is a nice place to put things you installed from source). >> >> While I agree that /usr(/bin) is incorrect, I believe that "for >> OS-installed files only" is taking it a bit far. >> >> My (admittedly, dim) recollection of the FHS is that the /usr hierarchy >> is for static[1] "user" binaries, libraries, and so on; while being >> OS-agnostic (so long as that OS followed the FHS). >> [...] > > You're not wrong, but there's still a fairly strong convention that > /usr/{bin,lib*,share,include} are only populated by (in some sense) > non-essential components of the OS only, with varying definitions of > "the OS". On Linux, this tends to mean "everything managed by the > package manager", while on *BSD, it tends to exclude extra packages and > ports collection. > > Whether we agree on the terminology here or not, of course we can agree > that you have to be bloody careful if you *do* decide to put things in > /usr/bin yourself :-) I really have to get better at transferring thoughts to text. Maybe some day I can write a tool for this :). How's this for a take two: While I agree that /usr(/bin) is incorrect, I believe that "for OS-installed files _only_" is taking it a bit far. Perhaps a better comment would've been "preferably not in /usr - it is RECOMMENDED[1] to reserve that for OS-installed files" (the bit where I referenced the FHS ...) [1] See RFC2119 -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From dan at djph.net Wed Oct 3 07:08:12 2018 From: dan at djph.net (Dan Purgert) Date: Wed, 3 Oct 2018 11:08:12 -0000 (UTC) Subject: python not working on RHEL6 References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> Message-ID: Chris Angelico wrote: > On Wed, Oct 3, 2018 at 5:17 AM Thomas Jollans wrote: >> [...] >> Whether we agree on the terminology here or not, of course we can agree >> that you have to be bloody careful if you *do* decide to put things in >> /usr/bin yourself :-) > > [...] On my system (Debian GNU/Linux), /usr/local/bin is ahead of > /usr/bin in $PATH, so even installing into local isn't going to > protect you. Here (MX 17), I'd also shoot myself in the foot if I installed something as "/usr/local/bin/python" :) $ echo $PATH /usr/local/bin:/usr/bin I imagine there's good reason for /usr/local/bin to override /usr/bin ... but it also seems like it's a good way to cause "fun(tm)" problems. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From rosuav at gmail.com Wed Oct 3 07:17:34 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 3 Oct 2018 21:17:34 +1000 Subject: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> Message-ID: On Wed, Oct 3, 2018 at 9:11 PM Dan Purgert wrote: > > Chris Angelico wrote: > > On Wed, Oct 3, 2018 at 5:17 AM Thomas Jollans wrote: > >> [...] > >> Whether we agree on the terminology here or not, of course we can agree > >> that you have to be bloody careful if you *do* decide to put things in > >> /usr/bin yourself :-) > > > > [...] On my system (Debian GNU/Linux), /usr/local/bin is ahead of > > /usr/bin in $PATH, so even installing into local isn't going to > > protect you. > > Here (MX 17), I'd also shoot myself in the foot if I installed something > as "/usr/local/bin/python" :) > > $ echo $PATH > /usr/local/bin:/usr/bin > > I imagine there's good reason for /usr/local/bin to override /usr/bin > ... but it also seems like it's a good way to cause "fun(tm)" problems. > If a system script depends on Python, it should be calling on /usr/bin/python2.7 explicitly, rather than depending on $PATH. (And possibly using -E for further isolation.) ChrisA From zljubisic at gmail.com Wed Oct 3 07:59:30 2018 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 3 Oct 2018 04:59:30 -0700 (PDT) Subject: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word In-Reply-To: References: <10477faf-48f6-aeb9-ff66-a8bf1f17a0f8@mrabarnett.plus.com> Message-ID: Yes it is. Thanks. > A slightly better solution would be: > > cnv_sel = re.sub(r":(\w+)", r"${\1}", sel) From tjol at tjol.eu Wed Oct 3 08:09:55 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 3 Oct 2018 14:09:55 +0200 Subject: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> <6b5309fb-2452-6d3b-4e06-469e81013fa9@tjol.eu> <2b0ba2c7-1ee2-d774-a82a-ffe49bf879d6@tjol.eu> Message-ID: On 03/10/2018 13:17, Chris Angelico wrote: > On Wed, Oct 3, 2018 at 9:11 PM Dan Purgert wrote: >> >> Chris Angelico wrote: >>> On Wed, Oct 3, 2018 at 5:17 AM Thomas Jollans wrote: >>>> [...] >>>> Whether we agree on the terminology here or not, of course we can agree >>>> that you have to be bloody careful if you *do* decide to put things in >>>> /usr/bin yourself :-) >>> >>> [...] On my system (Debian GNU/Linux), /usr/local/bin is ahead of >>> /usr/bin in $PATH, so even installing into local isn't going to >>> protect you. >> >> Here (MX 17), I'd also shoot myself in the foot if I installed something >> as "/usr/local/bin/python" :) >> >> $ echo $PATH >> /usr/local/bin:/usr/bin >> >> I imagine there's good reason for /usr/local/bin to override /usr/bin >> ... but it also seems like it's a good way to cause "fun(tm)" problems. >> > > If a system script depends on Python, it should be calling on > /usr/bin/python2.7 explicitly, rather than depending on $PATH. (And > possibly using -E for further isolation.) > (On Red Hat systems) they tend to call /usr/bin/python. From rowen at uw.edu Wed Oct 3 09:44:35 2018 From: rowen at uw.edu (Russell Owen) Date: Wed, 03 Oct 2018 06:44:35 -0700 Subject: asyncio await different coroutines on the same socket? Message-ID: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> 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 different commands simultaneously and I don't know which command will finish first. I want to do this: coro1 = start(command1) coro2 = start(command2) asyncio.gather(coro1, coro2) where either command may finish first. I?m hoping for a simple and idiomatic way to read the socket and tell each coroutine it is done. So far everything I have come up with is ugly, using multiple layers of "async def?, keeping a record of Tasks that are waiting and calling "set_result" on those Tasks when finished. Also Task isn?t even documented to have the set_result method (though "future" is) Is there a simple, idiomatic way to do this? -- Russell From tomusatov at gmail.com Wed Oct 3 11:05:37 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 08:05:37 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <7f44b090-61ef-589c-1041-98bc8605df61@digipen.edu> Message-ID: <70150c1a-6132-4e0e-8b8f-d217ee041924@googlegroups.com> On Tuesday, October 2, 2018 at 5:54:30 PM UTC-5, Gary Herron wrote: > On 10/02/2018 01:23 PM, tomusatov at gmail.com wrote: > > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > > DATA > > > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > > > EXAMPLE > > > > 7*5 - 3 - 1 = 31 > > > > 11*7 - 5 - 1 = 71 > > > > 11*7 - 5 + 1 = 73 > > > > 13*11 - 7 + 1 = 137 > > > > Can someone put this in a Python program and post? > > > No, sorry, but that's not how this works.? We're not here to do your > homework for you, and you won't learn anything if we do.? You make an > attempt at solving this, asking any specific Python related questions > you need help with, and you'll find this to be prompt, friendly, and > helpful group. > > > Gary Herron > > > -- > Dr. Gary Herron > Professor of Computer Science > DigiPen Institute of Technology > (425) 895-4418 Thank you, Gary. I checked out your program at DigiPen, looks neat. From tomusatov at gmail.com Wed Oct 3 11:11:43 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 08:11:43 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: <8dc3aa44-902a-43e1-bc23-4cc55e4f497f@googlegroups.com> On Tuesday, October 2, 2018 at 5:01:43 PM UTC-5, Max Zettlmei?l wrote: > On Tue, Oct 2, 2018 at 10:23 PM, Musatov wrote: > > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > > DATA > > > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > > > EXAMPLE > > > > 7*5 - 3 - 1 = 31 > > > > 11*7 - 5 - 1 = 71 > > > > 11*7 - 5 + 1 = 73 > > > > 13*11 - 7 + 1 = 137 > > > > Can someone put this in a Python program and post? > > > > Here you go, my friend: > > #!/usr/bin/env python3 > > primes = """Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > DATA > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 35\ > 47, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 3\ > 7831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 989\ > 09, 98911 > > EXAMPLE > > 7*5 - 3 - 1 = 31 > > 11*7 - 5 - 1 = 71 > > 11*7 - 5 + 1 = 73 > > 13*11 - 7 + 1 = 137 """ > > if __name__ == "__main__": > print(primes) > > > As soon as you start showing more effort yourself in the form of your > honest attempts to create a program or at least in the form of some > serious ideas, you might get replies which better fit what you > attempted to receive. Hi Max, I think I see the code you made pretty much just outputs the data I already have. At least I learned something. Thanks, Martin From tomusatov at gmail.com Wed Oct 3 11:25:20 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 08:25:20 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> Message-ID: <9d88342e-19ae-4720-9880-bf39389f465b@googlegroups.com> On Tuesday, October 2, 2018 at 6:13:01 PM UTC-5, Rick Johnson wrote: > Musatov wrote: > > > I am drafting a sequence for OEIS. > > And, have you tried your hand at any Python code yet? Or any > tutorials? I am reading this: https://doc.lagout.org/programmation/python/Beginning%20Programming%20with%20Python%20for%20Dummies%20%5BMueller%202014-09-22%5D.pdf > > > I was told Python was most accessible for beginners. > > And you were told correctly! > > However, be warned that if you happen to become the next > victim of one of our overzealous hall monitors[1], there is > probably very little i can do to help you -- except, perhaps > -- to inform you that switching to the "comp.lang.python" > newsgroup (accessible from GoogleGroups or any Usenet > newsreader) will ensure that at least ~some~ of us will see > your messages. > > Since GvR has resigned, the community has been in something > of a turmoil. And for some reason -- thus far unbeknownst to > me, but soon to be unearth by brute force if necessary! -- > the moderators have gone bad-guano crazy and are purging > members who have been sacrificing blood, sweat and tears > for, oh... i dunno... *DECADES*!!! Thus, to say that i'm > both saddened and angered by the current state of affairs, > would be an understatement. > > At this point I'm not sure how ugly this battle may > become... > > But, i can tell you one thing with absolute certainty... > > The people who have invested their lives into this language > and this community, and for all of these many years, are not > about to stand idle as a few hijackers move-in and destroy > everything we've known, experienced and loved about this > community and this language. I saw it finally made #3! Congrats to the community. https://www.tiobe.com/tiobe-index// > > Yes, Guido is gone. And no, i cannot be sure if he will ever > return. But for those of us who _remain_, the fire of > passion still burns in each of our hearts for the little > language that we love so dearly -- AND I'LL BE *DAMNED*! -- > if some puny, little hall-monitor *PUNK*, is going to come > in here and destroy -- with snobbish flicks of his harry > potter wand! -- *ALL* of the blood, sweat and tears that > have been *SACRIFICED* on the alters of progress for a > idealist dream that this little peon wretch couldn't even > fathom! > > > @Ethan Furman: The window for civility is quickly closing. > You, and you _ALONE_, have the power to reverse this toxic > course and sail our ship back into calmer waters before we > have ourselves an outright *MUTINY*. I have called upon the > members of this community to voice their frustrations with > your Captain-Bligh-inspired leadership, and, as a result, > your name and reputation have suffered greatly. However, > there is still time, should you choose to harness it, to ask > for forgiveness and right these wrongs. But i must remind > you, that haste is of the essence. For the hour is late. > THE. HOUR. IS... *LATE*! > > > [1] And be particularly cautious around one who's name > sort-of-rhymes with: "Eatin' Turdcan". From tomusatov at gmail.com Wed Oct 3 11:26:11 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 08:26:11 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> Message-ID: <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> On Tuesday, October 2, 2018 at 3:49:14 PM UTC-5, Rick Johnson wrote: > Musatov wrote: > > > Well you don't know until you ask. > > Fair enough. > > So, uh, have you made any attempt to compose a Python program from this assignment? > > If so, don't be shy... let's see it! I don't even know where to begin! (I'm reading the Dummies book) From tomusatov at gmail.com Wed Oct 3 11:27:51 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 08:27:51 -0700 (PDT) Subject: Congratulations to the community! Message-ID: <35219596-1206-4221-8226-8975415857c7@googlegroups.com> https://www.tiobe.com/tiobe-index// Python #3 ranked language as of 09/2018 UP from #5 last year Musatov From rosuav at gmail.com Wed Oct 3 11:36:06 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 4 Oct 2018 01:36:06 +1000 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: <9d88342e-19ae-4720-9880-bf39389f465b@googlegroups.com> References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9d88342e-19ae-4720-9880-bf39389f465b@googlegroups.com> Message-ID: On Thu, Oct 4, 2018 at 1:31 AM Musatov wrote: > > On Tuesday, October 2, 2018 at 6:13:01 PM UTC-5, Rick Johnson wrote: > > Musatov wrote: > > > > > I am drafting a sequence for OEIS. > > > > And, have you tried your hand at any Python code yet? Or any > > tutorials? > I am reading this: https://doc.lagout.org/programmation/python/Beginning%20Programming%20with%20Python%20for%20Dummies%20%5BMueller%202014-09-22%5D.pdf > > > > > I was told Python was most accessible for beginners. > > > > And you were told correctly! > > > > However, be warned that if you happen to become the next > > victim of one of our overzealous hall monitors[1], there is > > probably very little i can do to help you -- except, perhaps > > -- to inform you that switching to the "comp.lang.python" > > newsgroup (accessible from GoogleGroups or any Usenet > > newsreader) will ensure that at least ~some~ of us will see > > your messages. > > > > Since GvR has resigned, the community has been in something > > of a turmoil. And for some reason -- thus far unbeknownst to > > me, but soon to be unearth by brute force if necessary! -- > > the moderators have gone bad-guano crazy and are purging > > members who have been sacrificing blood, sweat and tears > > for, oh... i dunno... *DECADES*!!! Thus, to say that i'm > > both saddened and angered by the current state of affairs, > > would be an understatement. > > In case you haven't noticed, you're responding to one of the newsgroup's resident trolls. His posts have been completely blocked from the python-list mailing list for very good reason. I recommend ignoring him. Don't engage the trolls and eventually they might get bored of the sound of their own voices. (Not that I have very high hopes in his case. He could almost join Jim Hacker in parliament.) ChrisA From leo at superlel.me Wed Oct 3 11:58:43 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Wed, 3 Oct 2018 17:58:43 +0200 Subject: asyncio await different coroutines on the same socket? In-Reply-To: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> References: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> Message-ID: Hello Russell, On 03/10/2018 15:44, 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 different commands simultaneously and I don't know which command will > finish first. I want to do this: > > coro1 = start(command1) > coro2 = start(command2) > asyncio.gather(coro1, coro2) > > where either command may finish first. I?m hoping for a simple and > idiomatic way to read the socket and tell each coroutine it is done. So far > everything I have come up with is ugly, using multiple layers of "async > def?, keeping a record of Tasks that are waiting and calling "set_result" > on those Tasks when finished. Also Task isn?t even documented to have the > set_result method (though "future" is) I don't really get what you want to achieve. Do you want to signal other coroutines that one of the others finished ? >From what I understand, you want to have several coroutines reading on the same socket "simultaneously", and you want to stop all of them once one of them is finished. Am I getting it right ? -- L?o From ian.g.kelly at gmail.com Wed Oct 3 12:05:00 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 3 Oct 2018 10:05:00 -0600 Subject: asyncio await different coroutines on the same socket? In-Reply-To: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> References: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> Message-ID: 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 different commands simultaneously and I don't know which command will > finish first. I want to do this: > > coro1 = start(command1) > coro2 = start(command2) > asyncio.gather(coro1, coro2) > > where either command may finish first. I?m hoping for a simple and > idiomatic way to read the socket and tell each coroutine it is done. So far > everything I have come up with is ugly, using multiple layers of "async > def?, keeping a record of Tasks that are waiting and calling "set_result" > on those Tasks when finished. Also Task isn?t even documented to have the > set_result method (though "future" is) Because Tasks are used to wrap coroutines, and the result of the Task should be determined by the coroutine, not externally. Instead of tracking tasks (that's what the event loop is for) I would suggest tracking futures instead. Have start(command1) return a future (or create a future that it will await on itself) that is not a task. Whenever a response from the socket is parsed, that code would then look up the corresponding future and call set_result on it. It might look something like this: class Client: async def open(self, host, port): self.reader, self.writer = await asyncio.open_connection(host, port) asyncio.create_task(self.read_loop()) async def read_loop(self): while not self.reader.at_eof(): response = self.reader.read() id = get_response_id(response) self._futures.pop(id).set_result(response) def start(self, command): future = asyncio.Future() self._futures[get_command_id(command)] = future self.writer.write(command) return future In this case start() is not a coroutine but its result is a future and can be awaited. From torriem at gmail.com Wed Oct 3 12:12:14 2018 From: torriem at gmail.com (Michael Torrie) Date: Wed, 3 Oct 2018 10:12:14 -0600 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> Message-ID: On 10/03/2018 09:26 AM, Musatov wrote: > I don't even know where to begin! (I'm reading the Dummies book) If you have no experience in computer programming, it's going to be a steep learning curve. But your first step is to learn Python and how to write programs in it. That book and others will help with that. You'll have to write lots of simple programs unrelated to primes along the way that help you understand programming concepts. If you already have experience in other languages, the task will be easier. Computer programming is quite natural to some (small children seem to get it much easier than us adults), but I've seen others struggle to grasp the abstract concepts for years. Once you've grasped basic Python programming, you can return top the original problem at hand. Start by identifying the process or algorithm that would find these primes. In other words, how would you do it on pen and paper? Computer programs are not magic. They are only expressions of human thinking. Often some very smart mathematicians have come up with powerful algorithms (a step-by-step process) to do these things, and your job as a programmer is to turn this mathematical process into a computer program using things like loops and Boolean logic. How would you find these primes using your pen, paper, and calculator? From torriem at gmail.com Wed Oct 3 12:17:12 2018 From: torriem at gmail.com (Michael Torrie) Date: Wed, 3 Oct 2018 10:17:12 -0600 Subject: Use Software Collections for RH - was Re: python not working on RHEL6 In-Reply-To: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: On 10/02/2018 07:59 AM, mchathuranga4 at gmail.com wrote: > I guess from the little knowledge I have I should have executed > altinstall instead of install. Anyone know how to resolve this? Actually you probably should not have used a tarball at all. For some time now, Red Hat has offered more recent compilers and languages in RPM format that can install along side the system versions. This is far easier and far safer to work with on older operating systems. I assume you are using a redhat subscription for your RHEL6 install. Follow this: https://access.redhat.com/solutions/472793 If you don't have an active subscription, you might be able to use the CentOS version of software collections at: https://www.softwarecollections.org/en/ From torriem at gmail.com Wed Oct 3 12:34:42 2018 From: torriem at gmail.com (Michael Torrie) Date: Wed, 3 Oct 2018 10:34:42 -0600 Subject: Use Software Collections for RH - was Re: python not working on RHEL6 In-Reply-To: References: <300915fa-432a-4a36-a07a-9c2f09d7fbf6@googlegroups.com> Message-ID: <41beae40-1d89-c225-1921-79ec1abb3d2c@gmail.com> On 10/03/2018 10:17 AM, Michael Torrie wrote: > On 10/02/2018 07:59 AM, mchathuranga4 at gmail.com wrote: >> I guess from the little knowledge I have I should have executed >> altinstall instead of install. Anyone know how to resolve this? > > Actually you probably should not have used a tarball at all. For some > time now, Red Hat has offered more recent compilers and languages in RPM > format that can install along side the system versions. This is far > easier and far safer to work with on older operating systems. I assume > you are using a redhat subscription for your RHEL6 install. Follow this: > https://access.redhat.com/solutions/472793 > > If you don't have an active subscription, you might be able to use the > CentOS version of software collections at: > https://www.softwarecollections.org/en/ Sorry to reply to my own post, but here's a more specific page about Python 2.7 for either CentOS or RHEL: https://www.softwarecollections.org/en/scls/rhscl/python27/ See the bottom of the page for instructions on enabling the YUM repository for RHEL6. From tomusatov at gmail.com Wed Oct 3 12:43:07 2018 From: tomusatov at gmail.com (Musatov) Date: Wed, 3 Oct 2018 09:43:07 -0700 (PDT) Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> Message-ID: <1b7c84b9-6e4f-4312-8f03-e77ea6473e57@googlegroups.com> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie wrote: > On 10/03/2018 09:26 AM, Musatov wrote: > > I don't even know where to begin! (I'm reading the Dummies book) > > If you have no experience in computer programming, it's going to be a > steep learning curve. > > But your first step is to learn Python and how to write programs in it. > That book and others will help with that. You'll have to write lots of > simple programs unrelated to primes along the way that help you > understand programming concepts. > > If you already have experience in other languages, the task will be easier. > > Computer programming is quite natural to some (small children seem to > get it much easier than us adults), but I've seen others struggle to > grasp the abstract concepts for years. > > Once you've grasped basic Python programming, you can return top the > original problem at hand. Start by identifying the process or algorithm > that would find these primes. In other words, how would you do it on pen > and paper? Computer programs are not magic. They are only expressions > of human thinking. Often some very smart mathematicians have come up > with powerful algorithms (a step-by-step process) to do these things, > and your job as a programmer is to turn this mathematical process into a > computer program using things like loops and Boolean logic. How would > you find these primes using your pen, paper, and calculator? Literally, how I found them was taking a list of primes and checking if the calculations with the lesser primes resulted in numbers also further along on the list. Another way I guess would be to do the calculations then check if the number is prime. From ibrahimhusain007 at gmail.com Thu Oct 4 04:25:24 2018 From: ibrahimhusain007 at gmail.com (Ibrahim Dalal) Date: Thu, 4 Oct 2018 13:55:24 +0530 Subject: Calling an instance method defined without any 'self' parameter Message-ID: class A: def foo(): print 'Hello, world!' a = A()print A.foo # print a.foo # >print type(A.foo) # a.foo() # TypeError: foo() takes no arguments (1 given) A.foo() # TypeError: unbound method foo() must be called with A instance as first argument (got nothing instead) Clearly, foo is an instance method. I know one should use @staticmethod for declaring a method static. The question here is, given the above code, is there any way to call foo? Python 2.7 Thanks, From alister.ware at ntlworld.com Thu Oct 4 04:31:39 2018 From: alister.ware at ntlworld.com (Alister) Date: Thu, 04 Oct 2018 08:31:39 GMT Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> <1b7c84b9-6e4f-4312-8f03-e77ea6473e57@googlegroups.com> Message-ID: On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote: > On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie > wrote: >> On 10/03/2018 09:26 AM, Musatov wrote: >> > I don't even know where to begin! (I'm reading the Dummies book) >> >> If you have no experience in computer programming, it's going to be a >> steep learning curve. >> >> But your first step is to learn Python and how to write programs in it. >> That book and others will help with that. You'll have to write lots of >> simple programs unrelated to primes along the way that help you >> understand programming concepts. >> >> If you already have experience in other languages, the task will be >> easier. >> >> Computer programming is quite natural to some (small children seem to >> get it much easier than us adults), but I've seen others struggle to >> grasp the abstract concepts for years. >> >> Once you've grasped basic Python programming, you can return top the >> original problem at hand. Start by identifying the process or >> algorithm that would find these primes. In other words, how would you >> do it on pen and paper? Computer programs are not magic. They are >> only expressions of human thinking. Often some very smart >> mathematicians have come up with powerful algorithms (a step-by-step >> process) to do these things, >> and your job as a programmer is to turn this mathematical process into >> a computer program using things like loops and Boolean logic. How would >> you find these primes using your pen, paper, and calculator? > > Literally, how I found them was taking a list of primes and checking if > the calculations with the lesser primes resulted in numbers also further > along on the list. > > Another way I guess would be to do the calculations then check if the > number is prime. That is exactly how you do it with in a program. create a loop & check to see if the target number can be divided by each possible divisor in turn . for large numbers this will take a large number of tests (hey that is why you have the computer do them, it is faster than you & does not get bored ;-) ) there are numerous tricks for speeding up this process once you have the basic working. start by testing small numbers & then use your real data once you have something that works as a starter a simple loop in python could be as follows for x in xrange(10): print x once you have an outline of a program post it back here if things dont work as expected -- A narcissist is someone better looking than you are. -- Gore Vidal From lists at vanderhoff.org Thu Oct 4 04:44:01 2018 From: lists at vanderhoff.org (Tony van der Hoff) Date: Thu, 4 Oct 2018 09:44:01 +0100 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> <1b7c84b9-6e4f-4312-8f03-e77ea6473e57@googlegroups.com> Message-ID: On 04/10/18 09:31, Alister via Python-list wrote: > On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote: > >> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie >> wrote: >>> On 10/03/2018 09:26 AM, Musatov wrote: >>>> I don't even know where to begin! (I'm reading the Dummies book) >>> >>> If you have no experience in computer programming, it's going to be a >>> steep learning curve. >>> >>> But your first step is to learn Python and how to write programs in it. >>> That book and others will help with that. You'll have to write lots of >>> simple programs unrelated to primes along the way that help you >>> understand programming concepts. >>> >>> If you already have experience in other languages, the task will be >>> easier. >>> >>> Computer programming is quite natural to some (small children seem to >>> get it much easier than us adults), but I've seen others struggle to >>> grasp the abstract concepts for years. >>> >>> Once you've grasped basic Python programming, you can return top the >>> original problem at hand. Start by identifying the process or >>> algorithm that would find these primes. In other words, how would you >>> do it on pen and paper? Computer programs are not magic. They are >>> only expressions of human thinking. Often some very smart >>> mathematicians have come up with powerful algorithms (a step-by-step >>> process) to do these things, >>> and your job as a programmer is to turn this mathematical process into >>> a computer program using things like loops and Boolean logic. How would >>> you find these primes using your pen, paper, and calculator? >> >> Literally, how I found them was taking a list of primes and checking if >> the calculations with the lesser primes resulted in numbers also further >> along on the list. >> >> Another way I guess would be to do the calculations then check if the >> number is prime. > > That is exactly how you do it with in a program. > > create a loop & check to see if the target number can be divided by each > possible divisor in turn > . > for large numbers this will take a large number of tests (hey that is why > you have the computer do them, it is faster than you & does not get > bored ;-) ) there are numerous tricks for speeding up this process once > you have the basic working. > > start by testing small numbers & then use your real data once you have > something that works > > as a starter a simple loop in python could be as follows > > for x in xrange(10): > print x > > once you have an outline of a program post it back here if things dont > work as expected > Two lines, two errors! To save the noob a lot of head-scratching, that should be: for x in range(10): If you're running python 3, as you should do for any new project: print( x ) -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From remy.dupeyroux at gmail.com Thu Oct 4 06:05:18 2018 From: remy.dupeyroux at gmail.com (=?utf-8?Q?R=C3=A9my_Dpx?=) Date: Thu, 4 Oct 2018 12:05:18 +0200 Subject: problem Message-ID: <5bb5e5e4.1c69fb81.d690e.daed@mx.google.com> Hello, I?ve got a problem with my Python. Indeed my Idle act like if my ctrl button were always pushed ( when i press Q, it selects everything?; when i press W, it goes back in the last form) I tried to uninstall and download back and also to change the version, but my problem is still there. I hope u will give me a solution. Thanks. R?my --- L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. https://www.avast.com/antivirus From alister.ware at ntlworld.com Thu Oct 4 10:41:53 2018 From: alister.ware at ntlworld.com (Alister) Date: Thu, 04 Oct 2018 14:41:53 GMT Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> <1b7c84b9-6e4f-4312-8f03-e77ea6473e57@googlegroups.com> Message-ID: On Thu, 04 Oct 2018 09:44:01 +0100, Tony van der Hoff wrote: > On 04/10/18 09:31, Alister via Python-list wrote: >> On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote: >> >>> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie >>> wrote: >>>> On 10/03/2018 09:26 AM, Musatov wrote: >>>>> I don't even know where to begin! (I'm reading the Dummies book) >>>> >>>> If you have no experience in computer programming, it's going to be a >>>> steep learning curve. >>>> >>>> But your first step is to learn Python and how to write programs in >>>> it. >>>> That book and others will help with that. You'll have to write lots >>>> of simple programs unrelated to primes along the way that help you >>>> understand programming concepts. >>>> >>>> If you already have experience in other languages, the task will be >>>> easier. >>>> >>>> Computer programming is quite natural to some (small children seem to >>>> get it much easier than us adults), but I've seen others struggle to >>>> grasp the abstract concepts for years. >>>> >>>> Once you've grasped basic Python programming, you can return top the >>>> original problem at hand. Start by identifying the process or >>>> algorithm that would find these primes. In other words, how would you >>>> do it on pen and paper? Computer programs are not magic. They are >>>> only expressions of human thinking. Often some very smart >>>> mathematicians have come up with powerful algorithms (a step-by-step >>>> process) to do these things, >>>> and your job as a programmer is to turn this mathematical process >>>> into a computer program using things like loops and Boolean logic. >>>> How would you find these primes using your pen, paper, and >>>> calculator? >>> >>> Literally, how I found them was taking a list of primes and checking >>> if the calculations with the lesser primes resulted in numbers also >>> further along on the list. >>> >>> Another way I guess would be to do the calculations then check if the >>> number is prime. >> >> That is exactly how you do it with in a program. >> >> create a loop & check to see if the target number can be divided by >> each possible divisor in turn . >> for large numbers this will take a large number of tests (hey that is >> why you have the computer do them, it is faster than you & does not get >> bored ;-) ) there are numerous tricks for speeding up this process once >> you have the basic working. >> >> start by testing small numbers & then use your real data once you have >> something that works >> >> as a starter a simple loop in python could be as follows >> >> for x in xrange(10): >> print x >> >> once you have an outline of a program post it back here if things dont >> work as expected >> >> > Two lines, two errors! To save the noob a lot of head-scratching, that > should be: > for x in range(10): > > If you're running python 3, as you should do for any new project: > print( x ) perfectly legit python 2.7 I probably should have considered writing python 3 compatible code but range operates differently on the 2 versions & would be a poor choice for python 2 when numbers get larger ass for the head scratching a noob (& anyone else for that mater) far more from correcting code than they do from simply copy & pasting working code. -- TAILFINS!! ... click ... From rosuav at gmail.com Thu Oct 4 10:51:06 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 5 Oct 2018 00:51:06 +1000 Subject: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. In-Reply-To: References: <14c8378b-e4ab-4877-bd31-ef92fdff1caf@googlegroups.com> <9747b46e-290e-4230-a80d-38dbe6e1f442@googlegroups.com> <6670fb8b-1d52-4d89-9145-049c7c601104@googlegroups.com> <6eed53b5-2d3a-4b72-a6a3-351c0802e46f@googlegroups.com> <1b7c84b9-6e4f-4312-8f03-e77ea6473e57@googlegroups.com> Message-ID: On Fri, Oct 5, 2018 at 12:47 AM Alister via Python-list wrote: > > On Thu, 04 Oct 2018 09:44:01 +0100, Tony van der Hoff wrote: > > > On 04/10/18 09:31, Alister via Python-list wrote: > >> On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote: > >> > >>> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie > >>> wrote: > >>>> On 10/03/2018 09:26 AM, Musatov wrote: > >>>>> I don't even know where to begin! (I'm reading the Dummies book) > >>>> > >>>> If you have no experience in computer programming, it's going to be a > >>>> steep learning curve. > >>>> > >>>> But your first step is to learn Python and how to write programs in > >>>> it. > >>>> That book and others will help with that. You'll have to write lots > >>>> of simple programs unrelated to primes along the way that help you > >>>> understand programming concepts. > >>>> > >>>> If you already have experience in other languages, the task will be > >>>> easier. > >>>> > >>>> Computer programming is quite natural to some (small children seem to > >>>> get it much easier than us adults), but I've seen others struggle to > >>>> grasp the abstract concepts for years. > >>>> > >>>> Once you've grasped basic Python programming, you can return top the > >>>> original problem at hand. Start by identifying the process or > >>>> algorithm that would find these primes. In other words, how would you > >>>> do it on pen and paper? Computer programs are not magic. They are > >>>> only expressions of human thinking. Often some very smart > >>>> mathematicians have come up with powerful algorithms (a step-by-step > >>>> process) to do these things, > >>>> and your job as a programmer is to turn this mathematical process > >>>> into a computer program using things like loops and Boolean logic. > >>>> How would you find these primes using your pen, paper, and > >>>> calculator? > >>> > >>> Literally, how I found them was taking a list of primes and checking > >>> if the calculations with the lesser primes resulted in numbers also > >>> further along on the list. > >>> > >>> Another way I guess would be to do the calculations then check if the > >>> number is prime. > >> > >> That is exactly how you do it with in a program. > >> > >> create a loop & check to see if the target number can be divided by > >> each possible divisor in turn . > >> for large numbers this will take a large number of tests (hey that is > >> why you have the computer do them, it is faster than you & does not get > >> bored ;-) ) there are numerous tricks for speeding up this process once > >> you have the basic working. > >> > >> start by testing small numbers & then use your real data once you have > >> something that works > >> > >> as a starter a simple loop in python could be as follows > >> > >> for x in xrange(10): > >> print x > >> > >> once you have an outline of a program post it back here if things dont > >> work as expected > >> > >> > > Two lines, two errors! To save the noob a lot of head-scratching, that > > should be: > > for x in range(10): > > > > If you're running python 3, as you should do for any new project: > > print( x ) > > perfectly legit python 2.7 > I probably should have considered writing python 3 compatible code but > range operates differently on the 2 versions & would be a poor choice for > python 2 when numbers get larger For a loop with a print in it, I'd definitely just use range(). It'll work on all versions, and long before you run into problems with the RAM usage on Py2, you've spammed your terminal so much that you're waiting for it :) ChrisA From nulla.epistola at web.de Thu Oct 4 11:07:54 2018 From: nulla.epistola at web.de (Sibylle Koczian) Date: Thu, 4 Oct 2018 17:07:54 +0200 Subject: Help please installing Python on Windows 10 In-Reply-To: <16638d9c626-1ec1-1eed@webjasstg-vaa11.srv.aolmail.net> References: <16638d9c626-1ec1-1eed@webjasstg-vaa11.srv.aolmail.net> Message-ID: Am 03.10.2018 um 09:34 schrieb Timothy Cowell via Python-list: > Could I please ask for help installing Python on Windows 10 - I've tried twice (Version 3.7 for windows) selecting the install now option. After first attempt I uninstalled and tried again. > > Each time it has put 4 items in the programs list from the windows start button, all under heading Python 3.7, but the first time they said 64 bit and the second time only 32 bit - I guess I must have clicked on different versions. > 32 bit on a 64 bit PC and Windows version should work, 64 bit on 32 bit Windows probably not. So, if you kept your second attempt, that should be enough to start with. > > Both times there was IDLE, Python 3.7, Manuals, and Module Docs. The last two of these worked when clicked on, but the first two just put up a small window of which first was white, and second was black, but I couldn't make them do anything. > IDLE and the Python shell both start with windows showing text like this: Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> Did you get something like this? In that case nothing was wrong, Python just waited for your commands. The manual contains a tutorial which starts using the interactive interpreter - try it out. If you don't get the results the tutorial predicts, come back here or subscribe to the tutor list: Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor If your "small windows" don't contain such a header, that really would look wrong. In that case: are they completely empty? Or what else? If they contain any text at all, can you copy and paste it into your answer? Please don't try to send a screenshot, the list won't accept it. HTH Sibylle From tjol at tjol.eu Thu Oct 4 12:31:55 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 4 Oct 2018 18:31:55 +0200 Subject: Calling an instance method defined without any 'self' parameter In-Reply-To: References: Message-ID: On 2018-10-04 10:25, Ibrahim Dalal wrote: > class A: > def foo(): > print 'Hello, world!' > > a = A()print A.foo # print a.foo # > >print > type(A.foo) # > a.foo() # TypeError: foo() takes no arguments (1 given) > A.foo() # TypeError: unbound method foo() must be called > with A instance as first argument (got nothing instead) > > > Clearly, foo is an instance method. I know one should use @staticmethod for > declaring a method static. The question here is, given the above code, is > there any way to call foo? Yes: use Python 3! Python 3.7.0 (default, Jun 28 2018, 13:15:42) [GCC 7.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... def foo(): ... print('yo!') ... >>> A.foo >>> A.foo() yo! >>> > > Python 2.7 > There is a way in Python 2 as well, and I'm sure someone else will demonstrate. I won't. It's easy enough to discover if you know that it should exist. I'll just tell you that Python 3 is much nicer: Python 3 is much nicer. Cheers, Thomas From tjreedy at udel.edu Thu Oct 4 12:53:36 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 4 Oct 2018 12:53:36 -0400 Subject: Calling an instance method defined without any 'self' parameter In-Reply-To: References: Message-ID: On 10/4/2018 4:25 AM, Ibrahim Dalal wrote: > class A: > def foo(): > print 'Hello, world!' > > a = A()print A.foo # print a.foo # > >print > type(A.foo) # > a.foo() # TypeError: foo() takes no arguments (1 given) > A.foo() # TypeError: unbound method foo() must be called > with A instance as first argument (got nothing instead) > > > Clearly, foo is an instance method. It is either a buggy instance method, missing the required first parameter, *or* a buggy static method, missing the decorator, making it appear to the interpreter as an instance method even though it it not. I know one should use @staticmethod for > declaring a method static. The question here is, given the above code, is > there any way to call foo? Fix the bug, whichever deficiency you regard as the bug. -- Terry Jan Reedy From bob at mellowood.ca Thu Oct 4 13:00:51 2018 From: bob at mellowood.ca (Bob van der Poel) Date: Thu, 4 Oct 2018 10:00:51 -0700 Subject: Calling an instance method defined without any 'self' parameter In-Reply-To: References: Message-ID: On Thu, Oct 4, 2018 at 1:25 AM Ibrahim Dalal wrote: > class A: > def foo(): > print 'Hello, world!' > > a = A()print A.foo # print a.foo # > >print > type(A.foo) # > a.foo() # TypeError: foo() takes no arguments (1 given) > A.foo() # TypeError: unbound method foo() must be called > with A instance as first argument (got nothing instead) > > > Clearly, foo is an instance method. I know one should use @staticmethod for > declaring a method static. The question here is, given the above code, is > there any way to call foo? > > Python 2.7 > > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list > Use the magic of staticmethod :) class A: @staticmethod def foo(): ... do foo stuff Hope this helps. -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From tjreedy at udel.edu Thu Oct 4 13:02:33 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 4 Oct 2018 13:02:33 -0400 Subject: problem In-Reply-To: <5bb5e5e4.1c69fb81.d690e.daed@mx.google.com> References: <5bb5e5e4.1c69fb81.d690e.daed@mx.google.com> Message-ID: On 10/4/2018 6:05 AM, R?my Dpx wrote: > Hello, > I?ve got a problem with my Python. What OS?, What Python version? > Indeed my Idle act like if my ctrl button were always pushed ( when i press Q, it selects everything?; On all built-in keysets, Control-Q is bound to 'close-all-windows', which is 'quit'. > when i press W, it goes back in the last form) Control-W does not have this meaning in any built-in IDLE keyset. Are you really using IDLE? > I tried to uninstall and download back and also to change the version, but my problem is still there. Perhaps your keyboard or OS keyboard handler has a problem. -- Terry Jan Reedy From ibrahimhusain007 at gmail.com Thu Oct 4 13:38:31 2018 From: ibrahimhusain007 at gmail.com (Ibrahim Dalal) Date: Thu, 4 Oct 2018 23:08:31 +0530 Subject: Calling an instance method defined without any 'self' parameter In-Reply-To: References: Message-ID: On Thu, Oct 4, 2018 at 10:20 PM Thomas Jollans wrote: > On 2018-10-04 10:25, Ibrahim Dalal wrote: > > class A: > > def foo(): > > print 'Hello, world!' > > > > a = A()print A.foo # print a.foo # > > >print > > type(A.foo) # > > a.foo() # TypeError: foo() takes no arguments (1 given) > > A.foo() # TypeError: unbound method foo() must be called > > with A instance as first argument (got nothing instead) > > > > There is a way in Python 2 as well, and I'm sure someone else will > demonstrate. I won't. It's easy enough to discover if you know that it > should exist. I'll just tell you that Python 3 is much nicer: > Thought a little about it. A.__dict__['foo']() works! Thanks. > > Python 3 is much nicer. > > Cheers, > Thomas > -- > https://mail.python.org/mailman/listinfo/python-list > From rj.amdphreak at gmail.com Thu Oct 4 21:42:36 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Thu, 4 Oct 2018 20:42:36 -0500 Subject: pip hangs after successful operation Message-ID: <5bb6c18c.1c69fb81.c01f6.aae6@mx.google.com> Hello, I am seeking some quick help, and probably am reporting bugs along the way. I apologize that this is a long email. Please let me know what I should do in the future. On Windows, pip hangs and does not install packages in the proper location (or perhaps, at all), even if pip claims it installed successfully. Upon hanging, I can use Ctrl+C to terminate individual processes that have succeeded, and the results show up in ?pip list?, but this bug affects any packages that call pip within their install script, which makes this a critical bug, since the package install scripts will never complete. Filed bug report here: https://github.com/pypa/pip/issues/5850 My environment: ? Python 3.7.0 x64 ? pip 18.0 ? Windows 10 Pro x64 Steps taken to resolve, so far: ? Repaired Installation. ? Removed and Reinstalled Installation. ? Rebooted computer as last resort. This appears to be a bug similar to https://github.com/pypa/pip/issues/4588 However, unlike in that bug report, pip hangs after all of these commands: ? pip list ? pip install ? pip install --upgrade pip However, when called using ?py -m pip?, these commands do not hang, and, upon inspection of the package list, via ?pip list? and ?py -m pip list? methods, there is a discrepancy. This is the culprit, but I don?t know how to fix the problem. Output: ? PS C:\Users\Ryan> py -V Python 3.7.0 ? PS C:\Users\Ryan> pip list Package???? Version ----------- ------- Click?????? 7.0 mysqlclient 1.3.13 pip???????? 18.0 pip-tools?? 3.0.0 setuptools? 40.4.3 six???????? 1.11.0 ? PS C:\Users\Ryan> py -m pip list Package??? Version ---------- ------- pip??????? 18.0 setuptools 40.4.3 Notice the package lists are different. The outputs above are from the exact same pip executable: ? PS C:\Users\Ryan> pip -V pip 18.0 from c:\users\ryan\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7) ? PS C:\Users\Ryan> py -m pip -V pip 18.0 from C:\Users\Ryan\AppData\Local\Programs\Python\Python37\lib\site-packages\pip (python 3.7) I have another machine running Python 3.7.0 x64 that does not experience this issue. Both machines have the same set-up: ? Python 3.7.0 from x64 installer (local user install, not All Users install, with PATH option checked. pip runs directly in terminal.) ? Python 3.6.6 from Visual Studio 2017 installer (pip does not run unless called from py -m pip or py -3.6 m pip) ? Anaconda from installer (not used yet) ? MySQL Connector Python 8.0.12 from MySQL Installer (only installs for Python 3.6.6, not compatible with Python 3.7.0) ? Cygwin ? MinGW/MSYS I have exhausted all online help documentation, and none of the bug reports contain answers that explain why one computer fails while the other does not. Further testing reveals more bugs: This bug does not affect the older Python 3.6.6 pip on either machine: ? py -3.6 -m pip -V pip 10.0.1 from < blah path to Python36_64 package dir > ? py -3.6 -m pip install matplotlib MySQL-connector-python 8.0.12 requires protobuf>=3.0.0, which is not installed. The installation [also] fails, but at least it doesn?t hang. However it is not possible to install protobuf, as this also fails: ? py -3.6 -m pip install protobuf Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: C:\\ ?.. \\six.py And it cannot upgrade: ? py -3.6 -m pip install --upgrade pip Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: ?c:\\program...\\...\\pip-10.0.1.dist-info\\entry_points.txt? Consider using the `--user` option or check the permissions. Used the suggestion, which looked more like a warning: ? Py -3.6 -m pip install --upgrade pip --user Successfully installed Permission denied is a bad excuse to fail, when a command line argument can change this. I do not like adding command line switches to something that should work without them (since I specifically call this user-specific resource in the command statement), because there is no telling what the application will do from a black-box engineering viewpoint. This error message / hint should be more elaborate, explaining what the switch does, as it is counterintuitive for anyone familiar with Linux to believe for one second that ?--user? is supposed get around a ?permission denied? problem by elevating permissions, after years of telling users they need to use ?sudo? to run something as root. This is an advantage for the ignorant coder. If ignorance is an advantage, then that just means the error message is not explanative enough. Requiring users to glean the meaning of ??user? from the ??help? option wastes time and mental resources by adding another layer of complexity to the installation process. It is not obvious that there is a ??help? option for ?pip install? (hence the waste of time). Other bug encountered recently: Also, there is a bug that I reported approximately a week ago with the mysqlclient package installer, in which an install script for MySQL Connector-C chokes on its own assumptions about where the installation is: I worked around it by using Link Shell Extension to create an NTFS junction: From ?C:\Program Files\MySQL\MySQL Connector C 6.1? (actual install) To ?C:\Program Files (x86)\MySQL\MySQL Connector C 6.1? (where script believes install folder is) The sheer number of bugs and gotchas involving pip for a newcomer to have to deal with is inexcusable, in light of the fact that creating an executable of a python script for deployment on client computers is not straightforward either. The purpose of agile coding languages is to trade off deployment advantages for development speed, but these obstacles in pip absolutely kill this intended benefit of Python. If someone can share an up-to-date resource for making executables, I would appreciate it. I am single-handedly developing an inventory management solution for a business with no prior Python experience, and these problems are not trivial. They have taken several days to discover the causes and solutions, and every time I fix one, a new one pops up. Final Straw: Mysqlclient install exits with errors: ? PS C:\Users\Ryan> py -m pip install mysqlclient --user o Collecting mysqlclient o ? Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz o ??? Error [WinError 87] The parameter is incorrect while executing command python setup.py egg_info o Could not install packages due to an EnvironmentError: [WinError 87] The parameter is incorrect This package correctly installed on my original machine with ?pip install mysqlclient?, after linking the MySQL Connector C. Installing mysqlclient on Python 3.6.6 does not work, either: ? PS C:\Users\Ryan> py -3.6 -m pip install mysqlclient --user o Collecting mysqlclient o ? Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz o ??? Complete output from command python setup.py egg_info: o o ??? ---------------------------------------- o Command "python setup.py egg_info" failed with error code 1 in C:\Users\Ryan\AppData\Local\Temp\pip-install-rfj6k92m\mysqlclient\ However, as shown at the beginning of my email, these packages show up in ?pip list?, as though the install succeeded, but not in ?py -m pip list? or ?py -3.6 -m pip list?. Thanks, Ryan Johnson Sent from Mail for Windows 10 From brucecoram at clara.co.uk Fri Oct 5 06:22:29 2018 From: brucecoram at clara.co.uk (Bruce Coram) Date: Fri, 5 Oct 2018 11:22:29 +0100 Subject: Observations on the List - "Be More Kind" Message-ID: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> I will declare at the outset, I am a lurker.? I don't know enough about Python to give advice that I could 100% guarantee would be helpful. There have been two recent threads that summarise for me where the Python Mailing List has lost its way (and this started before Trump arrived as a new role model for how to treat your fellow man): "Re: This thread is closed [an actual new thread]" "Re: So apparently I've been banned from this list" The level of vitriol and personal attacks on the moderators was profoundly disappointing, but not totally out of character for those who made the attacks.? There is no doubt that these people know software and Python and this certainly earns my respect,? but perhaps they need to retain a sense of perspective.? There are 7 billion people in the world.? There are plenty more people at least as good as you and many better, but they don't have the compelling urge to demonstrate their genius.? They get on with their work in a quiet professional manner. Some humility in acknowledging that you stand on the shoulders of giants would not go amiss.? It might also reflect that you understand the good fortune that dealt you such a good hand in life. You aren't always right, and you don't always have to insist on being right.? I found Steve D'Aprano always had to have the last word and had to prove he was right.? I found some of his posts to be intemperate in tone. Why is there a need to score points with caustic remarks or throwaway comments?? Perhaps the person who posed his question should have read the documents, perhaps he should have searched the archives.? Tell them so politely and firmly.? If you cannot manage that then why say anything?? Not everyone who posts a poorly prepared question is idle and deserves a response that is less than polite.? Prepare a boilerplate standard reply that is polite for those questions that are easily resolved by the poster. Perhaps the person who posts something you regard as nonsense is ignorant and lacks the knowledge they think they possess.? Instead of wasting your time with scholastic debate, put the time to good use improving your education in subjects you don't excel at.? I can guarantee the depth of your ignorance will be profound - there will be much for you to learn.? The effort some of you put in to the endless debates suggests that you have plenty of time on your hands - don't waste it.? It will be gone soon enough. Don't waste time on the trolls, some of whom undoubtedly enjoy the ability to provoke a response.? Develop a greater sense of self awareness to enable you to recognise that you are being played.? The intemperate tone of some of the exchanges damages the reputation of the List. Life is hard enough without us adding to it.? Try silence as a response. Listen to Frank Turner's latest album: "Be More Kind".?? That is not a plug to buy the album, but the title seems apposite - and the music is good. Regards Bruce Coram From rj.amdphreak at gmail.com Fri Oct 5 10:40:47 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Fri, 5 Oct 2018 09:40:47 -0500 Subject: Solved: pip hangs after successful operation (sandboxed environment problem) Message-ID: <5bb777ee.1c69fb81.37918.3eaf@mx.google.com> It turns out that Comodo Antivirus auto-sandboxes any program that it doesn?t recognize, and this included python in the C:\Users\$user\AppData\Programs directory. This also affects Cygwin and MSYS2 (but not MSYS). If you are thinking about using Comodo, disable the Auto-Containment feature. Alternately, you may try to add the folder locations to the white-list, but this didn?t work for me. Have a nice day, Ryan Sent from Mail for Windows 10 From pjmclenon at gmail.com Fri Oct 5 10:59:22 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Fri, 5 Oct 2018 07:59:22 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> Message-ID: <53f5247f-c92e-48d0-8ae4-14c2909d9053@googlegroups.com> On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > ?> 1st is this script is from a library module online open source > > If it's open source, why didn't you show the link to the soruce? > I assume your code is this: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py > > And self.collFile is opened here: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 > > You need to add `encoding='utf-8'` argument. OCT 5TH 2018 new question to the Google forum Hello mr naoki thank you for your contributions to the Platform to be able to post questions ...I have a django project and it's slightly different from all django project videos I see on the Net ...I have a docs folder right next to the templates folder. ..in the docs folder I have text files. ...when i update or add text document files in the shell console and I follow all your steps to save and migrate and migrations. .it doesn't add the text file to the docs folder and when i look up the words on my browser page , in a lookfor/search box. just like yours, it only returns the original text files. ..not the text file I added or any modifications i made to the original txt files. .....even though if I go back to the python shell console and I can query the new added text file. .it's there.....how can I solve this? ??.... PS not sure if this is related..as i try to solve this..i cant seem to run a specific module/file in my mainwebapp folder.....the filter_docs.py.....in that file i have from filter.docs.py import Document..but i will get a module not found filter_docs...so i changed it to from . models import Document...and i will __main__ not a package....models.py and filter_docs.py are both in mainwebapp folder.......i am trying to run this specific file cuz i think this may solve my docs folder not updating .txt files that i add....in the filter_docs.py i have my functions that parse the words/terms in the docs folder...but it doesnt as i said when i made additions...i do see a line in 2 functions that says...# Run once if DocFrequency.objects.all().exists(): return so im thinking if i comment out this conditionel.. will it update my additons when i actually go to my website browser and do a lookup or search for terms in my docs folder?? sorry for the long email Jessica From ts9564 at gmail.com Fri Oct 5 16:48:16 2018 From: ts9564 at gmail.com (ts9564 at gmail.com) Date: Fri, 5 Oct 2018 13:48:16 -0700 (PDT) Subject: Python indentation (3 spaces) Message-ID: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" Thoughts? Thomas From rosuav at gmail.com Fri Oct 5 16:53:37 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 6 Oct 2018 06:53:37 +1000 Subject: Python indentation (3 spaces) In-Reply-To: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: On Sat, Oct 6, 2018 at 6:51 AM wrote: > > I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" > Thoughts? I don't understand how three spaces would prevent errors in a way that four wouldn't. But you're absolutely welcome to standardize all of your own code on indenting with tabs instead of spaces, or two space indents, or three, or four, or seventeen if you so desire. ChrisA From storchaka at gmail.com Fri Oct 5 17:23:49 2018 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 6 Oct 2018 00:23:49 +0300 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: 05.10.18 23:53, Chris Angelico ????: > I don't understand how three spaces would prevent errors in a way that > four wouldn't. In many editors and on terminal for a in x: if a: b() <-tab-->c() looks indistinguishable from for a in x: if a: b() c() but the former is a syntax error in Python 3. If use 3-space indentation this error is more visible: for a in x: if a: b() <-tab-->c() From Karsten.Hilbert at gmx.net Fri Oct 5 17:35:33 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Fri, 5 Oct 2018 23:35:33 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <20181005213533.GA2124@hermes.hilbert.loc> On Sat, Oct 06, 2018 at 12:23:49AM +0300, Serhiy Storchaka wrote: > > I don't understand how three spaces would prevent errors in a way that > > four wouldn't. > In many editors and on terminal > > for a in x: > if a: > b() > <-tab-->c() > > looks indistinguishable from > > for a in x: > if a: > b() > c() > > but the former is a syntax error in Python 3. > > If use 3-space indentation this error is more visible: > > for a in x: > if a: > b() > <-tab-->c() That is only incidental because the "width" of a tab stop is what you define it to be. On my system it might just be 3 spaces which would turn your argument on its head. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From rosuav at gmail.com Fri Oct 5 17:41:27 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 6 Oct 2018 07:41:27 +1000 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: On Sat, Oct 6, 2018 at 7:25 AM Serhiy Storchaka wrote: > > 05.10.18 23:53, Chris Angelico ????: > > I don't understand how three spaces would prevent errors in a way that > > four wouldn't. > In many editors and on terminal > > for a in x: > if a: > b() > <-tab-->c() > > looks indistinguishable from > > for a in x: > if a: > b() > c() > > but the former is a syntax error in Python 3. Considering that 8-space tabs are at least as common as 4-space, and that tabs measured in millimeters are also entirely viable, I don't think there's any way to define this perfectly consistently. It depends entirely on the particular setup that you have, and therefore is perfect for a per-project style guide. But hey. It's an instant syntax error. It's not exactly hard to fix. Some editors (including the one I use - SciTE) will highlight mismatched indentation right there as you type. ChrisA From tjreedy at udel.edu Fri Oct 5 17:47:35 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 5 Oct 2018 17:47:35 -0400 Subject: Python indentation (3 spaces) In-Reply-To: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: On 10/5/2018 4:48 PM, ts9564 at gmail.com wrote: > I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" IDLE (and other modern editors and IDEs) turns a typed TAB into a user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16). -- Terry Jan Reedy From rowen at uw.edu Fri Oct 5 21:25:20 2018 From: rowen at uw.edu (Russell Owen) Date: Fri, 05 Oct 2018 18:25:20 -0700 Subject: How to await multiple replies in arbitrary order (one coroutine per reply)? Message-ID: <0001HW.21684680000329D5700002F582CF@news.gmane.org> I am using asyncio and am fairly new to it. I have a stream to which I write commands and from which I read replies. (In this case the stream is custom wrapper around DDS written in C++ and pybind11). Multiple commands can run at the same time and I cannot predict which will finish first. I need aa different coroutine (or asyncio.Task or other awaitable object) for each command that is running. Is there a simple way to handle this in asyncio? So far the best I have come up is the following (greatly simplified), which works but has some misfeatures: import asyncio from iolib import read_reply, write_command, TIMED_OUT class RemoteCommand: def __init__(self): self._tasks = dict() def start(self, cmd, timeout): """Start a command""" cmd_id = write_command(cmd) task = asyncio.ensure_future(self._wait_for_command(cmd_id=cmd_id, timeout=timeout)) self._tasks[cmd_id] = task if len(self._tasks) == 1: asyncio.ensure_future(self._handle_replies()) return task async def _wait_for_command(self, cmd_id, timeout): """Wait for a command to finish""" await asyncio.sleep(timeout) if cmd_id in self._tasks: del self._tasks[cmd_id] return TIMED_OUT # our standard end code for timeouts async def _handle_replies(self): while True: cmd_id, end_code = read_reply() if cmd_id in self._tasks: task = self._tasks.pop(cmd_id) task.set_result(end_code) if not self._tasks: return await asyncio.sleep(0.1) Misfeatures include: - asyncio.Task is not documented to have a "set_result" method. The documentation says that Task is "A Future-like object that runs a Python coroutine" and Future does have such a method. - When "_handle_replies" calls "task.set_result(data)" this does not seem to cancel the "await asyncio.sleep(timeout)" in the task, resulting in scary messages to stdout. I have tried saving *that* as another task and canceling it, but it seems clumsy and I still see scary messages. I think what I'm looking for is a task-like thing I can create that I can end when *I* say it's time to end, and if I'm not quick enough then it will time out gracefully. But maybe there's a simpler way to do this. It doesn't seem like it should be difficult, but I'm stumped. Any advice would be appreciated. -- Russell From rj.amdphreak at gmail.com Fri Oct 5 23:30:53 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Fri, 5 Oct 2018 22:30:53 -0500 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: The point that OP is trying to make is that a fixed standard that is distinguishable from the even-spacing Tab-length convention in code and text editors will establish a level of trust between the end developer and upstream developers or co-developers who may not have the same development environment. For example, the first Python library I ever tried to use was poorly maintained and had spaces on one line with tabs on the next, and the author mixed naming conventions and syntax from Python 2 and 3 in his code. That type of experience doesn?t exactly instill trust in the coding language?s standards, when a noob tries to use a library they found and ends up having to debug weird errors with weirder error messages on the first project they do. Flexibility is great until the learning curve comes into play. That said, there is an easy fix for tab misuse: in Visual Studio Code, you can replace all Tabs with Spaces by highlighting the entire code block, hitting Tab once and Shift-Tab after. Peace Ryan On Fri, Oct 5, 2018 at 4:51 PM Terry Reedy wrote: > On 10/5/2018 4:48 PM, ts9564 at gmail.com wrote: > > I am new to Python programming but have significant SQL and C > experience. My simple question is,"Why not standardize Python indentations > to 3 spaces instead of 4 in order to avoid potential programming errors > associated with using "TAB" instead of 4 spaces?" > > IDLE (and other modern editors and IDEs) turns a typed TAB into a > user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16). > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Ryan Johnson From rowen at uw.edu Fri Oct 5 23:42:25 2018 From: rowen at uw.edu (Russell Owen) Date: Fri, 05 Oct 2018 20:42:25 -0700 Subject: asyncio await different coroutines on the same socket? References: <0001HW.2164FF4300011A2E70000136C2CF@news.gmane.org> Message-ID: <0001HW.216866A10008C97970000DD052CF@news.gmane.org> On Oct 3, 2018, Ian Kelly wrote (in article): > 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 different commands simultaneously and I don't know which command will > > finish first. I want to do this: > > > > coro1 = start(command1) > > coro2 = start(command2) > > asyncio.gather(coro1, coro2) > > > > where either command may finish first. I?m hoping for a simple and > > idiomatic way to read the socket and tell each coroutine it is done. So far > > everything I have come up with is ugly, using multiple layers of "async > > def?, keeping a record of Tasks that are waiting and calling "set_result" > > on those Tasks when finished. Also Task isn?t even documented to have the > > set_result method (though "future" is) > > Because Tasks are used to wrap coroutines, and the result of the Task > should be determined by the coroutine, not externally. > > Instead of tracking tasks (that's what the event loop is for) I would > suggest tracking futures instead. Have start(command1) return a future > (or create a future that it will await on itself) that is not a task. > Whenever a response from the socket is parsed, that code would then > look up the corresponding future and call set_result on it. It might > look something like this: > > class Client: > async def open(self, host, port): > self.reader, self.writer = await asyncio.open_connection(host, port) > asyncio.create_task(self.read_loop()) > > async def read_loop(self): > while not self.reader.at_eof(): > response = self.reader.read() > id = get_response_id(response) > self._futures.pop(id).set_result(response) > > def start(self, command): > future = asyncio.Future() > self._futures[get_command_id(command)] = future > self.writer.write(command) > return future > > In this case start() is not a coroutine but its result is a future and > can be awaited. That is exactly what I was looking for. Thank you very much! -- Russell (My apologies for double posting -- I asked this question again today because I did not think my original question -- this one -- had gone through). From marko at pacujo.net Sat Oct 6 05:17:25 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 06 Oct 2018 12:17:25 +0300 Subject: How to await multiple replies in arbitrary order (one coroutine per reply)? References: <0001HW.21684680000329D5700002F582CF@news.gmane.org> Message-ID: <875zyfv3h6.fsf@elektro.pacujo.net> Russell Owen : > I think what I'm looking for is a task-like thing I can create that I > can end when *I* say it's time to end, and if I'm not quick enough > then it will time out gracefully. But maybe there's a simpler way to > do this. It doesn't seem like it should be difficult, but I'm stumped. > Any advice would be appreciated. I have experimented with similar questions in the past. FWIW, you can see my small program here: Occasionally, people post questions here about asyncio, but there are few answers. I believe the reason is that asyncio hasn't broken through as a very popular programming model even with Python enthusiasts. I do a lot of network and system programming where event multiplexing is essential. There are different paradigms to manage concurrency and parallelism: * multithreading * multiprocessing * coroutines * callbacks from an event loop Out of these, I prefer callbacks and processes and steer clear of threads and coroutines. The reason is that in my (long) experience, Callbacks and processes make simple problems hard but manageable. Callbacks and processes make complex problems hard but manageable. Threads and coroutines make simple problems simple to solve. Threads and coroutines make complex problems humanly intractable. Why is this? Threads and coroutines follow the same line of thinking. They assume that concurrency involves a number linear state machines ("threads") that operate independently from each other. The "linear" part means that in each blocking state, the thread is waiting for one very definite event. When there are a number of possible events in each state -- which there invariably are -- the multithreading model loses its attractiveness. Marko From cl at isbd.net Sat Oct 6 05:29:34 2018 From: cl at isbd.net (Chris Green) Date: Sat, 6 Oct 2018 10:29:34 +0100 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: Terry Reedy wrote: > On 10/5/2018 4:48 PM, ts9564 at gmail.com wrote: > > I am new to Python programming but have significant SQL and C experience. > My simple question is,"Why not standardize Python indentations to 3 spaces > instead of 4 in order to avoid potential programming errors associated > with using "TAB" instead of 4 spaces?" > > IDLE (and other modern editors and IDEs) turns a typed TAB into a > user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16). > Other 'modern' editors? :-) I use a vile clone (hardly modern) and that gives me every possible option of what to do when a TAB is entered. -- Chris Green ? From anthony.flury at btinternet.com Sat Oct 6 07:09:22 2018 From: anthony.flury at btinternet.com (Anthony Flury) Date: Sat, 6 Oct 2018 12:09:22 +0100 Subject: Observations on the List - "Be More Kind" In-Reply-To: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: <2aca333a-e19e-cf42-b807-d0bc40cbd686@btinternet.com> Bruce, I completely agree; it is worth everyone remember that we are all here (even the moderators) as volunteers; we are here because either we want to ask questions, or we want to learn, or we want to help. We do need to remember that the moderators is here to be nasty or because of a power trip - they are here to help, and they are volunteers. Part of the really important thing about Python is the community and this list is a critical part of that community.; lets keep it that way please :-) -- Anthony Flury *Email* : anthony.flury at btinternet.com *Twitter* : @TonyFlury On 05/10/18 11:22, Bruce Coram wrote: > I will declare at the outset, I am a lurker.? I don't know enough > about Python to give advice that I could 100% guarantee would be helpful. > > There have been two recent threads that summarise for me where the > Python Mailing List has lost its way (and this started before Trump > arrived as a new role model for how to treat your fellow man): > > "Re: This thread is closed [an actual new thread]" > > "Re: So apparently I've been banned from this list" > > The level of vitriol and personal attacks on the moderators was > profoundly disappointing, but not totally out of character for those > who made the attacks.? There is no doubt that these people know > software and Python and this certainly earns my respect,? but perhaps > they need to retain a sense of perspective.? There are 7 billion > people in the world.? There are plenty more people at least as good as > you and many better, but they don't have the compelling urge to > demonstrate their genius.? They get on with their work in a quiet > professional manner. > > Some humility in acknowledging that you stand on the shoulders of > giants would not go amiss.? It might also reflect that you understand > the good fortune that dealt you such a good hand in life. > > You aren't always right, and you don't always have to insist on being > right.? I found Steve D'Aprano always had to have the last word and > had to prove he was right.? I found some of his posts to be > intemperate in tone. > > Why is there a need to score points with caustic remarks or throwaway > comments?? Perhaps the person who posed his question should have read > the documents, perhaps he should have searched the archives.? Tell > them so politely and firmly.? If you cannot manage that then why say > anything?? Not everyone who posts a poorly prepared question is idle > and deserves a response that is less than polite.? Prepare a > boilerplate standard reply that is polite for those questions that are > easily resolved by the poster. > > Perhaps the person who posts something you regard as nonsense is > ignorant and lacks the knowledge they think they possess.? Instead of > wasting your time with scholastic debate, put the time to good use > improving your education in subjects you don't excel at.? I can > guarantee the depth of your ignorance will be profound - there will be > much for you to learn.? The effort some of you put in to the endless > debates suggests that you have plenty of time on your hands - don't > waste it.? It will be gone soon enough. > > Don't waste time on the trolls, some of whom undoubtedly enjoy the > ability to provoke a response.? Develop a greater sense of self > awareness to enable you to recognise that you are being played. The > intemperate tone of some of the exchanges damages the reputation of > the List. > > Life is hard enough without us adding to it.? Try silence as a response. > > Listen to Frank Turner's latest album: "Be More Kind".?? That is not a > plug to buy the album, but the title seems apposite - and the music is > good. > > Regards > > Bruce Coram From eliteanarchyracer at gmail.com Sat Oct 6 14:10:02 2018 From: eliteanarchyracer at gmail.com (eliteanarchyracer at gmail.com) Date: Sat, 6 Oct 2018 11:10:02 -0700 (PDT) Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST Message-ID: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Hi, I am new to python and would like someones help on the following: After rolling 5 dice and putting the results into a list, I need to check if any dice is not a 1 or 5. if all dice in the list are either a 1 or 5 , I want to calculate a result. if there is a 2,3,4 or 6 in the list i want to let the user roll again FOR EXACT LINE: PLEASE CHECK CODE CODE: from random import * class Dice: def __init__(self, sides, color="white"): self.sides = sides self.color = color def roll_dice(self): result = randint(1, self.sides) return result die1 = Dice(6) die2 = Dice(6) die3 = Dice(6) die4 = Dice(6) die5 = Dice(6) alldice = [die1, die2, die3, die4, die5] result = [] start = input("Press enter to roll your dice:") for object in alldice: temp = object.roll_dice() result.append(temp) print(result) # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: ) print("you can roll again") else: print("you have all 1's and 5's in your result") From armand.foucault at telecom-bretagne.eu Sat Oct 6 15:33:35 2018 From: armand.foucault at telecom-bretagne.eu (armand.foucault at telecom-bretagne.eu) Date: Sat, 06 Oct 2018 21:33:35 +0200 Subject: =?ISO-8859-1?Q?Re=A0:_Creating_dice_game_:_NEED_H?= =?ISO-8859-1?Q?ELP_ON_CHECKING_ELEMENTS_IN_A_LIST?= References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: <20181006193337.043FD80F77@zproxy120.enst.fr> You could use any and a generator expression. It sounds pretty hard, but it's actually easily expressed, and pretty intelligible. Here you go: if any(n in result for n in [2, 3, 4, 6]): # reroll else: # do your thing --------------------------------------------- Armand FOUCAULT armand.foucault at telecom-bretagne.eu -------- Message original -------- Objet**: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST De**: eliteanarchyracer at gmail.com ****: python-list at python.org Cc**: Hi, I am new to python and would like someones help on the following: After rolling 5 dice and putting the results into a list, I need to check if any dice is not a 1 or 5. if all dice in the list are either a 1 or 5 , I want to calculate a result. if there is a 2,3,4 or 6 in the list i want to let the user roll again FOR EXACT LINE: PLEASE CHECK CODE CODE: from random import * class Dice: def __init__(self, sides, color="white"): self.sides = sides self.color = color def roll_dice(self): result = randint(1, self.sides) return result die1 = Dice(6) die2 = Dice(6) die3 = Dice(6) die4 = Dice(6) die5 = Dice(6) alldice = [die1, die2, die3, die4, die5] result = [] start = input("Press enter to roll your dice:") for object in alldice: temp = object.roll_dice() result.append(temp) print(result) # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: ) print("you can roll again") else: print("you have all 1's and 5's in your result") -- https://mail.python.org/mailman/listinfo/python-list From python at mrabarnett.plus.com Sat Oct 6 15:44:48 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 6 Oct 2018 20:44:48 +0100 Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST In-Reply-To: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: On 2018-10-06 19:10, eliteanarchyracer at gmail.com wrote: > Hi, I am new to python and would like someones help on the following: > > After rolling 5 dice and putting the results into a list, I need to check if any dice is not a 1 or 5. > > if all dice in the list are either a 1 or 5 , I want to calculate a result. > if there is a 2,3,4 or 6 in the list i want to let the user roll again > FOR EXACT LINE: PLEASE CHECK CODE > > > CODE: > > > from random import * > > class Dice: > > def __init__(self, sides, color="white"): > self.sides = sides > self.color = color > > def roll_dice(self): > result = randint(1, self.sides) > return result > > > die1 = Dice(6) > die2 = Dice(6) > die3 = Dice(6) > die4 = Dice(6) > die5 = Dice(6) > > alldice = [die1, die2, die3, die4, die5] > > result = [] > > start = input("Press enter to roll your dice:") > > for object in alldice: > temp = object.roll_dice() > result.append(temp) > print(result) > > # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: ) > print("you can roll again") > else: > print("you have all 1's and 5's in your result") > The simplest (and longest) way is: if 2 in result or 3 in result or 4 in result or 6 in result: A cleverer way is to use sets: if set(result) & {2, 3, 4, 6}: From cwr at seckford.org Sat Oct 6 15:47:47 2018 From: cwr at seckford.org (C W Rose) Date: Sat, 6 Oct 2018 20:47:47 +0100 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <34gn8f-m83.ln1@tanner.seckford.org> Ryan Johnson wrote: > The point that OP is trying to make is that a fixed standard that is > distinguishable from the even-spacing Tab-length convention in code and > text editors will establish a level of trust between the end developer and > upstream developers or co-developers who may not have the same development > environment. For example, the first Python library I ever tried to use was > poorly maintained and had spaces on one line with tabs on the next, and the > author mixed naming conventions and syntax from Python 2 and 3 in his code. > That type of experience doesn?t exactly instill trust in the coding > language?s standards, when a noob tries to use a library they found and > ends up having to debug weird errors with weirder error messages on the > first project they do. The view of the Python Gods (TM) is that significant whitespace make Python much easier to use, particularly for the inexperienced. If you disagree, then use another language. (Leibnitz had some snappy phrases on the subject of Theodicy, which explain the matter clearly.) Will From tjol at tjol.eu Sat Oct 6 15:56:09 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 6 Oct 2018 21:56:09 +0200 Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST In-Reply-To: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: On 06/10/2018 20:10, eliteanarchyracer at gmail.com wrote: > # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: ) > print("you can roll again") > else: > print("you have all 1's and 5's in your result") > You can use a loop: for good_number in [2,3,4,6]: if good_number in result: print("you can roll again") break else: print("you have all 1's and 5's in your result") From alister.ware at ntlworld.com Sat Oct 6 16:48:18 2018 From: alister.ware at ntlworld.com (Alister) Date: Sat, 06 Oct 2018 20:48:18 GMT Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: On Sat, 06 Oct 2018 21:56:09 +0200, Thomas Jollans wrote: > On 06/10/2018 20:10, eliteanarchyracer at gmail.com wrote: >> # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: >> ) >> print("you can roll again") >> else: >> print("you have all 1's and 5's in your result") >> >> > You can use a loop: > > for good_number in [2,3,4,6]: > if good_number in result: > print("you can roll again") > break > else: > print("you have all 1's and 5's in your result") or simply check for 1 & 5 to exit otherwise continue -- Someone hooked the twisted pair wires into the answering machine. From eliteanarchyracer at gmail.com Sat Oct 6 19:19:20 2018 From: eliteanarchyracer at gmail.com (eliteanarchyracer at gmail.com) Date: Sat, 6 Oct 2018 16:19:20 -0700 (PDT) Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST In-Reply-To: References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: Well these worked like a charm. Cant say I understand some of them and will have to look into utilizing them in the future, but I appreciate everyones responses and thank you all. Never needed to check for multiple instances in a list before. Nice to have help! From bgailer at gmail.com Sat Oct 6 19:54:18 2018 From: bgailer at gmail.com (bob gailer) Date: Sat, 6 Oct 2018 19:54:18 -0400 Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST In-Reply-To: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: # your program is quite complicated. classes are overkill. A simpler solution is: import random for i in range(5): ??? roll = random.randint(1,6) ??? if roll not in (1,5): ??????? print('you can roll again') ??????? break else: ??? print("you have all 1's and 5's in your result'") # comments on? using classes: class Dice: ??? ... # no need for die1...die5 - use list comprehension: alldice = [Dice(6) for i in range(5)] # object is a bult-in type. it is inadvisable to assign to names of built-ins # as this makes the built-in unavailable. Look up builtins (module) in help for # a complete list. # use list comprehension roll and report: print([d.roll_dice() for d in alldice]) From tjreedy at udel.edu Sun Oct 7 10:55:11 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 7 Oct 2018 10:55:11 -0400 Subject: Python indentation (3 spaces) In-Reply-To: <34gn8f-m83.ln1@tanner.seckford.org> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <34gn8f-m83.ln1@tanner.seckford.org> Message-ID: On 10/6/2018 3:47 PM, C W Rose via Python-list wrote: > Ryan Johnson wrote: >> The point that OP is trying to make is that a fixed standard that is >> distinguishable from the even-spacing Tab-length convention in code and >> text editors will establish a level of trust between the end developer and >> upstream developers or co-developers who may not have the same development >> environment. For example, the first Python library I ever tried to use was >> poorly maintained and had spaces on one line with tabs on the next, and the >> author mixed naming conventions and syntax from Python 2 and 3 in his code. >> That type of experience doesn?t exactly instill trust in the coding >> language?s standards, when a noob tries to use a library they found and >> ends up having to debug weird errors with weirder error messages on the >> first project they do. > > The view of the Python Gods (TM) is that significant whitespace make > Python much easier to use, particularly for the inexperienced. This seems completely irrelevant to Ryan's comment, which was about mixing whitespace, not eliminating it. > If you disagree, then use another language. Given the absence of any complaint about using whitespace, this seems rude. Did you actually read what Ryan wrote? > (Leibnitz had some snappy phrases on the subject of Theodicy, which > explain the matter clearly.) How it this a response to the Python style question? -- Terry Jan Reedy From tjreedy at udel.edu Sun Oct 7 11:32:21 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 7 Oct 2018 11:32:21 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: On 10/5/2018 11:30 PM, Ryan Johnson wrote: > The point that OP is trying to make is that a fixed standard that is > distinguishable from the even-spacing Tab-length convention in code and > text editors will establish a level of trust between the end developer and > upstream developers or co-developers who may not have the same development > environment. And my counter point is that a) we will not change the standard and b) we deliver an editor that by default enforces the standard, and c) to be fair, many other editors will do the same. > For example, the first Python library I ever tried to use was What library? From where? > poorly maintained and had spaces on one line with tabs on the next, and the > author mixed naming conventions and syntax from Python 2 and 3 in his code. > That type of experience doesn?t exactly instill trust in the coding > language?s standards, when a noob tries to use a library they found and > ends up having to debug weird errors with weirder error messages on the > first project they do. I don't follow the logic. If someone violates a law, does that make the law bad? And if people follow a law, does that make it good? People obviously should not distribute buggy messes, at least not without warning. Were you using the library with an unsupported version? Or inform the author or distributor? > Flexibility is great until the learning curve comes into play. That said, > there is an easy fix for tab misuse: in Visual Studio Code, you can replace > all Tabs with Spaces by highlighting the entire code block, hitting Tab > once and Shift-Tab after. IDLE does that also. -- Terry Jan Reedy From tjreedy at udel.edu Sun Oct 7 12:39:37 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 7 Oct 2018 12:39:37 -0400 Subject: Python indentation (3 spaces) In-Reply-To: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: On 10/5/2018 4:48 PM, ts9564 at gmail.com wrote: > I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" > Thoughts? You assumption that a tab means '4 spaces' is wrong. A tab means 'jump to the next tab stop'. On 10 char/inch US typewriters, tab stops were initially set to every 5 spaces or 1/2 inch. In terminals and code editors, virtual tab stops were often set to every 8 spaces, and python still interprets tabs that way. This means that editing Python code in an editor that *displays* tabs (as opposed to converting them to spaces) with other than every-8-space tab stops is arguably a bad idea if the file has or might have non-tab space indents. By making the standard indent 4 spaces, Python already partly did what you want. The following code is a SyntaxError in both 2.7 and 3.x. if 1: a = 1 # 4 space indent b = 2 # 1 tab indent, which may or may not display as 8 spaces In 3.x, the following raises TabError: inconsistent use of tabs and spaces in indentation if 1: if 2: # 4 space indent b = 2 1 tab indent In 2.x, this runs, but if you run it from IDLE, you get a message suggesting that you change the tab to spaces and telling you how to do so. This is because IDLE runs your code through the tabnanny script, which has the check later incorporated in compile in 3.x. One can also just check one's code without running it. In other words, it is easy to expose indent issues without changing the 4 space standard. Terry Jan Reedy From gheskett at shentel.net Sun Oct 7 14:19:15 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 14:19:15 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <201810071419.15949.gheskett@shentel.net> On Sunday 07 October 2018 11:32:21 Terry Reedy wrote: > On 10/5/2018 11:30 PM, Ryan Johnson wrote: > > The point that OP is trying to make is that a fixed standard that is > > distinguishable from the even-spacing Tab-length convention in code > > and text editors will establish a level of trust between the end > > developer and upstream developers or co-developers who may not have > > the same development environment. > > And my counter point is that a) we will not change the standard and b) > we deliver an editor that by default enforces the standard, and c) to > be fair, many other editors will do the same. > > > For example, the first Python library I ever tried to use was > > What library? From where? > Don't recall, or care. > > poorly maintained and had spaces on one line with tabs on the next, > > and the author mixed naming conventions and syntax from Python 2 and > > 3 in his code. That type of experience doesn?t exactly instill trust > > in the coding language?s standards, when a noob tries to use a > > library they found and ends up having to debug weird errors with > > weirder error messages on the first project they do. This poster is 200% correct. Somewhere, someplace, there should be easily found rule that dictates where one can use a tab, and where spaces only are allowed. > I don't follow the logic. If someone violates a law, does that make > the law bad? And if people follow a law, does that make it good? No, and I'll give you the USA's present state of "democracy" as a prime example. > > People obviously should not distribute buggy messes, at least not > without warning. Were you using the library with an unsupported > version? Or inform the author or distributor? > > > Flexibility is great until the learning curve comes into play. Understatement of the month, Terry. > > That > > said, there is an easy fix for tab misuse: in Visual Studio Code, > > you can replace all Tabs with Spaces by highlighting the entire code > > block, hitting Tab once and Shift-Tab after. But that automatically assumes one is running in a windows environment. I don't allow it on the premises if I own the machine. Are there good, alternatives that run on linux? > > IDLE does that also. > And idle for python-2.7 runs on linux. We have a mostly python app called camview that runs on and with LinuxCNC. Giving us the ability to mark a feature on a workpiece, and create a set of co-ordinates that autoaligns the workpiece and a about to be carved code. But with a 640x480 camera, the view dies if the display window its given is equal to or larger, at which point it dies/goes away, whatever, and the only way to restore it to operational status is to reboot the machine. I've installed idle on that particular machine, and will see if it will call my attention to bad coding. I'll be most appreciative if it can find something that will make this code Just Work(TM). Thank you for mentioning it, Terry. > -- > Terry Jan Reedy -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From rosuav at gmail.com Sun Oct 7 14:30:04 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 05:30:04 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <201810071419.15949.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> Message-ID: On Mon, Oct 8, 2018 at 5:20 AM Gene Heskett wrote: > This poster is 200% correct. Somewhere, someplace, there should be easily > found rule that dictates where one can use a tab, and where spaces only > are allowed. Ask the people who maintain makefiles whether that's a good thing or not. HINT: Many will say no. > > > That > > > said, there is an easy fix for tab misuse: in Visual Studio Code, > > > you can replace all Tabs with Spaces by highlighting the entire code > > > block, hitting Tab once and Shift-Tab after. > > But that automatically assumes one is running in a windows environment. I > don't allow it on the premises if I own the machine. Are there good, > alternatives that run on linux? VSCode runs on Linux. Also, there are easy ways to do the same sort of thing in many editors that I've used. > > IDLE does that also. > > > And idle for python-2.7 runs on linux. (Not sure why you specifically say 2.7, as IDLE for any version of Python runs on Linux, far as I know.) > We have a mostly python app called > camview that runs on and with LinuxCNC. Giving us the ability to mark a > feature on a workpiece, and create a set of co-ordinates that autoaligns > the workpiece and a about to be carved code. But with a 640x480 camera, > the view dies if the display window its given is equal to or larger, at > which point it dies/goes away, whatever, and the only way to restore it > to operational status is to reboot the machine. > > I've installed idle on that particular machine, and will see if it will > call my attention to bad coding. I'll be most appreciative if it can > find something that will make this code Just Work(TM). Thank you for > mentioning it, Terry. I don't understand what any of this has to do with anything. Do you suspect that your code is fraught with indentation bugs? If so, pretty much ANY Python-aware editor will help you, as will Python 3.x, as will Python2 with the "-tt" option. ChrisA From countryone77 at gmail.com Sun Oct 7 14:30:07 2018 From: countryone77 at gmail.com (Bev in TX) Date: Sun, 7 Oct 2018 13:30:07 -0500 Subject: Python indentation (3 spaces) In-Reply-To: <201810071419.15949.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> Message-ID: > On Oct 7, 2018, at 1:19 PM, Gene Heskett wrote: > >>> >>> That >>> said, there is an easy fix for tab misuse: in Visual Studio Code, >>> you can replace all Tabs with Spaces by highlighting the entire code >>> block, hitting Tab once and Shift-Tab after. > > But that automatically assumes one is running in a windows environment. I > don't allow it on the premises if I own the machine. Are there good, > alternatives that run on linux? > Free for Linux, Macs and Windows ... https://code.visualstudio.com/Download Bev in TX From rj.amdphreak at gmail.com Sun Oct 7 14:35:02 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Sun, 7 Oct 2018 13:35:02 -0500 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> > What library? From where? It was a GitHub repository for a zebra scanner (barcode scanner) module (and sorry for calling it a library; I don?t recall if it was a library or module). The logic is that all the text editors that are designed to work with Python code will KNOW to replace tab input with 3 characters, while still parsing the \t tab character as 4 characters; while the editors that aren?t made for python input are generally older or non-coding text editors that maintain the older Tab convention that looks like 4 spaces, so it is visually distinguishable, when loading code that a person made on one of these non-python-aware text editors. The difference we want to see is that Python-aware creates 3 spaces from the keyboard, while still displaying 4 spaces on parsing \t . If this becomes a coding convention for Python, it?ll be enforced by editors that are intended to be used with Python (i.e. the ones that currently replace `Tab` keyboard input with 4 characters). It?s slick. And annoying, because every OCD person in the room is going to choke when they see 3 characters for a tab. > If someone violates a law, does that make the law bad? And if people follow a law, does that make it good? No, the question you should ask is ?if the current law causes an unintended ambiguity or side-effect, could there be a more clear law that makes the ambiguity go away?? Clearly the current law wasn?t up to the task of delineating 1: bad code from a bad editor opened in a good editor, and 2: good code from a good editor opened in a good editor or bad editor. The distinction can be made known to the good programmer by having the good editors follow a convention that makes the difference evident, while a bad editor continues to show no distinction between good and bad code. Remember, the primary rule is that a good editor will obviously not permit a bad coder to type bad spacing, but a bad editor will. This convention change would allow a person using a good editor to know that the code was made in a non-python-oriented editor immediately, instead of blowing up their debug console with Syntax errors. If I was less than accurate in my explanation, I apologize, but the concept itself is solid, except for the annoyance of being an odd number of spaces. Sent from Mail for Windows 10 From: Terry Reedy Sent: Sunday, October 7, 2018 10:35 AM To: python-list at python.org Subject: Re: Python indentation (3 spaces) On 10/5/2018 11:30 PM, Ryan Johnson wrote: > The point that OP is trying to make is that a fixed standard that is > distinguishable from the even-spacing Tab-length convention in code and > text editors will establish a level of trust between the end developer and > upstream developers or co-developers who may not have the same development > environment. And my counter point is that a) we will not change the standard and b) we deliver an editor that by default enforces the standard, and c) to be fair, many other editors will do the same. > For example, the first Python library I ever tried to use was What library? From where? > poorly maintained and had spaces on one line with tabs on the next, and the > author mixed naming conventions and syntax from Python 2 and 3 in his code. > That type of experience doesn?t exactly instill trust in the coding > language?s standards, when a noob tries to use a library they found and > ends up having to debug weird errors with weirder error messages on the > first project they do. I don't follow the logic. If someone violates a law, does that make the law bad? And if people follow a law, does that make it good? People obviously should not distribute buggy messes, at least not without warning. Were you using the library with an unsupported version? Or inform the author or distributor? > Flexibility is great until the learning curve comes into play. That said, > there is an easy fix for tab misuse: in Visual Studio Code, you can replace > all Tabs with Spaces by highlighting the entire code block, hitting Tab > once and Shift-Tab after. IDLE does that also. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Sun Oct 7 14:44:37 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 05:44:37 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> Message-ID: On Mon, Oct 8, 2018 at 5:39 AM Ryan Johnson wrote: > > > What library? From where? > > It was a GitHub repository for a zebra scanner (barcode scanner) module (and sorry for calling it a library; I don?t recall if it was a library or module). > > The logic is that all the text editors that are designed to work with Python code will KNOW to replace tab input with 3 characters, while still parsing the \t tab character as 4 characters; while the editors that aren?t made for python input are generally older or non-coding text editors that maintain the older Tab convention that looks like 4 spaces, so it is visually distinguishable, when loading code that a person made on one of these non-python-aware text editors. > > The difference we want to see is that Python-aware creates 3 spaces from the keyboard, while still displaying 4 spaces on parsing \t . If this becomes a coding convention for Python, it?ll be enforced by editors that are intended to be used with Python (i.e. the ones that currently replace `Tab` keyboard input with 4 characters). > So.... why not just have them display differently from each other? Or have an editor that notices when a line disagrees with the one above it, and highlights that as an error? > It?s slick. And annoying, because every OCD person in the room is going to choke when they see 3 characters for a tab. Ahh, yes. The "annoy everyone until they do what you want" technique. Remind me why the language should mandate that editors annoy their users? > > If someone violates a law, does that make the law bad? And if people follow a law, does that make it good? > > No, the question you should ask is ?if the current law causes an unintended ambiguity or side-effect, could there be a more clear law that makes the ambiguity go away?? Clearly the current law wasn?t up to the task of delineating 1: bad code from a bad editor opened in a good editor, and 2: good code from a good editor opened in a good editor or bad editor. > Only if you're using bad code from a bad editor in a different bad editor. Lots of good editors will correctly differentiate. > If I was less than accurate in my explanation, I apologize, but the concept itself is solid, except for the annoyance of being an odd number of spaces. > Your explanation is fine. Your concept is internally consistent. I strongly disagree with it. :) ChrisA From gheskett at shentel.net Sun Oct 7 17:25:50 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 17:25:50 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> Message-ID: <201810071725.50224.gheskett@shentel.net> On Sunday 07 October 2018 14:30:04 Chris Angelico wrote: > On Mon, Oct 8, 2018 at 5:20 AM Gene Heskett wrote: > > This poster is 200% correct. Somewhere, someplace, there should be > > easily found rule that dictates where one can use a tab, and where > > spaces only are allowed. > > Ask the people who maintain makefiles whether that's a good thing or > not. HINT: Many will say no. > > > > > That > > > > said, there is an easy fix for tab misuse: in Visual Studio > > > > Code, you can replace all Tabs with Spaces by highlighting the > > > > entire code block, hitting Tab once and Shift-Tab after. > > > > But that automatically assumes one is running in a windows > > environment. I don't allow it on the premises if I own the machine. > > Are there good, alternatives that run on linux? > > VSCode runs on Linux. Also, there are easy ways to do the same sort of > thing in many editors that I've used. > > > > IDLE does that also. > > > > And idle for python-2.7 runs on linux. > > (Not sure why you specifically say 2.7, as IDLE for any version of > Python runs on Linux, far as I know.) > 3.5+ has not, and never will arrive on wheezy. We've a stretch based lcnc installer now, but I've got stretch on 2 machines now, and I'm not impressed. Making networking actually work makes work a 4 letter word. > > We have a mostly python app called > > camview that runs on and with LinuxCNC. Giving us the ability to > > mark a feature on a workpiece, and create a set of co-ordinates that > > autoaligns the workpiece and a about to be carved code. But with a > > 640x480 camera, the view dies if the display window its given is > > equal to or larger, at which point it dies/goes away, whatever, and > > the only way to restore it to operational status is to reboot the > > machine. > > > > I've installed idle on that particular machine, and will see if it > > will call my attention to bad coding. I'll be most appreciative if > > it can find something that will make this code Just Work(TM). Thank > > you for mentioning it, Terry. > > I don't understand what any of this has to do with anything. Do you > suspect that your code is fraught with indentation bugs? Not sure where the problem is Chris, but A: its not my code, and B: a potentially very useful machine vision utility to a cnc machinist actually works like the teats on a boar hog. Useless if it cannot be actually used on a daily basis. I've tried to make it work with pyvcp, and with gladevcp. Essentially the same errors (none reported) and behavior on both gui interfaces. With 3 different cameras. That, in 3 versions of it, is the main reason I've been mostly lurking on this list for several years. > If so, pretty > much ANY Python-aware editor will help you, as will Python 3.x, as > will Python2 with the "-tt" option. > > ChrisA Thanks ChrisA. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From gheskett at shentel.net Sun Oct 7 17:30:10 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 17:30:10 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> Message-ID: <201810071730.10170.gheskett@shentel.net> On Sunday 07 October 2018 14:30:07 Bev in TX wrote: > > On Oct 7, 2018, at 1:19 PM, Gene Heskett wrote: > >>> That > >>> said, there is an easy fix for tab misuse: in Visual Studio Code, > >>> you can replace all Tabs with Spaces by highlighting the entire > >>> code block, hitting Tab once and Shift-Tab after. > > > > But that automatically assumes one is running in a windows > > environment. I don't allow it on the premises if I own the machine. > > Are there good, alternatives that run on linux? > > Free for Linux, Macs and Windows ... > https://code.visualstudio.com/Download > > > Bev in TX Thank you for the url. Downloaded, but not installed on the target machine yet. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From rosuav at gmail.com Sun Oct 7 17:36:34 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 08:36:34 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <201810071725.50224.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> <201810071725.50224.gheskett@shentel.net> Message-ID: On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett wrote: > > On Sunday 07 October 2018 14:30:04 Chris Angelico wrote: > > > On Mon, Oct 8, 2018 at 5:20 AM Gene Heskett > wrote: > > > This poster is 200% correct. Somewhere, someplace, there should be > > > easily found rule that dictates where one can use a tab, and where > > > spaces only are allowed. > > > > Ask the people who maintain makefiles whether that's a good thing or > > not. HINT: Many will say no. > > > > > > > That > > > > > said, there is an easy fix for tab misuse: in Visual Studio > > > > > Code, you can replace all Tabs with Spaces by highlighting the > > > > > entire code block, hitting Tab once and Shift-Tab after. > > > > > > But that automatically assumes one is running in a windows > > > environment. I don't allow it on the premises if I own the machine. > > > Are there good, alternatives that run on linux? > > > > VSCode runs on Linux. Also, there are easy ways to do the same sort of > > thing in many editors that I've used. > > > > > > IDLE does that also. > > > > > > And idle for python-2.7 runs on linux. > > > > (Not sure why you specifically say 2.7, as IDLE for any version of > > Python runs on Linux, far as I know.) > > > 3.5+ has not, and never will arrive on wheezy. We've a stretch based lcnc > installer now, but I've got stretch on 2 machines now, and I'm not > impressed. Making networking actually work makes work a 4 letter word. Wheezy is no longer supported by Debian. It's not even oldstable any more. But if you still have old releases sitting around, you have two good options: 1) Use IDLE from CPython 3.2 by installing package idle3 2) Compile CPython 3.5+ from source But if you have issues with networking on Stretch, just uninstall Network Manager and try again. I've been using Stretch since before it was stable, and have not a whit of trouble. All my family use either Debian or Ubuntu (including the not-so-technically-literate ones), and those on Debian are mostly on Stretch. That includes laptops that connect to various different wifi networks, the routers/gateways that drive the networks themselves, everyone's desktop computers... the works. Also, that *still* has nothing to do with the matter at hand. There's no problems running some version of IDLE on any release of Debian that I've ever used. > > I don't understand what any of this has to do with anything. Do you > > suspect that your code is fraught with indentation bugs? > > Not sure where the problem is Chris, but A: its not my code, and B: a > potentially very useful machine vision utility to a cnc machinist > actually works like the teats on a boar hog. Useless if it cannot be > actually used on a daily basis. I've tried to make it work with pyvcp, > and with gladevcp. Essentially the same errors (none reported) and > behavior on both gui interfaces. With 3 different cameras. That, in 3 > versions of it, is the main reason I've been mostly lurking on this list > for several years. Okay, but I'm trying to understand why you're referencing this in this thread about indentation. That would imply that you at least have reason to suspect that the problem is indentation. ChrisA From countryone77 at gmail.com Sun Oct 7 17:41:06 2018 From: countryone77 at gmail.com (Bev in TX) Date: Sun, 7 Oct 2018 16:41:06 -0500 Subject: Python indentation (3 spaces) In-Reply-To: <201810071730.10170.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> <201810071730.10170.gheskett@shentel.net> Message-ID: > On Oct 7, 2018, at 4:30 PM, Gene Heskett wrote: > >> Free for Linux, Macs and Windows ... >> https://code.visualstudio.com/Download >> > >> >> Bev in TX > > Thank you for the url. Downloaded, but not installed on the target > machine yet. Don?t forget to read the license agreement ? the link is at the bottom of that webpage. Bev in TX From gheskett at shentel.net Sun Oct 7 18:25:02 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 18:25:02 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071725.50224.gheskett@shentel.net> Message-ID: <201810071825.02575.gheskett@shentel.net> On Sunday 07 October 2018 17:36:34 Chris Angelico wrote: > On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett wrote: [...]> > Okay, but I'm trying to understand why you're referencing this in this > thread about indentation. That would imply that you at least have > reason to suspect that the problem is indentation. > > ChrisA Grasping at straws ChrisA. And anything that will reach out and slap me around when it see's a syntax problem might accidentally teach me something about this snake. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From pacqa100 at yahoo.com.au Sun Oct 7 18:28:53 2018 From: pacqa100 at yahoo.com.au (Peter) Date: Mon, 8 Oct 2018 09:28:53 +1100 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: It's also useful to be aware of the standard tabnanny module for "Detection of ambiguous indentation". Very useful for highlighting problems with tabs and spaces. Peter On 8/10/2018 2:32 AM, Terry Reedy wrote: > On 10/5/2018 11:30 PM, Ryan Johnson wrote: >> The point that OP is trying to make is that a fixed standard that is >> distinguishable from the even-spacing Tab-length convention in code and >> text editors will establish a level of trust between the end >> developer and >> upstream developers or co-developers who may not have the same >> development >> environment. > > And my counter point is that a) we will not change the standard and b) > we deliver an editor that by default enforces the standard, and c) to > be fair, many other editors will do the same. > >> For example, the first Python library I ever tried to use was > > What library?? From where? > >> poorly maintained and had spaces on one line with tabs on the next, >> and the >> author mixed naming conventions and syntax from Python 2 and 3 in his >> code. >> That type of experience doesn?t exactly instill trust in the coding >> language?s standards, when a noob tries to use a library they found and >> ends up having to debug weird errors with weirder error messages on the >> first project they do. > > I don't follow the logic.? If someone violates a law, does that make > the law bad?? And if people follow a law, does that make it good? > > People obviously should not distribute buggy messes, at least not > without warning.? Were you using the library with an unsupported > version?? Or inform the author or distributor? > >> Flexibility is great until the learning curve comes into play. That >> said, >> there is an easy fix for tab misuse: in Visual Studio Code, you can >> replace >> all Tabs with Spaces by highlighting the entire code block, hitting Tab >> once and Shift-Tab after. > > IDLE does that also. > From rosuav at gmail.com Sun Oct 7 18:29:21 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 09:29:21 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <201810071825.02575.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071725.50224.gheskett@shentel.net> <201810071825.02575.gheskett@shentel.net> Message-ID: On Mon, Oct 8, 2018 at 9:26 AM Gene Heskett wrote: > > On Sunday 07 October 2018 17:36:34 Chris Angelico wrote: > > > On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett > wrote: > [...]> > > Okay, but I'm trying to understand why you're referencing this in this > > thread about indentation. That would imply that you at least have > > reason to suspect that the problem is indentation. > > > > ChrisA > > Grasping at straws ChrisA. And anything that will reach out and slap me > around when it see's a syntax problem might accidentally teach me > something about this snake. > Ah. Fair enough, then. Basically, you want the Python equivalent of "gcc -Wall -Wpedantic". ChrisA From gheskett at shentel.net Sun Oct 7 18:45:16 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 18:45:16 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071825.02575.gheskett@shentel.net> Message-ID: <201810071845.16671.gheskett@shentel.net> On Sunday 07 October 2018 18:29:21 Chris Angelico wrote: > On Mon, Oct 8, 2018 at 9:26 AM Gene Heskett wrote: > > On Sunday 07 October 2018 17:36:34 Chris Angelico wrote: > > > On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett > > > > wrote: > > [...]> > > > > > Okay, but I'm trying to understand why you're referencing this in > > > this thread about indentation. That would imply that you at least > > > have reason to suspect that the problem is indentation. > > > > > > ChrisA > > > > Grasping at straws ChrisA. And anything that will reach out and > > slap me around when it see's a syntax problem might accidentally > > teach me something about this snake. > > Ah. Fair enough, then. Basically, you want the Python equivalent of > "gcc -Wall -Wpedantic". > Is there such a critter? > ChrisA -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From rosuav at gmail.com Sun Oct 7 18:47:45 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 09:47:45 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <201810071845.16671.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071825.02575.gheskett@shentel.net> <201810071845.16671.gheskett@shentel.net> Message-ID: On Mon, Oct 8, 2018 at 9:46 AM Gene Heskett wrote: > > On Sunday 07 October 2018 18:29:21 Chris Angelico wrote: > > > On Mon, Oct 8, 2018 at 9:26 AM Gene Heskett > wrote: > > > On Sunday 07 October 2018 17:36:34 Chris Angelico wrote: > > > > On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett > > > > > > wrote: > > > [...]> > > > > > > > Okay, but I'm trying to understand why you're referencing this in > > > > this thread about indentation. That would imply that you at least > > > > have reason to suspect that the problem is indentation. > > > > > > > > ChrisA > > > > > > Grasping at straws ChrisA. And anything that will reach out and > > > slap me around when it see's a syntax problem might accidentally > > > teach me something about this snake. > > > > Ah. Fair enough, then. Basically, you want the Python equivalent of > > "gcc -Wall -Wpedantic". > > > Is there such a critter? Not really; there's -Wall, of course, but it's not nearly as comprehensive as gcc's pedantic mode. Sorry. ChrisA From tjreedy at udel.edu Sun Oct 7 19:30:06 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 7 Oct 2018 19:30:06 -0400 Subject: Python indentation (3 spaces) In-Reply-To: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> Message-ID: On 10/7/2018 2:35 PM, Ryan Johnson wrote: > The logic is that all the text editors that are designed to work with Python code will KNOW to replace tab input with 3 characters, while still parsing the \t tab character as 4 characters; What do you mean by 'parsing a tab character as 4 characters'? If the editor *converts* the tab to k spaces in its buffer, then k must be the same number as when the user types a tab, and there is no tab left to worry about. If the editor put the tab into its buffer (and saves it with tabs), then what users on particular display devices depends on what the device does with tabs. Theoretically, all tabs might seem like a good idea, but since 0 spaces, 1/2 inch, and 8 spaces are possible display results, in addition to a users custom setting, this does not work except in a circumscribed environment. That leaves space indents and no tabs except in strings where needed. -- Terry Jan Reedy From rosuav at gmail.com Sun Oct 7 19:36:21 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 8 Oct 2018 10:36:21 +1100 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> Message-ID: On Mon, Oct 8, 2018 at 10:31 AM Terry Reedy wrote: > > On 10/7/2018 2:35 PM, Ryan Johnson wrote: > > > The logic is that all the text editors that are designed to work with Python code will KNOW to replace tab input with 3 characters, while still parsing the \t tab character as 4 characters; > > What do you mean by 'parsing a tab character as 4 characters'? If the > editor *converts* the tab to k spaces in its buffer, then k must be the > same number as when the user types a tab, and there is no tab left to > worry about. If the editor put the tab into its buffer (and saves it > with tabs), then what users on particular display devices depends on > what the device does with tabs. > > Theoretically, all tabs might seem like a good idea, but since 0 spaces, > 1/2 inch, and 8 spaces are possible display results, in addition to a > users custom setting, this does not work except in a circumscribed > environment. That leaves space indents and no tabs except in strings > where needed. > TBH, I think that tab width should be up to the display, just like the font. You're allowed to view code in any font that makes sense for you, and you should be able to view code with any indentation that makes sense for you. If someone submits code and says "it looks tidiest in Times New Roman 12/10pt", I'm sure you'd recommend making sure it doesn't matter [1]; if someone submits code and says "you have to set your tabs equal to 5 spaces or it looks ugly", you'd say the same, right? How wide my indents are on my screen shouldn't influence your screen or your choices. ChrisA [1] eg the last of the Pet Peeves https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements From cs at cskk.id.au Sun Oct 7 20:15:44 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 8 Oct 2018 11:15:44 +1100 Subject: Python indentation (3 spaces) In-Reply-To: References: Message-ID: <20181008001544.GA63651@cskk.homeip.net> On 08Oct2018 09:47, Chris Angelico wrote: >On Mon, Oct 8, 2018 at 9:46 AM Gene Heskett wrote: >> On Sunday 07 October 2018 18:29:21 Chris Angelico wrote: >> > Ah. Fair enough, then. Basically, you want the Python equivalent of >> > "gcc -Wall -Wpedantic". >> > >> Is there such a critter? > >Not really; there's -Wall, of course, but it's not nearly as >comprehensive as gcc's pedantic mode. Sorry. But there's any number of lint tools. My current "lint" script runs pyflakes and pep8 and pylint. What I do wish was that I had a vim mode that highlighted an indent column so I can line up indented code with its controlling top line. (A vim mode because I use vim, not as a recommendation.) Cheers, Cameron Simpson From gheskett at shentel.net Sun Oct 7 21:11:31 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 21:11:31 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071845.16671.gheskett@shentel.net> Message-ID: <201810072111.31857.gheskett@shentel.net> On Sunday 07 October 2018 18:47:45 Chris Angelico wrote: > On Mon, Oct 8, 2018 at 9:46 AM Gene Heskett wrote: > > On Sunday 07 October 2018 18:29:21 Chris Angelico wrote: > > > On Mon, Oct 8, 2018 at 9:26 AM Gene Heskett > > > > wrote: > > > > On Sunday 07 October 2018 17:36:34 Chris Angelico wrote: > > > > > On Mon, Oct 8, 2018 at 8:27 AM Gene Heskett > > > > > > > > > > > > > wrote: > > > > [...]> > > > > > > > > > Okay, but I'm trying to understand why you're referencing this > > > > > in this thread about indentation. That would imply that you at > > > > > least have reason to suspect that the problem is indentation. > > > > > > > > > > ChrisA > > > > > > > > Grasping at straws ChrisA. And anything that will reach out and > > > > slap me around when it see's a syntax problem might accidentally > > > > teach me something about this snake. > > > > > > Ah. Fair enough, then. Basically, you want the Python equivalent > > > of "gcc -Wall -Wpedantic". > > > > Is there such a critter? > > Not really; there's -Wall, of course, but it's not nearly as > comprehensive as gcc's pedantic mode. Sorry. > > ChrisA Oh, fudge. Probably beyond my fading abilities anyway. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From gheskett at shentel.net Sun Oct 7 21:13:39 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 7 Oct 2018 21:13:39 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> Message-ID: <201810072113.39332.gheskett@shentel.net> On Sunday 07 October 2018 19:20:57 Dennis Lee Bieber wrote: > On Sun, 7 Oct 2018 14:19:15 -0400, Gene Heskett > > declaimed the following: > >But that automatically assumes one is running in a windows > > environment. I don't allow it on the premises if I own the machine. > > Are there good, alternatives that run on linux? > > Visual Studio Code /does/ run on Linux. Without having to install > WINE or similar. > > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ I just read the License TOC, and deleted the deb. I have very little use for spyware. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From marko at pacujo.net Mon Oct 8 02:31:10 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 08 Oct 2018 09:31:10 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> Message-ID: <87murpt0ep.fsf@elektro.pacujo.net> Chris Angelico : > How wide my indents are on my screen shouldn't influence your screen > or your choices. Where I work (and at home), the only control character that is allowed in source code is LF. Marko From ben+python at benfinney.id.au Mon Oct 8 03:06:51 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 08 Oct 2018 18:06:51 +1100 Subject: Python indentation (correct behaviour) (was: Python indentation (3 spaces)) References: <20181008001544.GA63651@cskk.homeip.net> Message-ID: <867eis533o.fsf_-_@benfinney.id.au> Cameron Simpson writes: > What I do wish was that I had a vim mode that highlighted an indent > column so I can line up indented code with its controlling top line. For Vim: . For Emacs: The latter is used by default in Elpy, an excellent Python development suite . -- \ ?When a well-packaged web of lies has been sold to the masses | `\ over generations, the truth will seem utterly preposterous and | _o__) its speaker a raving lunatic.? ?Dresden James | Ben Finney From ben+python at benfinney.id.au Mon Oct 8 03:13:49 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 08 Oct 2018 18:13:49 +1100 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <8636tg52s2.fsf@benfinney.id.au> Terry Reedy writes: > You assumption that a tab means '4 spaces' is wrong. A tab means > 'jump to the next tab stop'. On 10 char/inch US typewriters, tab > stops were initially set to every 5 spaces or 1/2 inch. In terminals > and code editors, virtual tab stops were often set to every 8 spaces, > and python still interprets tabs that way. > > This means that editing Python code in an editor that *displays* tabs > (as opposed to converting them to spaces) with other than > every-8-space tab stops is arguably a bad idea if the file has or > might have non-tab space indents. The distinctions Terry is drawing attention to are important. Often the confusion in these discussions comes from people conflating the three separate issues that jwz described in this classic essay . -- \ ?I find the whole business of religion profoundly interesting. | `\ But it does mystify me that otherwise intelligent people take | _o__) it seriously.? ?Douglas Adams | Ben Finney From tjol at tjol.eu Mon Oct 8 04:14:13 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 8 Oct 2018 10:14:13 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <201810072113.39332.gheskett@shentel.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <201810071419.15949.gheskett@shentel.net> <201810072113.39332.gheskett@shentel.net> Message-ID: On 08/10/2018 03:13, Gene Heskett wrote: > On Sunday 07 October 2018 19:20:57 Dennis Lee Bieber wrote: > >> On Sun, 7 Oct 2018 14:19:15 -0400, Gene Heskett >> >> declaimed the following: >>> But that automatically assumes one is running in a windows >>> environment. I don't allow it on the premises if I own the machine. >>> Are there good, alternatives that run on linux? >> >> Visual Studio Code /does/ run on Linux. Without having to install >> WINE or similar. >> >> >> >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > I just read the License TOC, and deleted the deb. I have very little use > for spyware. > You can use the open source version though. According to https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005 it's essentially identical but without the spyware (though you can check that yourself, because you know, it's open source) From cs at cskk.id.au Mon Oct 8 06:08:06 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 8 Oct 2018 21:08:06 +1100 Subject: Python indentation (correct behaviour) (was: Python indentation (3 spaces)) In-Reply-To: <867eis533o.fsf_-_@benfinney.id.au> References: <867eis533o.fsf_-_@benfinney.id.au> Message-ID: <20181008100806.GA79938@cskk.homeip.net> On 08Oct2018 18:06, Ben Finney wrote: >Cameron Simpson writes: >> What I do wish was that I had a vim mode that highlighted an indent >> column so I can line up indented code with its controlling top line. > >For Vim: . >For Emacs: > >The latter is used by default in Elpy, an excellent Python development >suite . Thank you! - Cameron From rhodri at kynesim.co.uk Mon Oct 8 10:10:07 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 8 Oct 2018 15:10:07 +0100 Subject: Python indentation (3 spaces) In-Reply-To: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> Message-ID: <088c02e8-951e-6a08-106b-58054df7c42b@kynesim.co.uk> On 05/10/18 21:48, ts9564 at gmail.com wrote: > I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" Thank you for the suggestion, Thomas. Unfortunately I think it's a perfect example of something that was being discussed elsewhere, the well-intentioned name change that actually makes things worse in the long run. I think the most likely outcome of switching to 3 space indentation, which we could do right now with no need to change a single thing, is that it would all seem to work perfectly well for a while. It wouldn't take long for people to get irritated with actually typing three spaces though, and to reprogram their Tab keys to three space tab stops. Once that happens, it's only a matter of time before the people who believe that Tabs should give you actual Tab characters do the same, and lo and behold you are back where you started but with 3-space tab stops as well as 4-space tab stops. Why do I think that's what would happen? Because that's how we got 4-space tab stops in the first place. The original de facto standard was for 8-space tab stops (see https://en.wikipedia.org/wiki/Tab_key#Tab_characters for some background). 8 characters on a 132-character line printer isn't that much. 8 characters on an 80 column monitor is quite a long way, on the other hand. People started using four spaces as a more reasonable size, used the Tab key for convenience and eventually ended up with the unholy mess we know and love today. Fortunately 2-space tabbing never attracted the attention of the tab-character purists, or we'd be in an even worse situation :-) I've watched this sort of thing happen in too many different arenas over the years, most obviously with my father's job. He worked with disabled people, and changing terms used to refer to them never once got rid of the associated prejudices. This doesn't seem to be an easy thing to hear particularly when it's associated with something emotive like the master/slave debate, but changing terms buys you at best a couple of months free of previous associations. Then the old associations catch up, and usually bring some new friends with them. Changing indent sizes is falling into the same trap as changing terminology, I'm afraid. It's an obvious, well-intentioned thought, but it won't actually change anything for the better. Thank you for bringing it up, though. -- Rhodri James *-* Kynesim Ltd From rhodri at kynesim.co.uk Mon Oct 8 10:43:03 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 8 Oct 2018 15:43:03 +0100 Subject: Observations on the List - "Be More Kind" In-Reply-To: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> On 05/10/18 11:22, Bruce Coram wrote: > The level of vitriol and personal attacks on the moderators was > profoundly disappointing, but not totally out of character for those who > made the attacks.? There is no doubt that these people know software and > Python and this certainly earns my respect,? but perhaps they need to > retain a sense of perspective.? There are 7 billion people in the > world.? There are plenty more people at least as good as you and many > better, but they don't have the compelling urge to demonstrate their > genius.? They get on with their work in a quiet professional manner. Speaking as one of the people who have been vocally unimpressed with the moderators of late, I'd personally appreciate something a little more specific than "not totally out of character". Because actually it *is* out of character for me to be confrontational. I appreciate that the moderators are volunteers, but they have official power on this list. Being volunteers doesn't mean that they can't get it wrong, or that we shouldn't call them on it when they do. They have got things wrong, and I have called them on it. The response has been... I'm trying not to say "patronising" because I'm fairly sure it wasn't meant that way, but "I'm sorry you feel that way" made me feel patronised. It certainly didn't (and doesn't) make me feel that my outright anger at their actions has been considered with any degree of seriousness. Unsurprisingly that doesn't lead to me taking them seriously any more. The formal language only makes me take them less seriously. I don't know what else to say to you. With one or maybe two exceptions, I haven't seen anything that is even close to qualifying as vitriol. Much of what has been said could be cast as personal attacks, but that is true of almost any confrontation, especially where abuse of power is or may be involved. (Oh, and posting a thumbnail character assassination of someone who isn't allowed to post in their defense is hardly blameless behaviour, by the way.) Flatly, I do not see what you see. I'm open to persuasion, but I'll say up front I don't expect you to succeed. -- Rhodri James *-* Kynesim Ltd From mvoicem at gmail.com Mon Oct 8 10:52:29 2018 From: mvoicem at gmail.com (m) Date: Mon, 8 Oct 2018 16:52:29 +0200 Subject: kivy [quick report] In-Reply-To: References: Message-ID: <5bbb6f2d$0$503$65785112@news.neostrada.pl> W dniu 05.10.2018 o?18:43, Stefan Ram pisze: > BTW: For Android, there is a "Bulldozer" (or some such) that > can create an APK. I wonder what the best way to package one's > kivy program to distribute it to Windows users? I use wine + pyinstaller. regards m From hjp-python at hjp.at Mon Oct 8 13:31:21 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 8 Oct 2018 19:31:21 +0200 Subject: Python indentation (correct behaviour) (was: Python indentation (3 spaces)) In-Reply-To: <867eis533o.fsf_-_@benfinney.id.au> References: <20181008001544.GA63651@cskk.homeip.net> <867eis533o.fsf_-_@benfinney.id.au> Message-ID: <20181008173121.54sfcuzkhdkmb4h5@hjp.at> On 2018-10-08 18:06:51 +1100, Ben Finney wrote: > Cameron Simpson writes: > > What I do wish was that I had a vim mode that highlighted an indent > > column so I can line up indented code with its controlling top line. > > For Vim: . Nice. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Oct 8 13:43:22 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 8 Oct 2018 19:43:22 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> Message-ID: <20181008174322.oudxrqahwicuu6rv@hjp.at> On 2018-10-08 10:36:21 +1100, Chris Angelico wrote: > TBH, I think that tab width should be up to the display, just like the > font. You're allowed to view code in any font that makes sense for > you, and you should be able to view code with any indentation that > makes sense for you. If someone submits code and says "it looks > tidiest in Times New Roman 12/10pt", I'm sure you'd recommend making > sure it doesn't matter [1]; if someone submits code and says "you have > to set your tabs equal to 5 spaces or it looks ugly", you'd say the > same, right? > > How wide my indents are on my screen shouldn't influence your screen > or your choices. Theoretically I would agree with you: Just use a single tab per indentation level and let the user decide whether that's displayed as 2, 3, 4, or 8 spaces or 57 pixels or whatever. In practice it doesn't work in my experience. There is always someone in a team who was "just testing that new editor" and replaced all tabs with spaces (or vice versa) or - worse - just some of them. It is safer to disallow tabs completely and mandate a certain number of spaces per indentation level. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rosuav at gmail.com Mon Oct 8 13:59:43 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 9 Oct 2018 04:59:43 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <20181008174322.oudxrqahwicuu6rv@hjp.at> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> Message-ID: On Tue, Oct 9, 2018 at 4:44 AM Peter J. Holzer wrote: > > On 2018-10-08 10:36:21 +1100, Chris Angelico wrote: > > TBH, I think that tab width should be up to the display, just like the > > font. You're allowed to view code in any font that makes sense for > > you, and you should be able to view code with any indentation that > > makes sense for you. If someone submits code and says "it looks > > tidiest in Times New Roman 12/10pt", I'm sure you'd recommend making > > sure it doesn't matter [1]; if someone submits code and says "you have > > to set your tabs equal to 5 spaces or it looks ugly", you'd say the > > same, right? > > > > How wide my indents are on my screen shouldn't influence your screen > > or your choices. > > Theoretically I would agree with you: Just use a single tab per > indentation level and let the user decide whether that's displayed as 2, > 3, 4, or 8 spaces or 57 pixels or whatever. > > In practice it doesn't work in my experience. There is always someone in > a team who was "just testing that new editor" and replaced all tabs > with spaces (or vice versa) or - worse - just some of them. It is safer > to disallow tabs completely and mandate a certain number of spaces per > indentation level. > Ahh yes, it hurts to stick your neck out and have someone hack at it... :| ChrisA From olousseh at yahoo.fr Mon Oct 8 15:21:16 2018 From: olousseh at yahoo.fr (Olivier Oussou) Date: Mon, 8 Oct 2018 19:21:16 +0000 (UTC) Subject: Encounter issues to install Python References: <1715165778.8897506.1539026476320.ref@mail.yahoo.com> Message-ID: <1715165778.8897506.1539026476320@mail.yahoo.com> Hi!I downloaded and installed python 3.6.4 (32-bit) on my computer but I have problems and can not access the python interface. I need your technical assistance to solve this matter.? Best regard! Olivier OUSSOUMedical entomologist, Benin From liamhanninen at gmail.com Mon Oct 8 15:40:55 2018 From: liamhanninen at gmail.com (liamhanninen at gmail.com) Date: Mon, 8 Oct 2018 12:40:55 -0700 (PDT) Subject: How to use Python's built-in Logging with Asyncio (Permission Error) Message-ID: <5ec5ccbf-4972-4a4b-a9ca-49083d5db125@googlegroups.com> >From the logging docs I found out there was another avenue (comp.lang.python) to ask questions about it. I already posted to stackoverflow but if anyone could help out here or via stackoverflow I would greatly appreciate it. Here is the link to my question: https://stackoverflow.com/questions/52708756/how-to-use-pythons-built-in-logging-with-asyncio-permission-error From ethan at stoneleaf.us Mon Oct 8 15:46:48 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 8 Oct 2018 12:46:48 -0700 Subject: Observations on the List - "Be More Kind" In-Reply-To: <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> Message-ID: On 10/08/2018 07:43 AM, Rhodri James wrote: > I appreciate that the moderators are volunteers, but they have official > power on this list.? Being volunteers doesn't mean that they can't get > it wrong, or that we shouldn't call them on it when they do. I completely agree. > They have got things wrong, I completely disagree. > and I have called them on it. Yes, you and a few others -- and nobody has actually talked (emailed) us directly, but rather talked *about* us on the list [1]. > The response has > been... I'm trying not to say "patronising" because I'm fairly sure it > wasn't meant that way, but "I'm sorry you feel that way" made me feel > patronised. You're right, I didn't mean it that way, and I apologize. To briefly explain our decisions of late: Suspending D'Aprano: ------------------- His public post to me was shared with several people, including moderators of others lists, and it was unanimously agreed that his post was completely unacceptable and a two month suspension was appropriate. I restarted that suspension because, according to his own words, "I am ignoring the ban in this instance"; had he emailed me privately I would have correctly posted the notice to the list; had he not said that and just posted I would have fixed the filter and left the suspension alone (he posts from comp.lang.python). Suspending Mark Lawrence: ------------------------ He has a history of posting attacks. I sent him a private warning, he responded a couple days later with another attack. Suspending BartC: ---------------- Many, if not most, of his posts' primary relation to Python was how his personal language was better. The resulting threads seemed to be largely unfriendly, unproductive, and unnecessary. Banning Rick Johnson: -------------------- Hopefully no explanation needed [2]. Shutting down threads: --------------------- There is a problem with threads getting heated and people not exercising self-control and posting inappropriately. That makes the list unwelcoming. As soon as we feel that that is happening we are going to shut down the thread. Personal attacks and name-calling are not appropriate and will not be tolerated. The goal is not to shut down debate -- as long as the debate stays civil it will get no moderation action. If a thread is shut down and you feel there is more to be (civilly) said -- wait a couple days so everyone can cool off, and then start a new thread. Hopefully you now agree with our decisions, or at least support us in them. If you don't, I actually am sorry -- I would much rather have your support (and everyone's). Either way, we are not changing our minds about them. -- ~Ethan~ Python List Moderator [1] Please correct me if I'm wrong. [2] If one is needed: his posts can contain profanity, personal attacks, condescension, and completely inappropriate language. From grant.b.edwards at gmail.com Mon Oct 8 16:13:38 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 8 Oct 2018 20:13:38 +0000 (UTC) Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> Message-ID: On 2018-10-08, Peter J. Holzer wrote: > Theoretically I would agree with you: Just use a single tab per > indentation level and let the user decide whether that's displayed > as 2, 3, 4, or 8 spaces or 57 pixels or whatever. > > In practice it doesn't work in my experience. Nor in mine. On problem is that under Unix is that there isn't just one place where you would need to configure the tab width. There are dozens of text-processing tools that get used on all sorts of text, including program sources in a variety of languages. For "just use tabs" to work, all of those tools would have to magically recognize that they're looking at Python source and adjust the tab size accordingly. That isn't going to happen. > There is always someone in a team who was "just testing that new > editor" and replaced all tabs with spaces (or vice versa) or - worse > - just some of them. It is safer to disallow tabs completely and > mandate a certain number of spaces per indentation level. Indeed. That's the only thing that actually works. -- Grant Edwards grant.b.edwards Yow! Being a BALD HERO at is almost as FESTIVE as a gmail.com TATTOOED KNOCKWURST. From tjol at tjol.eu Mon Oct 8 16:17:55 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 8 Oct 2018 22:17:55 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <87murpt0ep.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <87murpt0ep.fsf@elektro.pacujo.net> Message-ID: On 08/10/2018 08:31, Marko Rauhamaa wrote: > Chris Angelico : >> How wide my indents are on my screen shouldn't influence your screen >> or your choices. > > Where I work (and at home), the only control character that is allowed > in source code is LF. > No tolerance for form feeds? From ian.g.kelly at gmail.com Mon Oct 8 16:42:00 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 8 Oct 2018 14:42:00 -0600 Subject: How to use Python's built-in Logging with Asyncio (Permission Error) In-Reply-To: <5ec5ccbf-4972-4a4b-a9ca-49083d5db125@googlegroups.com> References: <5ec5ccbf-4972-4a4b-a9ca-49083d5db125@googlegroups.com> Message-ID: 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 handler instance. I've not used it myself, but I believe that this is effectively the problem that QueueHandler and QueueListener were created to solve: https://docs.python.org/3.7/library/logging.handlers.html#queuehandler The parent process should create a queue and a QueueListener to service that queue, using the TimedRotatingFileHandler. Each subprocess should log to the queue using QueueHandler instead. This way the actual log file is only handled by one process. On Mon, Oct 8, 2018 at 1:54 PM wrote: > > From the logging docs I found out there was another avenue (comp.lang.python) to ask questions about it. I already posted to stackoverflow but if anyone could help out here or via stackoverflow I would greatly appreciate it. Here is the link to my question: > > https://stackoverflow.com/questions/52708756/how-to-use-pythons-built-in-logging-with-asyncio-permission-error > -- > https://mail.python.org/mailman/listinfo/python-list From marko at pacujo.net Mon Oct 8 18:00:41 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 09 Oct 2018 01:00:41 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <87murpt0ep.fsf@elektro.pacujo.net> Message-ID: <87in2ct7xy.fsf@elektro.pacujo.net> Thomas Jollans : > On 08/10/2018 08:31, Marko Rauhamaa wrote: >> Where I work (and at home), the only control character that is allowed >> in source code is LF. > > No tolerance for form feeds? None whatsoever. CR is ok but only if immediately followed by BEL. That way typing source code gives out the air of an old typewriter. Highlighting keywords with ANSI escape sequences can also be rather cute. Marko From rosuav at gmail.com Mon Oct 8 18:16:09 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 9 Oct 2018 09:16:09 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <87in2ct7xy.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <87murpt0ep.fsf@elektro.pacujo.net> <87in2ct7xy.fsf@elektro.pacujo.net> Message-ID: On Tue, Oct 9, 2018 at 9:06 AM Marko Rauhamaa wrote: > > Thomas Jollans : > > > On 08/10/2018 08:31, Marko Rauhamaa wrote: > >> Where I work (and at home), the only control character that is allowed > >> in source code is LF. > > > > No tolerance for form feeds? > > None whatsoever. > > CR is ok but only if immediately followed by BEL. That way typing source > code gives out the air of an old typewriter. > > Highlighting keywords with ANSI escape sequences can also be rather > cute. > Bah, you're missing out on so much fun by banning control characters. Inserting a "cursor up one line" character in the middle of a quoted string makes typing source code ever so much more exciting! Especially if you carefully engineer it so it gently changes a few variable names... ChrisA From jfong at ms4.hinet.net Tue Oct 9 00:10:00 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Mon, 8 Oct 2018 21:10:00 -0700 (PDT) Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> I am wondering the role of the moderator. Does he own the server or pay the bill? Where he get the power to suspending people? Is he a police or judge? Can he shoot someone just because he has any reason? What will happen if his power was limited? Will the forum be end in disorder? No, I don't think so. We are mature enough to keep it running. --Jach From upadhyay.kamayani at gmail.com Tue Oct 9 01:17:44 2018 From: upadhyay.kamayani at gmail.com (upadhyay.kamayani at gmail.com) Date: Mon, 8 Oct 2018 22:17:44 -0700 (PDT) Subject: My python code has suddenly started to give me error. Please see code below** Message-ID: <59e40f95-6d89-4d0a-abfe-687698f0daac@googlegroups.com> ## Calculating the Lower Limits(LLi) and Upper Limit(ULi) for each Band, where i is 1,2,.....10 LL1=0 print(LL1) print(P2) print(D2) if(P2>25): UL1=D1 print(UL1) elif(UL1==D2): print(UL1) LL2=UL1 if(P3>25): UL2=D2 print(UL2) elif(UL2==D3): print(UL2) LL3=UL2 if(P4>25): UL3=D3 print(UL3) elif(UL3==D4): print(UL3) LL4=UL3 if(P5>25): UL4=D4 print(UL4) elif(UL4==D5): print(UL4) LL5=UL4 if(P6>25): UL5=D5 print(UL5) elif(UL5==D6): print(UL5) LL6=UL5 if(P7>25): UL6=D6 print(UL6) elif(UL6==D7): print(UL6) LL7=UL6 if(P8>25): UL7=D7 print(UL7) elif(UL7==D8): print(UL7) LL8=UL7 if(P9>25): UL8=D8 print(UL8) elif(UL8==D9): print(UL8) LL9=UL8 if(P10>25): UL9=D9 print(UL9) elif(UL9==D10): print(UL9) LL10=UL9 UL10=("& Above") print(UL10) ** n1=int(UL1) count=0 while (n1>0): count=count+1 n1=n1//10 print(count) B11=LL1 If((count)/2)==0: B12=int((UL1)/(10**(count-2))) B12 elif(B12=int((UL1)/(10**(count-1)))): B12 B1=(B11,"-",B12,"M") B1 From gherron at digipen.edu Tue Oct 9 02:14:16 2018 From: gherron at digipen.edu (Gary Herron) Date: Mon, 8 Oct 2018 23:14:16 -0700 Subject: My python code has suddenly started to give me error. Please see code below** In-Reply-To: <59e40f95-6d89-4d0a-abfe-687698f0daac@googlegroups.com> References: <59e40f95-6d89-4d0a-abfe-687698f0daac@googlegroups.com> Message-ID: <4e5ec307-e68b-5fe3-d2a8-98aa320e30c8@digipen.edu> So, tell us the error and we'll see what we can do.? Give us something to work with: ? Cut and past the full error message, trace back, whatever you can. Also tell us what version of Python, what system you are running on, how you run this code, ... On 10/08/2018 10:17 PM, upadhyay.kamayani at gmail.com wrote: > ## Calculating the Lower Limits(LLi) and Upper Limit(ULi) for each Band, where i is 1,2,.....10 > LL1=0 > print(LL1) > > print(P2) > print(D2) > > if(P2>25): > UL1=D1 > print(UL1) > > elif(UL1==D2): > print(UL1) > > LL2=UL1 > > if(P3>25): > UL2=D2 > print(UL2) > > elif(UL2==D3): > print(UL2) > > LL3=UL2 > > if(P4>25): > UL3=D3 > print(UL3) > > elif(UL3==D4): > print(UL3) > > > LL4=UL3 > > if(P5>25): > UL4=D4 > print(UL4) > > elif(UL4==D5): > print(UL4) > > LL5=UL4 > > if(P6>25): > UL5=D5 > print(UL5) > > elif(UL5==D6): > print(UL5) > > LL6=UL5 > > if(P7>25): > UL6=D6 > print(UL6) > > elif(UL6==D7): > print(UL6) > > LL7=UL6 > > if(P8>25): > UL7=D7 > print(UL7) > > elif(UL7==D8): > print(UL7) > > LL8=UL7 > > if(P9>25): > UL8=D8 > print(UL8) > > elif(UL8==D9): > print(UL8) > > LL9=UL8 > > if(P10>25): > UL9=D9 > print(UL9) > > elif(UL9==D10): > print(UL9) > > LL10=UL9 > UL10=("& Above") > > print(UL10) > > > > ** > n1=int(UL1) > count=0 > while (n1>0): > count=count+1 > n1=n1//10 > > print(count) > > B11=LL1 > If((count)/2)==0: > B12=int((UL1)/(10**(count-2))) > B12 > elif(B12=int((UL1)/(10**(count-1)))): > B12 > B1=(B11,"-",B12,"M") > B1 -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From luca72.bertolotti at gmail.com Tue Oct 9 03:12:25 2018 From: luca72.bertolotti at gmail.com (Luca Bertolotti) Date: Tue, 9 Oct 2018 00:12:25 -0700 (PDT) Subject: variable exchange Message-ID: <8ab71d55-79fa-4aca-a539-26038a326437@googlegroups.com> Hello i'm using python with pyqt but i have a problem on varable: I have two class: from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QWidget from PyQt5.QtSql import QSqlDatabase, QSqlTableModel from PyQt5 import QtWidgets from PyQt5.QtCore import Qt from Ui_form import Ui_Form from form_cli import Form_cli class Form(QWidget, Ui_Form): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(Form, self).__init__(parent) self.setupUi(self) self.ftc = Form_cli()....................................etc from PyQt5.QtCore import pyqtSlot, QModelIndex from PyQt5.QtWidgets import QWidget, QTableWidgetItem, QLineEdit from PyQt5.QtSql import QSqlTableModel from PyQt5.QtSql import QSqlDatabase from PyQt5.QtCore import Qt from Ui_form_cli import Ui_Form class Form_cli(QWidget, Ui_Form): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(Form_cli, self).__init__(parent) self.setupUi(self) self.db = QSqlDatabase() self.tableWidget.setRowCount(1) self.tableWidget.setColumnCount(10) >From the class Form_cli how i can modify a textedit that is in the class Form? Thanks From ftg at lutix.org Tue Oct 9 03:20:04 2018 From: ftg at lutix.org (ftg at lutix.org) Date: Tue, 09 Oct 2018 07:20:04 +0000 Subject: My environment doesn't load Message-ID: <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> Hello, I have rsynced a folder on my distant server. Now I try to source my environment: source ./env/bin/activate and nothing happens. When type > which python, /usr/bin/python is still printed. What could be the issue? Thanks From cs at cskk.id.au Tue Oct 9 03:37:18 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 9 Oct 2018 18:37:18 +1100 Subject: variable exchange In-Reply-To: <8ab71d55-79fa-4aca-a539-26038a326437@googlegroups.com> References: <8ab71d55-79fa-4aca-a539-26038a326437@googlegroups.com> Message-ID: <20181009073718.GA13333@cskk.homeip.net> On 09Oct2018 00:12, Luca Bertolotti wrote: >Hello i'm using python with pyqt but i have a problem on varable: >I have two class: [...] >class Form(QWidget, Ui_Form): > """ > Class documentation goes here. > """ > def __init__(self, parent=None): > """ > Constructor > > @param parent reference to the parent widget > @type QWidget > """ > super(Form, self).__init__(parent) > self.setupUi(self) > self.ftc = Form_cli()....................................etc [...] >class Form_cli(QWidget, Ui_Form): > """ > Class documentation goes here. > """ > def __init__(self, parent=None): > """ > Constructor > > @param parent reference to the parent widget > @type QWidget > """ > super(Form_cli, self).__init__(parent) > self.setupUi(self) > self.db = QSqlDatabase() > self.tableWidget.setRowCount(1) > self.tableWidget.setColumnCount(10) > >From the class Form_cli how i can modify a textedit that is in the >class Form? Directly. Just for clarity, you're working with an instance of Form_cli, which is a subclass of Form. So the instance has been initialised by running the Form initialiser and then the Form_cli initialiser. The consequence is that your instance has all the attributes of both. So if there's a textedit widget associated with the form just access it by whatever name it was given. Python's not like C++ where only public or protected attributes are available from outside the class; there aren't such things. Just use it. Cheers, Cameron Simpson From antoon.pardon at vub.be Tue Oct 9 03:55:34 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Tue, 9 Oct 2018 09:55:34 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <20181008174322.oudxrqahwicuu6rv@hjp.at> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> Message-ID: On 08-10-18 19:43, Peter J. Holzer wrote: > On 2018-10-08 10:36:21 +1100, Chris Angelico wrote: >> TBH, I think that tab width should be up to the display, just like the >> font. You're allowed to view code in any font that makes sense for >> you, and you should be able to view code with any indentation that >> makes sense for you. If someone submits code and says "it looks >> tidiest in Times New Roman 12/10pt", I'm sure you'd recommend making >> sure it doesn't matter [1]; if someone submits code and says "you have >> to set your tabs equal to 5 spaces or it looks ugly", you'd say the >> same, right? >> >> How wide my indents are on my screen shouldn't influence your screen >> or your choices. > Theoretically I would agree with you: Just use a single tab per > indentation level and let the user decide whether that's displayed as 2, > 3, 4, or 8 spaces or 57 pixels or whatever. > > In practice it doesn't work in my experience. There is always someone in > a team who was "just testing that new editor" and replaced all tabs > with spaces (or vice versa) or - worse - just some of them. Isn't that caugth in the process of commiting to version control? -- Antoon Pardon. From tjol at tjol.eu Tue Oct 9 04:03:26 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 9 Oct 2018 10:03:26 +0200 Subject: My environment doesn't load In-Reply-To: <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> References: <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> Message-ID: <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> On 09/10/2018 09:20, ftg at lutix.org wrote: > Hello, > > I have rsynced a folder on my distant server. Now I try to source my environment: source ./env/bin/activate and nothing happens. > When type > which python, /usr/bin/python is still printed. What could be the issue? > > Thanks > What shell are you using? Was the environment created by virtualenv, venv or something else? After sourcing activate, what is your PATH? Is there a ./env/bin/python? Does it work? (The hopefully easy fix is obviously to just recreate the environment locally from your requirements.txt, assuming you have one) From luca72.bertolotti at gmail.com Tue Oct 9 04:12:00 2018 From: luca72.bertolotti at gmail.com (Luca Bertolotti) Date: Tue, 9 Oct 2018 01:12:00 -0700 (PDT) Subject: variable exchange In-Reply-To: <8ab71d55-79fa-4aca-a539-26038a326437@googlegroups.com> References: <8ab71d55-79fa-4aca-a539-26038a326437@googlegroups.com> Message-ID: <7c8b6358-5b12-42ed-a354-81528939df5f@googlegroups.com> Thanks Cameron but my problem is that i can't access to a line edit of the class Form from the class Form_cli i get this error: 'Form_cli' object has no attribute 'lineEdit_29' From ftg at lutix.org Tue Oct 9 04:36:58 2018 From: ftg at lutix.org (ftg at lutix.org) Date: Tue, 09 Oct 2018 08:36:58 +0000 Subject: My environment doesn't load In-Reply-To: <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> References: <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> Message-ID: <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> Thx, initially the env was created with virtualenv yes, and then I copied the folder of the project on a remote server. I am using zsh (both locally and remotely). My PATH env variable does includes well the path of my env bin. In this folder there are symbolic links. And yes there is well an /env/bin/python in there: drwxrwxr-x 3 ftg ftg 4096 Jul 6 21:38 . drwxrwxr-x 6 ftg ftg 4096 May 29 20:33 .. -rw-rw-r-- 1 ftg ftg 2114 May 29 20:30 activate -rw-rw-r-- 1 ftg ftg 1056 May 29 20:30 activate.csh -rw-rw-r-- 1 ftg ftg 2210 May 29 20:30 activate.fish -rw-rw-r-- 1 ftg ftg 1137 May 29 20:30 activate_this.py -rwxrwxr-x 1 ftg ftg 276 Jul 6 21:38 chardetect -rwxrwxr-x 1 ftg ftg 318 May 29 20:33 django-admin -rwxrwxr-x 1 ftg ftg 176 May 29 20:33 django-admin.py -rwxrwxr-x 1 ftg ftg 9267 Jul 6 21:38 dumppdf.py -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install-3.5 -rwxrwxr-x 1 ftg ftg 2438 Jul 6 21:38 latin2ascii.py -rwxrwxr-x 1 ftg ftg 5970 Jul 6 21:38 pdf2txt.py -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3 -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3.5 drwxrwxr-x 2 ftg ftg 4096 Jul 6 21:38 __pycache__ lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python -> python3 -rwxrwxr-x 1 ftg ftg 4743656 May 29 20:30 python3 lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python3.5 -> python3 -rwxrwxr-x 1 ftg ftg 2373 May 29 20:30 python-config -rwxrwxr-x 1 ftg ftg 264 May 29 20:30 wheel So I guess that copying an environment is not "creating" it remotely. However it works in a certain point of view because apache can find it an use it as python-path is set for my WSGI Daemon Process. DOn't understand... October 9 2018 10:18 AM, "Thomas Jollans" wrote: > On 09/10/2018 09:20, ftg at lutix.org wrote: > >> Hello, >>> I have rsynced a folder on my distant server. Now I try to source my environment: source >> ./env/bin/activate and nothing happens. >> When type > which python, /usr/bin/python is still printed. What could be the issue? >>> Thanks > > What shell are you using? Was the environment created by virtualenv, venv or something else? After > sourcing activate, what is your PATH? Is there a ./env/bin/python? Does it work? > > (The hopefully easy fix is obviously to just recreate the environment locally from your > requirements.txt, assuming you have one) > -- https://mail.python.org/mailman/listinfo/python-list From tjol at tjol.eu Tue Oct 9 05:03:28 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 9 Oct 2018 11:03:28 +0200 Subject: My environment doesn't load In-Reply-To: <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> References: <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> Message-ID: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> On 2018-10-09 10:36, ftg at lutix.org wrote: > Thx, > > initially the env was created with virtualenv yes, and then I copied the folder of the project on a remote server. I am using zsh (both locally and remotely). > My PATH env variable does includes well the path of my env bin. In this folder there are symbolic links. > And yes there is well an /env/bin/python in there: But can you run it? If it exists, and it's at the top of your PATH, then everything should be fine unless your shell's command hash table is getting in the way - which it shouldn't. virtualenv knows about those: % tail -6 bin/activate # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then hash -r 2>/dev/null fi > drwxrwxr-x 3 ftg ftg 4096 Jul 6 21:38 . > drwxrwxr-x 6 ftg ftg 4096 May 29 20:33 .. > -rw-rw-r-- 1 ftg ftg 2114 May 29 20:30 activate > -rw-rw-r-- 1 ftg ftg 1056 May 29 20:30 activate.csh > -rw-rw-r-- 1 ftg ftg 2210 May 29 20:30 activate.fish > -rw-rw-r-- 1 ftg ftg 1137 May 29 20:30 activate_this.py > -rwxrwxr-x 1 ftg ftg 276 Jul 6 21:38 chardetect > -rwxrwxr-x 1 ftg ftg 318 May 29 20:33 django-admin > -rwxrwxr-x 1 ftg ftg 176 May 29 20:33 django-admin.py > -rwxrwxr-x 1 ftg ftg 9267 Jul 6 21:38 dumppdf.py > -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install > -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install-3.5 > -rwxrwxr-x 1 ftg ftg 2438 Jul 6 21:38 latin2ascii.py > -rwxrwxr-x 1 ftg ftg 5970 Jul 6 21:38 pdf2txt.py > -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip > -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3 > -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3.5 > drwxrwxr-x 2 ftg ftg 4096 Jul 6 21:38 __pycache__ > lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python -> python3 > -rwxrwxr-x 1 ftg ftg 4743656 May 29 20:30 python3 > lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python3.5 -> python3 > -rwxrwxr-x 1 ftg ftg 2373 May 29 20:30 python-config > -rwxrwxr-x 1 ftg ftg 264 May 29 20:30 wheel > > So I guess that copying an environment is not "creating" it remotely. > However it works in a certain point of view because apache can find it an use it as python-path is set for my WSGI Daemon Process. > DOn't understand... > > > October 9 2018 10:18 AM, "Thomas Jollans" wrote: >> On 09/10/2018 09:20, ftg at lutix.org wrote: >> >>> Hello, >>>> I have rsynced a folder on my distant server. Now I try to source my environment: source >>> ./env/bin/activate and nothing happens. >>> When type > which python, /usr/bin/python is still printed. What could be the issue? >>>> Thanks >> >> What shell are you using? Was the environment created by virtualenv, venv or something else? After >> sourcing activate, what is your PATH? Is there a ./env/bin/python? Does it work? >> >> (The hopefully easy fix is obviously to just recreate the environment locally from your >> requirements.txt, assuming you have one) >> -- https://mail.python.org/mailman/listinfo/python-list -- Thomas Jollans m ? +31 (6) 42630259 e ? tjol at tjol.eu From fabienluce at lutix.org Tue Oct 9 05:15:07 2018 From: fabienluce at lutix.org (Fabien LUCE) Date: Tue, 09 Oct 2018 09:15:07 +0000 Subject: My environment doesn't load In-Reply-To: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> Message-ID: <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> Here are the ouput during sourcing: [ftg @ localhost] [/var/www/ffablob] % source env-p3/bin/activate [ftg @ localhost] [/var/www/ffablob] % which python /usr/bin/python and if I run some of my code that import beautyfulsoup it fails (python mycode.py), althoug running directly ./env-p3/python3.5 mycode.py is working... October 9 2018 11:06 AM, "Thomas Jollans" wrote: > On 2018-10-09 10:36, ftg at lutix.org wrote: > >> Thx, >> >> initially the env was created with virtualenv yes, and then I copied the folder of the project on a >> remote server. I am using zsh (both locally and remotely). >> My PATH env variable does includes well the path of my env bin. In this folder there are symbolic >> links. >> And yes there is well an /env/bin/python in there: > > But can you run it? > > If it exists, and it's at the top of your PATH, then everything should > be fine unless your shell's command hash table is getting in the way - > which it shouldn't. virtualenv knows about those: > > % tail -6 bin/activate > # This should detect bash and zsh, which have a hash command that must > # be called to get it to forget past commands. Without forgetting > # past commands the $PATH changes we made may not be respected > if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then > hash -r 2>/dev/null > fi > >> drwxrwxr-x 3 ftg ftg 4096 Jul 6 21:38 . >> drwxrwxr-x 6 ftg ftg 4096 May 29 20:33 .. >> -rw-rw-r-- 1 ftg ftg 2114 May 29 20:30 activate >> -rw-rw-r-- 1 ftg ftg 1056 May 29 20:30 activate.csh >> -rw-rw-r-- 1 ftg ftg 2210 May 29 20:30 activate.fish >> -rw-rw-r-- 1 ftg ftg 1137 May 29 20:30 activate_this.py >> -rwxrwxr-x 1 ftg ftg 276 Jul 6 21:38 chardetect >> -rwxrwxr-x 1 ftg ftg 318 May 29 20:33 django-admin >> -rwxrwxr-x 1 ftg ftg 176 May 29 20:33 django-admin.py >> -rwxrwxr-x 1 ftg ftg 9267 Jul 6 21:38 dumppdf.py >> -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install >> -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install-3.5 >> -rwxrwxr-x 1 ftg ftg 2438 Jul 6 21:38 latin2ascii.py >> -rwxrwxr-x 1 ftg ftg 5970 Jul 6 21:38 pdf2txt.py >> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip >> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3 >> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3.5 >> drwxrwxr-x 2 ftg ftg 4096 Jul 6 21:38 __pycache__ >> lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python -> python3 >> -rwxrwxr-x 1 ftg ftg 4743656 May 29 20:30 python3 >> lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python3.5 -> python3 >> -rwxrwxr-x 1 ftg ftg 2373 May 29 20:30 python-config >> -rwxrwxr-x 1 ftg ftg 264 May 29 20:30 wheel >> >> So I guess that copying an environment is not "creating" it remotely. >> However it works in a certain point of view because apache can find it an use it as python-path is >> set for my WSGI Daemon Process. >> DOn't understand... >> >> October 9 2018 10:18 AM, "Thomas Jollans" wrote: >>> On 09/10/2018 09:20, ftg at lutix.org wrote: >>> >>>> Hello, >>>>> I have rsynced a folder on my distant server. Now I try to source my environment: source >>>> >>>> ./env/bin/activate and nothing happens. >>>> When type > which python, /usr/bin/python is still printed. What could be the issue? >>>>> Thanks >>> >>> What shell are you using? Was the environment created by virtualenv, venv or something else? After >>> sourcing activate, what is your PATH? Is there a ./env/bin/python? Does it work? >>> >>> (The hopefully easy fix is obviously to just recreate the environment locally from your >>> requirements.txt, assuming you have one) >>> -- https://mail.python.org/mailman/listinfo/python-list > > -- > Thomas Jollans > > m ? +31 (6) 42630259 > e ? tjol at tjol.eu > -- > https://mail.python.org/mailman/listinfo/python-list From ftg at lutix.org Tue Oct 9 05:16:53 2018 From: ftg at lutix.org (ftg at lutix.org) Date: Tue, 09 Oct 2018 09:16:53 +0000 Subject: My environment doesn't load In-Reply-To: <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> References: <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> Message-ID: <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> Here are the ouput during sourcing: > [ftg @ localhost] [/var/www/ffablob] > % source env-p3/bin/activate > [ftg @ localhost] [/var/www/ffablob] > % which python > /usr/bin/python and if I run some of my code that import beautyfulsoup it fails (python mycode.py), althoug running directly ./env-p3/python3.5 mycode.py is working... > > October 9 2018 11:06 AM, "Thomas Jollans" wrote: > >> On 2018-10-09 10:36, ftg at lutix.org wrote: >> >>> Thx, >>> >>> initially the env was created with virtualenv yes, and then I copied the folder of the project on a >>> remote server. I am using zsh (both locally and remotely). >>> My PATH env variable does includes well the path of my env bin. In this folder there are symbolic >>> links. >>> And yes there is well an /env/bin/python in there: >> >> But can you run it? >> >> If it exists, and it's at the top of your PATH, then everything should >> be fine unless your shell's command hash table is getting in the way - >> which it shouldn't. virtualenv knows about those: >> >> % tail -6 bin/activate >> # This should detect bash and zsh, which have a hash command that must >> # be called to get it to forget past commands. Without forgetting >> # past commands the $PATH changes we made may not be respected >> if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then >> hash -r 2>/dev/null >> fi >> >>> drwxrwxr-x 3 ftg ftg 4096 Jul 6 21:38 . >>> drwxrwxr-x 6 ftg ftg 4096 May 29 20:33 .. >>> -rw-rw-r-- 1 ftg ftg 2114 May 29 20:30 activate >>> -rw-rw-r-- 1 ftg ftg 1056 May 29 20:30 activate.csh >>> -rw-rw-r-- 1 ftg ftg 2210 May 29 20:30 activate.fish >>> -rw-rw-r-- 1 ftg ftg 1137 May 29 20:30 activate_this.py >>> -rwxrwxr-x 1 ftg ftg 276 Jul 6 21:38 chardetect >>> -rwxrwxr-x 1 ftg ftg 318 May 29 20:33 django-admin >>> -rwxrwxr-x 1 ftg ftg 176 May 29 20:33 django-admin.py >>> -rwxrwxr-x 1 ftg ftg 9267 Jul 6 21:38 dumppdf.py >>> -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install >>> -rwxrwxr-x 1 ftg ftg 285 May 29 20:30 easy_install-3.5 >>> -rwxrwxr-x 1 ftg ftg 2438 Jul 6 21:38 latin2ascii.py >>> -rwxrwxr-x 1 ftg ftg 5970 Jul 6 21:38 pdf2txt.py >>> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip >>> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3 >>> -rwxrwxr-x 1 ftg ftg 267 May 29 20:30 pip3.5 >>> drwxrwxr-x 2 ftg ftg 4096 Jul 6 21:38 __pycache__ >>> lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python -> python3 >>> -rwxrwxr-x 1 ftg ftg 4743656 May 29 20:30 python3 >>> lrwxrwxrwx 1 ftg ftg 7 May 29 20:30 python3.5 -> python3 >>> -rwxrwxr-x 1 ftg ftg 2373 May 29 20:30 python-config >>> -rwxrwxr-x 1 ftg ftg 264 May 29 20:30 wheel >>> >>> So I guess that copying an environment is not "creating" it remotely. >>> However it works in a certain point of view because apache can find it an use it as python-path is >>> set for my WSGI Daemon Process. >>> DOn't understand... >>> >>> October 9 2018 10:18 AM, "Thomas Jollans" wrote: >>>> On 09/10/2018 09:20, ftg at lutix.org wrote: >>>> >>>>> Hello, >>>>>> I have rsynced a folder on my distant server. Now I try to source my environment: source >>>>> >>>>> ./env/bin/activate and nothing happens. >>>>> When type > which python, /usr/bin/python is still printed. What could be the issue? >>>>>> Thanks >>>> >>>> What shell are you using? Was the environment created by virtualenv, venv or something else? After >>>> sourcing activate, what is your PATH? Is there a ./env/bin/python? Does it work? >>>> >>>> (The hopefully easy fix is obviously to just recreate the environment locally from your >>>> requirements.txt, assuming you have one) >>>> -- https://mail.python.org/mailman/listinfo/python-list >> >> -- >> Thomas Jollans >> >> m ? +31 (6) 42630259 >> e ? tjol at tjol.eu >> -- >> https://mail.python.org/mailman/listinfo/python-list From cs at cskk.id.au Tue Oct 9 05:33:25 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 9 Oct 2018 20:33:25 +1100 Subject: variable exchange In-Reply-To: <7c8b6358-5b12-42ed-a354-81528939df5f@googlegroups.com> References: <7c8b6358-5b12-42ed-a354-81528939df5f@googlegroups.com> Message-ID: <20181009093325.GA66808@cskk.homeip.net> On 09Oct2018 01:12, Luca Bertolotti wrote: >Thanks Cameron >but my problem is that i can't access to a line edit of the class Form from the class Form_cli i get this error: >'Form_cli' object has no attribute 'lineEdit_29' It is best to always show the entire error message including traceback. As text, pasted directly into your post, not as an attachment. I see nothing in the code you provided which makes a "lineEdit_29" attribute, so on the face of it this error message is pretty expectable. But conversely, I don't see anything in your code which tries to access such an attribute either. So clearly there's stuff you haven't shown us. More information required. Cheers, Cameron Simpson From arj.python at gmail.com Tue Oct 9 06:07:12 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 9 Oct 2018 14:07:12 +0400 Subject: Test before PR Message-ID: just a simple question. how do you test PR before merge? yours, Abdur-Rahmaan Janhangeer Mauritius From rhodri at kynesim.co.uk Tue Oct 9 07:12:33 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 9 Oct 2018 12:12:33 +0100 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> Message-ID: <4310a16b-629b-e905-cab5-54909a370b0e@kynesim.co.uk> On 08/10/18 20:46, Ethan Furman wrote: > On 10/08/2018 07:43 AM, Rhodri James wrote: > >> I appreciate that the moderators are volunteers, but they have >> official power on this list.? Being volunteers doesn't mean that they >> can't get it wrong, or that we shouldn't call them on it when they do. > > I completely agree. > >> They have got things wrong, > > I completely disagree. Understood :-) > >> and I have called them on it. > > Yes, you and a few others -- and nobody has actually talked (emailed) us > directly, but rather talked *about* us on the list [1]. https://mail.python.org/pipermail/python-list/2018-October/737396.html was addressed to you on the list (I don't think public decisions should be questioned in private). I posted to the "So apparently I've been banned..." thread as well, but that doesn't seem to be in the archive. Definitely one of my angrier posts, but to you rather than about you. I have actual work to do, so I'm not going to trawl the archives for other examples, but I'm pretty sure I'm not the only person to question you like that. >> The response has been... I'm trying not to say "patronising" because >> I'm fairly sure it wasn't meant that way, but "I'm sorry you feel that >> way" made me feel patronised. > > You're right, I didn't mean it that way, and I apologize. Thank you. I understand using formal language to show objectivity, but at the moment its also creating a them-and-us separation. It's a large chunk of the reason why I'm angry rather than merely lacking in respect for your collective decisions. > To briefly explain our decisions of late: > > Suspending D'Aprano: > ------------------- > His public post to me was shared with several people, including > moderators of others lists, and it was unanimously agreed that his post > was completely unacceptable and a two month suspension was appropriate. > I restarted that suspension because, according to his own words, "I am > ignoring the ban in this instance"; had he emailed me privately I would > have correctly posted the notice to the list; had he not said that and > just posted I would have fixed the filter and left the suspension alone > (he posts from comp.lang.python). I disagree with the original ban, frankly. Reimposing it seems petty. > Suspending Mark Lawrence: > ------------------------ > He has a history of posting attacks.? I sent him a private warning, he > responded a couple days later with another attack. No contest. Mark was way over the line, and it's not the first time. > Suspending BartC: > ---------------- > Many, if not most, of his posts' primary relation to Python was how his > personal language was better.? The resulting threads seemed to be > largely unfriendly, unproductive, and unnecessary. I killfiled Bart a long time ago for his poor signal to noise ratio, but that's as far as my reaction to him goes. I don't think "unfriendly, unproductive and unnecessary" are good enough reasons to ban him. Encourage people not to listen and not to feed the trolling, fine, but a ban is over the top. > Banning Rick Johnson: > -------------------- > Hopefully no explanation needed [2]. Explanation/justification needed, but given :-) Again, I killfiled Rick ages ago, and I agree his language does justify banning. > Shutting down threads: > --------------------- > There is a problem with threads getting heated and people not exercising > self-control and posting inappropriately.? That makes the list > unwelcoming.? As soon as we feel that that is happening we are going to > shut down the thread.? Personal attacks and name-calling are not > appropriate and will not be tolerated.? The goal is not to shut down > debate -- as long as the debate stays civil it will get no moderation > action.? If a thread is shut down and you feel there is more to be > (civilly) said -- wait a couple days so everyone can cool off, and then > start a new thread. Well, no. It doesn't work like that. Rapping people over the knuckles for name-calling and aggressive behaviour is all well and good, and doing more of that would be entirely appropriate. However regardless of what you think, shutting down threads *is* shutting down debate. The thread is closed, and there is a strong implication that the subject is taboo. Had I restarted it, I would have expected to be slapped. That's why I snuck a key argument about the master/slave debate into an entirely different thread, and didn't even reference the master/slave discussion. The impression that I'm getting is that in recent times the moderators have become heavy-handed. I realise that a certain amount of that is due to the rather blunt tools you have, but that doesn't make it any less heavy handed. That is something I don't, and never will, respect. > Hopefully you now agree with our decisions, or at least support us in > them.? If you don't, I actually am sorry -- I would much rather have > your support (and everyone's).? Either way, we are not changing our > minds about them. That's your privilege as moderators, and mine as an individual that I still don't agree with you. -- Rhodri James *-* Kynesim Ltd From rhodri at kynesim.co.uk Tue Oct 9 07:36:12 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 9 Oct 2018 12:36:12 +0100 Subject: Test before PR In-Reply-To: References: Message-ID: <3644fcba-6150-c088-1b4d-28e34f90f785@kynesim.co.uk> On 09/10/18 11:07, Abdur-Rahmaan Janhangeer wrote: > just a simple question. how do you test PR before merge? I doubt there's a single answer to that question. Some things like documentation changes can just be read, code reviews might work for sufficiently small changes, and so on. If you have a test suite, of course, run it. I'm an embedded engineer, and sometimes testing changes fully involve creating hardware setups that are not trivial. It's not always practical to run those tests for everything. You sometimes just have to make a judgement about what is reasonable to test, and hope that later QA and pre-release testing (which should involve running those hard-to-set-up tests) will catch anything that slips through. -- Rhodri James *-* Kynesim Ltd From Richard at Damon-Family.org Tue Oct 9 08:40:07 2018 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 9 Oct 2018 08:40:07 -0400 Subject: Observations on the List - "Be More Kind" In-Reply-To: <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: On 10/9/18 12:10 AM, jfong at ms4.hinet.net wrote: > I am wondering the role of the moderator. > > Does he own the server or pay the bill? Where he get the power to suspending people? Is he a police or judge? Can he shoot someone just because he has any reason? > > What will happen if his power was limited? Will the forum be end in disorder? No, I don't think so. We are mature enough to keep it running. > > --Jach > > Moderators are generally appointed by those who do 'pay the bill' for the mailing list they are moderators for, and serve at their pleasure. Mailing List are generally 'private property', though often made open to the public for general use. The owners of that property, generally have rights to establish rules for the public to use that property (perhaps somewhat constrained by whatever laws are applicable at the physical location that the mailing list server, owner or moderator resides at). Shoot, as in physically, generally no such right; metaphorically, as in sever discipline in list operations, generally yes, though perhaps limited from some grounds based on applicable Laws. From kwpolska at gmail.com Tue Oct 9 11:20:50 2018 From: kwpolska at gmail.com (Chris Warrick) Date: Tue, 9 Oct 2018 17:20:50 +0200 Subject: My environment doesn't load In-Reply-To: <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> Message-ID: On Tue, 9 Oct 2018 at 11:18, wrote: > > Here are the ouput during sourcing: > > > [ftg @ localhost] [/var/www/ffablob] > > % source env-p3/bin/activate > > [ftg @ localhost] [/var/www/ffablob] > > % which python > > /usr/bin/python > > and if I run some of my code that import beautyfulsoup it fails (python mycode.py), althoug running > directly ./env-p3/python3.5 mycode.py is working... Was the virtualenv copied between machines or directories? If yes: you can?t do that, you must create a new virtualenv in the desired location and install dependencies to it. -- Chris Warrick PGP: 5EAAEA16 From fabienluce at lutix.org Tue Oct 9 11:30:17 2018 From: fabienluce at lutix.org (Fabien LUCE) Date: Tue, 09 Oct 2018 15:30:17 +0000 Subject: My environment doesn't load In-Reply-To: References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> Message-ID: I rsynced the full local project directory (which contains the virtualenv dir) to a remote server. And there I couldn't enter into it. However, obviously apache2 achieved to... October 9 2018 5:21 PM, "Chris Warrick" wrote: > On Tue, 9 Oct 2018 at 11:18, wrote: > >> Here are the ouput during sourcing: >> >>> [ftg @ localhost] [/var/www/ffablob] >>> % source env-p3/bin/activate >>> [ftg @ localhost] [/var/www/ffablob] >>> % which python >>> /usr/bin/python >> >> and if I run some of my code that import beautyfulsoup it fails (python mycode.py), althoug running >> directly ./env-p3/python3.5 mycode.py is working... > > Was the virtualenv copied between machines or directories? If yes: you > can?t do that, you must create a new virtualenv in the desired > location and install dependencies to it. > > -- > Chris Warrick > PGP: 5EAAEA16 > -- > https://mail.python.org/mailman/listinfo/python-list From ftg at lutix.org Tue Oct 9 11:30:42 2018 From: ftg at lutix.org (ftg at lutix.org) Date: Tue, 09 Oct 2018 15:30:42 +0000 Subject: My environment doesn't load In-Reply-To: References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> Message-ID: <0e8c5f82af3d9f968ee40ed3a3a3b6fd@webmail.lutix.org> I rsynced the full local project directory (which contains the virtualenv dir) to a remote server. And there I couldn't enter into it. However, obviously apache2 achieved to... > October 9 2018 5:21 PM, "Chris Warrick" wrote: > >> On Tue, 9 Oct 2018 at 11:18, wrote: >> >>> Here are the ouput during sourcing: >>> >>>> [ftg @ localhost] [/var/www/ffablob] >>>> % source env-p3/bin/activate >>>> [ftg @ localhost] [/var/www/ffablob] >>>> % which python >>>> /usr/bin/python >>> >>> and if I run some of my code that import beautyfulsoup it fails (python mycode.py), althoug running >>> directly ./env-p3/python3.5 mycode.py is working... >> >> Was the virtualenv copied between machines or directories? If yes: you >> can?t do that, you must create a new virtualenv in the desired >> location and install dependencies to it. >> >> -- >> Chris Warrick >> PGP: 5EAAEA16 >> -- >> https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Tue Oct 9 11:34:10 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 10 Oct 2018 02:34:10 +1100 Subject: My environment doesn't load In-Reply-To: <0e8c5f82af3d9f968ee40ed3a3a3b6fd@webmail.lutix.org> References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> <0e8c5f82af3d9f968ee40ed3a3a3b6fd@webmail.lutix.org> Message-ID: On Wed, Oct 10, 2018 at 2:32 AM wrote: > > I rsynced the full local project directory (which contains the virtualenv dir) to a remote server. > And there I couldn't enter into it. > However, obviously apache2 achieved to... Not so obvious. It's possible Apache is ignoring the venv and just running the app in its own environment. As others have said, you should maintain a requirements.txt and then create a virtual environment on the target system. Since you're on a recent Python, ignore the old "virtualenv" package, and use "venv" from the stdlib. ChrisA From alister.ware at ntlworld.com Tue Oct 9 13:22:22 2018 From: alister.ware at ntlworld.com (Alister) Date: Tue, 09 Oct 2018 17:22:22 GMT Subject: Observations on the List - "Be More Kind" References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> Message-ID: On Mon, 08 Oct 2018 12:46:48 -0700, Ethan Furman wrote: > On 10/08/2018 07:43 AM, Rhodri James wrote: > >> I appreciate that the moderators are volunteers, but they have official >> power on this list.? Being volunteers doesn't mean that they can't get >> it wrong, or that we shouldn't call them on it when they do. > > I completely agree. > >> They have got things wrong, > > I completely disagree. from my reading the general feeling in the community would not support this > >> and I have called them on it. > > Yes, you and a few others -- and nobody has actually talked (emailed) us > directly, but rather talked *about* us on the list [1]. > >> The response has been... I'm trying not to say "patronising" because >> I'm fairly sure it wasn't meant that way, but "I'm sorry you feel that >> way" made me feel patronised. > > You're right, I didn't mean it that way, and I apologize. > > To briefly explain our decisions of late: > > Suspending D'Aprano: > ------------------- > His public post to me was shared with several people, including > moderators of others lists, and it was unanimously agreed that his post > was completely unacceptable and a two month suspension was appropriate. > I restarted that suspension because, according to his own words, "I am > ignoring the ban in this instance"; had he emailed me privately I would > have correctly posted the notice to the list; had he not said that and > just posted I would have fixed the filter and left the suspension alone > (he posts from comp.lang.python). after it be cam apparent that you had made an error, & the general feeling that the ban was a bit harsh it would have be far more beneficial to you reputation to have rescinded the ban on this occasion with a public warning regarding the claimed unacceptable behaviour. as it was your response of I made a mistake so I am going to restart the ban simply makes you look like a petulant child, I am sorely tempted to kill file you now myself. > > Suspending Mark Lawrence: > ------------------------ > He has a history of posting attacks. I sent him a private warning, he > responded a couple days later with another attack. > > Suspending BartC: > ---------------- > Many, if not most, of his posts' primary relation to Python was how his > personal language was better. The resulting threads seemed to be > largely unfriendly, unproductive, and unnecessary. > > Banning Rick Johnson: > -------------------- > Hopefully no explanation needed [2]. > > Shutting down threads: > --------------------- > There is a problem with threads getting heated and people not exercising > self-control and posting inappropriately. That makes the list > unwelcoming. As soon as we feel that that is happening we are going to > shut down the thread. Personal attacks and name-calling are not > appropriate and will not be tolerated. The goal is not to shut down > debate -- as long as the debate stays civil it will get no moderation > action. If a thread is shut down and you feel there is more to be > (civilly) said -- wait a couple days so everyone can cool off, and then > start a new thread. > > Hopefully you now agree with our decisions, or at least support us in > them. If you don't, I actually am sorry -- I would much rather have > your support (and everyone's). Either way, we are not changing our > minds about them. > > -- > ~Ethan~ > Python List Moderator > > > > [1] Please correct me if I'm wrong. > > [2] If one is needed: his posts can contain profanity, personal attacks, > condescension, and completely inappropriate language. -- What about WRITING it first and rationalizing it afterwords? :-) -- Larry Wall in <8162 at jpl-devvax.JPL.NASA.GOV> From rosuav at gmail.com Tue Oct 9 13:58:08 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 10 Oct 2018 04:58:08 +1100 Subject: Observations on the List - "Be More Kind" In-Reply-To: <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: On Wed, Oct 10, 2018 at 4:49 AM wrote: > > I am wondering the role of the moderator. > > Does he own the server or pay the bill? Where he get the power to suspending people? Is he a police or judge? Can he shoot someone just because he has any reason? > The mods represent the Python Software Foundation, which does own the servers. ChrisA From rosuav at gmail.com Tue Oct 9 14:03:36 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 10 Oct 2018 05:03:36 +1100 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: On Wed, Oct 10, 2018 at 4:57 AM Richard Damon wrote: > Shoot, as in physically, generally no such right; metaphorically, as in > sever discipline in list operations, generally yes, though perhaps > limited from some grounds based on applicable Laws. AIUI there is no law stating that I have to carry someone else's traffic. So the power to cut someone's traffic off my server is unlimited. (Principles like "free speech" are often misunderstood as "I have the right to say what I like, where I like, and to have people listen to me". That's not the case, particularly the last part.) ChrisA From fabienluce at gmail.com Tue Oct 9 14:25:59 2018 From: fabienluce at gmail.com (Fabien LUCE) Date: Tue, 9 Oct 2018 20:25:59 +0200 Subject: My environment doesn't load In-Reply-To: References: <89a9902d-e389-435e-ab41-75c17f036c63@tjol.eu> <03135433-e16a-747b-67f4-e585f7e18928@tjol.eu> <0a1ea996e0e5c874723adffefa9d522b@webmail.lutix.org> <3a624f926cec965cc5525f78ddeb072d@webmail.lutix.org> <6323d51ab78f0c940398bd7fa66de181@webmail.lutix.org> <051ea78dcbc65ee2bae6b6cec73aa730@webmail.lutix.org> <0e8c5f82af3d9f968ee40ed3a3a3b6fd@webmail.lutix.org> Message-ID: <20181009182559.GE21344@serveur.jeangui.eu> Well, Beautifulsoup is not On Wed, Oct 10, 2018 at 02:installed on my system, just in the environment, so how could apache run correctly my app without accessing my environment? I thought that venv or virtualenv point was only to create some folder which was simply sourced. What other things they do? 34:10AM +1100, Chris Angelico wrote: > On Wed, Oct 10, 2018 at 2:32 AM wrote: > > > > I rsynced the full local project directory (which contains the virtualenv dir) to a remote server. > > And there I couldn't enter into it. > > However, obviously apache2 achieved to... > > Not so obvious. It's possible Apache is ignoring the venv and just > running the app in its own environment. > > As others have said, you should maintain a requirements.txt and then > create a virtual environment on the target system. Since you're on a > recent Python, ignore the old "virtualenv" package, and use "venv" > from the stdlib. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From vergos.nikolas at gmail.com Tue Oct 9 14:29:34 2018 From: vergos.nikolas at gmail.com (vergos.nikolas at gmail.com) Date: Tue, 9 Oct 2018 11:29:34 -0700 (PDT) Subject: Return html data + serve a file Message-ID: Hello, iam using Python + Flask. Iam trying to print some html and also serve a file to the user. My code is: pdata = pdata + '''''' # Prepare selected file for download.... filename = request.form.get('filename') filepath = '/home/user/wsgi/static/files/' yield send_from_directory( filepath, filename, as_attachment=True ) return pdata The error i'm receiving is: TypeError: 'generator' object is not callable The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a generator. Can you help me understand why iam getting this error and how i should write it? From hjp-python at hjp.at Tue Oct 9 15:54:05 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Tue, 9 Oct 2018 21:54:05 +0200 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> Message-ID: <20181009195405.oxim4lno3joxmh3q@hjp.at> On 2018-10-08 12:46:48 -0700, Ethan Furman wrote: > On 10/08/2018 07:43 AM, Rhodri James wrote: > > I appreciate that the moderators are volunteers, but they have official > > power on this list.? Being volunteers doesn't mean that they can't get > > it wrong, or that we shouldn't call them on it when they do. > > I completely agree. > > > They have got things wrong, > > I completely disagree. > > > and I have called them on it. > > Yes, you and a few others -- and nobody has actually talked (emailed) us > directly, but rather talked *about* us on the list [1]. I haven't posted on the issue before, but I think that the right place to discuss moderation policy is on the list and not in private communication. I also think that it would be better if you warned people with unacceptable behaviour in public. Looking back through my archive (I've been on the list only for a year or so, I was reading the newsgroup before), I see that you did ask people to tone it down a couple of times. That's good. But AFAICT these people were newbies. You didn't admonish Steve or Mark or Bart or Rick (all of them long-time regulars) that they are getting close to being banned (instead you wrote once that people should just ignore Bart). This created the impression that their behaviour was ok for the moderation. And then - seemingly out of the blue - they were banned. In some cases without an explanation (at the time). This makes it a bit hard to know what is and is not acceptable on this list. [explanations snipped] hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From tjreedy at udel.edu Tue Oct 9 21:17:18 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 9 Oct 2018 21:17:18 -0400 Subject: From Mathematica to Jypyter Message-ID: https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper/ Jupyter, Mathematica, and the Future of the Research Paper Paul Romer, new Nobel prize winner in economics, for research on how ideas interact with economic growth, explained last April why he has switched from Mathematica to Jupyter. -- Terry Jan Reedy From jfong at ms4.hinet.net Tue Oct 9 22:18:05 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Tue, 9 Oct 2018 19:18:05 -0700 (PDT) Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: Richard Damon at 2018.10.9 UTC+8 PM 8:40:29 wrote: > Moderators are generally appointed by those who do 'pay the bill' for > the mailing list they are moderators for, and serve at their pleasure. > Mailing List are generally 'private property', though often made open to > the public for general use. The owners of that property, generally have > rights to establish rules for the public to use that property (perhaps > somewhat constrained by whatever laws are applicable at the physical > location that the mailing list server, owner or moderator resides at). > > Shoot, as in physically, generally no such right; metaphorically, as in > sever discipline in list operations, generally yes, though perhaps > limited from some grounds based on applicable Laws. Then, I respect their right of doing this if it's a 'private property'. I switched from comp.lang.python to mailing list a few months ago for those spam threads there. Now it seems a bad decision because 1) replied mail can be lost or duplicated or even banned. 2) look at each separately mail is not as comfortable as at a single thread. 3) Google group is a more free land to live. So, have to switch back to comp.lang.python to get ride of all these problems. --Jach From rosuav at gmail.com Tue Oct 9 22:31:07 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 10 Oct 2018 13:31:07 +1100 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: On Wed, Oct 10, 2018 at 1:21 PM wrote: > I switched from comp.lang.python to mailing list a few months ago for those spam threads there. Now it seems a bad decision because 1) replied mail can be lost or duplicated or even banned. 2) look at each separately mail is not as comfortable as at a single thread. 3) Google group is a more free land to live. > > So, have to switch back to comp.lang.python to get ride of all these problems. > Well, just be aware that a lot of people block ALL posts that come from Google Groups. The signal-to-noise ratio there is sufficiently low that it's often just not worth carrying that traffic. So you're welcome to switch over to there to get freedom, but you're basically getting the Wild West, where spammers run free and the lawless rule... and the genteel avoid the place. ChrisA From jfong at ms4.hinet.net Tue Oct 9 23:12:53 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Tue, 9 Oct 2018 20:12:53 -0700 (PDT) Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: Chris Angelico at 2018.10.10 UTC+8 AM 10:31:33 wrote: > On Wed, Oct 10, 2018 at 1:21 PM wrote: > > I switched from comp.lang.python to mailing list a few months ago for those spam threads there. Now it seems a bad decision because 1) replied mail can be lost or duplicated or even banned. 2) look at each separately mail is not as comfortable as at a single thread. 3) Google group is a more free land to live. > > > > So, have to switch back to comp.lang.python to get ride of all these problems. > > > > Well, just be aware that a lot of people block ALL posts that come > from Google Groups. The signal-to-noise ratio there is sufficiently > low that it's often just not worth carrying that traffic. So you're > welcome to switch over to there to get freedom, but you're basically > getting the Wild West, where spammers run free and the lawless rule... > and the genteel avoid the place. > > ChrisA Wild West? haha.. nice metaphor, thanks for reminding. But, in cyberspace, I prefer more freedom than more safety:-) --Jach From Richard at Damon-Family.org Tue Oct 9 23:18:27 2018 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 9 Oct 2018 23:18:27 -0400 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: <4197a567-26ee-5584-3d9f-d07170da65e0@Damon-Family.org> On 10/9/18 2:03 PM, Chris Angelico wrote: > On Wed, Oct 10, 2018 at 4:57 AM Richard Damon wrote: >> Shoot, as in physically, generally no such right; metaphorically, as in >> sever discipline in list operations, generally yes, though perhaps >> limited from some grounds based on applicable Laws. > AIUI there is no law stating that I have to carry someone else's > traffic. So the power to cut someone's traffic off my server is > unlimited. > > (Principles like "free speech" are often misunderstood as "I have the > right to say what I like, where I like, and to have people listen to > me". That's not the case, particularly the last part.) > > ChrisA My comment is about laws regarding 'Protected Classes', which once you open yourself to providing services to the 'general public' you are not allow to decide not to serve a particular person because of their membership in a 'Protected Class' (but could perhaps deny them for other grounds). -- Richard Damon From robin at reportlab.com Wed Oct 10 03:32:26 2018 From: robin at reportlab.com (Robin Becker) Date: Wed, 10 Oct 2018 08:32:26 +0100 Subject: From Mathematica to Jypyter In-Reply-To: References: Message-ID: On 10/10/2018 02:17, Terry Reedy wrote: > https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper/ > Jupyter, Mathematica, and the Future of the Research Paper > Paul Romer, new Nobel prize winner in economics, for research on how ideas interact with economic growth, explained last April why > he has switched from Mathematica to Jupyter. > I'm a great fan of erroneous spelling and this blog needs a spelling check as this quote shows "Mathematica exemplifies the horde of new Vandals whose pursuit of private gain threatens a far greater pubic loss?the collapse of social systems that took centuries to build." these Vandals are probably not in favour of the #me-too movement either :) -- Robin Becker From arj.python at gmail.com Wed Oct 10 03:36:35 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 10 Oct 2018 11:36:35 +0400 Subject: Test before PR In-Reply-To: <3644fcba-6150-c088-1b4d-28e34f90f785@kynesim.co.uk> References: <3644fcba-6150-c088-1b4d-28e34f90f785@kynesim.co.uk> Message-ID: ok, thank you! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius From antoon.pardon at vub.be Wed Oct 10 05:13:31 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Wed, 10 Oct 2018 11:13:31 +0200 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: <4b9b63ce-5f5d-5200-96ce-1de33c9bf92c@vub.be> On 10-10-18 04:18, jfong at ms4.hinet.net wrote: > Richard Damon at 2018.10.9 UTC+8 PM 8:40:29 wrote: >> Moderators are generally appointed by those who do 'pay the bill' for >> the mailing list they are moderators for, and serve at their pleasure. >> Mailing List are generally 'private property', though often made open to >> the public for general use. The owners of that property, generally have >> rights to establish rules for the public to use that property (perhaps >> somewhat constrained by whatever laws are applicable at the physical >> location that the mailing list server, owner or moderator resides at). >> >> Shoot, as in physically, generally no such right; metaphorically, as in >> sever discipline in list operations, generally yes, though perhaps >> limited from some grounds based on applicable Laws. > Then, I respect their right of doing this if it's a 'private property'. > > I switched from comp.lang.python to mailing list a few months ago for those spam threads there. Now it seems a bad decision because 1) replied mail can be lost or duplicated or even banned. That seems a bit incoherent. How did you think those spam thread are to be avoided? > 2) look at each separately mail is not as comfortable as at a single thread. Any decent mail client can group related messages in threads. > 3) Google group is a more free land to live. Possibly, each has to choose their own priorities. I perfer choosing the medium that maximizes the chance of being noticed after your contribution was allowed, over maximizing the chance that your contribution will be "allowed", but lessening the chance it will be noticed. -- Antoon. From dan at djph.net Wed Oct 10 05:22:31 2018 From: dan at djph.net (Dan Purgert) Date: Wed, 10 Oct 2018 09:22:31 -0000 (UTC) Subject: Observations on the List - "Be More Kind" References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <1d083bbc-deec-4383-8b35-e56cc9a27a9f@googlegroups.com> Message-ID: jfong at ms4.hinet.net wrote: > Chris Angelico at 2018.10.10 UTC+8 AM 10:31:33 wrote: >> On Wed, Oct 10, 2018 at 1:21 PM wrote: >> > [...] 3) Google group is a more free land to live. >> > >> > >> >> Well, just be aware that a lot of people block ALL posts that come >> from Google Groups. [...] > > Wild West? haha.. nice metaphor, thanks for reminding. But, in > cyberspace, I prefer more freedom than more safety:-) You don't *have* to use GG to get Usenet access. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From kw at codebykevin.com Wed Oct 10 08:52:02 2018 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 10 Oct 2018 08:52:02 -0400 Subject: Python on 10.14 Mojave Message-ID: I'm trying to build Python 3.7.0 on macOS 10.14, and Tkinter is not linking to my installation of Tcl/Tk 8.6.8 in /Library/Frameworks. Instead it is linking to the ancient 8.5 Tk installed in /System/Library/Frameworks. My usual way of forcing Python to link to my installation is to edit setup.py and comment out all search directories except /Library/Frameworks, but that seems to be ignored here. Is there any other way to link to the correct frameworks? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From daankahmann01 at gmail.com Wed Oct 10 09:53:32 2018 From: daankahmann01 at gmail.com (daankahmann01 at gmail.com) Date: Wed, 10 Oct 2018 06:53:32 -0700 (PDT) Subject: Python doesn't install Message-ID: <4023e28d-9db1-4d89-b190-a39a18e6df48@googlegroups.com> Hi Guys! I have an annoying problem, I can download Python (from python.org) but it won't install on my laptop. If I try to open the installer, it closes again. I also don't get a error message. I'm using windows 10. I already tried most of the obvious things like restarting, deleting the program and downloading it again and I tried windows problem solver from tweaking.com. But nothing seems te work. Does anyone know how I might be able to fix this? Thanks! From tjol at tjol.eu Wed Oct 10 09:58:12 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 10 Oct 2018 15:58:12 +0200 Subject: Python on 10.14 Mojave In-Reply-To: References: Message-ID: <58745b42-cc13-4079-ca84-a489a7544303@tjol.eu> On 2018-10-10 14:52, Kevin Walzer wrote: > I'm trying to build Python 3.7.0 on macOS 10.14, and Tkinter is not > linking to my installation of Tcl/Tk 8.6.8 in /Library/Frameworks. > Instead it is linking to the ancient 8.5 Tk installed in > /System/Library/Frameworks. My usual way of forcing Python to link to my > installation is to edit setup.py and comment out all search directories > except /Library/Frameworks, but that seems to be ignored here. Is there > any other way to link to the correct frameworks? > My knowledge of macOS is based mostly on hearsay, but I suppose the usual way would be to specify appropriate ./configure flags -- which might be mentioned in ./configure --help. % ./configure --help | grep -i tcl --with-tcltk-includes='-I...' override search for Tcl and Tk include files --with-tcltk-libs='-L...' override search for Tcl and Tk libs From jfine2358 at gmail.com Wed Oct 10 11:23:36 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Wed, 10 Oct 2018 08:23:36 -0700 (PDT) Subject: Paul Romer, 2018 Economics Nobel Laureate, uses Python and Jupyter In-Reply-To: References: Message-ID: Terry Reedy wrote: > https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper/ > Jupyter, Mathematica, and the Future of the Research Paper > Paul Romer, new Nobel prize winner in economics, for research on how > ideas interact with economic growth, explained last April why he has > switched from Mathematica to Jupyter. Well done, Terry, for spotting this. I hope you don't mind, I've changed the subject to give Paul Romer star billing. I think he deserves it. Here's some URLs on Romer and Python. https://qz.com/1417145/economics-nobel-laureate-paul-romer-is-a-python-programming-convert/ https://developers.slashdot.org/story/18/10/09/0042240/economics-nobel-laureate-paul-romer-is-a-python-programming-convert https://www.reddit.com/r/Python/comments/9mhxq2/this_years_nobel_prize_in_economics_was_awarded/ https://news.ycombinator.com/item?id=18173812&ref=hvper.com&utm_source=hvper.com&utm_medium=website https://www.wsj.com/articles/nobel-in-economics-goes-to-american-pair-1538992672 And some related URLs https://www.nature.com/articles/d41586-018-01322-9 # Future of online publishing https://pypi.org/project/nobel/ # Python interface to Nobel Prize API! https://jfine2358.github.io/slides/2018-nature-jupyter-altair-vega-binder.html And some Python code: >>> import nobel >>> api = nobel.Api() >>> api.prizes.filter(year=2018, category='economics')[0].laureates[1].surname u'Romer' -- Jonathan From rhodri at kynesim.co.uk Wed Oct 10 12:09:10 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 10 Oct 2018 17:09:10 +0100 Subject: From Mathematica to Jypyter In-Reply-To: References: Message-ID: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> On 10/10/18 08:32, Robin Becker wrote: > On 10/10/2018 02:17, Terry Reedy wrote: >> https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper/ >> >> Jupyter, Mathematica, and the Future of the Research Paper >> Paul Romer, new Nobel prize winner in economics, for research on how >> ideas interact with economic growth, explained last April why he has >> switched from Mathematica to Jupyter. >> > > I'm a great fan of erroneous spelling and this blog needs a spelling > check as this quote shows > > "Mathematica exemplifies the horde of new Vandals whose pursuit of > private gain threatens a far greater pubic loss?the collapse of social > systems that took centuries to build." > > these Vandals are probably not in favour of the #me-too movement either :) OK, colour me confused. The only spelling mistake I can spot in that is in the subject line of this thread. What am I missing? -- Rhodri James *-* Kynesim Ltd From jfine2358 at gmail.com Wed Oct 10 12:24:39 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Wed, 10 Oct 2018 09:24:39 -0700 (PDT) Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: Rhodri James wrote: > Robin Becker wrote: > > I'm a great fan of erroneous spelling and this blog needs a spelling > > check as this quote shows [Paul Romer's blog] > > "Mathematica exemplifies the horde of new Vandals whose pursuit of > > private gain threatens a far greater pubic loss?the collapse of social > > systems that took centuries to build." > > these Vandals are probably not in favour of the #me-too movement either :) > OK, colour me confused. The only spelling mistake I can spot in that is > in the subject line of this thread. What am I missing? In addition to Jypyter for Jupyter, there are TWO typos above. One in Paul Romer's blog, followed by one in Robin Becker's comment. -- Jonathan From codewizard at gmail.com Wed Oct 10 12:25:46 2018 From: codewizard at gmail.com (codewizard at gmail.com) Date: Wed, 10 Oct 2018 09:25:46 -0700 (PDT) Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: <33096fdd-138e-4c5a-babf-49560221e471@googlegroups.com> On Wednesday, October 10, 2018 at 12:09:41 PM UTC-4, Rhodri James wrote: > On 10/10/18 08:32, Robin Becker wrote: > > > > I'm a great fan of erroneous spelling and this blog needs a spelling > > check as this quote shows > > > > "Mathematica exemplifies the horde of new Vandals whose pursuit of > > private gain threatens a far greater pubic loss?the collapse of social > > systems that took centuries to build." > > > > these Vandals are probably not in favour of the #me-too movement either :) > > OK, colour me confused. The only spelling mistake I can spot in that is > in the subject line of this thread. What am I missing? The loss is far greater than a single letter. :) From tjreedy at udel.edu Wed Oct 10 13:20:07 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 10 Oct 2018 13:20:07 -0400 Subject: Python doesn't install In-Reply-To: <4023e28d-9db1-4d89-b190-a39a18e6df48@googlegroups.com> References: <4023e28d-9db1-4d89-b190-a39a18e6df48@googlegroups.com> Message-ID: On 10/10/2018 9:53 AM, daankahmann01 at gmail.com wrote: > I have an annoying problem, I can download Python (from python.org) but it won't install on my laptop. If I try to open the installer, it closes again. I also don't get a error message. I'm using windows 10. I already tried most of the obvious things like restarting, deleting the program and downloading it again and I tried windows problem solver from tweaking.com. But nothing seems to work. Does anyone know how I might be able to fix this? Which exact binary? Have you tried other versions? Have you installed Python before? -- Terry Jan Reedy From daankahmann01 at gmail.com Wed Oct 10 14:05:30 2018 From: daankahmann01 at gmail.com (Daan Kahmann) Date: Wed, 10 Oct 2018 11:05:30 -0700 (PDT) Subject: Python doesn't install In-Reply-To: References: <4023e28d-9db1-4d89-b190-a39a18e6df48@googlegroups.com> Message-ID: Op woensdag 10 oktober 2018 19:20:42 UTC+2 schreef Terry Reedy: > On 10/10/2018 9:53 AM, daankahmann01 at gmail.com wrote: > > > I have an annoying problem, I can download Python (from python.org) but it won't install on my laptop. If I try to open the installer, it closes again. I also don't get a error message. I'm using windows 10. I already tried most of the obvious things like restarting, deleting the program and downloading it again and I tried windows problem solver from tweaking.com. But nothing seems to work. Does anyone know how I might be able to fix this? > > Which exact binary? Have you tried other versions? Have you installed > Python before? > > -- > Terry Jan Reedy version 3.7.0, I have tried installing other versions but I get the same problem. I have not installed Python on this laptop before. Daan Kahmann From rhodri at kynesim.co.uk Wed Oct 10 14:07:17 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 10 Oct 2018 19:07:17 +0100 Subject: Observations on the List - "Be More Kind" In-Reply-To: <4310a16b-629b-e905-cab5-54909a370b0e@kynesim.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> <4310a16b-629b-e905-cab5-54909a370b0e@kynesim.co.uk> Message-ID: <66b9144d-de1f-bd71-d2af-d3c2bff121f8@kynesim.co.uk> On 09/10/18 12:12, Rhodri James wrote: > On 08/10/18 20:46, Ethan Furman wrote: >> Banning Rick Johnson: >> -------------------- >> Hopefully no explanation needed [2]. > > Explanation/justification needed, but given :-)? Again, I killfiled Rick > ages ago, and I agree his language does justify banning. Now I've had a chance to go back through the archive (it's been that kind of day at work), I'm going to have to recant. I can't find anything that Rick wrote in the week or two before the ban that I would call offensive, and not much that even gets as far as irritating. I can think of past instances where his behaviour would have justified a ban, but in recent times? Not really. That's getting perilously close to banning people because we don't like them. We may be entirely justified in our dislike, but that's not enough on its own. And that, I'm afraid, is very much what the recent spate of bans looks like. -- Rhodri James *-* Kynesim Ltd From ethan at stoneleaf.us Wed Oct 10 14:14:14 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 10 Oct 2018 11:14:14 -0700 Subject: Observations on the List - "Be More Kind" In-Reply-To: <66b9144d-de1f-bd71-d2af-d3c2bff121f8@kynesim.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> <4310a16b-629b-e905-cab5-54909a370b0e@kynesim.co.uk> <66b9144d-de1f-bd71-d2af-d3c2bff121f8@kynesim.co.uk> Message-ID: On 10/10/2018 11:07 AM, Rhodri James wrote: > Now I've had a chance to go back through the archive (it's been that > kind of day at work), I'm going to have to recant.? I can't find > anything that Rick wrote in the week or two before the ban Where are you looking? -- ~Ethan~ From larry.martell at gmail.com Wed Oct 10 14:27:32 2018 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 10 Oct 2018 14:27:32 -0400 Subject: Observations on the List - "Be More Kind" In-Reply-To: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: On Fri, Oct 5, 2018 at 6:54 AM Bruce Coram wrote: > > I will declare at the outset, I am a lurker. I don't know enough about > Python to give advice that I could 100% guarantee would be helpful. > > There have been two recent threads that summarise for me where the > Python Mailing List has lost its way (and this started before Trump > arrived as a new role model for how to treat your fellow man): I do not think a Trump reference is approprate here at all. I could start a political rant here, but I won't. If you think this list is harsh you must not have been on the internet very long. This is a post that was going around back in 1996: Welcome to the Internet. No one here likes you. We're going to offend, insult, abuse, and belittle the living hell out of you. And when you rail against us with "FUCK YOU YOU GEEK WIMP SKATER GOTH LOSER PUNK FAG BITCH!1!!", we smile to ourselves. We laugh at you because you don't get it. Then we turn up the heat, hoping to draw more entertainment from your irrational fuming. We will judge you, and we will find you unworthy. It is a trial by fire, and we won't even think about turning down the flames until you finally understand. Some of you are smart enough to realize that, when you go online, it's like entering a foreign country ... and you know better than to ignorantly fuck with the locals. You take the time to listen and think before speaking. You learn, and by learning are gladly welcomed. For some of you, it takes a while, then one day it all dawns on you - you get it, and are welcomed into the fold. Some of you give up, and we breathe a sigh of relief - we didn't want you here anyway. And some of you just never get it. The offensively clueless have a special place in our hearts - as objects of ridicule. We don't like you, but we do love you. You will get mad. You will tell us to go to hell, and call us "nerds" and "geeks". Don't bother ... we already know exactly what we are. And, much like the way hardcore rap has co-opted the word "nigger", turning an insult around on itself to become a semiserious badge of honor, so have we done. "How dare you! I used to beat the crap out of punks like you in high school/college!" You may have owned the playing field because you were an athlete. You may have owned the student council because you were more popular. You may have owned the hallways and sidewalks because you were big and intimidating. Well, welcome to our world. Things like athleticism, popularity, and physical prowess mean nothing here. We place no value on them ... or what car you drive, the size of your bank account, what you do for a living or where you went to school. Allow us to introduce you to the concept of a "meritocracy" - the closest thing to a form of self-government we have. In The United Meritocratic nation-states of the Internet, those who can do, rule. Those who wish to rule, learn. Everyone else watches from the stands. You may posses everything in the off-line world. We don't care. You come to the Internet penniless, lacking the only thing of real value here: knowledge. "Who cares? The Internet isn't real anyway!" This attitude is universally unacceptable. The Internet is real. Real people live behind those handles and screen names. Real machines allow it to exist. It's real enough to change government policy, real enough to feed the world's hungry, and even, for some of us, real enough to earn us a paycheck. Using your own definition, how "real" is your job? Your stock portfolio? Your political party? What is the meaning of "real", anyway? Do I sound arrogant? Sure ... to you. Because you probably don't get it yet. If you insist on staying, then, at the very least, follow this advice: 1) No one, ESPECIALLY YOU, will make any law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the government for a redress of grievances. 2) Use your brain before ever putting fingers to keys. 3) Do you want a picture of you getting anally raped by Bill Clinton while you're performing oral sex on a cow saved to hundreds of thousands of people's hard drives? No? Then don't put your fucking picture on the Internet. We can, will, and probably already HAVE altered it in awful ways. Expect it to show up on an equally offensive website. 4) Realize that you are never, EVER going to get that, or any other, offensive web page taken down. Those of us who run those sites LIVE to piss off people like you. Those of us who don't run those sites sometimes visit them just to read the hatemail from fools like you. 5) Oh, you say you're going to a lawyer? Be prepared for us to giggle with girlish delight, and for your lawyer to laugh in your face after he explains current copyright and parody law. 6) The Web is not the Internet. Stop referring to it that way. 7) We have already received the e-mail you are about to forward to us. Shut up. 8) Don't reply to spam. You are not going to be "unsubscribed". 9) Don't ever use the term "cyberspace" (only William Gibson gets to say that, and even he hasn't really used it for two or three books now). Likewise, you prove yourself a marketing-hype victim if you ever use the term "surfing". 10) With one or two notable exceptions, chat rooms will not get you laid. 11) It's a hoax, not a virus warning. 12) The internet is made up of thousands of computers, all connected but owned by different people. Learn how to use *your* computer before attempting to connect it to someone else's. 13) The first person who offers to help you is really just trying to fuck with you for entertainment. So is the second. And the third. And me. 14) Never insult someone who's been active in any group longer than you have. You may as well paint a damn target on your back. 15) Never get comfortable and arrogant behind your supposed mask of anonymity. Don't be surprised when your name, address, and home phone number get thrown back in your smug face. Hell, some of us will snail-mail you a printed satellite photograph of your house to drive the point home. Realize that you are powerless if this happens ... it's all public information, and information is our stock and trade. 16) No one thinks you are as cool as you think you are. 17) You aren't going to win any argument that you start. 18) If you're on AOL, don't worry about anything I've said here. You're already a fucking laughing stock, and there's no hope for you. 19) If you can't take a joke, immediately sell your computer to someone who can. RIGHT NOW. Pissed off? It's the TRUTH, not these words, that hurts your feelings. Don't ever even pretend like I've gone & hurt them. We don't like you. We don't want you here. We never will. Save us all the trouble and go away. From neilc at norwich.edu Wed Oct 10 16:02:19 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 10 Oct 2018 20:02:19 GMT Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: On 2018-10-06, eliteanarchyracer at gmail.com wrote: > Hi, I am new to python and would like someones help on the > following: > > After rolling 5 dice and putting the results into a list, I > need to check if any dice is not a 1 or 5. if any(roll != 1 and roll != 5 for roll in result): > # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: ) > print("you can roll again") > else: > print("you have all 1's and 5's in your result") Ha! Didn't think I'd get to apply DeMorgan's Law so soon. -- Neil Cerutti From rshepard at appl-ecosys.com Wed Oct 10 16:05:47 2018 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 10 Oct 2018 13:05:47 -0700 (PDT) Subject: Python3 packages installation Message-ID: Here, both python-2.7.15 and python3-3.6.6 are installed. Using pip (which I understand works with both python versions) I was able to install ipython, matplotlib, numpy, and pandas. They're all in /usr/lib64/python2.7/site-packages. Now I want to install the same packages for python3 so they are are found also in /usr/lib64/python3.6/site-packages. I've not found the proper command line syntax to do this. When I try, for example, 'python3 -m pip install numpy3' the system tells me that pip is not available. I want to learn how to manage both series since some of the applications I regularly use require python2 while any python scripts I now write use python3. If there's a document or web site that explains how to manage both versions please point me to it. Rich From arj.python at gmail.com Wed Oct 10 16:22:50 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 11 Oct 2018 00:22:50 +0400 Subject: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST In-Reply-To: References: <27350a17-a68a-44ca-84ed-7a4ed9f939ac@googlegroups.com> Message-ID: *if any(roll != 1 and roll != 5 for roll in result):* another extract of py's beauty! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius From neilc at norwich.edu Wed Oct 10 16:42:35 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 10 Oct 2018 20:42:35 GMT Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> Message-ID: On 2018-10-09, Paul Rubin wrote: > If anyone cares, Eric Raymond posted a big rant saying > basically he's giving up on Python and porting a big program > he's working on to Go. Reasons he gives are > performance (Go is 40x faster for his app) > memory footprint (high overhead of simple Python objects cause > his 64GB 16 core box to OOM on his data) As Stephen said, it's sort of silly not to be aware of those issues going in. > the GIL (15/16th of his CPUs are unused, of course there are > ways around that but I'm summarizing what he says even when I > don't fully agree), Channels are a big selling point of Go, no argument there. Using them right is considerably trickier than it appears at first, but they have good syntax and feel lightweight. > Unicode (he says Go's uniform use of UTF8 is better than > Python's bloaty codepoint lists), Go's system for character encoding is objectively worse, IMHO. Both Python and Go require you to decode to an internal unicode storage format on the way into your program, and to encode it again on the way out. But the internal storage formats are not equally usable. The internal storage format is UTF8 in Go, but it's regarded simply as bytes by most normal operations and functions. You must carefully use a different set of functions and operators to regard the bytes as unicode code-points. So Go makes it easy to do things incorrectly, a la Python 2, which is a benefit only if you just don't care to do things correctly. On the other hand, I only used Go until it made me feel really annoyed that I couldn't build my own data types and interfaces without feeling like they were 2nd or 3rd class citizens, forced to carry around heavy, clunking chains, while the builtin types and interfaces enjoyed unfair syntax and usability privileges. I tried to be open minded about the error propogation mechanism in Go, but it remained stubbornly frustrating, especially when designing my own interface. > It is ranty and there are parts I don't agree with, but I think > it is worth reading. It is around 300 lines, followed by > several pages of reader comments. > > http://esr.ibiblio.org/?p=8161 Thanks for sharing it. -- Neil Cerutti From greg.ewing at canterbury.ac.nz Wed Oct 10 17:32:34 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 11 Oct 2018 10:32:34 +1300 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: Rhodri James wrote: >> I'm a great fan of erroneous spelling and this blog needs a spelling >> check as this quote shows >> >> "Mathematica exemplifies the horde of new Vandals whose pursuit of >> private gain threatens a far greater pubic loss?the collapse of social >> systems that took centuries to build." > > OK, colour me confused. The only spelling mistake I can spot in that is > in the subject line of this thread. What am I missing? Presumably Romer meant that it was a loss suffered by everyone, but that's not quite what he wrote. BTW, an automatic spelling checker wouldn't have helped here. We really need to redesign English spelling so that it has error correction built in. -- Greg From rosuav at gmail.com Wed Oct 10 17:39:27 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 11 Oct 2018 08:39:27 +1100 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: On Thu, Oct 11, 2018 at 8:36 AM Gregory Ewing wrote: > > BTW, an automatic spelling checker wouldn't have helped here. > We really need to redesign English spelling so that it has > error correction built in. You mean at the level of words, or sentences? A sentence already has enough redundancy that it's frequently possible to reconstruct the original intent despite errors (as in this case), but it's impossible to be 100% certain in all cases without either severely limiting the forms of communication, or simply increasing redundancy, which will result in abbreviation. ChrisA From jf_byrnes at comcast.net Wed Oct 10 17:47:28 2018 From: jf_byrnes at comcast.net (Jim) Date: Wed, 10 Oct 2018 16:47:28 -0500 Subject: Python3 packages installation In-Reply-To: References: Message-ID: On 10/10/2018 03:05 PM, Rich Shepard wrote: > ? Here, both python-2.7.15 and python3-3.6.6 are installed. Using pip > (which > I understand works with both python versions) I was able to install > ipython, matplotlib, numpy, and pandas. They're all in > /usr/lib64/python2.7/site-packages. > > ? Now I want to install the same packages for python3 so they are are > found > also in /usr/lib64/python3.6/site-packages. I've not found the proper > command line syntax to do this. > > ? When I try, for example, 'python3 -m pip install numpy3' the system > tells > me that pip is not available. I want to learn how to manage both series > since some of the applications I regularly use require python2 while any > python scripts I now write use python3. > > ? If there's a document or web site that explains how to manage both > versions please point me to it. > > Rich I think you have to first install a package called 'python3-pip'. At least that's what I had to do on Ubuntu. Regards, Jim From rshepard at appl-ecosys.com Wed Oct 10 17:55:03 2018 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 10 Oct 2018 14:55:03 -0700 (PDT) Subject: Python3 packages installation In-Reply-To: References: Message-ID: On Wed, 10 Oct 2018, Jim wrote: > I think you have to first install a package called 'python3-pip'. At least > that's what I had to do on Ubuntu. Jim, Well, it did not occur to me to try a hyphenated name. I'm sure that's the solution. Thanks for the pointer! Best regards, Rich From tjol at tjol.eu Wed Oct 10 18:23:39 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 11 Oct 2018 00:23:39 +0200 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: On 10/10/2018 23:32, Gregory Ewing wrote: > Rhodri James wrote: >>> I'm a great fan of erroneous spelling and this blog needs a spelling >>> check as this quote shows >>> >>> "Mathematica exemplifies the horde of new Vandals whose pursuit of >>> private gain threatens a far greater pubic loss?the collapse of >>> social systems that took centuries to build." >> >> OK, colour me confused.? The only spelling mistake I can spot in that >> is in the subject line of this thread.? What am I missing? > > Presumably Romer meant that it was a loss suffered by everyone, > but that's not quite what he wrote. Sure it is. He's contrasting *private* gain with *public* loss. If there is any ambiguity here it is whether there is a threat *of* a public loss, or *to* a public loss ^_^ Still, there is a mistake here (and just the one) ? that's not the right way to use an en-dash. > > BTW, an automatic spelling checker wouldn't have helped here. > We really need to redesign English spelling so that it has > error correction built in. > From rosuav at gmail.com Wed Oct 10 19:26:55 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 11 Oct 2018 10:26:55 +1100 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: On Thu, Oct 11, 2018 at 10:09 AM Thomas Jollans wrote: > > On 10/10/2018 23:32, Gregory Ewing wrote: > > Rhodri James wrote: > >>> I'm a great fan of erroneous spelling and this blog needs a spelling > >>> check as this quote shows > >>> > >>> "Mathematica exemplifies the horde of new Vandals whose pursuit of > >>> private gain threatens a far greater pubic loss?the collapse of > >>> social systems that took centuries to build." > >> > >> OK, colour me confused. The only spelling mistake I can spot in that > >> is in the subject line of this thread. What am I missing? > > > > Presumably Romer meant that it was a loss suffered by everyone, > > but that's not quite what he wrote. > > Sure it is. He's contrasting *private* gain with *public* loss. If there > is any ambiguity here it is whether there is a threat *of* a public > loss, or *to* a public loss ^_^ Now read the quote again, very VERY carefully. The human brain is very good at ignoring insignificant errors. (The troll brain is very good at pointing out insignificant errors.) ChrisA From tjol at tjol.eu Wed Oct 10 19:29:08 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 11 Oct 2018 01:29:08 +0200 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: <0a81798f-6f18-81d4-05f4-38f70f23474d@tjol.eu> On 11/10/2018 01:26, Chris Angelico wrote: > On Thu, Oct 11, 2018 at 10:09 AM Thomas Jollans wrote: >> >> On 10/10/2018 23:32, Gregory Ewing wrote: >>> Rhodri James wrote: >>>>> I'm a great fan of erroneous spelling and this blog needs a spelling >>>>> check as this quote shows >>>>> >>>>> "Mathematica exemplifies the horde of new Vandals whose pursuit of >>>>> private gain threatens a far greater pubic loss?the collapse of >>>>> social systems that took centuries to build." >>>> >>>> OK, colour me confused. The only spelling mistake I can spot in that >>>> is in the subject line of this thread. What am I missing? >>> >>> Presumably Romer meant that it was a loss suffered by everyone, >>> but that's not quite what he wrote. >> >> Sure it is. He's contrasting *private* gain with *public* loss. If there >> is any ambiguity here it is whether there is a threat *of* a public >> loss, or *to* a public loss ^_^ > > Now read the quote again, very VERY carefully. > > The human brain is very good at ignoring insignificant errors. > > (The troll brain is very good at pointing out insignificant errors.) ... and this is why we need exception tracebacks From gheskett at shentel.net Wed Oct 10 20:17:31 2018 From: gheskett at shentel.net (Gene Heskett) Date: Wed, 10 Oct 2018 20:17:31 -0400 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: <201810102017.31737.gheskett@shentel.net> On Wednesday 10 October 2018 14:27:32 Larry Martell wrote: > On Fri, Oct 5, 2018 at 6:54 AM Bruce Coram wrote: > > I will declare at the outset, I am a lurker. I don't know enough > > about Python to give advice that I could 100% guarantee would be > > helpful. > > > > There have been two recent threads that summarise for me where the > > Python Mailing List has lost its way (and this started before Trump > > arrived as a new role model for how to treat your fellow man): > > I do not think a Trump reference is approprate here at all. I could > start a political rant here, but I won't. > > If you think this list is harsh you must not have been on the internet > very long. > > This is a post that was going around back in 1996: > > Welcome to the Internet. > > No one here likes you. > > We're going to offend, insult, abuse, and belittle the living hell out > of you. And when you rail against us with "FUCK YOU YOU GEEK WIMP > SKATER GOTH LOSER PUNK FAG BITCH!1!!", we smile to ourselves. We laugh > at you because you don't get it. Then we turn up the heat, hoping to > draw more entertainment from your irrational fuming. > > We will judge you, and we will find you unworthy. It is a trial by > fire, and we won't even think about turning down the flames until you > finally understand. > > Some of you are smart enough to realize that, when you go online, it's > like entering a foreign country ... and you know better than to > ignorantly fuck with the locals. You take the time to listen and think > before speaking. You learn, and by learning are gladly welcomed. > > For some of you, it takes a while, then one day it all dawns on you - > you get it, and are welcomed into the fold. > > Some of you give up, and we breathe a sigh of relief - we didn't want > you here anyway. And some of you just never get it. The offensively > clueless have a special place in our hearts - as objects of ridicule. > We don't like you, but we do love you. > > You will get mad. You will tell us to go to hell, and call us "nerds" > and "geeks". Don't bother ... we already know exactly what we are. > And, much like the way hardcore rap has co-opted the word "nigger", > turning an insult around on itself to become a semiserious badge of > honor, so have we done. > > "How dare you! I used to beat the crap out of punks like you in high > school/college!" You may have owned the playing field because you were > an athlete. You may have owned the student council because you were > more popular. You may have owned the hallways and sidewalks because > you were big and intimidating. Well, welcome to our world. > > Things like athleticism, popularity, and physical prowess mean nothing > here. We place no value on them ... or what car you drive, the size of > your bank account, what you do for a living or where you went to > school. > > Allow us to introduce you to the concept of a "meritocracy" - the > closest thing to a form of self-government we have. In The United > Meritocratic nation-states of the Internet, those who can do, rule. > Those who wish to rule, learn. Everyone else watches from the stands. > > You may posses everything in the off-line world. We don't care. You > come to the Internet penniless, lacking the only thing of real value > here: knowledge. > > "Who cares? The Internet isn't real anyway!" This attitude is > universally unacceptable. The Internet is real. Real people live > behind those handles and screen names. Real machines allow it to > exist. It's real enough to change government policy, real enough to > feed the world's hungry, and even, for some of us, real enough to earn > us a paycheck. Using your own definition, how "real" is your job? Your > stock portfolio? Your political party? What is the meaning of "real", > anyway? > > Do I sound arrogant? Sure ... to you. Because you probably don't get > it yet. > > If you insist on staying, then, at the very least, follow this advice: > > 1) No one, ESPECIALLY YOU, will make any law respecting an > establishment of religion, or prohibiting the free exercise thereof; > or abridging the freedom of speech, or of the press; or the right of > the people peaceably to assemble, and to petition the government for a > redress of grievances. > > 2) Use your brain before ever putting fingers to keys. > > 3) Do you want a picture of you getting anally raped by Bill Clinton > while you're performing oral sex on a cow saved to hundreds of > thousands of people's hard drives? No? Then don't put your fucking > picture on the Internet. We can, will, and probably already HAVE > altered it in awful ways. Expect it to show up on an equally offensive > website. > > 4) Realize that you are never, EVER going to get that, or any other, > offensive web page taken down. Those of us who run those sites LIVE to > piss off people like you. Those of us who don't run those sites > sometimes visit them just to read the hatemail from fools like you. > > 5) Oh, you say you're going to a lawyer? Be prepared for us to giggle > with girlish delight, and for your lawyer to laugh in your face after > he explains current copyright and parody law. > > 6) The Web is not the Internet. Stop referring to it that way. > > 7) We have already received the e-mail you are about to forward to us. > Shut up. > > 8) Don't reply to spam. You are not going to be "unsubscribed". > > 9) Don't ever use the term "cyberspace" (only William Gibson gets to > say that, and even he hasn't really used it for two or three books > now). Likewise, you prove yourself a marketing-hype victim if you ever > use the term "surfing". > > 10) With one or two notable exceptions, chat rooms will not get you > laid. > > 11) It's a hoax, not a virus warning. > > 12) The internet is made up of thousands of computers, all connected > but owned by different people. Learn how to use *your* computer before > attempting to connect it to someone else's. > > 13) The first person who offers to help you is really just trying to > fuck with you for entertainment. So is the second. And the third. And > me. > > 14) Never insult someone who's been active in any group longer than > you have. You may as well paint a damn target on your back. > > 15) Never get comfortable and arrogant behind your supposed mask of > anonymity. Don't be surprised when your name, address, and home phone > number get thrown back in your smug face. Hell, some of us will > snail-mail you a printed satellite photograph of your house to drive > the point home. Realize that you are powerless if this happens ... > it's all public information, and information is our stock and trade. > > 16) No one thinks you are as cool as you think you are. > > 17) You aren't going to win any argument that you start. > > 18) If you're on AOL, don't worry about anything I've said here. > You're already a fucking laughing stock, and there's no hope for you. > > 19) If you can't take a joke, immediately sell your computer to > someone who can. RIGHT NOW. > > Pissed off? It's the TRUTH, not these words, that hurts your feelings. > Don't ever even pretend like I've gone & hurt them. > > We don't like you. We don't want you here. We never will. Save us all > the trouble and go away. Larry, I laughed my ass off when this came around in about that time frame the first time I saw it, long before I was invited to the off-topic list. And I'm laughing again right now. Thanks for digging it out of the archives. Take care Larry. -- Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From rj.amdphreak at gmail.com Thu Oct 11 00:39:41 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Wed, 10 Oct 2018 23:39:41 -0500 Subject: Python doesn't install In-Reply-To: References: <4023e28d-9db1-4d89-b190-a39a18e6df48@googlegroups.com> Message-ID: Need more info than that. For a problem as unusual as that, it'll take a lot of scrutiny to find the problem. Dump as much info as you can about your system environment and your existing installations and upload them to https://hastebin.com/ (secure and private text host). Include relevant screenshots via Imgur.com and add to a private album (for access by link only). Windows eventually needs reinstalling, even in 2018. Sad really. On Wed, Oct 10, 2018 at 1:12 PM Daan Kahmann wrote: > Op woensdag 10 oktober 2018 19:20:42 UTC+2 schreef Terry Reedy: > > On 10/10/2018 9:53 AM, daankahmann01 at gmail.com wrote: > > > > > I have an annoying problem, I can download Python (from python.org) > but it won't install on my laptop. If I try to open the installer, it > closes again. I also don't get a error message. I'm using windows 10. I > already tried most of the obvious things like restarting, deleting the > program and downloading it again and I tried windows problem solver from > tweaking.com. But nothing seems to work. Does anyone know how I might be > able to fix this? > > > > Which exact binary? Have you tried other versions? Have you installed > > Python before? > > > > -- > > Terry Jan Reedy > > version 3.7.0, I have tried installing other versions but I get the same > problem. I have not installed Python on this laptop before. > > Daan Kahmann > -- > https://mail.python.org/mailman/listinfo/python-list > -- If you believe in an open internet, and that you should be free to fix your own computer and program and modify it without restrictions, join the Free Software Foundation and the Electronic Frontier Foundation . They protect your digital rights. Ryan Everett Johnson From greg.ewing at canterbury.ac.nz Thu Oct 11 01:04:06 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 11 Oct 2018 18:04:06 +1300 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: Chris Angelico wrote: > You mean at the level of words, or sentences? I mean at the word level, so that a dumb algorithm can find spelling errors. Auto-correcting errors at the semantic level would require considerably better AI than we have at the moment. -- Greg From greg.ewing at canterbury.ac.nz Thu Oct 11 01:06:01 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 11 Oct 2018 18:06:01 +1300 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: Thomas Jollans wrote: > Sure it is. He's contrasting *private* gain with *public* loss. If there > is any ambiguity here it is whether there is a threat *of* a public > loss, or *to* a public loss ^_^ I don't think you've spotted the error yet. I'm trying to provide a clue as to which word you need to examine... -- Greg From greg.ewing at canterbury.ac.nz Thu Oct 11 01:15:43 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 11 Oct 2018 18:15:43 +1300 Subject: ESR "Waning of Python" post In-Reply-To: <87bm81pii1.fsf@nightsong.com> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: Paul Rubin wrote [concerning GIL removal]: > It's weird that Python's designers were willing to mess up the user > language in the 2-to-3 transition but felt that the C API had to be kept > sarcosanct. Huge opportunities were blown at multiple levels. You say that as though we had a solution for GIL removal all thought out and ready to go, and the only thing that stopped us is that it would have required changing the C API. But it's not like that at all. As far as I know, all the attempts that have been made so far to remove the GIL have led to performance that was less than satisfactory. It's a hard problem that we haven't found a good solution to yet. -- Greg From rosuav at gmail.com Thu Oct 11 02:50:48 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 11 Oct 2018 17:50:48 +1100 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: On Thu, Oct 11, 2018 at 4:21 PM Gregory Ewing wrote: > > Paul Rubin wrote [concerning GIL removal]: > > It's weird that Python's designers were willing to mess up the user > > language in the 2-to-3 transition but felt that the C API had to be kept > > sarcosanct. Huge opportunities were blown at multiple levels. > > You say that as though we had a solution for GIL removal all > thought out and ready to go, and the only thing that stopped us > is that it would have required changing the C API. > > But it's not like that at all. As far as I know, all the > attempts that have been made so far to remove the GIL have > led to performance that was less than satisfactory. It's a > hard problem that we haven't found a good solution to yet. > In actual fact, it's not a problem per-se. It's a design choice, and every alternative choice tried so far has even worse problems. THAT is why we still have it. ChrisA From ben+python at benfinney.id.au Thu Oct 11 03:11:00 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 11 Oct 2018 18:11:00 +1100 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: <86tvlt2c1n.fsf@benfinney.id.au> Chris Angelico writes: > In actual fact, it's not a problem per-se. It's a design choice, and > every alternative choice tried so far has even worse problems. THAT is > why we still have it. That reads to me like a rejection of the point made in the blog post: that the GIL prevents Python from taking proper advantage of multi-core machines. In other words: Yes, it's a design decision, but that design decision causes the problems described. Is it your position that the described behaviour is not a problem? Do you hold that position because you think multi-core machines are not a sector that Python needs to be good at? Or that the described behaviour doesn't occur? Or something else? -- \ ?A hundred times every day I remind myself that [?] I must | `\ exert myself in order to give in the same measure as I have | _o__) received and am still receiving? ?Albert Einstein | Ben Finney From rosuav at gmail.com Thu Oct 11 03:22:13 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 11 Oct 2018 18:22:13 +1100 Subject: ESR "Waning of Python" post In-Reply-To: <86tvlt2c1n.fsf@benfinney.id.au> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> Message-ID: On Thu, Oct 11, 2018 at 6:12 PM Ben Finney wrote: > > Chris Angelico writes: > > > In actual fact, it's not a problem per-se. It's a design choice, and > > every alternative choice tried so far has even worse problems. THAT is > > why we still have it. > > That reads to me like a rejection of the point made in the blog post: > that the GIL prevents Python from taking proper advantage of multi-core > machines. > > In other words: Yes, it's a design decision, but that design decision > causes the problems described. > > Is it your position that the described behaviour is not a problem? Do > you hold that position because you think multi-core machines are not a > sector that Python needs to be good at? Or that the described behaviour > doesn't occur? Or something else? Multi-core machines are important, but even on multi-core machines, most Python processes don't need more than one. AFAIK, every single alternative to the GIL has resulted in a measurable performance penalty when running on a single core. (Happy to be proven wrong if that's not the case.) So if you want better multi-core performance, you MUST accept a single-core penalty. Frankly, I don't see a problem with saying "Python doesn't make it easy to write code that floods eight cores with work, therefore I will choose a different language for this job". It doesn't mean Python is a bad language. It just means that Python is not the one and only language that all code must forever be written in. There's a huge difference between deciding on using some different language for a project, and going on a massive ire-filled rant. ChrisA From tjol at tjol.eu Thu Oct 11 03:38:19 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 11 Oct 2018 09:38:19 +0200 Subject: ESR "Waning of Python" post In-Reply-To: <86tvlt2c1n.fsf@benfinney.id.au> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> Message-ID: <09c16e6f-5e66-0a78-2437-2345fc3f79c6@tjol.eu> On 11/10/2018 09:11, Ben Finney wrote: > Chris Angelico writes: > >> In actual fact, it's not a problem per-se. It's a design choice, and >> every alternative choice tried so far has even worse problems. THAT is >> why we still have it. > > That reads to me like a rejection of the point made in the blog post: > that the GIL prevents Python from taking proper advantage of multi-core > machines. > > In other words: Yes, it's a design decision, but that design decision > causes the problems described. > > Is it your position that the described behaviour is not a problem? Do > you hold that position because you think multi-core machines are not a > sector that Python needs to be good at? Or that the described behaviour > doesn't occur? Or something else? > I recently watched this talk by Raymond Hettinger on concurrency which gives some perspective on this question especially in the first ten minutes: https://www.youtube.com/watch?v=9zinZmE3Ogk The gist is that the GIL is a problem only for relatively few problems (e.g. games that need limited-scale low-latency parallelism). Most of the time, you either only need one process in the first place, or you can take full advantage of your multi-core machine, or multiple multi-core machines, using multiple processes (with ipyparallel or whatever) From rosuav at gmail.com Thu Oct 11 03:53:03 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 11 Oct 2018 18:53:03 +1100 Subject: ESR "Waning of Python" post In-Reply-To: <09c16e6f-5e66-0a78-2437-2345fc3f79c6@tjol.eu> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <09c16e6f-5e66-0a78-2437-2345fc3f79c6@tjol.eu> Message-ID: On Thu, Oct 11, 2018 at 6:43 PM Thomas Jollans wrote: > The gist is that the GIL is a problem only for relatively few problems > (e.g. games that need limited-scale low-latency parallelism). Most of > the time, you either only need one process in the first place, or you > can take full advantage of your multi-core machine, or multiple > multi-core machines, using multiple processes (with ipyparallel or whatever) Right. If someone goes on a long rant saying how he wasn't able to write his device driver in Python, and he's giving up on the language and going to C, would that be taken as an affront to Python, or the knell of the language, or anything like that? No, it'd be "well, that's not Python's role". But if someone needs to manage a billion teensy sub-jobs and then finds that Python is unsuitable, it's clearly the GIL's fault, and this is a fundamental flaw in the language, and we should all move to Go for all our coding because Python utterly sucks. Why? Why not just let other languages do things differently, and have other design tradeoffs? This is one fairly specific class of problem which is poorly served by Python's/CPython's design. (I'm not sure how much of this could be done differently in an alternative implementation; so far, we haven't seen a "Python for embarrassingly parallel problems" implementation, so I suspect part of it is language design.) So pick a different language *for those problems*. ChrisA From spencer.graves at effectivedefense.org Thu Oct 11 04:17:34 2018 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Thu, 11 Oct 2018 03:17:34 -0500 Subject: Problems installing RStudio from Anaconda Navigator Message-ID: <9dee2afb-310a-f121-5c7b-ab861bb9647a@effectivedefense.org> ????? I clicked "Install" for "RStudio 1.1.456" in Anaconda Navigator 1.9.2 under Windows 7 Home Premium SP1.? It said "Installing application RStudio" for over 30 minutes.? It looked stuck. ????? Then I read a GitHub post that said, "On the environments tab create a new R/Python3.5 environment", then install RStudio into that new environment.[1] ????? So I killed the RStudio install and looked at the "Environments tab".? I'm new to Anaconda Navigator, and I didn't know what I was looking at so decided to ask here. ????? Suggestions? ????? Thanks, ????? Spencer Graves p.s.? I do not currently have RStudio installed on that machine.? On a macOS 10.13.6 machine, I have have RStudio 1.2.792 on a macOS 10.13.6.? Anaconda Navigator 1.9.2 on my Mac fails to recognize the existing and more recent installation of RStudio 1.2.792 there. Should I, e.g., try to "Import" that existing RStudio installation? [1] https://github.com/conda/conda/issues/4204 From jfine2358 at gmail.com Thu Oct 11 04:48:52 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Thu, 11 Oct 2018 01:48:52 -0700 (PDT) Subject: From Mathematica to Jypyter In-Reply-To: <4690d86b-061a-4a28-a3bd-e1f8db9196e2@googlegroups.com> References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> <4690d86b-061a-4a28-a3bd-e1f8db9196e2@googlegroups.com> Message-ID: It is fun to find fault in the work of a new Nobel laureate. In this case, a typo. However, I'm disappointed that no-one has picked up the other error. Someone posted to this thread "the #me-too movement". It should be "#MeToo". Yes, I know it's CamelCase. I think that's actually Pythonic. It's the name for a class of messages. -- Jonathan From tjol at tjol.eu Thu Oct 11 05:00:03 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 11 Oct 2018 11:00:03 +0200 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> <4690d86b-061a-4a28-a3bd-e1f8db9196e2@googlegroups.com> Message-ID: <6ac4d9f1-cd9a-f2d3-f819-2d1673c27693@tjol.eu> On 2018-10-11 10:48, jfine2358 at gmail.com wrote: > It is fun to find fault in the work of a new Nobel laureate. In this case, a typo. Not a Nobel laureate. It's not a Nobel prize. > > However, I'm disappointed that no-one has picked up the other error. Someone posted to this thread "the #me-too movement". It should be "#MeToo". > > Yes, I know it's CamelCase. I think that's actually Pythonic. It's the name for a class of messages. > From iranna.gani28 at gmail.com Thu Oct 11 05:44:49 2018 From: iranna.gani28 at gmail.com (Iranna Mathapati) Date: Thu, 11 Oct 2018 15:14:49 +0530 Subject: how to replace line on particular line in file[no need to write it back whole file again] Message-ID: Hi Team, How to replace particular line text with new text on a file i have below code but its writing whole code. def replace_line(file_name, line_num, text): lines = open(file_name, 'r').readlines() lines[line_num] = text out = open(file_name, 'w') out.writelines(lines) <<<<< *writing back whole file instead of particular line* out.close() replace_line('stats.txt', 0, 'good') Thanks, Iranna M From dan at djph.net Thu Oct 11 06:05:28 2018 From: dan at djph.net (Dan Purgert) Date: Thu, 11 Oct 2018 10:05:28 -0000 (UTC) Subject: Observations on the List - "Be More Kind" References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: 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 ... 10/10, would read again. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From lutz.horn at outlook.de Thu Oct 11 07:05:48 2018 From: lutz.horn at outlook.de (Lutz Horn) Date: Thu, 11 Oct 2018 11:05:48 +0000 Subject: AW: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: References: Message-ID: Try something like this: ``` import sys def replace(lineno, replacement): for i, line in enumerate(sys.stdin.readlines()): if i == lineno: line = replacement print(line.strip()) replace(2, "REPLACEMENT") ``` ________________________________________ Von: Python-list im Auftrag von Iranna Mathapati Gesendet: Donnerstag, 11. Oktober 2018 11:44 An: python list Betreff: how to replace line on particular line in file[no need to write it back whole file again] Hi Team, How to replace particular line text with new text on a file i have below code but its writing whole code. def replace_line(file_name, line_num, text): lines = open(file_name, 'r').readlines() lines[line_num] = text out = open(file_name, 'w') out.writelines(lines) <<<<< *writing back whole file instead of particular line* out.close() replace_line('stats.txt', 0, 'good') Thanks, Iranna M -- https://mail.python.org/mailman/listinfo/python-list From rhodri at kynesim.co.uk Thu Oct 11 07:43:05 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Thu, 11 Oct 2018 12:43:05 +0100 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> <4aee8bba-299f-4734-8651-4997a8552ca7@kynesim.co.uk> <4310a16b-629b-e905-cab5-54909a370b0e@kynesim.co.uk> <66b9144d-de1f-bd71-d2af-d3c2bff121f8@kynesim.co.uk> Message-ID: On 10/10/18 19:14, Ethan Furman wrote: > On 10/10/2018 11:07 AM, Rhodri James wrote: > >> Now I've had a chance to go back through the archive (it's been that >> kind of day at work), I'm going to have to recant.? I can't find >> anything that Rick wrote in the week or two before the ban > > Where are you looking? https://mail.python.org/pipermail/python-list specifically the June and July archives. I wouldn't be surprised if those aren't complete; there's at least one post of mine I can't find there. -- Rhodri James *-* Kynesim Ltd From rhodri at kynesim.co.uk Thu Oct 11 07:49:14 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Thu, 11 Oct 2018 12:49:14 +0100 Subject: From Mathematica to Jypyter In-Reply-To: References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> Message-ID: On 10/10/18 17:24, jfine2358 at gmail.com wrote: > Rhodri James wrote: >> Robin Becker wrote: > >>> I'm a great fan of erroneous spelling and this blog needs a spelling >>> check as this quote shows > > [Paul Romer's blog] >>> "Mathematica exemplifies the horde of new Vandals whose pursuit of >>> private gain threatens a far greater pubic loss?the collapse of social >>> systems that took centuries to build." > >>> these Vandals are probably not in favour of the #me-too movement either :) > >> OK, colour me confused. The only spelling mistake I can spot in that is >> in the subject line of this thread. What am I missing? > > In addition to Jypyter for Jupyter, there are TWO typos above. One in > Paul Romer's blog, followed by one in Robin Becker's comment. Ah, the missing l, now I see it. -- Rhodri James *-* Kynesim Ltd From tjol at tjol.eu Thu Oct 11 07:57:57 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 11 Oct 2018 13:57:57 +0200 Subject: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: References: Message-ID: On 2018-10-11 11:44, Iranna Mathapati wrote: > Hi Team, > > How to replace particular line text with new text on a file > i have below code but its writing whole code. > > def replace_line(file_name, line_num, text): > lines = open(file_name, 'r').readlines() > lines[line_num] = text > out = open(file_name, 'w') > out.writelines(lines) <<<<< *writing back whole file instead of > particular line* > out.close() > replace_line('stats.txt', 0, 'good') > > > Thanks, > Iranna M > Can't be done. There's no easy way to write to the middle of a file (though I think it can be done by mmap'ing a file) -- and even if you manage to do that, you'd have to write back anything after the changed line if the length of that line changed by as little as a byte. If you really want, you can avoid writing back anything *before* your change by carefully using truncate(): def replace_line(file_name, line_num, new_text): # Use a with statement to make sure the file is closed with open(file_name, 'r+') as f: # Ignore the first (line_num) lines for _ in range(line_num): f.readline() # Save position, skip the line to be replaced line_start = f.tell() f.readline() # We're keeping the rest of the file: remaining_content = f.read() # Chop off the file's tail! f.seek(line_start) f.truncate() # Write the new tail. if not new_text.endswith('\n'): new_text = new_text + '\n' f.write(new_text) f.write(remaining_content) That works, but your solution is more elegant.* This solution might make sense for fairly large files where you can guarantee that the change will be near the end. * though you should close the file after you read it, preferable using a with statement. From iranna.gani28 at gmail.com Thu Oct 11 10:44:13 2018 From: iranna.gani28 at gmail.com (Iranna Mathapati) Date: Thu, 11 Oct 2018 20:14:13 +0530 Subject: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: References: Message-ID: Thanks Dennis Lee and Thomas On Thu, Oct 11, 2018 at 6:32 PM Dennis Lee Bieber wrote: > On Thu, 11 Oct 2018 15:14:49 +0530, Iranna Mathapati > declaimed the following: > > >Hi Team, > > > >How to replace particular line text with new text on a file > >i have below code but its writing whole code. > > > > > For C-style streams (which seem to have taken over every operating > system) in which "lines" are determined by specific characters in the > stream, you can only "replace" a line IF THE REPLACEMENT IS THE EXACT SAME > SIZE! If there is any difference in length of the input and output lines, > you have to read/write everything from the line to the end of the file. > > I emphasize "C-style streams" as there were operating systems that > did > support other file organizations natively. Xerox CP-V offered > "consecutive", "keyed", and "random" file organizations. > > "Consecutive" being the closest to streams -- pure sequentially > written > data. > > "Keyed" files used a multi-level ISAM structure -- which is what > was > used by the text editor and by the FORTRAN direct-access mode (line/record > numbers were used as the ISAM key). In these, replacing a line meant > writing a new line and updating the ISAM headers to point to > the new line. Periodically one would have to pack the file to reclaim > unused/freed space. > > "Random" files were an organization in which the OS did /nothing/. > These files were created as a predetermined maximum size, and were > allocated as a contiguous section of disk space -- the OS didn't even > bother tracking blocks. An application basically was given two pieces of > information: the starting address on disk, and the total length of the > allocation. ALL data management had to be done by the application. > > Past that, there is the concept of a fixed-length record. ALL > records > (lines) in the file having the same predefined maximum length. Internally, > each record would either have a length datum at the beginning, or use some > special character to indicate where the end of the record's data really is > -- but all I/O was performed on the full . Even > TRSDOS/LS-DOS (TRS-80 Model III/4) supported fixed-length I/O in the OS, > though the maximum record length was one disk sector (256 bytes; shorter > records definitions were permitted and the system /did/ pack them into disk > space rather than wasting the tail of the sector). Fixed length schemes > typically permit direct access > > x = read(rec=123) > > write(y, rec=123) > > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From eryksun at gmail.com Thu Oct 11 11:53:43 2018 From: eryksun at gmail.com (eryk sun) Date: Thu, 11 Oct 2018 10:53:43 -0500 Subject: From Mathematica to Jypyter In-Reply-To: <6ac4d9f1-cd9a-f2d3-f819-2d1673c27693@tjol.eu> References: <15da9b25-e352-0b0a-799f-05d288ab2820@kynesim.co.uk> <4690d86b-061a-4a28-a3bd-e1f8db9196e2@googlegroups.com> <6ac4d9f1-cd9a-f2d3-f819-2d1673c27693@tjol.eu> Message-ID: On Thu, Oct 11, 2018 at 4:10 AM Thomas Jollans wrote: > > On 2018-10-11 10:48, jfine2358 at gmail.com wrote: > > It is fun to find fault in the work of a new Nobel laureate. In this case, a typo. > > Not a Nobel laureate. It's not a Nobel prize. More precisely it's the Nobel Memorial Prize in Economics, established by the central bank of Sweden in 1968, not Alfred Nobel in 1895. Recipients of this prize are counted among Nobel laureates, though it's not without controversy. https://en.wikipedia.org/wiki/List_of_Nobel_laureates From ian.g.kelly at gmail.com Thu Oct 11 12:01:34 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 11 Oct 2018 10:01:34 -0600 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: 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 ... 10/10, would read > again. For 4chan, maybe. From rtomek at ceti.pl Thu Oct 11 12:51:55 2018 From: rtomek at ceti.pl (Tomasz Rola) Date: Thu, 11 Oct 2018 18:51:55 +0200 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> Message-ID: <20181011165154.GA11681@tau1.ceti.pl> On Thu, Oct 11, 2018 at 06:22:13PM +1100, Chris Angelico wrote: [...] > > There's a huge difference between deciding on using some different > language for a project, and going on a massive ire-filled rant. I agree, in fact this is the kind of posture that I myself implemented in my actions. I have read the article, which was interesting, but am yet to read the comments. I have a question. What is the size of data? I could not spot it. If one had read it into one huge byte array, how many bytes would it be? ESR says he makes a graph of it and there are ~350k objects - i.e. nodes, I assume? How many edges (arcs, lines) for a node, on average? on max? I am curious, as always. Because it is nice of him to rant, but technical/mathematical side of decision making is still a bit too foggy for me and I cannot assess it. -- Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From neilc at norwich.edu Thu Oct 11 13:56:43 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 11 Oct 2018 17:56:43 GMT Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: On 2018-10-10, Paul Rubin wrote: > Neil Cerutti writes: >> As Stephen said, it's sort of silly not to be aware of those >> issues going in. > > If you're saying ESR messed up by using Python in the first > place for that program, that's not a great advert for Python > either. I meant Stefan, by the way. Sorry, Stefan. I actually do kind of think that, but ESR is a much better and more experienced programmer than me and a whole lot more knowledgable about the resource usage his program requires. So take that part of my opinion with a grain of salt, if you didn't already have one. Somebody in his comments section was incredulous that his software could possible bog down with such a "small" code base. It concerning to me that he glossed over his decision process when abandoning the idea of offloading the part of the work that's getting stuck in one core to a suitable engine. To me, that has to be easier than rewriting from scratch in a new language, but we don't have enough information to judge. One issue I didn't address was his criticism of deploying Python programs, thanks to library location issues. As I understand it, Go's library system has it own huge bloc of complainants regaring versioning hell, with a solution that's vaporware. Python's library issues can be addressed with virtualenv or py2exe type tools. I also disliked how he lumped current problems with Python in together with "ancient" history. It was definitely a good enough article for a blog post but would need rewriting for a journal or a magazine. >>> the GIL (15/16th of his CPUs are unused..) >> Channels are a big selling point of Go, no argument there. > > The unused CPUs are not about channels (Python has Queue which > is similar). They're about the GIL, which is an implementation > artifact of CPython that's hard to eliminate without modifying > CPython's C API. ESR didn't say this explicitly but it came to > mind when reading his post: It's weird that Python's designers > were willing to mess up the user language in the 2-to-3 > transition but felt that the C API had to be kept sarcosanct. > Huge opportunities were blown at multiple levels. OK. I assumed he planned to parallelize computations in Go by offloading to concurrent channels--I guess I don't understand why he can't do that in Python. >> You must carefully use a different set of functions and >> operators to regard the bytes as unicode code-points. So Go >> makes it easy to do things incorrectly > > That seems like a deficiency in Go's type system rather than in > the UTF8 representation per se. I agree. Python could've used UTF8 as the internal representation as well, but there's no need to go back into that jmxfauth horror show. >> On the other hand, I only used Go until it made me feel really >> annoyed > > Yeah I haven't used Go a whole lot either, for similar and > other reasons. ESR's criticisms of Python are imho mostly > valid but I don't think Go is the answer. It's too low level, > showing its roots in C. Haskell and Ocaml have their own > deficiencies but I think they are closer to the right > direction. I.e. I'd like something with a serious type system > and a more functional-programming flavor than either Go or > Python currently have. A big reason he chose Go in the article is that he regarded it as more simple to translate Python->Go than those other options. It's hard to believe that good Python code would make could Go code, but at least its a starting point. I imagine that if I stuck with Go long enough I'd develop a new coding style that didn't inolve creating useful data types. I've used C++ and Python so long I just don't think that way. -- Neil Cerutti From rosuav at gmail.com Thu Oct 11 14:10:37 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 12 Oct 2018 05:10:37 +1100 Subject: Observations on the List - "Be More Kind" In-Reply-To: References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: On Fri, Oct 12, 2018 at 5:07 AM Ian Kelly wrote: > > 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 ... 10/10, would read > > again. > > For 4chan, maybe. He said "would read again". I absolutely agree. This is a CoC that is worth reading again. Worth adopting for python-list? Ehh, not so much. But it's definitely worth reading again. :) ChrisA From rj.amdphreak at gmail.com Thu Oct 11 19:19:09 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Thu, 11 Oct 2018 18:19:09 -0500 Subject: Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references. Message-ID: <5bbfda6c.1c69fb81.99eaa.e3ff@mx.google.com> I am working on using mysql.connector in a class and have found an example of how to create a single connection that spans the lifetime of all instances of the class: https://softwareengineering.stackexchange.com/a/358061/317228 however, I do not understand a few things about the class, including 1. Why it is subclassed as an object: `class Postgres(object):` ? I thought classes were necessarily objects. 2. Why is this portion of code directly addressing the class, instead of using the `cls` reference variable? connection = Postgres._instance.connection = psycopg2.connect(**db_config) cursor = Postgres._instance.cursor = connection.cursor() 3. And is it me or does anyone else think {anydb}.connector?s usage is messy and inelegant? Ex: print('connecting to PostgreSQL database...') connection = Postgres._instance.connection = psycopg2.connect(**db_config) cursor = Postgres._instance.cursor = connection.cursor() cursor.execute('SELECT VERSION()') db_version = cursor.fetchone() Why can?t we associate the focus of the connection with the connection itself, instead of creating a separate cursor object? Also, within the code example, and in Python in general, why does there needs to be a __new__ constructor when there?s an __init__ constructor? I?ve read about the usage of singletons. It seems you could create singletons within __init__ or __new__ . Any enlightenment would be really helpful. I am very sleep-deprived, so I?m sorry if this seems like a dumb question. I have read the official docs. Have also been reading ?Python 3: Patterns, Recipes, and Idioms?. The first was mildly helpful but I still don?t see the benefit of a __new__ constructor. Why is there dislike for Metaclasses? Thanks, and I?ll have better incisive questions in the future. Sent from Mail for Windows 10 From frank at chagford.com Fri Oct 12 01:55:58 2018 From: frank at chagford.com (Frank Millman) Date: Fri, 12 Oct 2018 07:55:58 +0200 Subject: Quickest way to concatenate strings Message-ID: Hi all I have often read that the quickest way to concatenate a number of strings is to place them in a list and 'join' them - C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" ''.join([x, y, z]) 500000 loops, best of 5: 307 nsec per loop I seem to have found a quicker method, using the new 'f' format operator - C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" f'{x}{y}{z}' 1000000 loops, best of 5: 226 nsec per loop Interestingly, the 'format' function is slower - C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" '{}{}{}'.format(x, y, z) 500000 loops, best of 5: 559 nsec per loop I am using Python 3.7.0 on Windows 10. Frank Millman From dieter at handshake.de Fri Oct 12 02:14:37 2018 From: dieter at handshake.de (dieter) Date: Fri, 12 Oct 2018 08:14:37 +0200 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> Message-ID: <87zhvjelo2.fsf@handshake.de> Ben Finney writes: > ... > Is it your position that the described behaviour is not a problem? Do > you hold that position because you think multi-core machines are not a > sector that Python needs to be good at? Or that the described behaviour > doesn't occur? Or something else? Every system you use has its advantages and its drawbacks. Depending on the specific context (problem, resources, knowledge, ...), you must choose an appropriate one. Python uses the GIL mainly because it uses reference counting (with almost constant changes to potentially concurrently used objects) for memory management. Dropping the GIL would mean dropping reference counting likely in favour of garbage collection. I work in the domain of web applications. And I made there a nasty experience with garbage collection: occasionally, the web application stopped to respond for about a minute. A (quite difficult) analysis revealed that some (stupid) component created in some situations (a search) hundreds of thousands of temporary objects and thereby triggered a complete garbage collection. The garbage collector started its mark and sweep phase to detect unreachable objects - traversing a graph of millions of objects. As garbage collection becomes drastically more complex if the object graph can change during this phase (and this was Python), a global look prevented any other activity -- leading to the observed latencies. When I remember right, there are garbage collection schemes that can operate safely without stopping other concurrent work. Nevertheless, even those garbage collectors have a significant impact on performance when they become active (at apparently non-deterministic times) and that may be inacceptable for some applications. From bkaantaze at gmail.com Fri Oct 12 02:29:35 2018 From: bkaantaze at gmail.com (Kaan Taze) Date: Fri, 12 Oct 2018 09:29:35 +0300 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? Message-ID: Hi everyone, Since this is my first post to mail-list I'm kind of hesitant to ask this question here but as many of you spend years working with Python maybe some of you can guide me. What I trouble with is not a logical error that exist on a program I wrote. It's the Python itself. Well, I'm 22 years old CS student -from Turkey- and what they showed us at university was C Language and Java but I mainly use C in school projects etc. So it's been few months that I started to use Python for my personal side-projects. There are lots of resources to learn language. I do what I need to do with Python too but I was kinda shocked when I solve Python questions at Hackerrank. Even with list comprehensions you can implement in very smart way to get things done and easy. Iterations, string operations. The codes I see on the Internet using basics in a very clever way which I couldn't come up with the same solution if I tried to for some time. I do understand this ways but coming from ANSI C makes it hard to see this flexibility. I probably do things in a both inefficient and hard way in my projects. How do I get used to this? Is this just another "practice, practice, practice" situation? Anything you can recommend? All the best. Kaan. From tjol at tjol.eu Fri Oct 12 02:33:50 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 12 Oct 2018 08:33:50 +0200 Subject: Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references. In-Reply-To: <5bbfda6c.1c69fb81.99eaa.e3ff@mx.google.com> References: <5bbfda6c.1c69fb81.99eaa.e3ff@mx.google.com> Message-ID: On 12/10/2018 01:19, Ryan Johnson wrote: > I am working on using mysql.connector in a class and have found an example of how to create a single connection that spans the lifetime of all instances of the class: > > https://softwareengineering.stackexchange.com/a/358061/317228 > > however, I do not understand a few things about the class, including > > 1. Why it is subclassed as an object: `class Postgres(object):` ? I thought classes were necessarily objects. This was sometimes necessary in Python 2. > 2. Why is this portion of code directly addressing the class, instead of using the `cls` reference variable? > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() In a subclass, the `cls' argument would refer to the subclass, while `Postgres' would still refer to the original class. I have no idea what this is trying to achieve, and I think it's probably a bug. Maybe someone else has an idea. > 3. And is it me or does anyone else think {anydb}.connector?s usage is messy and inelegant? Ex: > print('connecting to PostgreSQL database...') > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() > cursor.execute('SELECT VERSION()') > db_version = cursor.fetchone() > Why can?t we associate the focus of the connection with the connection itself, instead of creating a separate cursor object? You can have multiple cursors on the same connection. > > Also, within the code example, and in Python in general, why does there needs to be a __new__ constructor when there?s an __init__ constructor? I?ve read about the usage of singletons. It seems you could create singletons within __init__ or __new__ . Any enlightenment would be really helpful. I am very sleep-deprived, so I?m sorry if this seems like a dumb question. > > I have read the official docs. Have also been reading ?Python 3: Patterns, Recipes, and Idioms?. The first was mildly helpful but I still don?t see the benefit of a __new__ constructor. You can't create a singleton with __init__: by the time __init__ is called, a new instance has already been created, and you can't switch the object for a different one. By using __new__, you can bypass the creation of a new instance. If what you want is some shared state between all instances, a class variable or global will do just fine and there's no need for a singleton instance of anything. > Why is there dislike for Metaclasses? They can be confusing. From tjol at tjol.eu Fri Oct 12 02:36:23 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 12 Oct 2018 08:36:23 +0200 Subject: Quickest way to concatenate strings In-Reply-To: References: Message-ID: <2ed5bb3c-4bb8-0ac0-d9b3-4ec2aba47f6e@tjol.eu> On 12/10/2018 07:55, Frank Millman wrote: > Hi all > > I have often read that the quickest way to concatenate a number of > strings is to place them in a list and 'join' them - > > ?? C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > ''.join([x, y, z]) > ?? 500000 loops, best of 5: 307 nsec per loop > > I seem to have found a quicker method, using the new 'f' format operator - If you know beforehand how many strings you're going to have, you might as well just use (x + y + z). > > ?? C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > f'{x}{y}{z}' > ?? 1000000 loops, best of 5: 226 nsec per loop > > Interestingly, the 'format' function is slower - > > ?? C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > '{}{}{}'.format(x, y, z) > ?? 500000 loops, best of 5: 559 nsec per loop > > I am using Python 3.7.0 on Windows 10. > > Frank Millman > > From marko at pacujo.net Fri Oct 12 02:48:02 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 12 Oct 2018 09:48:02 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> Message-ID: <87bm7zu0d9.fsf@elektro.pacujo.net> dieter : > Every system you use has its advantages and its drawbacks. > Depending on the specific context (problem, resources, knowledge, ...), > you must choose an appropriate one. Yep. I use Python for numerous tasks professionally and at home. Just this past week I used it to plan a junior soccer winter tournament. Python is used to verify various team and match constraints and Sudoku-solver-type match order generation. > Python uses the GIL mainly because it uses reference counting (with > almost constant changes to potentially concurrently used objects) for > memory management. Dropping the GIL would mean dropping reference > counting likely in favour of garbage collection. Reference counting was likely a bad idea to begin with. > I work in the domain of web applications. And I made there a nasty > experience with garbage collection: occasionally, the web application > stopped to respond for about a minute. A (quite difficult) analysis > revealed that some (stupid) component created in some situations (a > search) hundreds of thousands of temporary objects and thereby > triggered a complete garbage collection. The garbage collector started > its mark and sweep phase to detect unreachable objects - traversing a > graph of millions of objects. > > As garbage collection becomes drastically more complex if the object > graph can change during this phase (and this was Python), a global > look prevented any other activity -- leading to the observed > latencies. Yes. The occasional global freeze is unavoidable in any garbage-collected runtime environment regardless of the programming language. However, I challenge the notion that creating hundreds of thousands of temporary objects is stupid. I suspect that the root cause of the lengthy pauses is that the program maintains millions of *nongarbage* objects in RAM (a cache, maybe?). > When I remember right, there are garbage collection schemes that > can operate safely without stopping other concurrent work. There are heuristics, but I believe the worst case is the same. > Nevertheless, even those garbage collectors have a significant impact > on performance when they become active (at apparently > non-deterministic times) and that may be inacceptable for some > applications. If performance is key, Python is probably not the answer. Python's dynamism make it necessarily much slower than, say, Java or Go. Marko From rosuav at gmail.com Fri Oct 12 02:54:47 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 12 Oct 2018 17:54:47 +1100 Subject: ESR "Waning of Python" post In-Reply-To: <87bm7zu0d9.fsf@elektro.pacujo.net> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> Message-ID: On Fri, Oct 12, 2018 at 5:51 PM Marko Rauhamaa wrote: > > Python uses the GIL mainly because it uses reference counting (with > > almost constant changes to potentially concurrently used objects) for > > memory management. Dropping the GIL would mean dropping reference > > counting likely in favour of garbage collection. > > Reference counting was likely a bad idea to begin with. Then prove CPython wrong by making a fantastically better implementation that uses some other form of garbage collection. The language spec does not stipulate refcounting, and in fact very clearly does NOT stipulate what kind of garbage collection is used, so if refcounting is such a bad idea, you should be able to take advantage of CPython's flaw and make something better. Go ahead. Put your code where your mouth is. ChrisA From dieter at handshake.de Fri Oct 12 02:57:09 2018 From: dieter at handshake.de (dieter) Date: Fri, 12 Oct 2018 08:57:09 +0200 Subject: Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references. References: <5bbfda6c.1c69fb81.99eaa.e3ff@mx.google.com> Message-ID: <87va67ejp6.fsf@handshake.de> Ryan Johnson writes: > I am working on using mysql.connector in a class and have found an example of how to create a single connection that spans the lifetime of all instances of the class: > > https://softwareengineering.stackexchange.com/a/358061/317228 > > however, I do not understand a few things about the class, including > > 1. Why it is subclassed as an object: `class Postgres(object):` ? I thought classes were necessarily objects. This obviously is for Python 2. For historical reasons, Python 2 has two kinds of "class"es, old style and new style classes. As new style classes were introduced into Python 2, a need arose to distinguish them from old style classes: a new style class can be recognized by the fact that is has "object" in its inheritance graph. I.e. "class Postgres(object)" indicates that "Postgres" is a new style class. Python 3 only supports new style classes. Every class implicitely inherits "object". > 2. Why is this portion of code directly addressing the class, instead of using the `cls` reference variable? > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() There is not real reason to use "Postgres" in this place instead of "cls". > 3. And is it me or does anyone else think {anydb}.connector?s usage is messy and inelegant? Ex: > print('connecting to PostgreSQL database...') > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() > cursor.execute('SELECT VERSION()') > db_version = cursor.fetchone() > Why can?t we associate the focus of the connection with the connection itself, instead of creating a separate cursor object? I think this is meant as an example to demonstrate how to implement singleton database connections. As such, it has print statements to demonstrates what is going on (i.e. to convince you that several functions instantiating "postgres" indeed share a common postgres connection. In your own productive class, you would likely not have "print" statements. > Also, within the code example, and in Python in general, why does there needs to be a __new__ constructor when there?s an __init__ constructor? "__new__" essentially allocated the storage for a class instance, "__init__" initializes this storage. You rarely need "__new__". Typically, you need it only for classes where the amount of storage initially allocated for a class instance depends on the instance's value. An example is a class inheriting from "tuple": A "tuple" directly stores references to its components in itself - therefore, the amount of storage depends on the number of components. Most classes store the "content" of an instance in an extensible structure of the instance (the so called "instance dict"). They can use a standard "__new__" implementation and do not require there own. The example you reference could be rewritten to avoid the use of "__new__" (and integrate its functionality instead into "__init__"). Note that "__new__" is a class method, "__init__" is (by default) an instance method. This means, the the "cls" in "__new__" corresponds to "self.__class__" in "__init__". >I?ve read about the usage of singletons. It seems you could create singletons within __init__ or __new__ . You are right. From frank at chagford.com Fri Oct 12 03:00:40 2018 From: frank at chagford.com (Frank Millman) Date: Fri, 12 Oct 2018 09:00:40 +0200 Subject: Quickest way to concatenate strings In-Reply-To: <2ed5bb3c-4bb8-0ac0-d9b3-4ec2aba47f6e@tjol.eu> References: <2ed5bb3c-4bb8-0ac0-d9b3-4ec2aba47f6e@tjol.eu> Message-ID: On 12/10/2018 08:36, Thomas Jollans wrote: > On 12/10/2018 07:55, Frank Millman wrote: > Hi all > > > I have often read that the quickest way to concatenate a number of > > strings is to place them in a list and 'join' them - > > > > > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > > ''.join([x, y, z]) > > 500000 loops, best of 5: 307 nsec per loop > > > > I seem to have found a quicker method, using the new 'f' format operator - > > If you know beforehand how many strings you're going to have, you might > as well just use (x + y + z). > I tried that, and the ?f? operator is still quicker - C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" x+y+z 1000000 loops, best of 5: 374 nsec per loop C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" f'{x}{y}{z}' 1000000 loops, best of 5: 231 nsec per loop Frank From jfong at ms4.hinet.net Fri Oct 12 03:24:37 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Fri, 12 Oct 2018 00:24:37 -0700 (PDT) Subject: How to run/debug a script file its name has characters such as space, (, etc. Message-ID: <873aeccc-cfa9-4d7f-ae81-8515e773933f@googlegroups.com> I saw a directory where all its filenames are something like this: ... 1a PSG (Entry and PopUp).py 1b PSG (Format).py 1c PSG (persistent form and bind key).py ... Just wondering how these file can run and debugged under Windows? --Jach From rosuav at gmail.com Fri Oct 12 04:39:04 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 12 Oct 2018 19:39:04 +1100 Subject: How to run/debug a script file its name has characters such as space, (, etc. In-Reply-To: <873aeccc-cfa9-4d7f-ae81-8515e773933f@googlegroups.com> References: <873aeccc-cfa9-4d7f-ae81-8515e773933f@googlegroups.com> Message-ID: On Fri, Oct 12, 2018 at 6:26 PM wrote: > > I saw a directory where all its filenames are something like this: > ... > 1a PSG (Entry and PopUp).py > 1b PSG (Format).py > 1c PSG (persistent form and bind key).py > ... > > Just wondering how these file can run and debugged under Windows? > Put the file name inside double quotes. You can probably do this by tab-completing the name - type 1c and then hit the tab key - your shell should fill out the rest of the name with whatever quoting is necessary. ChrisA From jfong at ms4.hinet.net Fri Oct 12 06:14:47 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Fri, 12 Oct 2018 03:14:47 -0700 (PDT) Subject: How to run/debug a script file its name has characters such as space, (, etc. In-Reply-To: References: <873aeccc-cfa9-4d7f-ae81-8515e773933f@googlegroups.com> Message-ID: <481dabcd-5cda-41b5-935b-28e50464f5a5@googlegroups.com> Chris Angelico? 2018?10?12???? UTC+8??4?39?37???? > On Fri, Oct 12, 2018 at 6:26 PM wrote: > > > > I saw a directory where all its filenames are something like this: > > ... > > 1a PSG (Entry and PopUp).py > > 1b PSG (Format).py > > 1c PSG (persistent form and bind key).py > > ... > > > > Just wondering how these file can run and debugged under Windows? > > > > Put the file name inside double quotes. You can probably do this by > tab-completing the name - type 1c and then hit the tab key - your > shell should fill out the rest of the name with whatever quoting is > necessary. > > ChrisA After using Windows so many years, I don't know this trick the double quotes and tab can do in the shell. It really embarrass me:-( Thanks you, Chris. --Jach From dan at djph.net Fri Oct 12 06:19:09 2018 From: dan at djph.net (Dan Purgert) Date: Fri, 12 Oct 2018 10:19:09 -0000 (UTC) Subject: Observations on the List - "Be More Kind" References: <58c4c169-61ee-8f9d-72ea-742b816f2883@clara.co.uk> Message-ID: Chris Angelico wrote: > On Fri, Oct 12, 2018 at 5:07 AM Ian Kelly wrote: >> >> 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 ... 10/10, would read >> > again. >> >> For 4chan, maybe. > > He said "would read again". I absolutely agree. This is a CoC that is > worth reading again. Realistically, it's quite too hostile for "normal people[1]" -- and would likely never fly anywhere (although, a few weeks ago, I'd have said it'd fit on the LKML). That being said, I'd rather see a "blatantly hostile" document defining the rules of conduct for a place, rather than one whose hostility is derived from interpretation (that is, whether or not something is "against" the rules depends on the mod, and whether or not they had coffee this morning, and whether or not you generally get along with them). Note that both examples above are merely the extremes to which we can go, and that perhaps giving a "normal person[1]" examples of both, we would get a document somewhere in the middle that, while a compromise, would be better than anything we've as yet seen. [1]http://www.mit.edu/~jcb/tact.html -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From frank at chagford.com Fri Oct 12 06:30:27 2018 From: frank at chagford.com (Frank Millman) Date: Fri, 12 Oct 2018 12:30:27 +0200 Subject: Quickest way to concatenate strings In-Reply-To: References: Message-ID: "Dennis Lee Bieber" wrote in message news:cnk0sdl5a7p17framc5er811p1230mpmrk at 4ax.com... > On Fri, 12 Oct 2018 07:55:58 +0200, "Frank Millman" > declaimed the following: > > >I have often read that the quickest way to concatenate a number of > >strings > >is to place them in a list and 'join' them - > > > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > >''.join([x, y, z]) > > 500000 loops, best of 5: 307 nsec per loop > > > >I seem to have found a quicker method, using the new 'f' format > >operator - > > > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > >f'{x}{y}{z}' > > 1000000 loops, best of 5: 226 nsec per loop > > But your format operator is tied to just a specific number of > substrings. > > The list/join algorithm works when the substrings are gathered on an > ad-hoc basis, and the total number of items is unknown. > > collect = [] > while True: > ln = raw_input("enter a string (empty line to exit)> ").strip() > #yes, Python 2.x > if not ln: break > collect.append(ln) > > result = "".join(collect) That makes sense, thanks. My use case is that I am building a string from a number of building blocks - some of them literal strings, some of them string objects. As Thomas says, I could have just used the '+' operator. In practice I was building a list and then joining it. It turns out that the 'f' operator is faster than both of these methods in my particular case. Frank From rosuav at gmail.com Fri Oct 12 08:04:30 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 12 Oct 2018 23:04:30 +1100 Subject: How to run/debug a script file its name has characters such as space, (, etc. In-Reply-To: <481dabcd-5cda-41b5-935b-28e50464f5a5@googlegroups.com> References: <873aeccc-cfa9-4d7f-ae81-8515e773933f@googlegroups.com> <481dabcd-5cda-41b5-935b-28e50464f5a5@googlegroups.com> Message-ID: On Fri, Oct 12, 2018 at 9:16 PM wrote: > > Chris Angelico? 2018?10?12???? UTC+8??4?39?37???? > > On Fri, Oct 12, 2018 at 6:26 PM wrote: > > > > > > I saw a directory where all its filenames are something like this: > > > ... > > > 1a PSG (Entry and PopUp).py > > > 1b PSG (Format).py > > > 1c PSG (persistent form and bind key).py > > > ... > > > > > > Just wondering how these file can run and debugged under Windows? > > > > > > > Put the file name inside double quotes. You can probably do this by > > tab-completing the name - type 1c and then hit the tab key - your > > shell should fill out the rest of the name with whatever quoting is > > necessary. > > > > ChrisA > > After using Windows so many years, I don't know this trick the double quotes and tab can do in the shell. It really embarrass me:-( Thanks you, Chris. > No need to feel bad. Windows isn't as shell-heavy as Unix systems (including Linux) tend to be, and Windows users are almost never as shell-heavy as Unix users are. There are a lot of really cool tricks and features available that aren't heavily used, and that applies on ALL systems (seriously, have you ever met ANYONE who uses the entire power of bash??); it's awesome to learn new ways to work more efficiently, but there's no shame in not having used those methods already :) ChrisA From rgaddi at highlandtechnology.invalid Fri Oct 12 12:12:03 2018 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Fri, 12 Oct 2018 09:12:03 -0700 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: References: Message-ID: On 10/11/2018 11:29 PM, Kaan Taze wrote: > Hi everyone, > > Since this is my first post to mail-list I'm kind of hesitant to ask this > question here but as many of you spend years working with Python maybe some > of you can guide me. > > What I trouble with is not a logical error that exist on a program I wrote. > It's the Python itself. Well, I'm 22 years old CS student -from Turkey- and > what they showed us at university was C Language and Java but I mainly use > C in school projects etc. So it's been few months that I started to use > Python for my personal side-projects. There are lots of resources to learn > language. I do what I need to do with Python too but I was kinda shocked > when I solve Python questions at Hackerrank. Even with list comprehensions > you can implement in very smart way to get things done and easy. > Iterations, string operations. The codes I see on the Internet using basics > in a very clever way which I couldn't come up with the same solution if I > tried to for some time. I do understand this ways but coming from ANSI C > makes it hard to see this flexibility. I probably do things in a both > inefficient and hard way in my projects. > > How do I get used to this? Is this just another "practice, practice, > practice" situation? Anything you can recommend? > > > All the best. > > Kaan. > A) Yes, it's practice practice practice. B) Don't get hung up on finding the clever solution. Comprehensions and generators and lots of other things are great under some circumstances for making the code clearer and easier to read, but they too can become the hammer that makes everything look like a nail. The most important thing is that your code is logical, clean, and easy to understand. If it doesn't take full advantage of the language features, or if the performance isn't optimized to within an inch of its life, well so be it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From skip.montanaro at gmail.com Fri Oct 12 12:43:02 2018 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Fri, 12 Oct 2018 11:43:02 -0500 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: I sort of skimmed ESR's post, and sort of skimmed this thread, so obviously I'm totally qualified to offer my observations on the post and follow ups. :-) Eric makes a mistake, in my opinion, confusing his particular application with the mainstream, when in fact it seems pretty specialized to me. Consequently, he foresees the waning of Python, in my opinion, incorrectly. As to the problems posed by the GIL, I am aware of serious attempts to remove it at least as far back as Python ~ 1.4 (by Greg Smith, as I recall). His experience was what has been reported in this thread. While he could improve CPU utilization for multi-threaded applications, that came at an unacceptable performance cost for single-threaded applications, which I believe still dominate the application landscape today. Beyond performance, there is the issue that the GIL keeps extension authors from shooting themselves in the foot. When your code is called, the GIL insures that nobody else can stomp on your data when you are executing. Skip Montanaro From rhodri at kynesim.co.uk Fri Oct 12 12:44:58 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 12 Oct 2018 17:44:58 +0100 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: References: Message-ID: <928b9a9e-b1bc-15b9-6b5e-24ee0db75f60@kynesim.co.uk> On 12/10/18 17:12, Rob Gaddi wrote: > On 10/11/2018 11:29 PM, Kaan Taze wrote: >> Hi everyone, >> >> Since this is my first post to mail-list I'm kind of hesitant to ask this >> question here but as many of you spend years working with Python maybe >> some >> of you can guide me. >> >> What I trouble with is not a logical error that exist on a program I >> wrote. >> It's the Python itself. Well, I'm 22 years old CS student -from >> Turkey- and >> what they showed us at university was C Language and Java but I mainly >> use >> C in school projects etc. So it's been few months that I started to use >> Python for my personal side-projects. There are lots of resources to >> learn >> language. I do what I need to do with Python too but I was kinda shocked >> when I solve Python questions at Hackerrank. Even with list >> comprehensions >> you can implement in very smart way to get things done and easy. >> Iterations, string operations. The codes I see on the Internet using >> basics >> in a very clever way which I couldn't come up with the same solution if I >> tried to for some time. I do understand this ways but coming from ANSI C >> makes it hard to see this flexibility. I probably do things in a both >> inefficient and hard way in my projects. >> >> How do I get used to this? Is this just another "practice, practice, >> practice" situation? Anything you can recommend? >> >> >> All the best. >> >> Kaan. >> > > A) Yes, it's practice practice practice. > > B) Don't get hung up on finding the clever solution.? Comprehensions and > generators and lots of other things are great under some circumstances > for making the code clearer and easier to read, but they too can become > the hammer that makes everything look like a nail.? The most important > thing is that your code is logical, clean, and easy to understand.? If > it doesn't take full advantage of the language features, or if the > performance isn't optimized to within an inch of its life, well so be it. I completely agree. I too have come from a background in C, and still do most of my day job in C or assembler. It took a while before I was writing idiomatic Python, never mind efficient Python (arguably I still don't, but as Rob says, who cares?). Don't worry about it; at some point you will discover that the "obvious" Python you are writing looks a lot like the code you are looking at now and thinking "that's really clever, I'll never be able to to that." -- Rhodri James *-* Kynesim Ltd From rosuav at gmail.com Fri Oct 12 13:06:40 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 13 Oct 2018 04:06:40 +1100 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: References: Message-ID: On Sat, Oct 13, 2018 at 3:07 AM Kaan Taze wrote: > > Hi everyone, > > Since this is my first post to mail-list I'm kind of hesitant to ask this > question here but as many of you spend years working with Python maybe some > of you can guide me. Hey there, welcome! :) > I do what I need to do with Python too but I was kinda shocked > when I solve Python questions at Hackerrank. Even with list comprehensions > you can implement in very smart way to get things done and easy. > Iterations, string operations. There are many many different ways to write code, and you can approach your coding challenges from all sorts of directions. My recommendation is: Pseudo-code first, then implement in actual Python. https://en.wikipedia.org/wiki/Pseudocode Note how, in the Wiki page, there are a number of different forms of pseudocode. You're free to develop your own particular style. In general, pseudocode is a bit more rigorous than plain English, but less than actually-executable code. Once you have some pseudocode written, make as few changes as you can, getting it to be runnable. In other words, you want your final code to look as much like pseudocode as you possibly can. Python is great at this; the syntax lends itself well to that style of writing. (In fact, when I'm teaching JavaScript, I often push students towards a pseudocode style that looks a lot like Python code.) Code should express an algorithm, not showcase your ability to wield language features :) Hope that helps! ChrisA From spencer.graves at effectivedefense.org Fri Oct 12 13:40:30 2018 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Fri, 12 Oct 2018 12:40:30 -0500 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: <928b9a9e-b1bc-15b9-6b5e-24ee0db75f60@kynesim.co.uk> References: <928b9a9e-b1bc-15b9-6b5e-24ee0db75f60@kynesim.co.uk> Message-ID: <13adb197-e3d6-5510-aab3-21e125b723c5@effectivedefense.org> On 2018-10-12 11:44, Rhodri James wrote: > On 12/10/18 17:12, Rob Gaddi wrote: >> On 10/11/2018 11:29 PM, Kaan Taze wrote: >>> Hi everyone, >>> >>> Since this is my first post to mail-list I'm kind of hesitant to ask >>> this >>> question here but as many of you spend years working with Python >>> maybe some >>> of you can guide me. >>> >>> What I trouble with is not a logical error that exist on a program I >>> wrote. >>> It's the Python itself. Well, I'm 22 years old CS student -from >>> Turkey- and >>> what they showed us at university was C Language and Java but I >>> mainly use >>> C in school projects etc. So it's been few months that I started to use >>> Python for my personal side-projects. There are lots of resources to >>> learn >>> language. I do what I need to do with Python too but I was kinda >>> shocked >>> when I solve Python questions at Hackerrank. Even with list >>> comprehensions >>> you can implement in very smart way to get things done and easy. >>> Iterations, string operations. The codes I see on the Internet using >>> basics >>> in a very clever way which I couldn't come up with the same solution >>> if I >>> tried to for some time. I do understand this ways but coming from >>> ANSI C >>> makes it hard to see this flexibility. I probably do things in a both >>> inefficient and hard way in my projects. >>> >>> How do I get used to this? Is this just another "practice, practice, >>> practice" situation? Anything you can recommend? >>> >>> >>> All the best. >>> >>> Kaan. >>> >> >> A) Yes, it's practice practice practice. >> >> B) Don't get hung up on finding the clever solution. Comprehensions >> and generators and lots of other things are great under some >> circumstances for making the code clearer and easier to read, but >> they too can become the hammer that makes everything look like a >> nail.? The most important thing is that your code is logical, clean, >> and easy to understand.? If it doesn't take full advantage of the >> language features, or if the performance isn't optimized to within an >> inch of its life, well so be it. > > I completely agree.? I too have come from a background in C, and still > do most of my day job in C or assembler.? It took a while before I was > writing idiomatic Python, never mind efficient Python (arguably I > still don't, but as Rob says, who cares?).? Don't worry about it; at > some point you will discover that the "obvious" Python you are writing > looks a lot like the code you are looking at now and thinking "that's > really clever, I'll never be able to to that." I suggest two things: ????? 1.? Document your work as you do it in something like Jupyter Notebooks that were discussed in another recent thread.? I use "R Markdown Documents" in RStudio.? This allows me to mix Python code with text and code for other languages (including R, C, SQL, and others).? I tried installing Jupyter using Ananconda Navigator and failed -- under both Windows 7 and macOS 10.14.[1]? One consulting gig I had involved spending roughly a week creating an "R Markdown Document" mixing text with code and results analyzing a client's data, followed by months replying to questions by asking, "Did you look at p. ___ in the R Markdown Document I gave you" -- plus a few extensions to that document.? An article in The Atlantic last April claimed, "The scientific research paper is obsolete" and is being replaced by Jupyter Notebooks.[2]? I'd like to see a serious comparison of "R Markdown Documents" with "Jupyter Notebooks":? The latter may be better, but I was unable to even started with them after two days of effort. ????? 2.? Find a reasonable "Introduction to Python" on the web. Others on this list should be able to suggest several.? I just found "https://docs.python.org/2/tutorial/introduction.html".? A web search for "an introduction to Python" identified several others. I'd also be interested in reference(s) others might suggest for "creating python packages". ????? Hope this helps. ????? Spencer Graves [1] RStudio offers a free "Desktop" version, which I have used routinely for the past three years.? It's available at "www.rstudio.com/products/rstudio/download".? Creating "R Markdown Documents" (File > "New File" > "R Markdown..." in RStudio) made a dramatic improvement in my productivity in many ways similar to those described by Paul Romer in "https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper". (I also experimented with File > "New File" > "R Notebook" in RStudio and encountered bazaar errors I could not understand -- and no benefits that I could see that would push me to spend more time trying to get past the problems I encountered.? I've used "R Markdown Documents" extensively for three years -- with R -- and I found it easy to use with Python once I learned I could do that. See "https://bookdown.org/yihui/rmarkdown". [2] https://www.theatlantic.com/science/archive/2018/04/the-scientific-paper-is-obsolete/556676/ From neilc at norwich.edu Fri Oct 12 14:18:16 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 12 Oct 2018 18:18:16 GMT Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? References: Message-ID: On 2018-10-12, Kaan Taze wrote: > How do I get used to this? Is this just another "practice, > practice, practice" situation? Anything you can recommend? You will become comfortable with Python with time and practice. Be patient with yourself. I don't care for my early Python code, but it still works and I can still maintain it with little trouble. -- Neil Cerutti From rj.amdphreak at gmail.com Fri Oct 12 14:28:22 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Fri, 12 Oct 2018 13:28:22 -0500 Subject: Single DB connection during class's lifetime. Metaclass,singleton and __new__() examples and references. In-Reply-To: References: <5bbfda6c.1c69fb81.99eaa.e3ff@mx.google.com> Message-ID: <5bc0e7c6.1c69fb81.28d45.6203@mx.google.com> Thanks for the clarification. If I am creating a class variable, are you suggesting I perform the ?if it exists, great, otherwise make it? logic in the __init__ block or in the class definition block? Will that even run in a class definition? I never see examples do anything besides assignment operations and flow control, although it would follow that if the block allows creation of strings (an object), it would allow creation of connection objects. On the other hand, the __init__ block seems like a natural place to put the cursor instantiation. >From this answer ( https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642 ) the pythonic way to access the class variable is using type(self), but doesn?t this access the local class?s variable, if someone subclasses my class? Can I specify my class variable via the class name itself? Example: instancevar = ClassName.classvar . I am hoping that because of the way python points labels to objects, this should give my instance an instance var that refers to the class var. Am I right? RJ Sent from Mail for Windows 10 From: Thomas Jollans Sent: Friday, October 12, 2018 2:05 AM To: python-list at python.org Subject: Re: Single DB connection during class's lifetime. Metaclass,singleton and __new__() examples and references. On 12/10/2018 01:19, Ryan Johnson wrote: > I am working on using mysql.connector in a class and have found an example of how to create a single connection that spans the lifetime of all instances of the class: > > https://softwareengineering.stackexchange.com/a/358061/317228 > > however, I do not understand a few things about the class, including > > 1. Why it is subclassed as an object: `class Postgres(object):` ? I thought classes were necessarily objects. This was sometimes necessary in Python 2. > 2. Why is this portion of code directly addressing the class, instead of using the `cls` reference variable? > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() In a subclass, the `cls' argument would refer to the subclass, while `Postgres' would still refer to the original class. I have no idea what this is trying to achieve, and I think it's probably a bug. Maybe someone else has an idea. > 3. And is it me or does anyone else think {anydb}.connector?s usage is messy and inelegant? Ex: > print('connecting to PostgreSQL database...') > connection = Postgres._instance.connection = psycopg2.connect(**db_config) > cursor = Postgres._instance.cursor = connection.cursor() > cursor.execute('SELECT VERSION()') > db_version = cursor.fetchone() > Why can?t we associate the focus of the connection with the connection itself, instead of creating a separate cursor object? You can have multiple cursors on the same connection. > > Also, within the code example, and in Python in general, why does there needs to be a __new__ constructor when there?s an __init__ constructor? I?ve read about the usage of singletons. It seems you could create singletons within __init__ or __new__ . Any enlightenment would be really helpful. I am very sleep-deprived, so I?m sorry if this seems like a dumb question. > > I have read the official docs. Have also been reading ?Python 3: Patterns, Recipes, and Idioms?. The first was mildly helpful but I still don?t see the benefit of a __new__ constructor. You can't create a singleton with __init__: by the time __init__ is called, a new instance has already been created, and you can't switch the object for a different one. By using __new__, you can bypass the creation of a new instance. If what you want is some shared state between all instances, a class variable or global will do just fine and there's no need for a singleton instance of anything. > Why is there dislike for Metaclasses? They can be confusing. -- https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Fri Oct 12 14:39:48 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 12 Oct 2018 20:39:48 +0200 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: <20181012183948.ynubmo2wnwxgnn5p@hjp.at> On 2018-10-11 17:56:43 +0000, Neil Cerutti wrote: > On 2018-10-10, Paul Rubin wrote: > > Neil Cerutti writes: > >> > >>> the GIL (15/16th of his CPUs are unused..) > >> Channels are a big selling point of Go, no argument there. > > > > The unused CPUs are not about channels (Python has Queue which > > is similar). They're about the GIL, which is an implementation > > artifact of CPython that's hard to eliminate without modifying > > CPython's C API. ESR didn't say this explicitly but it came to > > mind when reading his post: It's weird that Python's designers > > were willing to mess up the user language in the 2-to-3 > > transition but felt that the C API had to be kept sarcosanct. > > Huge opportunities were blown at multiple levels. > > OK. I assumed he planned to parallelize computations in Go by > offloading to concurrent channels-- You mean goroutines, not channels. Channels are a mechanism which goroutines use to communicate with each other. In Python terms, goroutines are sort of like threads, channels like queues. > I guess I don't understand why he can't do that in Python. The Go runtime can efficiently distribute goroutines over all cores. The CPython runtime can't do the same with threads (mostly because of the GIL, as already discussed). You can run several Python processes and let them communicate via some IPC mechanism (indeed the Python multiprocessing module provides Pipe and Queue classes for this purpose), but IPC is generally more expensive than communication within the same process. So the overhead may be too hight if you need very fine-grained communication. > I imagine that if I stuck with Go long enough I'd develop a new coding > style that didn't inolve creating useful data types. I haven't used Go for any real project yet (that may change next year - we'll see whether I love it or hate it), but I don't see why you wouldn't create useful data types in your Go programs. Go isn't object-oriented, but that doesn't make its type system useless (I've certainly created lots of useful data types in C). hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From tjreedy at udel.edu Fri Oct 12 14:41:02 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 12 Oct 2018 14:41:02 -0400 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: References: Message-ID: On 10/12/2018 1:06 PM, Chris Angelico wrote: > There are many many different ways to write code, and you can approach > your coding challenges from all sorts of directions. My recommendation > is: Pseudo-code first, then implement in actual Python. > > https://en.wikipedia.org/wiki/Pseudocode > > Note how, in the Wiki page, there are a number of different forms of > pseudocode. You're free to develop your own particular style. In > general, pseudocode is a bit more rigorous than plain English, but > less than actually-executable code. Over two decades ago, I dubbed Python 'executable pseudocode'. I recommend using it as such. Here is a common program template that makes the basic logic clear def f() it = get_iterable() for item in it: process(item) return summary() f(some args) > Once you have some pseudocode > written, make as few changes as you can, getting it to be runnable. In > other words, you want your final code to look as much like pseudocode > as you possibly can. Either write the currently fake functions or replace the calls with inline code. Do the latter for items. -- Terry Jan Reedy From hjp-python at hjp.at Fri Oct 12 14:55:41 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 12 Oct 2018 20:55:41 +0200 Subject: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: References: Message-ID: <20181012185541.kycfedu4lvcpg5yr@hjp.at> On 2018-10-11 13:57:57 +0200, Thomas Jollans wrote: > There's no easy way to write to the middle of a file (though I think it > can be done by mmap'ing a file) #!/usr/bin/python3 import os with open("foo.bin", "wb") as f: f.write(b'abcdefghijklmnopqrstuvwxyz') with open("foo.bin", "rb") as f: print("-----") for i, c in enumerate(f.read()): print("%2d %2x" % (i, c)) with open("foo.bin", "r+b") as f: f.seek(10, os.SEEK_SET) f.write(b'000') f.seek(20, os.SEEK_SET) f.write(b'11') f.seek(30, os.SEEK_SET) f.write(b'2') with open("foo.bin", "rb") as f: print("-----") for i, c in enumerate(f.read()): print("%2d %2x" % (i, c)) Mmap doesn't allow you to do anything you can't do with normal file I/O. It's just sometimes more convenient and/or performant. > -- and even if you manage to do that, > you'd have to write back anything after the changed line if the length > of that line changed by as little as a byte. This is correct. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Fri Oct 12 15:00:45 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 12 Oct 2018 21:00:45 +0200 Subject: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: References: Message-ID: <20181012190045.xmwdavg4clmig6qq@hjp.at> On 2018-10-11 09:01:55 -0400, Dennis Lee Bieber wrote: > On Thu, 11 Oct 2018 15:14:49 +0530, Iranna Mathapati > declaimed the following: > >How to replace particular line text with new text on a file > >i have below code but its writing whole code. > > > For C-style streams (which seem to have taken over every operating > system) in which "lines" are determined by specific characters in the > stream, you can only "replace" a line IF THE REPLACEMENT IS THE EXACT SAME > SIZE! If there is any difference in length of the input and output lines, > you have to read/write everything from the line to the end of the file. > > I emphasize "C-style streams" as there were operating systems that did > support other file organizations natively. And therefore you should call them "Unix-style streams". > Xerox CP-V offered "consecutive", "keyed", and "random" file > organizations. I don't know if there was a C implementation for CP-V, but there is certainly nothing in the C standard which would prevent a standard conforming implementation of those file organizations. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From info at tundraware.com Fri Oct 12 15:07:56 2018 From: info at tundraware.com (Tim Daneliuk) Date: Fri, 12 Oct 2018 14:07:56 -0500 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: <6202606b-7944-0f92-b9a3-83491c13399a@tundraware.com> On 10/11/2018 12:15 AM, Gregory Ewing wrote: > Paul Rubin wrote [concerning GIL removal]: >> It's weird that Python's designers were willing to mess up the user >> language in the 2-to-3 transition but felt that the C API had to be kept >> sarcosanct.? Huge opportunities were blown at multiple levels. > > You say that as though we had a solution for GIL removal all > thought out and ready to go, and the only thing that stopped us > is that it would have required changing the C API. > > But it's not like that at all. As far as I know, all the > attempts that have been made so far to remove the GIL have > led to performance that was less than satisfactory. It's a > hard problem that we haven't found a good solution to yet. > Do you happen to have a reference that explains what the issues are for GIL removal? From info at tundraware.com Fri Oct 12 15:10:36 2018 From: info at tundraware.com (Tim Daneliuk) Date: Fri, 12 Oct 2018 14:10:36 -0500 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> Message-ID: On 10/12/2018 11:43 AM, Skip Montanaro wrote: > I sort of skimmed ESR's post, and sort of skimmed this thread, so > obviously I'm totally qualified to offer my observations on the post > and follow ups. :-) Skip - In the 15-ish years I've been reading this group, this has NEVER been an obstacle for posters :P From vito.detullio at gmail.com Fri Oct 12 16:23:57 2018 From: vito.detullio at gmail.com (Vito De Tullio) Date: Fri, 12 Oct 2018 22:23:57 +0200 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> Message-ID: Chris Angelico wrote: >> Reference counting was likely a bad idea to begin with. > > Then prove CPython wrong by making a fantastically better > implementation that uses some other form of garbage collection. I'm not talking about the "goodness" of the implemetations, but AFAIK jython and ironpython doesn't have the refcount gb (and they don't even have the GIL...) -- By ZeD From rosuav at gmail.com Fri Oct 12 16:27:36 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 13 Oct 2018 07:27:36 +1100 Subject: ESR "Waning of Python" post In-Reply-To: References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> Message-ID: On Sat, Oct 13, 2018 at 7:25 AM Vito De Tullio wrote: > > Chris Angelico wrote: > > >> Reference counting was likely a bad idea to begin with. > > > > Then prove CPython wrong by making a fantastically better > > implementation that uses some other form of garbage collection. > > I'm not talking about the "goodness" of the implemetations, but AFAIK jython > and ironpython doesn't have the refcount gb (and they don't even have the > GIL...) > Yes, which proves that it's viable. I notice that neither of them has swept CPython away by massively outperforming them, so perhaps reference counting isn't such a terrible idea after all? I'm not disputing that refcounting has its downsides, but "likely a bad idea to begin with" seems to be a bit beyond reasonable. ChrisA From neilc at norwich.edu Fri Oct 12 16:51:56 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 12 Oct 2018 20:51:56 GMT Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <20181012183948.ynubmo2wnwxgnn5p@hjp.at> Message-ID: On 2018-10-12, Peter J. Holzer wrote: > Neil Cerutti said: >> I imagine that if I stuck with Go long enough I'd develop a >> new coding style that didn't inolve creating useful data >> types. > > I haven't used Go for any real project yet (that may change > next year - we'll see whether I love it or hate it), but I > don't see why you wouldn't create useful data types in your Go > programs. Go isn't object-oriented, but that doesn't make its > type system useless (I've certainly created lots of useful data > types in C). Yeah, my comment was fairly flippant. It isn't that you can't make new data types in Go, it's that you can't transparently use Go's syntax facilities with them. In Python (and C++), if the language provides a facility, my datatype can usually take direct advantage of it, e.g., for loops or iterators. I didn't stick around long enough to get used to the restrictions on this in Go. -- Neil Cerutti From alan at csail.mit.edu Fri Oct 12 19:14:05 2018 From: alan at csail.mit.edu (Alan Bawden) Date: 12 Oct 2018 19:14:05 -0400 Subject: Quickest way to concatenate strings References: Message-ID: <86tvlqrc5e.fsf@richard.bawden.org> "Frank Millman" writes: > I have often read that the quickest way to concatenate a number of strings > is to place them in a list and 'join' them - > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > ''.join([x, y, z]) ... > > I seem to have found a quicker method, using the new 'f' format operator - > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > f'{x}{y}{z}' If you look at the compiled byte code for the f-string case you'll see why it's faster: there's nothing used other than opcodes designed specifically for building strings. I note that although 'x + y' is faster than f'{x}{y}', 'x + y + z' is slower than f'{x}{y}{z}'. Apparently the overhead of making just _one_ temporary intermediate string is enough to tip the balance. I'm a bit surprised that it doesn't take a few more than that. Although I imagine that that balance might tip at a different point in future releases of Python (I tested using 3.6.6). -- Alan Bawden From greg.ewing at canterbury.ac.nz Sat Oct 13 00:43:25 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sat, 13 Oct 2018 17:43:25 +1300 Subject: ESR "Waning of Python" post In-Reply-To: <87zhvknmm5.fsf@nightsong.com> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <87zhvknmm5.fsf@nightsong.com> Message-ID: Paul Rubin wrote: > I even wonder what happens if you turn Py_INCREF etc. into no-ops, > install the Boehm garbage collector in a stop-the-world mode, and > disable the GIL. I suspect you would run into problems with things that need mutual exclusion but don't do any locking of their own, because the GIL is assumed to take care of it. -- Greg From dieter at handshake.de Sat Oct 13 02:01:53 2018 From: dieter at handshake.de (dieter) Date: Sat, 13 Oct 2018 08:01:53 +0200 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> Message-ID: <87muriz8oe.fsf@handshake.de> Marko Rauhamaa writes: > dieter : > ... >> I work in the domain of web applications. And I made there a nasty >> experience with garbage collection: occasionally, the web application >> stopped to respond for about a minute. A (quite difficult) analysis >> revealed that some (stupid) component created in some situations (a >> search) hundreds of thousands of temporary objects and thereby >> triggered a complete garbage collection. The garbage collector started >> its mark and sweep phase to detect unreachable objects - traversing a >> graph of millions of objects. >> >> As garbage collection becomes drastically more complex if the object >> graph can change during this phase (and this was Python), a global >> look prevented any other activity -- leading to the observed >> latencies. > > Yes. The occasional global freeze is unavoidable in any > garbage-collected runtime environment regardless of the programming > language. > > However, I challenge the notion that creating hundreds of thousands of > temporary objects is stupid. I suspect that the root cause of the > lengthy pauses is that the program maintains millions of *nongarbage* > objects in RAM (a cache, maybe?). Definitely. The application concerned was a long running web application; caching was an important feature to speed up its typical use cases. I do not say that creating hundreds of thousands of temporary objects is always stupid. But in this case, those temporary objects were used to wrap early on the document ids found in an index entry just to get a comfortable interface to access the corresponding documents. While the index authors were aware that they treat mass data and therefore stored it in a compact way as C level objects with efficient "C" level implemented filtering operations on it, the search author has neglected this aspect and wrapped all document ids into Python objects. "search" is essentially a filtering operation; typically, you need to access far less documents (at most those in a prefiltered result set) than document ids (the input to the filtering); in this case, it is stupid to create temporary objects for all document ids in order to access much less documents later in a comfortable way. From hjp-python at hjp.at Sat Oct 13 02:46:06 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 13 Oct 2018 08:46:06 +0200 Subject: how to replace line on particular line in file[no need to write it back whole file again] In-Reply-To: <2ll2sd56u1j9175eb73m1e188ijrc99hn7@4ax.com> References: <20181012190045.xmwdavg4clmig6qq@hjp.at> <2ll2sd56u1j9175eb73m1e188ijrc99hn7@4ax.com> Message-ID: <20181013064606.af7bstme6bwnauln@hjp.at> On 2018-10-12 22:28:44 -0400, Dennis Lee Bieber wrote: > On Fri, 12 Oct 2018 21:00:45 +0200, "Peter J. Holzer" > declaimed the following: > >I don't know if there was a C implementation for CP-V, but there is > >certainly nothing in the C standard which would prevent a standard > >conforming implementation of those file organizations. [...] > However -- my point was that those formats were supported natively at > the OS level, not some language utility library working on top of the basic > streams. Right. And since this is an OS capability (which Unix lacks), not a language capability, I think it is better to talk about Unix-style streams, not C-style streams. > A more recent (my age shows) example would be the features in DEC VMS > Record Management Services. Again the format was handled at the system > service level by any language -- stream, fixed length with counts, ISAM... Any language includes C. I haven't programmed in C on VMS, but my understanding is that the C library works works fine with fixed length records on VMS. Indeed I think that VMS was a major reason for some restrictions in the C standard. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Sat Oct 13 03:00:17 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 13 Oct 2018 09:00:17 +0200 Subject: ESR "Waning of Python" post In-Reply-To: <6202606b-7944-0f92-b9a3-83491c13399a@tundraware.com> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <6202606b-7944-0f92-b9a3-83491c13399a@tundraware.com> Message-ID: <20181013070017.x6fejmdk4ukfly2f@hjp.at> On 2018-10-12 14:07:56 -0500, Tim Daneliuk wrote: > On 10/11/2018 12:15 AM, Gregory Ewing wrote: > > But it's not like that at all. As far as I know, all the > > attempts that have been made so far to remove the GIL have > > led to performance that was less than satisfactory. It's a > > hard problem that we haven't found a good solution to yet. > > Do you happen to have a reference that explains what the issues are > for GIL removal? I'm certainly not an expert on CPython internals, but what I've gathered from talks and discussions on the topic is that the CPython interpreter accesses shared state a lot (the reference count fields are an obvious example, but there are others), so to remove the GIL you would have to replace it with a myriad of small locks which are taken and released all the time - this adds a lot of overhead compared to a single lock which is basically always taken and just released before blocking syscalls. (If you ask your favourite search engine for "gilectomy", you'll probably find lots of info) It might be better to start from scratch: Design a new VM suitable for Python which can run mostly without locks. But this is of course a lot of work with no guarantee of success. (JPython and IronPython did something similar, although they didn't design new VMs, but reused VMs designed for other languages). hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Sat Oct 13 03:26:11 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 13 Oct 2018 09:26:11 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> Message-ID: <20181013072611.pqy6yhalf2watuff@hjp.at> On 2018-10-08 20:13:38 +0000, Grant Edwards wrote: > On 2018-10-08, Peter J. Holzer wrote: > > Theoretically I would agree with you: Just use a single tab per > > indentation level and let the user decide whether that's displayed > > as 2, 3, 4, or 8 spaces or 57 pixels or whatever. > > > > In practice it doesn't work in my experience. > > Nor in mine. On problem is that under Unix is that there isn't just > one place where you would need to configure the tab width. There are > dozens of text-processing tools that get used on all sorts of text, > including program sources in a variety of languages. > > For "just use tabs" to work, all of those tools would have to > magically recognize that they're looking at Python source and adjust > the tab size accordingly. That isn't going to happen. Well, no. The idea of "just use tabs" isn't have a different tab width per language, but a different tab width per user. So I - being a fan of fixed-width fonts - would set the tab width to 5 spaces (just to pick a somewhat unusual number), and Python, Perl, C, TypeScript, HTML, CSS, etc. code containing tabs would be displayed and printed with that tab width. You set your tab width to half an inch. And all your text files are displayed and printed with that tab width. Gene uses 3 spaces, etc. There aren't that many tools which would have to be configured. For me that would be vim (the text editor), the tty driver and/or the terminal emulator (not sure what the right place is), less (the pager), and paps (for printing). Maybe a few others, but the vast majority of tools doesn't care about the tab width. For them a tab is just a single byte. The problem is in my experience that a "use only tabs" policy is hard to enforce. People will type spaces when they should use tabs (and use tabs when they should use spaces), their software will autoconvert between spaces and tabs (with a different number of spaces per tab for each user), etc. The result is an awful mess. "Use only spaces" is much easier to enforce: Just reject any file (except binaries and makefiles) with a 0x09 byte at commit time. (Now that I think of it, "use tabs" might work better in Python than in other languages because in Python indentation has syntactic meaning. If your editor replaces some tabs with spaces or vice versa, your program won't compile any more and you will (hopefully) fix it before committing it.) hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Sat Oct 13 03:37:44 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 13 Oct 2018 09:37:44 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> Message-ID: <20181013073744.kpemgmae7wkarvrr@hjp.at> On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: > On 08-10-18 19:43, Peter J. Holzer wrote: > > On 2018-10-08 10:36:21 +1100, Chris Angelico wrote: > >> How wide my indents are on my screen shouldn't influence your screen > >> or your choices. > > Theoretically I would agree with you: Just use a single tab per > > indentation level and let the user decide whether that's displayed as 2, > > 3, 4, or 8 spaces or 57 pixels or whatever. > > > > In practice it doesn't work in my experience. There is always someone in > > a team who was "just testing that new editor" and replaced all tabs > > with spaces (or vice versa) or - worse - just some of them. > > Isn't that caugth in the process of commiting to version control? Tabs are easy to catch. If a file contains a tab, reject it. Spaces aren't, because spaces are everywhere. So you would have to check whether a particular run of spaces should really be a tab, which is a much harder problem. At the very least you will have to parse enough of the language to find multi-line strings and indented blocks. So it's easier to mandate "no tabs" than "only tabs for indentation". Especially if you are dealing with more than one language. (I think Python would be relatively easy. Perl is somewhere between hard and impossible, but there is a library which can handle most non-pathological code, C is somewhere between, etc. But the point is that you would need a different checking tool for every language.) hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From jfine2358 at gmail.com Sat Oct 13 04:16:23 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Sat, 13 Oct 2018 01:16:23 -0700 (PDT) Subject: ESR "Waning of Python" post In-Reply-To: <877einneb8.fsf@nightsong.com> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <6202606b-7944-0f92-b9a3-83491c13399a@tundraware.com> <877einneb8.fsf@nightsong.com> Message-ID: <775e7849-570f-4401-917d-b0c71297caaa@googlegroups.com> On Friday, October 12, 2018 at 8:41:12 PM UTC+1, Paul Rubin wrote: > 1) If you keep the existing refcount mechanism, you have to put locks > around all the refcounts, which kills performance since refcounts are > updated all the time. I think BUFFERED multi-core reference count garbage collection is possible. If so, then locks are not needed. I explain this in this thread: [Python-ideas] Multi-core reference count garbage collection https://groups.google.com/forum/#!topic/python-ideas/xRPdu3ZGeuk https://mail.python.org/pipermail/python-ideas/2018-July/052054.html -- Jonathan From shakti.shrivastava13 at gmail.com Sat Oct 13 04:40:11 2018 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sat, 13 Oct 2018 14:10:11 +0530 Subject: socket: Too many open files Message-ID: Hello, I?m running a script which basically does a traceroute to the list of hosts provided, and then pulls up some info by logging in to gateways in the path. I am running this script for a list of almost 40k hosts in our data centers. Also, I am using commands module to get the traceroute output. out = commands.getstatusoutput('traceroute ' + ip) However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. I know commands module is using pipes to execute the given command and this is one reason for exhaustion of file descriptors. Any suggestions for improving this and getting a workaround? Thanks, Shakti From shakti.shrivastava13 at gmail.com Sat Oct 13 04:48:29 2018 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sat, 13 Oct 2018 14:18:29 +0530 Subject: Fwd: socket: Too many open files In-Reply-To: References: Message-ID: >Hello, >I?m running a script which basically does a traceroute to the list of hosts provided, and then pulls up some info by logging in to gateways in the path. >I am running this script for a list of almost 40k hosts in our data centers. >Also, I am using commands module to get the traceroute output. >out = commands.getstatusoutput('traceroute ' + ip) >However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. >I know commands module is using pipes to execute the given command and this is one reason for exhaustion of file descriptors. >Any suggestions for improving this and getting a workaround? >Thanks, >Shakti I dont understand how I should close the socket created by commands module after I do traceroute to one host. Also, if I?m not wrong, isn?t commands module supposed to do that on its own? From marko at pacujo.net Sat Oct 13 04:55:23 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 13 Oct 2018 11:55:23 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> Message-ID: <87murirzt0.fsf@elektro.pacujo.net> dieter : > Marko Rauhamaa writes: >> However, I challenge the notion that creating hundreds of thousands of >> temporary objects is stupid. I suspect that the root cause of the >> lengthy pauses is that the program maintains millions of *nongarbage* >> objects in RAM (a cache, maybe?). > > Definitely. The application concerned was a long running web application; > caching was an important feature to speed up its typical use cases. As an optimization technique, I suggest turning the cache into a "binary blob" opaque to GC, or using some external component like SQLite. Keeping the number of long-term objects low is key. Note that Python creates a temporary object every time you invoke a method. CPython removes them quickly through reference counting, but other Python implementations just let GC deal with them, and that's generally ok. Marko From marko at pacujo.net Sat Oct 13 05:03:01 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 13 Oct 2018 12:03:01 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87woqmmin7.fsf@nightsong.com> Message-ID: <87in26rzga.fsf@elektro.pacujo.net> Paul Rubin : > Note that Java has a lot of [GC] options to choose from: > https://docs.oracle.com/javase/9/gctuning/available-collectors.htm I'm all for GC, but Java's GC tuning options are the strongest counter-argument against it. The options just shift the blame from the programming language to the operator of the software. For GC to be acceptable, you shouldn't ever have to tune it. And I've seen it in action. A customer complains about bad performance. The system engineer makes a tailored GC recipe to address the issue, which may help for a short while. Here's my rule of thumb. Calculate how much memory you need for long-term objects. Don't let the application exceed that amount. Multiply the amount by 10 and allocate that much RAM for your application. > Another approach is Erlang's, where the application is split into a > lot of small lightweight processes, each of which has its own GC and > heap. So while some of them are GC'ing, the rest can keep running. So the lightweight processes don't share any data. That may be a fine approach. Marko From alister.ware at ntlworld.com Sat Oct 13 05:25:17 2018 From: alister.ware at ntlworld.com (Alister) Date: Sat, 13 Oct 2018 09:25:17 GMT Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? Message-ID: <1SiwD.34186$F96.18282@fx40.am4> On Fri, 12 Oct 2018 09:12:03 -0700, Rob Gaddi wrote: > On 10/11/2018 11:29 PM, Kaan Taze wrote: >> Hi everyone, >> >> Since this is my first post to mail-list I'm kind of hesitant to ask >> this question here but as many of you spend years working with Python >> maybe some of you can guide me. >> >> What I trouble with is not a logical error that exist on a program I >> wrote. >> It's the Python itself. Well, I'm 22 years old CS student -from Turkey- >> and what they showed us at university was C Language and Java but I >> mainly use C in school projects etc. So it's been few months that I >> started to use Python for my personal side-projects. There are lots of >> resources to learn language. I do what I need to do with Python too but >> I was kinda shocked when I solve Python questions at Hackerrank. Even >> with list comprehensions you can implement in very smart way to get >> things done and easy. Iterations, string operations. The codes I see on >> the Internet using basics in a very clever way which I couldn't come up >> with the same solution if I tried to for some time. I do understand >> this ways but coming from ANSI C makes it hard to see this flexibility. >> I probably do things in a both inefficient and hard way in my projects. >> >> How do I get used to this? Is this just another "practice, practice, >> practice" situation? Anything you can recommend? >> >> >> All the best. >> >> Kaan. >> >> > A) Yes, it's practice practice practice. > > B) Don't get hung up on finding the clever solution. Comprehensions and > generators and lots of other things are great under some circumstances > for making the code clearer and easier to read, but they too can become > the hammer that makes everything look like a nail. The most important > thing is that your code is logical, clean, and easy to understand. If > it doesn't take full advantage of the language features, or if the > performance isn't optimized to within an inch of its life, well so be > it. To re-enforce this someone much wiser than me wrote (& I a paraphrasing a bit) It takes more skill to debug code than to write it so if you write code at the limits of your ability yo do not have the skills needed to debug it. KISS - Keep It Simple Stupid -- Even if you do learn to speak correct English, whom are you going to speak it to? -- Clarence Darrow From arj.python at gmail.com Sat Oct 13 06:00:08 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 13 Oct 2018 14:00:08 +0400 Subject: Overwhelmed by the Simplicity of Python. Any Recommendation? In-Reply-To: References: Message-ID: become wiser in python me i came from c/java and was doing for i in range(0, len(list)): # get list item by index instead of for item in list: .... XD well the more you are exposed to py, the better you knoe hoe things work. reading source of popular projects is really great, and ... read the docs, ask your doubts on the mailing list, not to be afraid to read technical stuffs about py etc oh and ... do some projects (500+ lines) in py Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius From cl at isbd.net Sat Oct 13 11:15:36 2018 From: cl at isbd.net (Chris Green) Date: Sat, 13 Oct 2018 16:15:36 +0100 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? Message-ID: I use a Python script (called directly by '| ' in .forward) which routes incoming mail to various mailboxes according to the mailing list it's from (plus a few other criteria). The first lines of the program are:- #!/usr/bin/python # # # Mail filtering script # import email import mailbox import os import sys import time import mailLib import shlex # # # Redirect any exceptions to a file # sys.stderr = open("/home/chris/tmp/mail.err", 'a') # # # Some constants (i.e. configuration) # home = "/home/chris" logfile = home + "/tmp/mail.log" filtfile = home + "/.mutt/filter" mldir = home + "/Mail/" indir = mldir + "In/" judir = mldir + "Ju/" # # # Set to log to mail.log in ~/tmp with name 'filter' and the envelope/from # log = mailLib.initLog("filter") # # # Initialise destination mailbox name to empty # dest = "" # # # Read the message from standard input and make a message object from it # # msg = email.message_from_string(sys.stdin.read()) msg = mailbox.mboxMessage(sys.stdin.read()) # # # Extract the To:, Cc: and Subject: headers and the envelope/from # msgcc = msg.get("Cc", "unknown").lower() msgto = msg.get("To", "unknown").lower() msgsb = msg.get("Subject", "unknown") msgfm = msg.get("From", "unknown").lower() I then do various things according to the values in msgcc, msgto, msgsb and msgfm. The program works well and I've been using it for quite a few years. Now I want to do some minor changes and I can't for the life of me see how those lines with msg.get(... in them work. The mailbox.mboxMessage() class doesn't have a get() method and the get() method for the parent class mailbox() doesn't seem to do what it appears to be doing here. Can anyone suggest how this might be working? What will those msg.get() calls return? Will it simply be the whole message (there's always only one message fed into the program from .froward) or is there something going on that means it does work as I intended by getting the content of the individual header lines. Looking at the rest of the code it *might* work OK even if all of msgcc, msgto, msgsb and msgfm contain the whole message. It just wouldn't be working quite as I intended! :-) -- Chris Green ? From jfine2358 at gmail.com Sat Oct 13 11:49:35 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Sat, 13 Oct 2018 08:49:35 -0700 (PDT) Subject: socket: Too many open files In-Reply-To: References: Message-ID: <3442ecd8-4f4a-4b67-b231-cef2b1d8d5a4@googlegroups.com> Hi Shakti You wrote: > out = commands.getstatusoutput('traceroute ' + ip) The page https://docs.python.org/3/library/subprocess.html#legacy-shell-invocation-functions describes subprocess.getstatusoutput as one of the "legacy functions from the 2.x commands module. These operations implicitly invoke the system shell and none of the guarantees described above regarding security and exception handling consistency are valid for these functions." I suggest you use subprocess.run or Popen.communicate instead. Once you've done that, perhaps your problem will go away. And even if it does not, I think you're better placed for getting support, when you're not using legacy commands. I hope this helps, and good luck. -- Jonathan From cl at isbd.net Sat Oct 13 12:28:27 2018 From: cl at isbd.net (Chris Green) Date: Sat, 13 Oct 2018 17:28:27 +0100 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? References: Message-ID: Stefan Ram wrote: > Chris Green writes: > >msg.get > > You can get some information about ?get?: > > print( "msg.get.__doc__ =", msg.get.__doc__ ) > print( "msg.get.__func__ =", msg.get.__func__ ) > print( "msg.get.__self__ =", msg.get.__self__ ) > print( "msg.get.__str__() =", msg.get.__str__() ) > print( "msg.get.__repr__() =", msg.get.__repr__() ) > print( "msg.get.__name__ =", msg.get.__name__ ) > import dis > dis.dis( msg.get ) > dis.show_code( msg.get ) > Thanks, yes, this tells me a little:- ('msg.get.__doc__ =', 'Get a header value.\n\n Like __getitem__() but return failobj instead of None when the field\n is missing.\n ') However it isn't mentioned *anywhere* in the documentation that I can see. There's only __getitem__() and get() for the mailbox class which operate on a whole mailbox and return a whole message.` -- Chris Green ? From tjol at tjol.eu Sat Oct 13 12:44:49 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 13 Oct 2018 18:44:49 +0200 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? In-Reply-To: References: Message-ID: <894f43e4-8f9c-e380-6c3d-5a52873d56dc@tjol.eu> On 13/10/2018 18:28, Chris Green wrote: > Stefan Ram wrote: >> Chris Green writes: >>> msg.get >> >> You can get some information about ?get?: >> >> print( "msg.get.__doc__ =", msg.get.__doc__ ) >> print( "msg.get.__func__ =", msg.get.__func__ ) >> print( "msg.get.__self__ =", msg.get.__self__ ) >> print( "msg.get.__str__() =", msg.get.__str__() ) >> print( "msg.get.__repr__() =", msg.get.__repr__() ) >> print( "msg.get.__name__ =", msg.get.__name__ ) >> import dis >> dis.dis( msg.get ) >> dis.show_code( msg.get ) >> > Thanks, yes, this tells me a little:- > > ('msg.get.__doc__ =', 'Get a header value.\n\n Like > __getitem__() but return failobj instead of None when the field\n > is missing.\n ') > > However it isn't mentioned *anywhere* in the documentation that I can > see. There's only __getitem__() and get() for the mailbox class which > operate on a whole mailbox and return a whole message.` > https://docs.python.org/3.7/library/mailbox.html#message-objects does say that all the different message types are subclasses of email.message.Message. ... and these are the docs you're looking for: https://docs.python.org/3.7/library/email.compat32-message.html#email.message.Message.get From cl at isbd.net Sat Oct 13 12:46:15 2018 From: cl at isbd.net (Chris Green) Date: Sat, 13 Oct 2018 17:46:15 +0100 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? References: Message-ID: Chris Green wrote: > Stefan Ram wrote: > > Chris Green writes: > > >msg.get > > > > You can get some information about ?get?: > > > > print( "msg.get.__doc__ =", msg.get.__doc__ ) > > print( "msg.get.__func__ =", msg.get.__func__ ) > > print( "msg.get.__self__ =", msg.get.__self__ ) > > print( "msg.get.__str__() =", msg.get.__str__() ) > > print( "msg.get.__repr__() =", msg.get.__repr__() ) > > print( "msg.get.__name__ =", msg.get.__name__ ) > > import dis > > dis.dis( msg.get ) > > dis.show_code( msg.get ) > > > Thanks, yes, this tells me a little:- > > ('msg.get.__doc__ =', 'Get a header value.\n\n Like > __getitem__() but return failobj instead of None when the field\n > is missing.\n ') > > However it isn't mentioned *anywhere* in the documentation that I can > see. There's only __getitem__() and get() for the mailbox class which > operate on a whole mailbox and return a whole message.` > I've worked it out, sort of, by looking at the actual Python code. The mailbox.mboxMessage() class is a sub-class of email.message and *that* has the get() function I'm calling. It does tell you this in the documentation but it's not immediately obvious. In particular one isn't really expecting an object in the mailbox class to be a sub-class of a different 'parent' class, or at least I wasn't! :-) -- Chris Green ? From hjp-python at hjp.at Sat Oct 13 12:46:43 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 13 Oct 2018 18:46:43 +0200 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? In-Reply-To: References: Message-ID: <20181013164643.6o2gkds34w7f3p5u@hjp.at> On 2018-10-13 17:28:27 +0100, Chris Green wrote: > ('msg.get.__doc__ =', 'Get a header value.\n\n Like > __getitem__() but return failobj instead of None when the field\n > is missing.\n ') > > However it isn't mentioned *anywhere* in the documentation that I can > see. There's only __getitem__() and get() for the mailbox class which > operate on a whole mailbox and return a whole message.` The documentation for mailbox.mboxMessage refers to mailbox.Message, which refers to email.message.Message, which documents the get method: https://docs.python.org/3/library/email.compat32-message.html#email.message.Message.get hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From roel at roelschroeven.net Sat Oct 13 12:55:04 2018 From: roel at roelschroeven.net (Roel Schroeven) Date: Sat, 13 Oct 2018 18:55:04 +0200 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? In-Reply-To: References: Message-ID: Chris Green schreef op 13/10/2018 om 17:15: > I use a Python script (called directly by '| ' in > .forward) which routes incoming mail to various mailboxes according to > the mailing list it's from (plus a few other criteria). The first > lines of the program are:- > ... > msg = mailbox.mboxMessage(sys.stdin.read()) > # > # > # Extract the To:, Cc: and Subject: headers and the envelope/from > # > msgcc = msg.get("Cc", "unknown").lower() > msgto = msg.get("To", "unknown").lower() > msgsb = msg.get("Subject", "unknown") > msgfm = msg.get("From", "unknown").lower() > Can anyone suggest how this might be working? What will those > msg.get() calls return? I think your question is answered by this quote from the documentation (https://docs.python.org/3/library/email.message.html): "*The conceptual model provided by an EmailMessage object is that of an ordered dictionary of headers coupled with a payload that represents the RFC 5322 body of the message, which might be a list of sub-EmailMessage objects*. *In addition to the normal dictionary methods for accessing the header names and values*, there are methods for accessing specialized information from the headers (for example the MIME content type), for operating on the payload, for generating a serialized version of the message, and for recursively walking over the object tree. The EmailMessage dictionary-like interface is indexed by the header names, which must be ASCII values. The values of the dictionary are strings with some extra methods. Headers are stored and returned in case-preserving form, but field names are matched case-insensitively. Unlike a real dict, there is an ordering to the keys, and there can be duplicate keys. Additional methods are provided for working with headers that have duplicate keys." I.e. email.message instances provide the get() method because it is one of the "normal dictionary methods" you can use to access the headers. More specifically, get() is documented as (https://docs.python.org/3/library/email.message.html#email.message.EmailMessage.get): "Return the value of the named header field. This is identical to __getitem__() except that optional failobj is returned if the named header is missing (failobj defaults to None)." Watch out for headers with duplicate keys (like multiple Received: headers): use get_all() for those (https://docs.python.org/3/library/email.message.html#email.message.EmailMessage.get_all). -- "Honest criticism is hard to take, particularly from a relative, a friend, an acquaintance, or a stranger." -- Franklin P. Jones Roel Schroeven From python at mrabarnett.plus.com Sat Oct 13 13:06:31 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 13 Oct 2018 18:06:31 +0100 Subject: Is this mailbox manipulation working by luck, or can't I understand my own code? In-Reply-To: References: Message-ID: On 2018-10-13 16:15, Chris Green wrote: > I use a Python script (called directly by '| ' in > .forward) which routes incoming mail to various mailboxes according to > the mailing list it's from (plus a few other criteria). The first > lines of the program are:- > > #!/usr/bin/python > # > # > # Mail filtering script > # > import email > import mailbox > import os > import sys > import time > import mailLib > import shlex > # > # > # Redirect any exceptions to a file > # > sys.stderr = open("/home/chris/tmp/mail.err", 'a') > # > # > # Some constants (i.e. configuration) > # > home = "/home/chris" > logfile = home + "/tmp/mail.log" > filtfile = home + "/.mutt/filter" > mldir = home + "/Mail/" > indir = mldir + "In/" > judir = mldir + "Ju/" > # > # > # Set to log to mail.log in ~/tmp with name 'filter' and the > envelope/from > # > log = mailLib.initLog("filter") > # > # > # Initialise destination mailbox name to empty > # > dest = "" > # > # > # Read the message from standard input and make a message object from > it > # > # msg = email.message_from_string(sys.stdin.read()) > msg = mailbox.mboxMessage(sys.stdin.read()) > # > # > # Extract the To:, Cc: and Subject: headers and the envelope/from > # > msgcc = msg.get("Cc", "unknown").lower() > msgto = msg.get("To", "unknown").lower() > msgsb = msg.get("Subject", "unknown") > msgfm = msg.get("From", "unknown").lower() > > I then do various things according to the values in msgcc, msgto, > msgsb and msgfm. The program works well and I've been using it for > quite a few years. > > Now I want to do some minor changes and I can't for the life of me see > how those lines with msg.get(... in them work. The mailbox.mboxMessage() > class doesn't have a get() method and the get() method for the parent > class mailbox() doesn't seem to do what it appears to be doing here. > > Can anyone suggest how this might be working? What will those > msg.get() calls return? Will it simply be the whole message (there's > always only one message fed into the program from .froward) or is > there something going on that means it does work as I intended by > getting the content of the individual header lines. > > Looking at the rest of the code it *might* work OK even if all of > msgcc, msgto, msgsb and msgfm contain the whole message. It just > wouldn't be working quite as I intended! :-) > 'mailbox.mboxMessage' is class 'mboxMessage' in file 'mailbox.py' in the stdlib. In file 'mailbox.py' in the stdlib, class 'mboxMessage' inherits from '_mboxMMDFMessage', which inherits from '_mboxMMDFMessage', which inherits from 'Message', which inherits from 'email.message.Message' (class 'Message' from file 'email/message.py' in the stdlib. Those msg.get() calls return is the contents (a string) of the relevant field in the message's header. This: msg.get("Cc", "unknown").lower() returns the contents of the "Cc" field if it exists, or the default value "unknown" if it doesn't exist. That string is then converted to lowercase. From anthony.flury at btinternet.com Sat Oct 13 13:24:21 2018 From: anthony.flury at btinternet.com (Anthony Flury) Date: Sat, 13 Oct 2018 18:24:21 +0100 Subject: Encounter issues to install Python In-Reply-To: <1715165778.8897506.1539026476320@mail.yahoo.com> References: <1715165778.8897506.1539026476320.ref@mail.yahoo.com> <1715165778.8897506.1539026476320@mail.yahoo.com> Message-ID: Olivier, Welcome to the list - before we can help you, we need some more information : * What Operating system are you using - Windows/Mac/Linux/Raspberry Pi/Android for something else ? * What command or installer did you use to try to install Python. * What issues did you have during installation - if any ? * What interface are you trying to access, and how are you doing that ? * Do you get error messages? Unless you tell us what the problem is we can't possibly help. On 08/10/18 20:21, Olivier Oussou via Python-list wrote: > Hi!I downloaded and installed python 3.6.4 (32-bit) on my computer but I have problems and can not access the python interface. > I need your technical assistance to solve this matter. > > Best regard! > > Olivier OUSSOUMedical entomologist, Benin -- Anthony Flury *Email* : anthony.flury at btinternet.com *Twitter* : @TonyFlury From bgailer at gmail.com Sat Oct 13 14:17:16 2018 From: bgailer at gmail.com (bob gailer) Date: Sat, 13 Oct 2018 14:17:16 -0400 Subject: snakify issues In-Reply-To: References: Message-ID: <5803775b-4376-2ba5-d824-d02b4436211e@gmail.com> 5:50 AM Dec 8, 2016 a post was made to this list - subject "Snakify - free introductory Python online course with exercises" Recently I was engaged by a student seeking help with some of the exercises. I found a number of issues at the snakify web site. Thus began a conversation between me and the Site Maintainer Here is the latest: On 9/28/2018 1:02 PM, Vitaly Pavlenko wrote: > Hi Bob, > > Thanks for your email. I?d be very happy if you could describe what > sort of issues were you running into. I drafted a rather lengthy reply which I sent to you on October 1. I have not received any response. Did you get it? Was it helpful? I don't see any changes of the website. Please let me know. As I continue to assist my student I run into more and more issues. I will be glad to send them after I hear from you. Examples: - misspelled words - unclear statements - information missing from tracebacks - no way to interrupt an infinite loop. My worst fear is that the list was overwhelming or seen as trivia or nit-pickingl. I have had other publishers refuse to talk to me after I had pointed out legitimate concerns. I don't understand that, but it happens. Bob Gailer From ben.usenet at bsb.me.uk Sat Oct 13 16:11:05 2018 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Sat, 13 Oct 2018 21:11:05 +0100 Subject: snakify issues References: <5803775b-4376-2ba5-d824-d02b4436211e@gmail.com> Message-ID: <87y3b1mwti.fsf@bsb.me.uk> bob gailer writes: > 5:50 AM Dec 8, 2016 a post was made to this list - subject "Snakify - > free introductory Python online course with exercises" > > Recently I was engaged by a student seeking help with some of the > exercises. I found a number of issues at the snakify web site. Thus > began a conversation between me and the Site Maintainer Here is the > latest: > > On 9/28/2018 1:02 PM, Vitaly Pavlenko wrote: >> Hi Bob, >> >> Thanks for your email. I?d be very happy if you could describe what >> sort of issues were you running into. > I drafted a rather lengthy reply which I sent to you on October 1. I > have not received any response. I looked at the "landing page" and they clearly need a proof-reader. It's intelligible, but the English is clunky. In the body of the course there's quite a lot of incorrect terminology. But the material itself is so dull -- numbers, arithmetic, more numbers, factorials, more arithmetic, numbers... And when a string exercise came up (capitalise a word) the hint was to use ord and chr. -- Ben. From nad at python.org Sat Oct 13 17:40:00 2018 From: nad at python.org (Ned Deily) Date: Sat, 13 Oct 2018 17:40:00 -0400 Subject: [RELEASE] Python 3.7.1rc2 and 3.6.7rc2 now available for testing Message-ID: <65B2DFC8-F64D-4E48-B33F-9AE88BC440F4@python.org> Python 3.7.1rc2 and 3.6.7rc2 are now available. 3.7.1rc2 is a release preview of the first maintenance release of Python 3.7, the latest feature release of Python. 3.6.7rc2 is a release preview of the next maintenance release of Python 3.6, the previous feature release of Python. Assuming no further critical problems are found prior to 2018-10-20, no code changes are planned between these release candidates and the final releases. These release candidates are intended to give you the opportunity to test the new security and bug fixes in 3.7.1 and 3.6.7. We strongly encourage you to test your projects and report issues found to bugs.python.org as soon as possible. Please keep in mind that these are preview releases and, thus, their use is not recommended for production environments. You can find these releases and more information here: https://www.python.org/downloads/release/python-371rc2/ https://www.python.org/downloads/release/python-367rc2/ -- Ned Deily nad at python.org -- [] From cs at cskk.id.au Sat Oct 13 18:04:05 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 14 Oct 2018 09:04:05 +1100 Subject: socket: Too many open files In-Reply-To: References: Message-ID: <20181013220405.GA97001@cskk.homeip.net> On 13Oct2018 14:10, Shakti Kumar wrote: >I?m running a script which basically does a traceroute to the list of >hosts >provided, and then pulls up some info by logging in to gateways in the path. >I am running this script for a list of almost 40k hosts in our data centers. >Also, I am using commands module to get the traceroute output. > >out = commands.getstatusoutput('traceroute ' + ip) > >However I observe that this particular line is failing with socket error >after I reach some 5k to 6k hosts. >I know commands module is using pipes to execute the given command and this >is one reason for exhaustion of file descriptors. >Any suggestions for improving this and getting a workaround? I'd figure out where your file descriptors are going. Is traceroute leaving sockets littering your system? If you're on Linux this command: netstat -anp will show you all the sockets, their state, and the pids of the processes which own them. Does your script cause sockets to accrue after the traceroutes? If you write a trivial shell script to do the traceroutes: while read ip do traceroute $ip done From cs at cskk.id.au Sat Oct 13 18:48:10 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 14 Oct 2018 09:48:10 +1100 Subject: Single DB connection during class's lifetime. Metaclass,singleton and __new__() examples and references. In-Reply-To: <5bc0e7c6.1c69fb81.28d45.6203@mx.google.com> References: <5bc0e7c6.1c69fb81.28d45.6203@mx.google.com> Message-ID: <20181013224810.GA75842@cskk.homeip.net> On 12Oct2018 13:28, Ryan Johnson wrote: >Thanks for the clarification. > >If I am creating a class variable, are you suggesting I perform the ?if it exists, great, otherwise make it? logic in the __init__ block or in the class definition block? Will that even run in a class definition? The class definition code runs when the class is defined (as Python reads it in your code). The __init__ block runs once each time a new instance of the class is initialised. When do you _want_ this logic to run? That dictates where the logic goes. If you run this in the class definition code it pretty much will unconditionally make a db connection. But in reality (a) you usually want to defer making the connection until you need it to reduce resource usage and (b) you often don't know enough to make the connection at class definition time i.e. you don't know the database host, the credentials, etc - they are often supplied to the initialiser (directly or via some config file). >I never see examples do anything besides assignment operations and flow >control, although it would follow that if the block allows creation of >strings (an object), it would allow creation of connection objects. On >the other hand, the __init__ block seems like a natural place to put >the cursor instantiation. You can do anything that is sensible in the __init__ block - it is just code. Your goal is to decide what is sensible. Normally the initialiser mosts sets up various arrtributes to sane initial values. It can do complex things, but is usually relatively basic. I'd note, as Thomas did, that the cursor is a control object associated with a query. You can have multiple cursors on a connection, and you often make one from a query, process the query results, then discard the cursor. SO you routinely use several during the lifetime of a connection. Therefore you don't make cursors when you set up the connection; you make them in association with queries. >From this answer ( https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642 ) the pythonic way to access the class variable is using type(self), but doesn?t this access the local class?s variable, if someone subclasses my class? Can I specify my class variable via the class name itself? Example: instancevar = ClassName.classvar . >I am hoping that because of the way python points labels to objects, this should give my instance an instance var that refers to the class var. Am I right? _Usually_ I access class attributes (which you're calling variables, I believe - they're not) via the instance: def foo(self, blah=None): if blah is None: blah = foo.DEFAULT_BLAH_VALUE ... work with blah ... As you suggest, this will find DEFAULT_BLAH_VALUE from the subclass before it finds it from the superclass. Usually that is what I want - the purpose of subclassing is to (possibly) override the aspects of the superclass. However, you _can_ always reach directly to a specific class to get a value: blah = MySuperCLass.DEFAULT_BLAH_VALUE if that is sensible. All you're doing is changing the way in which the name "DEFAULT_BLAH_VALUE" is found: do I use the instance's name lookup or go somewhere direct? In your case with a persistent database connection associated with a class it would be best to make the "get a connection" logic a class method because the "is there a connection" attribute is associated with the class, not the instance. Methods are, by default, "instance" methods: they are defined like this: def method(self, ...): and you largely work through "self", being the current instance. That is its "context". Class method are defined like this: @classmethod def method(cls, ...) and instead of having an instance as context (with the conventional name 'self"), you have the class (with the conventional name "cls"). These are for methods which _do_ _not_ care about the instance, just the class. So in the case of your database connection, made on demand once per class, you might go: @classmethod def conn(cls): c = cls.connection if c is None: c = connect_to_the_db(.....) cls.connection = c return c See that there's no "self" in here? Then your instance methods can look like this: def lookup(self, ....): conn = self.conn() cursor = conn.select(....) ... use the cursor to process the result ... The instance finds the "conn" class method in the usual way: look in the instance, then look in the class hierarchy. This in itself is an argument against making the connection in the __init__ block. Does this help? Cheers, Cameron Simpson From mingw.android at gmail.com Sat Oct 13 18:48:46 2018 From: mingw.android at gmail.com (Ray Donnelly) Date: Sat, 13 Oct 2018 23:48:46 +0100 Subject: [Python-Dev] [RELEASE] Python 3.7.1rc2 and 3.6.7rc2 now available for testing In-Reply-To: <65B2DFC8-F64D-4E48-B33F-9AE88BC440F4@python.org> References: <65B2DFC8-F64D-4E48-B33F-9AE88BC440F4@python.org> Message-ID: Hi Ned, I tried to report this on bpo, but it's not letting me log in for some reason. I ran into a problem trying to build 3.7.1-rc2 on macOS for Anaconda Distribution. I debugged it a little so hopefully this is useful? The error is: checking whether float word ordering is bigendian... unknown This happens because by default, clang on macOS still generates 'fat' binaries so the greps introduced in https://github.com/python/cpython/commit/2a9c3805ddedf282881ef7811a561c70b74f80b1 find both noonsees and seesnoon. If we add `-arch x86_64` to our `CFLAGS` then we get a successful build, so perhaps this should be added in the configure stuff when we detect macOS? Best regards, Ray Donnelly, Anaconda Inc, On Sat, Oct 13, 2018 at 10:51 PM Ned Deily wrote: > > Python 3.7.1rc2 and 3.6.7rc2 are now available. 3.7.1rc2 is a release > preview of the first maintenance release of Python 3.7, the latest > feature release of Python. 3.6.7rc2 is a release preview of the next > maintenance release of Python 3.6, the previous feature release of > Python. Assuming no further critical problems are found prior to > 2018-10-20, no code changes are planned between these release > candidates and the final releases. These release candidates are > intended to give you the opportunity to test the new security and bug > fixes in 3.7.1 and 3.6.7. We strongly encourage you to test your > projects and report issues found to bugs.python.org as soon as > possible. Please keep in mind that these are preview releases and, > thus, their use is not recommended for production environments. > > You can find these releases and more information here: > https://www.python.org/downloads/release/python-371rc2/ > https://www.python.org/downloads/release/python-367rc2/ > > -- > Ned Deily > nad at python.org -- [] > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/mingw.android%40gmail.com From pjmclenon at gmail.com Sat Oct 13 19:13:04 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Sat, 13 Oct 2018 16:13:04 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> Message-ID: <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > ?> 1st is this script is from a library module online open source > > If it's open source, why didn't you show the link to the soruce? > I assume your code is this: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py > > And self.collFile is opened here: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 > > You need to add `encoding='utf-8'` argument. hello i used this recommandtion in one of my projects in python and it worked fine im wrting today cuz i have this same unicode error in a slighty differn file code line and i added encoding utf 8 but i still get the same error here is my line of code with open(join("docs", path)) as f: where can i add the encoding="utf8" line?? does anyone on this forum happen to know?? ok thank you jessica From python at mrabarnett.plus.com Sat Oct 13 19:23:57 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 14 Oct 2018 00:23:57 +0100 Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> Message-ID: <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> On 2018-10-14 00:13, pjmclenon at gmail.com wrote: > On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: >> ?> 1st is this script is from a library module online open source >> >> If it's open source, why didn't you show the link to the soruce? >> I assume your code is this: >> >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py >> >> And self.collFile is opened here: >> >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 >> >> You need to add `encoding='utf-8'` argument. > > > > hello i used this recommandtion in one of my projects in python and it worked fine im wrting today cuz i have this same unicode error in a slighty differn file code line and i added encoding utf 8 but i still get the same error > > here is my line of code > > with open(join("docs", path)) as f: > > where can i add the encoding="utf8" line?? > does anyone on this forum happen to know?? > > ok thank you jessica > with open(join("docs", path), encoding="utf-8") as f: From grant.b.edwards at gmail.com Sat Oct 13 20:06:00 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 14 Oct 2018 00:06:00 +0000 (UTC) Subject: how to replace line on particular line in file[no need to write it back whole file again] References: <20181012190045.xmwdavg4clmig6qq@hjp.at> <2ll2sd56u1j9175eb73m1e188ijrc99hn7@4ax.com> Message-ID: On 2018-10-13, Dennis Lee Bieber wrote: > However -- my point was that those formats were supported natively at > the OS level, not some language utility library working on top of the basic > streams. > > A more recent (my age shows) example would be the features in DEC VMS > Record Management Services. Again the format was handled at the system > service level by any language -- stream, fixed length with counts, ISAM... Yep, and when writing C programs under VMS, you had to pay attention to which of the underlying file "formats" you were dealing with. Only the "stream" format worked the way that a Unix user expected. ISTR that "stream" wasn't commonly used by programs written in other languages (e.g. Fortran). I think "varible length record" was the one that I most often ran into. But, it's been a _long_ time since I worked with VMS (almost 30 years)... -- Grant From grant.b.edwards at gmail.com Sat Oct 13 20:45:49 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 14 Oct 2018 00:45:49 +0000 (UTC) Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: On 2018-10-13, Peter J. Holzer wrote: > >> For "just use tabs" to work, all of those tools would have to >> magically recognize that they're looking at Python source and adjust >> the tab size accordingly. That isn't going to happen. > > Well, no. The idea of "just use tabs" isn't have a different tab width > per language, but a different tab width per user. You work in a different environment than I do. for me, tab width varies from one project to another (sometimes even in the same language). I don't get to pick just one tab width. -- Grant From auriocus at gmx.de Sun Oct 14 03:48:20 2018 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 14 Oct 2018 09:48:20 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: Am 14.10.18 um 02:45 schrieb Grant Edwards: > On 2018-10-13, Peter J. Holzer wrote: >> >>> For "just use tabs" to work, all of those tools would have to >>> magically recognize that they're looking at Python source and adjust >>> the tab size accordingly. That isn't going to happen. >> >> Well, no. The idea of "just use tabs" isn't have a different tab width >> per language, but a different tab width per user. > > You work in a different environment than I do. for me, tab width > varies from one project to another (sometimes even in the same > language). I don't get to pick just one tab width. But if you use only tabs for indentation, the tab width setting simply does not matter. I'm in favour of using only tabs. There is a disadvantage only if you try to align something which is NOT an indentation level, e.g. when there are big string constants or list constants etc. Christian From hjp-python at hjp.at Sun Oct 14 04:06:09 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 14 Oct 2018 10:06:09 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: <20181014080609.hvbs6dytslu55pum@hjp.at> On 2018-10-14 00:45:49 +0000, Grant Edwards wrote: > On 2018-10-13, Peter J. Holzer wrote: > > > >> For "just use tabs" to work, all of those tools would have to > >> magically recognize that they're looking at Python source and adjust > >> the tab size accordingly. That isn't going to happen. > > > > Well, no. The idea of "just use tabs" isn't have a different tab width > > per language, but a different tab width per user. > > You work in a different environment than I do. for me, tab width > varies from one project to another (sometimes even in the same > language). I don't get to pick just one tab width. You probably don't because you use spaces, not tabs. If everybody used tabs, why would anyone care about your tab width? Unless they look over your shoulder while you are typing, they won't even know how wide your tabs are. (That said, I personally prefer shorter indentation for marked up text (like HTML or LaTeX) than for programming languages. But I could live with the same indentation if necessary (and of course it isn't necessary: Any decent editor has to be able detect the file type anyway for syntax highlighting so it can adjust the display of tabs, too.)) hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From grant.b.edwards at gmail.com Sun Oct 14 10:32:08 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 14 Oct 2018 14:32:08 +0000 (UTC) Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: On 2018-10-14, Christian Gollwitzer wrote: > Am 14.10.18 um 02:45 schrieb Grant Edwards: >> On 2018-10-13, Peter J. Holzer wrote: >>> >>>> For "just use tabs" to work, all of those tools would have to >>>> magically recognize that they're looking at Python source and adjust >>>> the tab size accordingly. That isn't going to happen. >>> >>> Well, no. The idea of "just use tabs" isn't have a different tab width >>> per language, but a different tab width per user. >> >> You work in a different environment than I do. for me, tab width >> varies from one project to another (sometimes even in the same >> language). I don't get to pick just one tab width. > > But if you use only tabs for indentation, the tab width setting simply > does not matter. > There is a disadvantage only if you try to align something which is NOT > an indentation level, e.g. when there are big string constants or list > constants etc. Exactly. In my experience, people who use tabs for indentation always end up using them for other things as well: aligning comments or columns in data tables, etc. -- Grant From shakti.shrivastava13 at gmail.com Sun Oct 14 10:54:53 2018 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sun, 14 Oct 2018 20:24:53 +0530 Subject: Fwd: socket: Too many open files In-Reply-To: <20181013220405.GA97001@cskk.homeip.net> References: <20181013220405.GA97001@cskk.homeip.net> Message-ID: >On 13Oct2018 14:10, Shakti Kumar wrote: >>I?m running a script which basically does a traceroute to the list of >>hosts >>provided, and then pulls up some info by logging in to gateways in the path. >>I am running this script for a list of almost 40k hosts in our data centers. >>Also, I am using commands module to get the traceroute output. >> >>out = commands.getstatusoutput('traceroute ' + ip) >> >>However I observe that this particular line is failing with socket error >>after I reach some 5k to 6k hosts. >>I know commands module is using pipes to execute the given command and this >>is one reason for exhaustion of file descriptors. >>Any suggestions for improving this and getting a workaround? >I'd figure out where your file descriptors are going. >Is traceroute leaving sockets littering your system? If you're on Linux >this command: > netstat -anp >will show you all the sockets, their state, and the pids of the >processes which own them. Does your script cause sockets to accrue after >the traceroutes? >If you write a trivial shell script to do the traceroutes: >while read ip >do > traceroute $ip > done does it also exhibit the problem? >The if doesn't, then traceroute may not be the problem and something >else is leaking file descriptors. >In fact, given that it is file descriptors, maybe sockets are not what >is leaking? >From another terminal, see what your Python programme has open when this >happens with "lsof -n -p pid-of-python-programme". Maybe the leaks are >pipes, or connections from your "logging in to gateways in the path" >code. It may be as simple as you not closing files or connections. >Cheers, >Cameron Simpson Thanks Cameron, I still cant get over the fact that you were able to pin point the issue even without looking at my code XD Indeed when I started looking for sockets, I realised I was not closing connections to ACI hosts in our datacentres, and the error was starting to pop up at around 2900 to 3k TCP connections open to the hosts. XD Thanks Jonathan for pointing me to more apt functions. It helped a lot :) Regards, Shakti. From rosuav at gmail.com Sun Oct 14 13:48:08 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 15 Oct 2018 04:48:08 +1100 Subject: Python indentation (3 spaces) In-Reply-To: References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: On Mon, Oct 15, 2018 at 1:35 AM Grant Edwards wrote: > > On 2018-10-14, Christian Gollwitzer wrote: > > Am 14.10.18 um 02:45 schrieb Grant Edwards: > >> On 2018-10-13, Peter J. Holzer wrote: > >>> > >>>> For "just use tabs" to work, all of those tools would have to > >>>> magically recognize that they're looking at Python source and adjust > >>>> the tab size accordingly. That isn't going to happen. > >>> > >>> Well, no. The idea of "just use tabs" isn't have a different tab width > >>> per language, but a different tab width per user. > >> > >> You work in a different environment than I do. for me, tab width > >> varies from one project to another (sometimes even in the same > >> language). I don't get to pick just one tab width. > > > > But if you use only tabs for indentation, the tab width setting simply > > does not matter. > > > There is a disadvantage only if you try to align something which is NOT > > an indentation level, e.g. when there are big string constants or list > > constants etc. > > Exactly. In my experience, people who use tabs for indentation always > end up using them for other things as well: aligning comments or columns > in data tables, etc. > Well, I don't, and I DO use tabs for indentation. So how about we restrict this discussion to indentation, and not worry about other things people might also use tabs for? Tabs for indentation have semantic meaning. Top-level has zero tabs. One indentation level is represented by one tab. Two indentation levels? Two tabs. It's about as perfect a representation as you could hope for. If you like your indentation levels to be as wide as four spaces, you can have that. I could have them at eight, and it wouldn't make a difference. And if someone messes up their code by using tabs to align all their comments, reject that code at code review time. This ain't rocket science. ChrisA From marko at pacujo.net Sun Oct 14 17:50:28 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 00:50:28 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> Message-ID: <874ldorye3.fsf@elektro.pacujo.net> Chris Angelico : > Tabs for indentation have semantic meaning. Top-level has zero tabs. > One indentation level is represented by one tab. Two indentation > levels? Two tabs. It's about as perfect a representation as you could > hope for. If you like your indentation levels to be as wide as four > spaces, you can have that. I could have them at eight, and it wouldn't > make a difference. And if someone messes up their code by using tabs > to align all their comments, reject that code at code review time. > This ain't rocket science. That *could* be the situation. However, it is trumped by an older convention whereby the indentation levels go as follows: 0: 1: SPC SPC 2: SPC SPC SPC SPC 3: SPC SPC SPC SPC SPC SPC 4: TAB 5: TAB SPC SPC 6: TAB SPC SPC SPC SPC 7: TAB SPC SPC SPC SPC SPC SPC 8: TAB TAB That's how emacs indents source code files out of the box, BTW. Moreover: SPC TAB = TAB SPC SPC SPC SPC SPC SPC SPC SPC = TAB etc. This older convention is honored by Python2 as well. This older convention has been honored by many operating systems (at least UNIX, CP/M and MS-DOS). If I had to choose between your scheme and the older scheme, I'd choose the older one. Instead, I have chosen to banish HT as an unnecessary distraction. Your scheme also is ad hoc in that it doesn't follow its logic to other ASCII control characters. Why not use VT to separate methods? Why not use US to separate operators from operands? Why not use RS to separate the operands of optional arguments? Why not use GS to separate logical blocks of code? After all, those schemes would allow people to personalize the visual representation of more aspects of the source code. Marko From rosuav at gmail.com Sun Oct 14 18:06:11 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 15 Oct 2018 09:06:11 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <874ldorye3.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> Message-ID: On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: > > Chris Angelico : > > > Tabs for indentation have semantic meaning. Top-level has zero tabs. > > One indentation level is represented by one tab. Two indentation > > levels? Two tabs. It's about as perfect a representation as you could > > hope for. If you like your indentation levels to be as wide as four > > spaces, you can have that. I could have them at eight, and it wouldn't > > make a difference. And if someone messes up their code by using tabs > > to align all their comments, reject that code at code review time. > > This ain't rocket science. > > That *could* be the situation. However, it is trumped by an older > convention whereby the indentation levels go as follows: > > 0: > 1: SPC SPC > 2: SPC SPC SPC SPC > 3: SPC SPC SPC SPC SPC SPC > 4: TAB > 5: TAB SPC SPC > 6: TAB SPC SPC SPC SPC > 7: TAB SPC SPC SPC SPC SPC SPC > 8: TAB TAB I've literally NEVER come across this as a convention. Not a single file that I have ever worked with has used it. Where is this convention from? > Your scheme also is ad hoc in that it doesn't follow its logic to other > ASCII control characters. Why not use VT to separate methods? Why not > use US to separate operators from operands? Why not use RS to separate > the operands of optional arguments? Why not use GS to separate logical > blocks of code? After all, those schemes would allow people to > personalize the visual representation of more aspects of the source > code. You're most welcome to use VT between methods. Not sure what you mean by US, RS, and GS, but if they count as whitespace, you are absolutely welcome to use them. I don't see why you have to use ALL of them if you use any, but hey, if you want to, nobody's stopping you. What's the issue here? ChrisA From hjp-python at hjp.at Sun Oct 14 18:33:45 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 15 Oct 2018 00:33:45 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> Message-ID: <20181014223345.vio35fhx6ub365up@hjp.at> On 2018-10-15 09:06:11 +1100, Chris Angelico wrote: > On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: > > Chris Angelico : > > > Tabs for indentation have semantic meaning. Top-level has zero tabs. > > > One indentation level is represented by one tab. Two indentation > > > levels? Two tabs. It's about as perfect a representation as you could > > > hope for. > > > > That *could* be the situation. However, it is trumped by an older > > convention whereby the indentation levels go as follows: > > > > 0: > > 1: SPC SPC > > 2: SPC SPC SPC SPC > > 3: SPC SPC SPC SPC SPC SPC > > 4: TAB > > 5: TAB SPC SPC > > 6: TAB SPC SPC SPC SPC > > 7: TAB SPC SPC SPC SPC SPC SPC > > 8: TAB TAB That's not using tabs for indentation, that's using tabs for compressing spaces (somebody already mentioned that in this thread). > I've literally NEVER come across this as a convention. Not a single > file that I have ever worked with has used it. Where is this > convention from? It's something vi does by default, and apparently emacs as well. In the 1970's saving space by replacing sequences of 8 spaces with tabs seemed lika a good idea. There are workarounds in vi(m), but I'm not sure if you can get rid of that behaviour completely. I'm sure it is possible in emacs. > > Your scheme also is ad hoc in that it doesn't follow its logic to other > > ASCII control characters. Why not use VT to separate methods? Why not > > use US to separate operators from operands? Why not use RS to separate > > the operands of optional arguments? Why not use GS to separate logical > > blocks of code? After all, those schemes would allow people to > > personalize the visual representation of more aspects of the source > > code. > > You're most welcome to use VT between methods. I sometimes use FF so separate sections of code in longer files. Had to stop that in Django projects because it messes up the stack traces. > Not sure what you mean by US, RS, and GS, Unit separator, record separator, group separator (and FS is file separator). I think they were intended for a CSV-like file format, but I have never seen them in use (outside of my own projects). hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From cs at cskk.id.au Sun Oct 14 18:49:12 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 15 Oct 2018 09:49:12 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <20181014223345.vio35fhx6ub365up@hjp.at> References: <20181014223345.vio35fhx6ub365up@hjp.at> Message-ID: <20181014224912.GA78543@cskk.homeip.net> On 15Oct2018 00:33, Peter J. Holzer wrote: >On 2018-10-15 09:06:11 +1100, Chris Angelico wrote: >> On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: >> > Chris Angelico : >> > > Tabs for indentation have semantic meaning. Top-level has zero tabs. >> > > One indentation level is represented by one tab. Two indentation >> > > levels? Two tabs. It's about as perfect a representation as you could >> > > hope for. >> > >> > That *could* be the situation. However, it is trumped by an older >> > convention whereby the indentation levels go as follows: >> > >> > 0: >> > 1: SPC SPC >> > 2: SPC SPC SPC SPC >> > 3: SPC SPC SPC SPC SPC SPC >> > 4: TAB >> > 5: TAB SPC SPC >> > 6: TAB SPC SPC SPC SPC >> > 7: TAB SPC SPC SPC SPC SPC SPC >> > 8: TAB TAB > >That's not using tabs for indentation, that's using tabs for compressing >spaces (somebody already mentioned that in this thread). > > >> I've literally NEVER come across this as a convention. Not a single >> file that I have ever worked with has used it. Where is this >> convention from? > >It's something vi does by default, and apparently emacs as well. >In the 1970's saving space by replacing sequences of 8 spaces >with tabs seemed lika a good idea. > >There are workarounds in vi(m), but I'm not sure if you can get rid of >that behaviour completely. I'm sure it is possible in emacs. I'm a "just use spaces" guy. I use the tab _key_ as a shortcut to do a bunch of spaces. My vim setup has this: set expandtab which turns them into spaces. Cheers, Cameron Simpson From alan at csail.mit.edu Sun Oct 14 18:50:26 2018 From: alan at csail.mit.edu (Alan Bawden) Date: 14 Oct 2018 18:50:26 -0400 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> Message-ID: <86o9bwqh1p.fsf@richard.bawden.org> Chris Angelico writes: > On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: > > Chris Angelico : ... > > That *could* be the situation. However, it is trumped by an older > > convention whereby the indentation levels go as follows: > > > > 0: > > 1: SPC SPC > > 2: SPC SPC SPC SPC > > 3: SPC SPC SPC SPC SPC SPC > > 4: TAB > > 5: TAB SPC SPC > > 6: TAB SPC SPC SPC SPC > > 7: TAB SPC SPC SPC SPC SPC SPC > > 8: TAB TAB > > I've literally NEVER come across this as a convention. Not a single > file that I have ever worked with has used it. Where is this > convention from? I just picked a C source code file AT RANDOM from the FreeBSD source tree on the machine I'm using to compose this message (/usr/src/gnu/usr.bin/man/man/glob.c), and I find that, as I expected, it uses exactly that convention. And in that file, the comments don't line up as the author clearly intended unless the tab stops are set every 8 columns. In my experience this is a very common way to assume that tabs will be interpreted. Virtually every source-code file I have encountered since the mid 1970s (for any programming language or operating system) has assumed either this convention or, slightly less often, its 4-column variant. It's surprising that you've never encountered it. -- Alan Bawden From cs at cskk.id.au Sun Oct 14 18:57:07 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 15 Oct 2018 09:57:07 +1100 Subject: Fwd: socket: Too many open files In-Reply-To: References: Message-ID: <20181014225707.GA85183@cskk.homeip.net> On 14Oct2018 20:24, Shakti Kumar wrote: >>On 13Oct2018 14:10, Shakti Kumar wrote: >>>I?m running a script which basically does a traceroute to the list of >>>hosts >>>provided, and then pulls up some info by logging in to gateways in the >path. >>>I am running this script for a list of almost 40k hosts in our data >centers. >>>Also, I am using commands module to get the traceroute output. >>> >>>out = commands.getstatusoutput('traceroute ' + ip) >>> >>>However I observe that this particular line is failing with socket error >>>after I reach some 5k to 6k hosts. [...] >>In fact, given that it is file descriptors, maybe sockets are not what >>is leaking? > >>From another terminal, see what your Python programme has open when this >>happens with "lsof -n -p pid-of-python-programme". Maybe the leaks are >>pipes, or connections from your "logging in to gateways in the path" >>code. It may be as simple as you not closing files or connections. > >Thanks Cameron, I still cant get over the fact that you were able to pin >point the issue even without looking at my code XD Well it seemed likely that traceroute itself was not the cause because as you expected, when the command terminates its resources should clear up. That is one of the nice things about external executables - the OS tidies up their leaks, if any. (TCP sockets tend to hand around for a while to catch stray resent packets, but traceroute doesn't use TCP.) >Indeed when I started looking for sockets, I realised I was not closing >connections to ACI hosts in our datacentres, and the error was starting to >pop up at around 2900 to 3k TCP connections open to the hosts. XD I think the takea away from my post, if any, is the usefulness of some external commands for inspecting behaviour if a problem seems intractable by inspection (eg "in Python" debugging, including prints etc). Tools like strace, netstat and lsof are really good for seeing what the program is doing/leaking/misusing at an OS level. Even for opaque things like third party Java programmes, etc. In your particular case, you're out of sockets (or possibly file desciptors). So use netstat to inspect the open sockets (and on Linux, "the open sockets for a particular PID" is an answerable question). Also, lsof will show your programme's open files, including the sockets. Cheers, Cameron Simpson From rosuav at gmail.com Sun Oct 14 18:59:40 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 15 Oct 2018 09:59:40 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <86o9bwqh1p.fsf@richard.bawden.org> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> Message-ID: On Mon, Oct 15, 2018 at 9:56 AM Alan Bawden wrote: > In my experience this is a very common way to assume that tabs will be > interpreted. Virtually every source-code file I have encountered since the > mid 1970s (for any programming language or operating system) has assumed > either this convention or, slightly less often, its 4-column variant. > > It's surprising that you've never encountered it. I've seen the four-column variant, but never the two. Maybe I just move in different circles. In any case, I wouldn't say that "two space indents, collapsed to a tab after eight" is somehow a universal convention any more than four-space with or without collapsing. ChrisA From alan at csail.mit.edu Sun Oct 14 23:48:40 2018 From: alan at csail.mit.edu (Alan Bawden) Date: 14 Oct 2018 23:48:40 -0400 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> Message-ID: <86in23rht3.fsf@richard.bawden.org> Chris Angelico writes: > On Mon, Oct 15, 2018 at 9:56 AM Alan Bawden wrote: > > In my experience this is a very common way to assume that tabs will be > > interpreted. Virtually every source-code file I have encountered since the > > mid 1970s (for any programming language or operating system) has assumed > > either this convention or, slightly less often, its 4-column variant. > > > > It's surprising that you've never encountered it. > > I've seen the four-column variant, but never the two. Maybe I just > move in different circles. In any case, I wouldn't say that "two space > indents, collapsed to a tab after eight" is somehow a universal > convention any more than four-space with or without collapsing. I think we're talking past each other somehow here. I described the common 8-column interpretation, and the less common 4-column interpretation. I did not mention, nor do I ever remember encountering in the wild, the 2-column variation. (I _have_ seen the 10-column variation used -- it was the standard on Multics.) The ANSI standard for ASCII only describes the tab character as follows: 7.21 HT (HORIZONTAL TABULATION). A format effector that causes the active position to advance to the next predetermined character position. This says nothing about where those "predetermined character positions" happen to be. They could be set at columns 5, 17, 23, 99 and 100, or they could be set every N columns for some N, or wherever you want, it's up to you. (Note that this is exactly the way mechanical typewriters used to work: "tab stops" were originally physical sliders that you would position manually, and then when you pressed the "tab" key, a spring would pull the carriage holding the paper to the left until it would be physically _stopped_ by the tab stop.) Given that the ANSI standard is silent on where the tab stops should be set for the HT character, we can only ask where they are set _in practice_, based on looking at he contents of files and the behavior of various pieces of software. For example, in the Linux termios(3) manual page describes one of the options you can set to control output to a terminal: TABDLY Horizontal tab delay mask. Values are TAB0, TAB1, TAB2, TAB3 (or XTABS). A value of TAB3, that is, XTABS, expands tabs to spaces (with tab stops every eight columns). So if tabs are going to be converted to spaces on output, your only choice is the every-8-columns interpretation. (Interestingly, setting TABDLY to TAB3 to convert tabs to spaces is part of POSIX, but the POSIX standard does _not_ appear to specify the positions of the tab stops!) The 8-column interpretation is also the default behavior in every text editor I have ever used (except, as I noted above, on Multics!). The 8-column interpretation also seems most common in source code files, although 4-column files do show up occasionally. So when you say: I've literally NEVER come across this as a convention. Not a single file that I have ever worked with has used it. Where is this convention from? I feel that there _must_ be some misunderstanding here. Maybe you misinterpreted Marko's description of how 8-column tabs are used to achieve 2-columns-per-level indentation. Or maybe I'm misunderstanding what you mean by "convention". Or maybe one of us just beamed in from parallel universe... -- Alan Bawden From rosuav at gmail.com Mon Oct 15 00:04:09 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 15 Oct 2018 15:04:09 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <86in23rht3.fsf@richard.bawden.org> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> Message-ID: On Mon, Oct 15, 2018 at 2:51 PM Alan Bawden wrote: > > Chris Angelico writes: > > On Mon, Oct 15, 2018 at 9:56 AM Alan Bawden wrote: > > > In my experience this is a very common way to assume that tabs will be > > > interpreted. Virtually every source-code file I have encountered since the > > > mid 1970s (for any programming language or operating system) has assumed > > > either this convention or, slightly less often, its 4-column variant. > > > > > > It's surprising that you've never encountered it. > > > > I've seen the four-column variant, but never the two. Maybe I just > > move in different circles. In any case, I wouldn't say that "two space > > indents, collapsed to a tab after eight" is somehow a universal > > convention any more than four-space with or without collapsing. > > I think we're talking past each other somehow here. I described the common > 8-column interpretation, and the less common 4-column interpretation. I > did not mention, nor do I ever remember encountering in the wild, the > 2-column variation. (I _have_ seen the 10-column variation used -- it was > the standard on Multics.) > [chomp details] I believe we are in agreement here - that it is common for a tab to be interpreted as equivalent to eight spaces, but also that this is definitely not the definition of the character. The convention that I'm saying I have never seen is this: On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: > However, it is trumped by an older > convention whereby the indentation levels go as follows: > > 0: > 1: SPC SPC > 2: SPC SPC SPC SPC > 3: SPC SPC SPC SPC SPC SPC > 4: TAB > 5: TAB SPC SPC > 6: TAB SPC SPC SPC SPC > 7: TAB SPC SPC SPC SPC SPC SPC > 8: TAB TAB Specifically that two-space indents and tab-collapsing are a *convention*. I have never seen this used anywhere, much less seen it commonly enough to call it a convention. ChrisA From marko at pacujo.net Mon Oct 15 00:45:16 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 07:45:16 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> Message-ID: <87tvlnrf6r.fsf@elektro.pacujo.net> Chris Angelico : > I'm saying I have never seen is this: > > On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: >> However, it is trumped by an older >> convention whereby the indentation levels go as follows: >> >> 0: >> 1: SPC SPC >> 2: SPC SPC SPC SPC >> 3: SPC SPC SPC SPC SPC SPC >> 4: TAB >> 5: TAB SPC SPC >> 6: TAB SPC SPC SPC SPC >> 7: TAB SPC SPC SPC SPC SPC SPC >> 8: TAB TAB > > Specifically that two-space indents and tab-collapsing are a > *convention*. I have never seen this used anywhere, much less seen it > commonly enough to call it a convention. The two-space indentation is the out-of-the-box default for emacs. However, the tab collapsing principle is a universal default. If you go against it, you will have to educate more tools than your editor. For example, try running this Python snippet (in REPL or as a program): for i in range(32): print("x{}\ty".format(" " * i)) Marko From rosuav at gmail.com Mon Oct 15 01:17:30 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 15 Oct 2018 16:17:30 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <87tvlnrf6r.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> Message-ID: On Mon, Oct 15, 2018 at 3:51 PM Marko Rauhamaa wrote: > The two-space indentation is the out-of-the-box default for emacs. > However, the tab collapsing principle is a universal default. If you go > against it, you will have to educate more tools than your editor. For > example, try running this Python snippet (in REPL or as a program): > > for i in range(32): > print("x{}\ty".format(" " * i)) > I don't understand your point here. It prints a letter, then some spaces, then a tab, then another letter. On my terminal, that displays the tab by advancing to the next tab position. If I highlight to select, it's obvious that the spaces have not been collapsed or converted in any way; it is indeed printing that many spaces, then a tab. Universal default? Not very. ChrisA From dieter at handshake.de Mon Oct 15 01:28:31 2018 From: dieter at handshake.de (dieter) Date: Mon, 15 Oct 2018 07:28:31 +0200 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> Message-ID: <877eij22yo.fsf@handshake.de> Marko Rauhamaa writes: > dieter : > ... >> Definitely. The application concerned was a long running web application; >> caching was an important feature to speed up its typical use cases. > > As an optimization technique, I suggest turning the cache into a "binary > blob" opaque to GC, or using some external component like SQLite. This was a Python application and as such, it was primarily working with Python objects. And it was a complex application heavily depending on subframeworks, many of them internally using caching to speed things up, the details hidden from the application. Redesigning the application to use an alternative caching was out of question. > Keeping the number of long-term objects low is key. Right, if I need near realtime behaviour and must live with [C]Python's garbage collector. But, a web application does usually not need near realtime behaviour. An occasional (maybe once in a few days) garbage collection and associated reduced response time is acceptable. A problem only arises if a badly designed component produces quite frequently hundreds of thousands of temporary objects likely triggering (frequent) garbage collections. > Note that Python creates a temporary object every time you invoke a > method. CPython removes them quickly through reference counting, but > other Python implementations just let GC deal with them, and that's > generally ok. The initial point has been that you must carefully look at the context for which you design a solution and choose appropriately (among other the implementation language). In my case, the web application framework was fixed ("Zope") and therefore the language ("Python") and its implementation ("CPython"). "Normal" temporary objects did not pose a problem (due to reference counting); only the mass creation of temporary objects can be problematic (as GC is triggered before the temporary objects are released again (due to reference counting). > > > Marko From florian.pelgrim at craneworks.de Mon Oct 15 05:27:05 2018 From: florian.pelgrim at craneworks.de (Florian Pelgrim) Date: Mon, 15 Oct 2018 11:27:05 +0200 Subject: pipenv and wheel/pre-compiled packages Message-ID: <4f9c7633-3dc9-ec1d-fd2a-e46991ddb8cf@craneworks.de> Hi there, I'm currently using a buildhost for third party packages running ``` $ pip3 wheel --wheel-dir=/root/wheelhouse -r /requirements.txt ``` After successful build I copy the directory `/root/wheelhouse` onto a new machine and install the compiled packages by running ``` $ pip3 install -r /requirements.txt --no-index --find-links=/root/wheelhouse ``` Is there something similar in `pipenv`? Everything I found in combination with `wheel` are bug reports on GitHub. Note that copying the venv directory is not an option for me. I'm using a docker container and want to install the packages system wide. Cheers Flo From italienisch1987 at gmail.com Mon Oct 15 06:48:41 2018 From: italienisch1987 at gmail.com (Bobby) Date: Mon, 15 Oct 2018 03:48:41 -0700 (PDT) Subject: Python-Verilog (Pyverilog) Message-ID: <27406799-f080-4b04-a777-7d3ed074ba0d@googlegroups.com> I am working on my own domain-specific language (DSL). The DSL is based on functional requirements of a device under test (DUT). The grammar has rules like 'if' and 'else'. I have made a grammar of my DSL without any programming code in my grammar. I am using ANTLR to generate Parser, Lexer, Visitor and Listeners in Python. I have made the visitor pattern in python to parse the input I give to my grammar. The input I am parsing is in natural words as my grammar itself consists of natural words rules. Therefore the input is not a programming language. Now I have a working visitor in python which can successfully interpret my input. I would like to generate a Verilog test bench structure from this stage on wards. Literally blocked at this point. I have come across this toolkit Pyverilog. It has a Verilog code generator as a tool. In this Verilog code generator, a Verilog HDL code is represented by using the AST classes defined in its parser called'vparser.ast'. Can I use this code generator as a standalone for my Python visitor pattern which I have made from my ANTLR ? Any workaround that I can use this kit considering the above mentioned scenario ? I would appreciate any suggestion. From italienisch1987 at gmail.com Mon Oct 15 06:53:16 2018 From: italienisch1987 at gmail.com (Bobby) Date: Mon, 15 Oct 2018 03:53:16 -0700 (PDT) Subject: Python-Verilog (PyHDI-Pyverilog) Message-ID: I am working on my own domain-specific language (DSL). The DSL is based on functional requirements of a device under test (DUT). The grammar has rules like 'if' and 'else'. I have made a grammar of my DSL without any programming code in my grammar. I am using ANTLR to generate Parser, Lexer, Visitor and Listeners in Python. I have made the visitor pattern in python to parse the input I give to my grammar. The input I am parsing is in natural words as my grammar itself consists of natural words rules. Therefore the input is not a programming language. Now I have a working visitor in python which can successfully interpret my input. I would like to generate a Verilog test bench structure from this stage on wards. Literally blocked at this point. I have come across this toolkit Pyverilog (https://github.com/PyHDI/Pyverilog). It has a Verilog code generator as a tool. In this Verilog code generator, a Verilog HDL code is represented by using the AST classes defined in its parser called'vparser.ast'. Can I use this code generator as a standalone for my Python visitor pattern which I have made from my ANTLR ? Any workaround that I can use this kit considering the above mentioned scenario ? I would appreciate any suggestion. From marko at pacujo.net Mon Oct 15 07:02:45 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 14:02:45 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> Message-ID: <871s8rlbfu.fsf@elektro.pacujo.net> Chris Angelico : > On Mon, Oct 15, 2018 at 3:51 PM Marko Rauhamaa wrote: > I don't understand your point here. It prints a letter, then some > spaces, then a tab, then another letter. On my terminal, that displays > the tab by advancing to the next tab position. If I highlight to > select, it's obvious that the spaces have not been collapsed or > converted in any way; it is indeed printing that many spaces, then a > tab. Universal default? Not very. The point is that your tab stops are at every 8th column even if some other tab stops were used in your editor. Unless you configured your terminal (emulator) with the same tab stops as your editor. Then, you'll need to configure your printer, browser and other visual tools that have the every-8th-column-tab-stop default. Marko From rhodri at kynesim.co.uk Mon Oct 15 07:06:06 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 15 Oct 2018 12:06:06 +0100 Subject: Python indentation (3 spaces) In-Reply-To: <20181014080609.hvbs6dytslu55pum@hjp.at> References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <20181014080609.hvbs6dytslu55pum@hjp.at> Message-ID: <5fcd6e82-6922-4560-6b8a-706a656c856c@kynesim.co.uk> On 14/10/18 09:06, Peter J. Holzer wrote: > On 2018-10-14 00:45:49 +0000, Grant Edwards wrote: >> On 2018-10-13, Peter J. Holzer wrote: >>> >>>> For "just use tabs" to work, all of those tools would have to >>>> magically recognize that they're looking at Python source and adjust >>>> the tab size accordingly. That isn't going to happen. >>> >>> Well, no. The idea of "just use tabs" isn't have a different tab width >>> per language, but a different tab width per user. >> >> You work in a different environment than I do. for me, tab width >> varies from one project to another (sometimes even in the same >> language). I don't get to pick just one tab width. > > You probably don't because you use spaces, not tabs. > > If everybody used tabs, why would anyone care about your tab width? > Unless they look over your shoulder while you are typing, they won't > even know how wide your tabs are. If you used two-space tab stops and I used (the normal :-) eight, comfortable indentations for you would rapidly become uncomfortably large indentations for me. I'd care about that. I'd also care if you used spaces to make sub-tab stop adjustments to line up appropriate text (inside brackets, for example). -- Rhodri James *-* Kynesim Ltd From marko at pacujo.net Mon Oct 15 07:07:08 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 14:07:08 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> Message-ID: <87woqjjwo3.fsf@elektro.pacujo.net> dieter : > Marko Rauhamaa writes: >> Keeping the number of long-term objects low is key. > > Right, if I need near realtime behaviour and must live > with [C]Python's garbage collector. Or any other GC ever invented. > But, a web application does usually not need near realtime behaviour. > An occasional (maybe once in a few days) garbage collection and > associated reduced response time is acceptable. > A problem only arises if a badly designed component produces > quite frequently hundreds of thousands of temporary objects > likely triggering (frequent) garbage collections. But I think you are barking up the wrong tree. You could rightly blame GC itself as an unworkable paradigm and switch to, say, C++ or Rust. Or you could blame the parts of the software that create too many long-term objects. You shouldn't blame the parts of the software that churn out zillions of short-term objects. Marko From rhodri at kynesim.co.uk Mon Oct 15 07:08:34 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 15 Oct 2018 12:08:34 +0100 Subject: Python indentation (3 spaces) In-Reply-To: <87tvlnrf6r.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> Message-ID: On 15/10/18 05:45, Marko Rauhamaa wrote: > Chris Angelico : >> I'm saying I have never seen is this: >> >> On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: >>> However, it is trumped by an older >>> convention whereby the indentation levels go as follows: >>> >>> 0: >>> 1: SPC SPC >>> 2: SPC SPC SPC SPC >>> 3: SPC SPC SPC SPC SPC SPC >>> 4: TAB >>> 5: TAB SPC SPC >>> 6: TAB SPC SPC SPC SPC >>> 7: TAB SPC SPC SPC SPC SPC SPC >>> 8: TAB TAB >> >> Specifically that two-space indents and tab-collapsing are a >> *convention*. I have never seen this used anywhere, much less seen it >> commonly enough to call it a convention. > > The two-space indentation is the out-of-the-box default for emacs. Ahem. It's the default for certain C styles. It's not even the default for C-mode itself, which is 4. Those of us who believe that tabs are evil set indent-tabs-mode nil anyway to stop the annoying behaviour. -- Rhodri James *-* Kynesim Ltd From marko at pacujo.net Mon Oct 15 07:28:50 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 14:28:50 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <20181013072611.pqy6yhalf2watuff@hjp.at> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> Message-ID: <87o9bvjvnx.fsf@elektro.pacujo.net> Rhodri James : > On 15/10/18 05:45, Marko Rauhamaa wrote: >> The two-space indentation is the out-of-the-box default for emacs. > > Ahem. It's the default for certain C styles. It's not even the default > for C-mode itself, which is 4. You must be running a different version of emacs than all the versions I've every run. Try running emacs -q abc.c and observe the indentation depth. > Those of us who believe that tabs are evil set indent-tabs-mode nil > anyway to stop the annoying behaviour. Yes. Marko From antoon.pardon at vub.be Mon Oct 15 08:12:54 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Mon, 15 Oct 2018 14:12:54 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <20181013073744.kpemgmae7wkarvrr@hjp.at> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> Message-ID: On 13-10-18 09:37, Peter J. Holzer wrote: > On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: >> On 08-10-18 19:43, Peter J. Holzer wrote: >>> On 2018-10-08 10:36:21 +1100, Chris Angelico wrote: >>>> How wide my indents are on my screen shouldn't influence your screen >>>> or your choices. >>> Theoretically I would agree with you: Just use a single tab per >>> indentation level and let the user decide whether that's displayed as 2, >>> 3, 4, or 8 spaces or 57 pixels or whatever. >>> >>> In practice it doesn't work in my experience. There is always someone in >>> a team who was "just testing that new editor" and replaced all tabs >>> with spaces (or vice versa) or - worse - just some of them. >> Isn't that caugth in the process of commiting to version control? > Tabs are easy to catch. If a file contains a tab, reject it. > > Spaces aren't, because spaces are everywhere. Spaces that replaced a tab by accident, are easy to catch too. They are all those lines that show up when you do a diff with the previous version that shouldn't show up. -- Antoon. From rhodri at kynesim.co.uk Mon Oct 15 09:13:54 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 15 Oct 2018 14:13:54 +0100 Subject: Python indentation (3 spaces) In-Reply-To: <87o9bvjvnx.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> <87o9bvjvnx.fsf@elektro.pacujo.net> Message-ID: <34a67f7f-88c3-fdd2-8e4d-23801d55a84c@kynesim.co.uk> On 15/10/18 12:28, Marko Rauhamaa wrote: > Rhodri James : > >> On 15/10/18 05:45, Marko Rauhamaa wrote: >>> The two-space indentation is the out-of-the-box default for emacs. >> >> Ahem. It's the default for certain C styles. It's not even the default >> for C-mode itself, which is 4. > > You must be running a different version of emacs than all the versions > I've every run. > > Try running > > emacs -q abc.c > > and observe the indentation depth. https://www.gnu.org/software/emacs/manual/html_node/ccmode/Customizing-Indentation.html#Customizing-Indentation """User Option: c-basic-offset This style variable holds the basic offset between indentation levels. It's factory default is 4, but all the built-in styles set it themselves, to some value between 2 (for gnu style) and 8 (for bsd, linux, and python styles).""" -- Rhodri James *-* Kynesim Ltd From marko at pacujo.net Mon Oct 15 11:41:05 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 15 Oct 2018 18:41:05 +0300 Subject: Python indentation (3 spaces) References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> <87o9bvjvnx.fsf@elektro.pacujo.net> <34a67f7f-88c3-fdd2-8e4d-23801d55a84c@kynesim.co.uk> Message-ID: <87murfqktq.fsf@elektro.pacujo.net> Rhodri James : > On 15/10/18 12:28, Marko Rauhamaa wrote: >> Try running >> >> emacs -q abc.c >> >> and observe the indentation depth. > > """User Option: c-basic-offset > > This style variable holds the basic offset between indentation > levels. It's factory default is 4, but all the built-in styles set it > themselves, to some value between 2 (for gnu style) and 8 (for bsd, > linux, and python styles).""" To realize why 2 is the factory default despite the above statement, we observe that the factory setting of c-default-style specifies "gnu" for C-like files other than Java and awk. Marko From pjmclenon at gmail.com Mon Oct 15 12:00:47 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Mon, 15 Oct 2018 09:00:47 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> Message-ID: <569abdbd-0ce4-446e-80b8-4121f4325a5d@googlegroups.com> On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: > On 2018-10-14 00:13, pjmclenon at gmail.com wrote: > > On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > >> ?> 1st is this script is from a library module online open source > >> > >> If it's open source, why didn't you show the link to the soruce? > >> I assume your code is this: > >> > >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py > >> > >> And self.collFile is opened here: > >> > >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 > >> > >> You need to add `encoding='utf-8'` argument. > > > > > > > > hello i used this recommandtion in one of my projects in python and it worked fine im wrting today cuz i have this same unicode error in a slighty differn file code line and i added encoding utf 8 but i still get the same error > > > > here is my line of code > > > > with open(join("docs", path)) as f: > > > > where can i add the encoding="utf8" line?? > > does anyone on this forum happen to know?? > > > > ok thank you jessica > > > with open(join("docs", path), encoding="utf-8") as f: THANK you very much that works i had forgot a comma , thats what gave me the error thaxz again Jesiica From rhodri at kynesim.co.uk Mon Oct 15 12:06:04 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 15 Oct 2018 17:06:04 +0100 Subject: Python indentation (3 spaces) In-Reply-To: <87murfqktq.fsf@elektro.pacujo.net> References: <0b98e687-7534-499d-9293-230b9b1d0a9e@googlegroups.com> <874ldorye3.fsf@elektro.pacujo.net> <86o9bwqh1p.fsf@richard.bawden.org> <86in23rht3.fsf@richard.bawden.org> <87tvlnrf6r.fsf@elektro.pacujo.net> <87o9bvjvnx.fsf@elektro.pacujo.net> <34a67f7f-88c3-fdd2-8e4d-23801d55a84c@kynesim.co.uk> <87murfqktq.fsf@elektro.pacujo.net> Message-ID: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> On 15/10/18 16:41, Marko Rauhamaa wrote: > Rhodri James : > >> On 15/10/18 12:28, Marko Rauhamaa wrote: >>> Try running >>> >>> emacs -q abc.c >>> >>> and observe the indentation depth. >> >> """User Option: c-basic-offset >> >> This style variable holds the basic offset between indentation >> levels. It's factory default is 4, but all the built-in styles set it >> themselves, to some value between 2 (for gnu style) and 8 (for bsd, >> linux, and python styles).""" > > To realize why 2 is the factory default despite the above statement, we > observe that the factory setting of c-default-style specifies "gnu" for > C-like files other than Java and awk. In other words, only for some C styles. As I said. -- Rhodri James *-* Kynesim Ltd From rj.amdphreak at gmail.com Mon Oct 15 12:16:38 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Mon, 15 Oct 2018 11:16:38 -0500 Subject: Single DB connection during class's lifetime. Metaclass,singletonand __new__() examples and references. In-Reply-To: <20181013224810.GA75842@cskk.homeip.net> References: <5bc0e7c6.1c69fb81.28d45.6203@mx.google.com> <20181013224810.GA75842@cskk.homeip.net> Message-ID: <5bc4bd64.1c69fb81.ec5a2.696c@mx.google.com> Thank you. That clears everything up. Sent from Mail for Windows 10 From: Cameron Simpson Sent: Saturday, October 13, 2018 6:06 PM To: Ryan Johnson Cc: python-list at python.org Subject: Re: Single DB connection during class's lifetime. Metaclass,singletonand __new__() examples and references. On 12Oct2018 13:28, Ryan Johnson wrote: >Thanks for the clarification. > >If I am creating a class variable, are you suggesting I perform the ?if it exists, great, otherwise make it? logic in the __init__ block or in the class definition block? Will that even run in a class definition? The class definition code runs when the class is defined (as Python reads it in your code). The __init__ block runs once each time a new instance of the class is initialised. When do you _want_ this logic to run? That dictates where the logic goes. If you run this in the class definition code it pretty much will unconditionally make a db connection. But in reality (a) you usually want to defer making the connection until you need it to reduce resource usage and (b) you often don't know enough to make the connection at class definition time i.e. you don't know the database host, the credentials, etc - they are often supplied to the initialiser (directly or via some config file). >I never see examples do anything besides assignment operations and flow >control, although it would follow that if the block allows creation of >strings (an object), it would allow creation of connection objects. On >the other hand, the __init__ block seems like a natural place to put >the cursor instantiation. You can do anything that is sensible in the __init__ block - it is just code. Your goal is to decide what is sensible. Normally the initialiser mosts sets up various arrtributes to sane initial values. It can do complex things, but is usually relatively basic. I'd note, as Thomas did, that the cursor is a control object associated with a query. You can have multiple cursors on a connection, and you often make one from a query, process the query results, then discard the cursor. SO you routinely use several during the lifetime of a connection. Therefore you don't make cursors when you set up the connection; you make them in association with queries. >From this answer ( https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642 ) the pythonic way to access the class variable is using type(self), but doesn?t this access the local class?s variable, if someone subclasses my class? Can I specify my class variable via the class name itself? Example: instancevar = ClassName.classvar . >I am hoping that because of the way python points labels to objects, this should give my instance an instance var that refers to the class var. Am I right? _Usually_ I access class attributes (which you're calling variables, I believe - they're not) via the instance: def foo(self, blah=None): if blah is None: blah = foo.DEFAULT_BLAH_VALUE ... work with blah ... As you suggest, this will find DEFAULT_BLAH_VALUE from the subclass before it finds it from the superclass. Usually that is what I want - the purpose of subclassing is to (possibly) override the aspects of the superclass. However, you _can_ always reach directly to a specific class to get a value: blah = MySuperCLass.DEFAULT_BLAH_VALUE if that is sensible. All you're doing is changing the way in which the name "DEFAULT_BLAH_VALUE" is found: do I use the instance's name lookup or go somewhere direct? In your case with a persistent database connection associated with a class it would be best to make the "get a connection" logic a class method because the "is there a connection" attribute is associated with the class, not the instance. Methods are, by default, "instance" methods: they are defined like this: def method(self, ...): and you largely work through "self", being the current instance. That is its "context". Class method are defined like this: @classmethod def method(cls, ...) and instead of having an instance as context (with the conventional name 'self"), you have the class (with the conventional name "cls"). These are for methods which _do_ _not_ care about the instance, just the class. So in the case of your database connection, made on demand once per class, you might go: @classmethod def conn(cls): c = cls.connection if c is None: c = connect_to_the_db(.....) cls.connection = c return c See that there's no "self" in here? Then your instance methods can look like this: def lookup(self, ....): conn = self.conn() cursor = conn.select(....) ... use the cursor to process the result ... The instance finds the "conn" class method in the usual way: look in the instance, then look in the class hierarchy. This in itself is an argument against making the connection in the __init__ block. Does this help? Cheers, Cameron Simpson From hjp-python at hjp.at Mon Oct 15 14:57:38 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 15 Oct 2018 20:57:38 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <20181014224912.GA78543@cskk.homeip.net> References: <20181014223345.vio35fhx6ub365up@hjp.at> <20181014224912.GA78543@cskk.homeip.net> Message-ID: <20181015185738.bcf7y7x5hl3pr5by@hjp.at> On 2018-10-15 09:49:12 +1100, Cameron Simpson wrote: > On 15Oct2018 00:33, Peter J. Holzer wrote: > > On 2018-10-15 09:06:11 +1100, Chris Angelico wrote: > > > On Mon, Oct 15, 2018 at 8:56 AM Marko Rauhamaa wrote: > > > > Chris Angelico : > > > > > Tabs for indentation have semantic meaning. Top-level has zero tabs. > > > > > One indentation level is represented by one tab. Two indentation > > > > > levels? Two tabs. It's about as perfect a representation as you could > > > > > hope for. > > > > > > > > That *could* be the situation. However, it is trumped by an older > > > > convention whereby the indentation levels go as follows: > > > > > > > > 0: > > > > 1: SPC SPC > > > > 2: SPC SPC SPC SPC > > > > 3: SPC SPC SPC SPC SPC SPC > > > > 4: TAB > > > > 5: TAB SPC SPC > > > > 6: TAB SPC SPC SPC SPC > > > > 7: TAB SPC SPC SPC SPC SPC SPC > > > > 8: TAB TAB > > > > That's not using tabs for indentation, that's using tabs for compressing > > spaces (somebody already mentioned that in this thread). > > > > > > > I've literally NEVER come across this as a convention. Not a single > > > file that I have ever worked with has used it. Where is this > > > convention from? > > > > It's something vi does by default, and apparently emacs as well. > > In the 1970's saving space by replacing sequences of 8 spaces > > with tabs seemed lika a good idea. > > > > There are workarounds in vi(m), but I'm not sure if you can get rid of > > that behaviour completely. I'm sure it is possible in emacs. > > I'm a "just use spaces" guy. So am I. As I wrote somewhere near the start of this thread, I find the "1 tab per indentation level" theoretically appealing but unworkable in practice. > I use the tab _key_ as a shortcut to do a bunch > of spaces. > > My vim setup has this: > > set expandtab > > which turns them into spaces. Yep, mine, too. But that doesn't help you if you want to use tabs (the character ASCII 0x09, not the tab key) to signify an indentation level in your files. So it's sort of off-topic in this sub-thread. My point was that with expandtab off, vim sometimes "optimizes" sequences of spaces into tabs in places where it shouldn't, and that it's hard (maybe impossible) to get vim leave tabs where they belong and not introduce them where they don't belong. So it isn't the ideal editor for the "1 tab per indentation level" style. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Oct 15 15:28:58 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 15 Oct 2018 21:28:58 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <5fcd6e82-6922-4560-6b8a-706a656c856c@kynesim.co.uk> References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013072611.pqy6yhalf2watuff@hjp.at> <20181014080609.hvbs6dytslu55pum@hjp.at> <5fcd6e82-6922-4560-6b8a-706a656c856c@kynesim.co.uk> Message-ID: <20181015192858.o2jsxg5m5dali5nx@hjp.at> On 2018-10-15 12:06:06 +0100, Rhodri James wrote: > On 14/10/18 09:06, Peter J. Holzer wrote: > > If everybody used tabs, why would anyone care about your tab width? > > Unless they look over your shoulder while you are typing, they won't > > even know how wide your tabs are. > > If you used two-space tab stops and I used (the normal :-) eight, > comfortable indentations for you would rapidly become uncomfortably large > indentations for me. I'd care about that. Buy a bigger monitor :-). On a more serious note, I think the number of indentation levels should be fairly low regardless of their width. If someone uses 2-space indentation so they can fit 20 nested ifs, the other programmers should complain during code review: Not because the lines are too long but because the nesting is too deep. > I'd also care if you used spaces to make sub-tab stop adjustments to > line up appropriate text (inside brackets, for example). I'm not sure what a "sub-tab stop adjustment" is. I think that for the "1 tab per indentation level" style, tabs would be used only for indentation, nothing else, and preferably only for block-level indentation. So a python function might look like this with 8 spaces per tab: def?foo(a_parameter,?another_parameter, ????????an_optional_parameter=DEFAULT_VALUE, ????????another_optional_parameter=None ????): ?x?=?a_parameter ?a?=?[ ?????{?'x':?1,???'y':?2,????'z':?3?}, ?????{?'x':?0.4,?'y':?3.14,?'z':?1.618?}, ?] ?if?another_optional_parameter: ? ?r?=?( ? ?????(another_optional_parameter?*?a[0]['x']?+?another_parameter?*?b[0]['y']) ? ?????/ ? ?????(a[1]['x']?+?a[1]['y']?+?a[1]['z']) ? ?) ?else: ? ?r?=?another_parameter?*?0 ?return?r (I'using ? to represent a tab here and ? to represent a space.) And like this with 2 spaces per tab: def?foo(a_parameter,?another_parameter, ????????an_optional_parameter=DEFAULT_VALUE, ????????another_optional_parameter=None ????): ?x?=?a_parameter ?a?=?[ ?????{?'x':?1,???'y':?2,????'z':?3?}, ?????{?'x':?0.4,?'y':?3.14,?'z':?1.618?}, ?] ?if?another_optional_parameter: ? ?r?=?( ? ?????(another_optional_parameter?*?a[0]['x']?+?another_parameter?*?b[0]['y']) ? ?????/ ? ?????(a[1]['x']?+?a[1]['y']?+?a[1]['z']) ? ?) ?else: ? ?r?=?another_parameter?*?0 ?return?r Note that everything still lines up nicely. hp (a four spaces per indentation level guy) -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Oct 15 15:31:54 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 15 Oct 2018 21:31:54 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> Message-ID: <20181015193154.5gm64rasvigp2ess@hjp.at> On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote: > On 13-10-18 09:37, Peter J. Holzer wrote: > > On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: > >> On 08-10-18 19:43, Peter J. Holzer wrote: > >>> In practice it doesn't work in my experience. There is always someone in > >>> a team who was "just testing that new editor" and replaced all tabs > >>> with spaces (or vice versa) or - worse - just some of them. > >> Isn't that caugth in the process of commiting to version control? > > Tabs are easy to catch. If a file contains a tab, reject it. > > > > Spaces aren't, because spaces are everywhere. > > Spaces that replaced a tab by accident, are easy to catch too. They are all > those lines that show up when you do a diff with the previous version that > shouldn't show up. And where is the AI that decides which lines in a diff are should show up? Whether a line in a diff should or should not show up seems to me to be even harder to determine than whether a tab fits the syntax. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rosuav at gmail.com Mon Oct 15 15:37:56 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 16 Oct 2018 06:37:56 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <20181015193154.5gm64rasvigp2ess@hjp.at> References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> <20181015193154.5gm64rasvigp2ess@hjp.at> Message-ID: On Tue, Oct 16, 2018 at 6:34 AM Peter J. Holzer wrote: > > On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote: > > On 13-10-18 09:37, Peter J. Holzer wrote: > > > On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: > > >> On 08-10-18 19:43, Peter J. Holzer wrote: > > >>> In practice it doesn't work in my experience. There is always someone in > > >>> a team who was "just testing that new editor" and replaced all tabs > > >>> with spaces (or vice versa) or - worse - just some of them. > > >> Isn't that caugth in the process of commiting to version control? > > > Tabs are easy to catch. If a file contains a tab, reject it. > > > > > > Spaces aren't, because spaces are everywhere. > > > > Spaces that replaced a tab by accident, are easy to catch too. They are all > > those lines that show up when you do a diff with the previous version that > > shouldn't show up. > > And where is the AI that decides which lines in a diff are should show > up? > > Whether a line in a diff should or should not show up seems to me to be > even harder to determine than whether a tab fits the syntax. > If there's a change, it shows up. If there's no change, it doesn't show up. Ergo, if you accidentally replace a tab with spaces, it's a change, and it shows up. ChrisA From cs at cskk.id.au Mon Oct 15 17:01:45 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 16 Oct 2018 08:01:45 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> References: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> Message-ID: <20181015210145.GA56263@cskk.homeip.net> > [ Marko and Rhdri discussing emacs indentation modes ... ] I can't express how pleasing it is to see the traditional vi-vs-emacs wars supplanted by emacs-vs-emacs :-) Cheers, Cameron Simpson From rosuav at gmail.com Mon Oct 15 17:04:51 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 16 Oct 2018 08:04:51 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <20181015210145.GA56263@cskk.homeip.net> References: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> <20181015210145.GA56263@cskk.homeip.net> Message-ID: On Tue, Oct 16, 2018 at 8:03 AM Cameron Simpson wrote: > > > [ Marko and Rhdri discussing emacs indentation modes ... ] > > I can't express how pleasing it is to see the traditional vi-vs-emacs > wars supplanted by emacs-vs-emacs :-) > Which editor should I use - vi in emacs mode, or emacs in vi mode? *diving for cover* ChrisA From tjol at tjol.eu Mon Oct 15 17:06:05 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 15 Oct 2018 23:06:05 +0200 Subject: Email parsing and unicode/utf8 Message-ID: <55a195b4-9c98-7db4-01b7-6849ee9b1c14@tjol.eu> Hi, I just stumbled over some curious behaviour of the stdlib email parsing APIs which accept strings rather than bytes. It appears that you can't parse an 8-bit UTF-8 message you have as a str without first encoding it. The docs do mention some problems (which I saw after the fact): > class email.parser.FeedParser(_factory=None, *, policy=policy.compat32) > > Works like BytesFeedParser except that the input to the feed() method must be a string. This is of limited utility, since the only way for such a message to be valid is for it to contain only ASCII text or, if utf8 is True, no binary attachments. > > Changed in version 3.3: Added the policy keyword. Okay, cool - let's try parsing a message with text only (no attachments, no BINARYMIME), with a UTF-8 Content-Type, and a policy with utf8=True. Python 3.7.1rc2 (default, Oct 14 2018, 15:27:05) [GCC 8.2.1 20180831 [gcc-8-branch revision 264010]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import email.parser, email.policy >>> pol = email.policy.SMTPUTF8 >>> pol.utf8 True >>> pol.cte_type '8bit' >>> msg = '''MIME-Version: 1.0 ... Content-Type: text/plain; charset="utf-8" ... Content-Transfer-Encoding: 8bit ... Subject: ?Will it parse? ???. ... ... ?This message contains two (?) non-ASCII characters! ... ''' >>> fp = email.parser.FeedParser(policy=pol) >>> fp.feed(msg) >>> msg_obj = fp.close() >>> msg_obj >>> print(msg_obj.get_content()) ?This message contains two (\u0662) non-ASCII characters! >>> print(msg_obj['Subject']) ?Will it parse? ???. I don't know WHAT it's doing with the body there... It doesn't look like utf8 mode actually did anything. Interesting that the subject header survived! Maybe this is what the utf8=True does? >>> email.policy.default.utf8 False >>> fp2 = email.parser.FeedParser(policy=email.policy.default) >>> fp2.feed(msg) >>> msg_obj2 = fp2.close() >>> print(msg_obj2['Subject']) ?Will it parse? ???. Nope. Apparently, contrary to what my reading of the docs suggests, the utf8 flag does nothing at all when parsing. Just to check that this was in fact a perfectly valid email: >>> bfp = email.parser.BytesFeedParser(policy=pol) >>> bfp.feed(msg.encode('utf-8')) >>> msg_objb = bfp.close() >>> print(msg_objb.get_content()) ?This message contains two (?) non-ASCII characters! >>> print(msg_objb['Subject']) ?Will it parse? ???. BytesFeedParser is happy. Question: Is this a bug? Am I missing something? Does the clause in the docs about utf8 mean anything? Cheers Thomas From ethan at stoneleaf.us Mon Oct 15 17:34:08 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 15 Oct 2018 14:34:08 -0700 Subject: Python indentation (3 spaces) In-Reply-To: References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> <20181015193154.5gm64rasvigp2ess@hjp.at> Message-ID: <183203ab-567f-6e49-90fb-09acacf7472f@stoneleaf.us> On 10/15/2018 12:37 PM, Chris Angelico wrote: > On Tue, Oct 16, 2018 at 6:34 AM Peter J. Holzer wrote: >> On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote: >>> Spaces that replaced a tab by accident, are easy to catch too. They are all >>> those lines that show up when you do a diff with the previous version that >>> shouldn't show up. >> >> And where is the AI that decides which lines in a diff are should show >> up? >> >> Whether a line in a diff should or should not show up seems to me to be >> even harder to determine than whether a tab fits the syntax. >> > > If there's a change, it shows up. If there's no change, it doesn't show up. > > Ergo, if you accidentally replace a tab with spaces, it's a change, > and it shows up. Unless you have your diff tool set to ignore whitespace-only changes. :( -- ~Ethan~ From greg.ewing at canterbury.ac.nz Mon Oct 15 17:54:16 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 16 Oct 2018 10:54:16 +1300 Subject: Python indentation (3 spaces) In-Reply-To: References: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> <20181015210145.GA56263@cskk.homeip.net> Message-ID: Cameron Simpson wrote: > I can't express how pleasing it is to see the traditional vi-vs-emacs > wars supplanted by emacs-vs-emacs :-) We're the People's Front of Emacs, not the Emacs People's Front! -- Greg From darcy at vex.net Mon Oct 15 18:09:01 2018 From: darcy at vex.net (D'Arcy Cain) Date: Mon, 15 Oct 2018 18:09:01 -0400 Subject: Python indentation (3 spaces) In-Reply-To: References: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> <20181015210145.GA56263@cskk.homeip.net> Message-ID: <238b0d6b-5bc5-11c5-ca86-d12656c4ec5a@vex.net> On 10/15/18 5:54 PM, Gregory Ewing wrote: > Cameron Simpson wrote: >> I can't express how pleasing it is to see the traditional vi-vs-emacs >> wars supplanted by emacs-vs-emacs :-) > > We're the People's Front of Emacs, not the Emacs People's Front! I thought we were the People's Emacs Front. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:darcy at Vex.Net VoIP: sip:darcy at Vex.Net From rosuav at gmail.com Mon Oct 15 18:46:23 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 16 Oct 2018 09:46:23 +1100 Subject: Python indentation (3 spaces) In-Reply-To: <238b0d6b-5bc5-11c5-ca86-d12656c4ec5a@vex.net> References: <8268534c-f510-6c28-4053-6a195a451481@kynesim.co.uk> <20181015210145.GA56263@cskk.homeip.net> <238b0d6b-5bc5-11c5-ca86-d12656c4ec5a@vex.net> Message-ID: On Tue, Oct 16, 2018 at 9:16 AM D'Arcy Cain wrote: > > On 10/15/18 5:54 PM, Gregory Ewing wrote: > > Cameron Simpson wrote: > >> I can't express how pleasing it is to see the traditional vi-vs-emacs > >> wars supplanted by emacs-vs-emacs :-) > > > > We're the People's Front of Emacs, not the Emacs People's Front! > > I thought we were the People's Emacs Front. > No, that's just a front for a tab-laundering enterprise... ChrisA From jfong at ms4.hinet.net Mon Oct 15 21:16:50 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Mon, 15 Oct 2018 18:16:50 -0700 (PDT) Subject: Is it dangeous when using custom metaclass? Message-ID: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> class StructureMeta(type): def __init__(self, clsname, bases, clsdict): offset = 0 ... ... setattr(self, 'struct_size', offset) class Structure(metaclass=StructureMeta): ... ... class PolyHeader(Structure): ... ... As my understanding, the metaclass's __init__ was called when a class was created. In the above example, both the Structure and PolyHeader called it. My question is: because the PolyHeader inherited Structure, is it reasonable for PolyHeader to call this __init__ again? Will it cause any possible trouble? --Jach From dieter at handshake.de Tue Oct 16 01:16:54 2018 From: dieter at handshake.de (dieter) Date: Tue, 16 Oct 2018 07:16:54 +0200 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> Message-ID: <87bm7uwjw9.fsf@handshake.de> Marko Rauhamaa writes: > dieter : >> Marko Rauhamaa writes: >>> Keeping the number of long-term objects low is key. >> >> Right, if I need near realtime behaviour and must live >> with [C]Python's garbage collector. > > Or any other GC ever invented. There are "realtime garbage collection" algorithms. For them, the creation of new objects must cooperate with the garbage collection - likely with the need to acquire a lock for a short period. But there is no (principle) need to block all "normal" activity during the complete garbage collection (as [C]Python's garbage collector has done this at the time of my problem). >> But, a web application does usually not need near realtime behaviour. >> An occasional (maybe once in a few days) garbage collection and >> associated reduced response time is acceptable. >> A problem only arises if a badly designed component produces >> quite frequently hundreds of thousands of temporary objects >> likely triggering (frequent) garbage collections. > > But I think you are barking up the wrong tree. You could rightly blame > GC itself as an unworkable paradigm and switch to, say, C++ or Rust. I am happy that [C]Python uses mainly reference counting for its memory management and that GC is used quite sparingly. > Or you could blame the parts of the software that create too many > long-term objects. I do not do that because I understand why in my application there are many long living objects. > You shouldn't blame the parts of the software that churn out zillions of > short-term objects. I do precisely that: the blamed component produced a very large number of short living objects -- without need and while it should have been aware that it operates on mass data - among others from the fact that its complete environment took special care to work with this mass data efficiently. I solved my problem by replacing this single component by one knowing what it does. No need to rewrite the complete application, get rid of Python object caches or even switch to a different language. From dieter at handshake.de Tue Oct 16 01:31:25 2018 From: dieter at handshake.de (dieter) Date: Tue, 16 Oct 2018 07:31:25 +0200 Subject: Email parsing and unicode/utf8 References: <55a195b4-9c98-7db4-01b7-6849ee9b1c14@tjol.eu> Message-ID: <877eiiwj82.fsf@handshake.de> Thomas Jollans writes: > I just stumbled over some curious behaviour of the stdlib email parsing > APIs which accept strings rather than bytes. It appears that you can't > parse an 8-bit UTF-8 message you have as a str without first encoding it. The primary purpose of an email parser is likely the parsing of RFC 822/2045 messages which are a sequence of bytes, encoded as dictated by RFC 822. Therefore, I would expect some peculiarities when you feed such a parser with general text. From rosuav at gmail.com Tue Oct 16 01:52:10 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 16 Oct 2018 16:52:10 +1100 Subject: ESR "Waning of Python" post In-Reply-To: <87bm7uwjw9.fsf@handshake.de> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87bm7uwjw9.fsf@handshake.de> Message-ID: On Tue, Oct 16, 2018 at 4:18 PM dieter wrote: > > Marko Rauhamaa writes: > > Or you could blame the parts of the software that create too many > > long-term objects. > > I do not do that because I understand why in my application > there are many long living objects. > > > You shouldn't blame the parts of the software that churn out zillions of > > short-term objects. > > I do precisely that: the blamed component produced a very large > number of short living objects -- without need and while it should > have been aware that it operates on mass data - among others from the > fact that its complete environment took special care to work with > this mass data efficiently. Exactly. Long-term objects are NOT a problem. Tell me, how many objects get created as a web app boots up and then are never destroyed for the lifetime of that process? To find out, I added this line just before a very VERY small Flask app of mine goes into its main loop: import gc; print(len(gc.get_objects()), "objects currently tracked") There are over 40,000 of them. Now, I can't say for sure that every one of those objects will stick around till the process shuts down, but I'd say a lot of them will. They're modules, functions, types, class dictionaries... oh, and the GC doesn't track strings or numbers, so that's another whole huge slab of objects that you'd have to count. If you replace the refcounting GC with a pure mark-and-sweep, you have to check every single one of them every time you do a GC pass. (For reference, running the same GC check in an empty Python interpreter gives around five thousand tracked objects, still mostly functions.) ChrisA From greg.ewing at canterbury.ac.nz Tue Oct 16 02:00:45 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 16 Oct 2018 19:00:45 +1300 Subject: Is it dangeous when using custom metaclass? In-Reply-To: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> References: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> Message-ID: jfong at ms4.hinet.net wrote: > class Structure(metaclass=StructureMeta): ... > > class PolyHeader(Structure): ... > > As my understanding, the metaclass's __init__ was called when a class was > created. In the above example, both the Structure and PolyHeader called it. > My question is: because the PolyHeader inherited Structure, is it reasonable > for PolyHeader to call this __init__ again? Will it cause any possible > trouble? It's reasonable for both to call it, because they're distinct instances of StructureMeta, each of which need to be initialised. Whether it will cause a problem depends on what StructureMeta's __init__ is supposed to do. Presumably you want a given structure class to start allocating its offsets where its base class left off, in which case you may need to do something like this: class StructureMeta(type): def __init__(self, clsname, bases, clsdict): if bases: offset = bases[0].offset # assuming there isn't more than one base else: offset = 0 ... (BTW, why do you use setattr() to set the offset attribute instead of just doing self.offset = offset?) -- Greg From marko at pacujo.net Tue Oct 16 03:00:07 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 16 Oct 2018 10:00:07 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> Message-ID: <87in22pea0.fsf@elektro.pacujo.net> Paul Rubin : > Marko Rauhamaa writes: >>> Right, if I need near realtime behaviour and must live >>> with [C]Python's garbage collector. >> Or any other GC ever invented. > > There are realtime ones, like the Azul GC for Java, that have bounded > delay in the milliseconds or lower. The total overhead is higher > though. I'd be interested in a definitive, non-anecdotal analysis on the topic. Do you happen to have a link? One reference I found stated there was no upper bound for heap use: A second cost of concurrent garbage collection is unpredictable heap growth. The program can allocate arbitrary amounts of memory while the GC is running. If that worst-case behavior were tolerated, it would be trivial to implement real-time GC: just let the objects pile up and never reclaim. Marko From jfong at ms4.hinet.net Tue Oct 16 04:45:01 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Tue, 16 Oct 2018 01:45:01 -0700 (PDT) Subject: Is it dangeous when using custom metaclass? In-Reply-To: References: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> Message-ID: <8564e592-d47d-4146-8ae4-abf03b0674a7@googlegroups.com> Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > jfong at ms4.hinet.net wrote: > > class Structure(metaclass=StructureMeta): ... > > > > class PolyHeader(Structure): ... > > > > As my understanding, the metaclass's __init__ was called when a class was > > created. In the above example, both the Structure and PolyHeader called it. > > My question is: because the PolyHeader inherited Structure, is it reasonable > > for PolyHeader to call this __init__ again? Will it cause any possible > > trouble? > > It's reasonable for both to call it, because they're distinct > instances of StructureMeta, each of which need to be initialised. The PolyHeader is already initialized by inheritance. Is there any way to bypass this __init__? > Whether it will cause a problem depends on what StructureMeta's > __init__ is supposed to do. Presumably you want a given structure > class to start allocating its offsets where its base class left > off, in which case you may need to do something like this: > > class StructureMeta(type): > def __init__(self, clsname, bases, clsdict): > if bases: > offset = bases[0].offset # assuming there isn't more than one base > else: > offset = 0 > ... > > (BTW, why do you use setattr() to set the offset attribute > instead of just doing self.offset = offset?) No particular reason, just follows the same code pattern ahead of it where the attribute names are from a list:-) --Jach From frank at chagford.com Tue Oct 16 05:10:28 2018 From: frank at chagford.com (Frank Millman) Date: Tue, 16 Oct 2018 11:10:28 +0200 Subject: Questions about weakref Message-ID: Hi all I have some questions about using weakrefs. My first question is whether weakrefs are the correct tool for my situation. My use-case is not mentioned in the docs, so maybe it is not intended to be used this way. I have a lot of objects active in my app. Some of them (A) are fairly long-lived. Others (B) are short-lived, but hold a reference to one of the A objects. For the lifetime of the existence of B, it needs to be notified of any change of state of A. Therefore when B is created, it adds itself to a list maintained by A. It adds a tuple consisting of itself and a function (C). Whenever A detects a change of state, it iterates through the list and calls the function C, passing B as an argument. I have quite a bit of additional housekeeping to perform to ensure that, when B goes out of scope, it removes itself from the list in A. I was hoping to use weakrefs to make this automatic. So the first question is, is this a reasonable use of weakrefs? If yes, my second question is how to guard against A calling methods using dead B objects, as A has no control over when B might be gc'd. My thinking is to use a WeakKeyDictionary, with the B object as the key and the C function as the data. When A detects a change of state, instead of iterating over the keys, it should call keyrefs() to get the weakrefs and iterate over that. For each weakref it should 'call' it to get the actual key, and check for None to ensure that it is still alive. Does that sound safe? Incidentally, the docs are slightly misleading. It says that the method keyrefs returns 'an iterable of the weak references to the keys'. I was not sure if that would expose me to the 'change size while iterating' error, so I checked the source. The source says 'return list(self.data)', and the docstring clearly states 'Return a list of weak references to the keys'. I think the docs should say the same. Should I raise an issue for this? Frank Millman From tjol at tjol.eu Tue Oct 16 05:57:53 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 16 Oct 2018 11:57:53 +0200 Subject: Questions about weakref In-Reply-To: References: Message-ID: <54c34198-cc98-93af-2c04-9d23276c1306@tjol.eu> On 2018-10-16 11:10, Frank Millman wrote: > Hi all > > I have some questions about using weakrefs. > > My first question is whether weakrefs are the correct tool for my > situation. My use-case is not mentioned in the docs, so maybe it is not > intended to be used this way. > > I have a lot of objects active in my app. Some of them (A) are fairly > long-lived. Others (B) are short-lived, but hold a reference to one of > the A objects. For the lifetime of the existence of B, it needs to be > notified of any change of state of A. Therefore when B is created, it > adds itself to a list maintained by A. It adds a tuple consisting of > itself and a function (C). Whenever A detects a change of state, it > iterates through the list and calls the function C, passing B as an > argument. > > I have quite a bit of additional housekeeping to perform to ensure that, > when B goes out of scope, it removes itself from the list in A. I was > hoping to use weakrefs to make this automatic. So the first question is, > is this a reasonable use of weakrefs? > > If yes, my second question is how to guard against A calling methods > using dead B objects, as A has no control over when B might be gc'd. > > My thinking is to use a WeakKeyDictionary, with the B object as the key > and the C function as the data. This sounds reasonable, though what you probably really want is a signal/slot library that does all of this for you, like PySignal. I believe all the pure-Python signal/slot libraries use weakrefs internally. -- Thomas From spencer.graves at effectivedefense.org Tue Oct 16 11:15:29 2018 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Tue, 16 Oct 2018 10:15:29 -0500 Subject: Package creation documentation? Message-ID: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> ????? Where can I find a reasonable tutorial on how to create a Python package? ????? I've not created a Python package before, and I want to. Sadly, I'm having trouble finding reasonable documentation on how to do so. ????? According to the Python 3 Glossary, "a package is a Python module with an __path__ attribute."[1] ????? I found "packaging.python.org", which recommends "Packaging Python Projects"[2] and "An Overview of Packaging for Python".[3] I failed to find "__path__" in either. ????? I've started a project on GitHub for this, which includes what I have so far toward building a Python package I want along with RStudio Rmarkdown Documents summarizing what I've tried so far.[4] ????? What would you suggest I do to understand what I should do to create a "__path__ attribute" for this, and what I should do after that? ????? I have decades of coding experience, but only a small portion of that was with Python, and that was roughly 7 years ago. ????? Thanks, ????? Spencer Graves [1] https://docs.python.org/3/glossary.html#term-package [2] https://packaging.python.org/tutorials/packaging-projects/ [3] https://packaging.python.org/overview/ [4] https://github.com/sbgraves237/radioMonitor From tjol at tjol.eu Tue Oct 16 11:34:46 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 16 Oct 2018 17:34:46 +0200 Subject: Package creation documentation? In-Reply-To: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> Message-ID: <4aacdf8f-00e5-d540-ba7b-5e615c1c19e1@tjol.eu> On 2018-10-16 17:15, Spencer Graves wrote: > ????? Where can I find a reasonable tutorial on how to create a Python > package? > > > ????? I've not created a Python package before, and I want to. Sadly, > I'm having trouble finding reasonable documentation on how to do so. > > > ????? According to the Python 3 Glossary, "a package is a Python module > with an __path__ attribute."[1] Never mind that. Pay attention to the next line: See also regular package and namespace package. A regular package is just a directory with an __init__.py file in it (and normally some submodules). Generally you should only create a package if your codebase has multiple somewhat independent but related bits, or is to large or complex to be maintainable as a single module (.py file). Now, if you want to package (verb) your module (noun) or package (noun) into a package (different noun) that others can install, you want to read the setuptools documentation. https://setuptools.readthedocs.io/en/latest/ The overloading of the term "package" is a bit unfortunate, but most of the time we don't notice since most packages contain packages, and most packages come in packages. Some packages just contain modules, and some packages are not packaged, though. I would like to apologize for the previous paragraph. -- Thomas From leo at superlel.me Tue Oct 16 12:14:43 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Tue, 16 Oct 2018 18:14:43 +0200 Subject: Package creation documentation? In-Reply-To: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> Message-ID: Hello Spencer, On 16/10/2018 17:15, Spencer Graves wrote: > Where can I find a reasonable tutorial on how to create a Python > package? IMO, the best documentation about this is the tutorial: https://docs.python.org/3/tutorial/modules.html#packages > According to the Python 3 Glossary, "a package is a Python module > with an __path__ attribute."[1] What you are looking at are the technical details of what a package is. Incidentally, if you follow the tutorial, everything will get in-place. > I found "packaging.python.org", which recommends "Packaging Python > Projects"[2] and "An Overview of Packaging for Python".[3] packaging.python.org is centered on "How to install and distribute Python packages (Or modules)" - L?o From leo at superlel.me Tue Oct 16 12:23:55 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Tue, 16 Oct 2018 18:23:55 +0200 Subject: Package creation documentation? In-Reply-To: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> Message-ID: <8aa091b8-c826-88b4-9589-431de828e17e@superlel.me> Given your coding experience also you may want to look at https://docs.python.org/3/reference/import.html#packages, which is the technical detail of what a package is (And "how" it's implemented). From jfine2358 at gmail.com Tue Oct 16 13:38:07 2018 From: jfine2358 at gmail.com (jfine2358 at gmail.com) Date: Tue, 16 Oct 2018 10:38:07 -0700 (PDT) Subject: ESR "Waning of Python" post In-Reply-To: <87in22pea0.fsf@elektro.pacujo.net> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> <87in22pea0.fsf@elektro.pacujo.net> Message-ID: <843b08dc-fc23-42f5-a558-0bcf1db3f996@googlegroups.com> On Tuesday, October 16, 2018 at 8:00:26 AM UTC+1, Marko Rauhamaa wrote: > I'm all in favour of collecting useful URLs. Here's some more suggestions: https://stackoverflow.com/questions/4491260/explanation-of-azuls-pauseless-garbage-collector https://pdfs.semanticscholar.org/9770/fc9baf0f2b6c7521f00958973657bf03337d.pdf https://www.researchgate.net/publication/220800769_Tax-and-spend_Democratic_scheduling_for_real-time_garbage_collection http://digg.com/2018/private-garbage-collection-propublica http://flyingfrogblog.blogspot.com/ Aside: One of the above is not about software garbage collection. Can you guess which one? -- Jonathan From spencer.graves at effectivedefense.org Tue Oct 16 14:03:23 2018 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Tue, 16 Oct 2018 13:03:23 -0500 Subject: Wikipedia on Python In-Reply-To: References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> Message-ID: <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> ????? Thanks to L?o El Amri and Thomas Jollans for their quick and helpful replies to my question about "Package creation documentation". ????? Beyond that, I'd like to encourage people on this list to review the Wikipedia article on "Python (programming language)",[1] especially the claim that "a package is a Python module with an __path__ attribute", which I added on 2018-09-24 to help me understand the distinction. ????? That Wikipedia article has averaged over 6,000 views per day over the past 3 years.? Therefore, any improvements will benefit lots of people. ????? If you have suggestions for how the article might be improved, you can post them to the "Talk" page associated with that article or send them to me.? If you are "autoconfirmed" with the Wikimedia system, you can make the changes yourself. ????? Thanks, ????? Spencer Graves [1] https://en.wikipedia.org/wiki/Python_(programming_language) On 2018-10-16 11:14, L?o El Amri wrote: > Hello Spencer, > > On 16/10/2018 17:15, Spencer Graves wrote: >> Where can I find a reasonable tutorial on how to create a Python >> package? > IMO, the best documentation about this is the tutorial: > https://docs.python.org/3/tutorial/modules.html#packages > >> According to the Python 3 Glossary, "a package is a Python module >> with an __path__ attribute."[1] > What you are looking at are the technical details of what a package is. > Incidentally, if you follow the tutorial, everything will get in-place. > >> I found "packaging.python.org", which recommends "Packaging Python >> Projects"[2] and "An Overview of Packaging for Python".[3] > packaging.python.org is centered on "How to install and distribute > Python packages (Or modules)" > > - L?o > From rosuav at gmail.com Tue Oct 16 14:09:33 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 17 Oct 2018 05:09:33 +1100 Subject: Wikipedia on Python In-Reply-To: <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> Message-ID: On Wed, Oct 17, 2018 at 5:05 AM Spencer Graves wrote: > Beyond that, I'd like to encourage people on this list to review > the Wikipedia article on "Python (programming language)",[1] especially > the claim that "a package is a Python module with an __path__ > attribute", which I added on 2018-09-24 to help me understand the > distinction. > You're welcome to put whatever you like into Wikipedia, but personally, I don't think that particular piece of terminology is all that helpful to the typical reader. Technical distinctions aren't important to someone who's trying to find out what Python's all about, or why s/he should learn the language. ChrisA From rj.amdphreak at gmail.com Tue Oct 16 15:44:42 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Tue, 16 Oct 2018 14:44:42 -0500 Subject: Wikipedia on Python In-Reply-To: <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> Message-ID: <5bc63fa9.1c69fb81.aafae.53c4@mx.google.com> Not really having read the whole story here, just wanna say that Wikipedia articles already suffer from a tug-of-war between professionals and students. Don?t worsen the problem. Include lay explanation and go into the technical details in a natural progression. Don?t force the reader to make large perspective jumps or conceptual jumps or require them to approach the article from the perspective of the designer from one sentence to the next. Pick your audience first, then write. Wikipedia requires a bridge between student and professional. Write it like it?s a synopsis that goes into detail, not like a reference manual for the already-initiated reader. If you like to write like it?s a reference, then there are list metapages on Wikipedia that tend to be agreeable to this. peace Sent from Mail for Windows 10 From: Spencer Graves Sent: Tuesday, October 16, 2018 1:06 PM To: L?o El Amri; python-list at python.org Subject: Wikipedia on Python ????? Thanks to L?o El Amri and Thomas Jollans for their quick and helpful replies to my question about "Package creation documentation". ????? Beyond that, I'd like to encourage people on this list to review the Wikipedia article on "Python (programming language)",[1] especially the claim that "a package is a Python module with an __path__ attribute", which I added on 2018-09-24 to help me understand the distinction. ????? That Wikipedia article has averaged over 6,000 views per day over the past 3 years.? Therefore, any improvements will benefit lots of people. ????? If you have suggestions for how the article might be improved, you can post them to the "Talk" page associated with that article or send them to me.? If you are "autoconfirmed" with the Wikimedia system, you can make the changes yourself. ????? Thanks, ????? Spencer Graves [1] https://en.wikipedia.org/wiki/Python_(programming_language) On 2018-10-16 11:14, L?o El Amri wrote: > Hello Spencer, > > On 16/10/2018 17:15, Spencer Graves wrote: >> Where can I find a reasonable tutorial on how to create a Python >> package? > IMO, the best documentation about this is the tutorial: > https://docs.python.org/3/tutorial/modules.html#packages > >> According to the Python 3 Glossary, "a package is a Python module >> with an __path__ attribute."[1] > What you are looking at are the technical details of what a package is. > Incidentally, if you follow the tutorial, everything will get in-place. > >> I found "packaging.python.org", which recommends "Packaging Python >> Projects"[2] and "An Overview of Packaging for Python".[3] > packaging.python.org is centered on "How to install and distribute > Python packages (Or modules)" > > - L?o > -- https://mail.python.org/mailman/listinfo/python-list From rj.amdphreak at gmail.com Tue Oct 16 15:48:38 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Tue, 16 Oct 2018 14:48:38 -0500 Subject: ESR "Waning of Python" post In-Reply-To: <843b08dc-fc23-42f5-a558-0bcf1db3f996@googlegroups.com> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> <87in22pea0.fsf@elektro.pacujo.net> <843b08dc-fc23-42f5-a558-0bcf1db3f996@googlegroups.com> Message-ID: <5bc64095.1c69fb81.fb73c.4f25@mx.google.com> Have seen this waning of python thread so many times. Hoping it would have waned by now. Lol. Sent from Mail for Windows 10 From: jfine2358 at gmail.com Sent: Tuesday, October 16, 2018 12:42 PM To: python-list at python.org Subject: Re: ESR "Waning of Python" post On Tuesday, October 16, 2018 at 8:00:26 AM UTC+1, Marko Rauhamaa wrote: > I'm all in favour of collecting useful URLs. Here's some more suggestions: https://stackoverflow.com/questions/4491260/explanation-of-azuls-pauseless-garbage-collector https://pdfs.semanticscholar.org/9770/fc9baf0f2b6c7521f00958973657bf03337d.pdf https://www.researchgate.net/publication/220800769_Tax-and-spend_Democratic_scheduling_for_real-time_garbage_collection http://digg.com/2018/private-garbage-collection-propublica http://flyingfrogblog.blogspot.com/ Aside: One of the above is not about software garbage collection. Can you guess which one? -- Jonathan -- https://mail.python.org/mailman/listinfo/python-list From kwpolska at gmail.com Tue Oct 16 16:06:04 2018 From: kwpolska at gmail.com (Chris Warrick) Date: Tue, 16 Oct 2018 22:06:04 +0200 Subject: Wikipedia on Python In-Reply-To: References: <0a0bf676-b6cb-5fcb-ce7d-3a94a623decb@effectivedefense.org> <790fa381-dee3-d39a-5c0a-7ec425d4cc1c@effectivedefense.org> Message-ID: On Tue, 16 Oct 2018 at 20:11, Chris Angelico wrote: > > On Wed, Oct 17, 2018 at 5:05 AM Spencer Graves > wrote: > > Beyond that, I'd like to encourage people on this list to review > > the Wikipedia article on "Python (programming language)",[1] especially > > the claim that "a package is a Python module with an __path__ > > attribute", which I added on 2018-09-24 to help me understand the > > distinction. > > > > You're welcome to put whatever you like into Wikipedia, but > personally, I don't think that particular piece of terminology is all > that helpful to the typical reader. Technical distinctions aren't > important to someone who's trying to find out what Python's all about, > or why s/he should learn the language. Seconded. This is not useful at all on Wikipedia. I took the liberty to remove this paragraph, because I don?t think anyone would find it useful; in fact, it would only confuse people. Here?s a diff for anyone interested in the original content: https://en.wikipedia.org/w/index.php?title=Python_(programming_language)&diff=prev&oldid=861064627 -- Chris Warrick PGP: 5EAAEA16 From tina_zy_qian at yahoo.com Tue Oct 16 17:14:10 2018 From: tina_zy_qian at yahoo.com (tina_zy_qian at yahoo.com) Date: Tue, 16 Oct 2018 14:14:10 -0700 (PDT) Subject: check whether a process is still running on remote hosts Message-ID: I newly learned Python, and I need to wrap up a script to do following. Env: 1: One launcher Linux VM (from where to run the Python script) 2. 100+ Linux VM requirement: In general, run a remote_script on remote 100 VMs and get the log files generated to remote hosts back to launcher. steps 1. cp (pexpect.spawn('scp ')) supporting files including the remote_script to remotehost:/remote_folder 2. run remote_script on remote host ( pexpect.spawn('ssh %s@%s "%s"' % (user,host,cmd)) 3. wait and check until the remote_script was run on remote host. (to check "ps -ef" result on remote hosts) 4. collect data from remote hosts -- reverse to step 1. I briefly implemented other steps expect step 3. Two options are below. option 1: run another script "ps -ef|grep remote_script and output result to a local file, then collected the files to launcher. option 2: run pexect.spawn('ssh' ....'ps -e') to get the result directly to laucher console. But how I can get only the output for "ps -ef" command only? I must use the (users, passwords, and hosts) way to do ssh and scp because I may not be allowed to use ssh key on some hosts. Any suggestions or sample code for step 3 or the whole script are appreciated. Thanks. From marko at pacujo.net Tue Oct 16 17:15:04 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 17 Oct 2018 00:15:04 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> <87in22pea0.fsf@elektro.pacujo.net> <87lg6xlkgw.fsf@nightsong.com> Message-ID: <87bm7tpp9j.fsf@elektro.pacujo.net> Paul Rubin : > But it's possible to do parallel GC with bounded latency. Perry > Cheng's 2001 PhD thesis says how to do it and is fairly readable: > > http://reports-archive.adm.cs.cmu.edu/anon/2001/CMU-CS-01-174.pdf Thanks. On a quick glance, it is difficult to judge what the worst-case time and space behavior are as the thesis mixes theory and practice and leans heavily on practice. The thesis says in its introduction: A real-time collector comprises two important features: pauses are bounded by some reasonably small value and the mutator can make sufficient progress between pauses. Different collectors meet these conditions with varying degrees of success and their viability depends on application needs. It is important to note that a collector must also complete collection within a reasonable time. A "real-time" collector which mereloy stops collections whenever it runs out of time would be hard real-time but useless if it never finishes a collection. In such cases, memory is soon exhausted. As with other real-time applications, the most important distinction among real-time collectors is the strength of the guarantee. > If you hang out with users of Lisp, Haskell, Ocaml, Java, Ruby, etc., > they (like Python users) have all kinds of complaints about their > languages, but GC pauses aren't a frequent topic of those complaints. I don't suffer from it, either. > Most applications don't actually care about sub-millisecond realtime. > They just want pauses to be small or infrequent enough to not interfere > with interactively using a program. If there's a millisecond pause > every few seconds of operation and an 0.2 second pause a few times an > hour, that's usually fine. Emacs occasionally hangs for about a minute to perform garbage collection. Similarly, Firefox occasionally becomes unresponsive for a long time, and I'm guessing it's due to GC. Marko From larry.martell at gmail.com Tue Oct 16 17:21:34 2018 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 16 Oct 2018 17:21:34 -0400 Subject: check whether a process is still running on remote hosts In-Reply-To: References: Message-ID: On Tue, Oct 16, 2018 at 5:15 PM tina_zy_qian--- via Python-list wrote: > > I newly learned Python, and I need to wrap up a script to do following. > > Env: > 1: One launcher Linux VM (from where to run the Python script) > 2. 100+ Linux VM > > requirement: > In general, run a remote_script on remote 100 VMs and get the log files generated to remote hosts back to launcher. > > steps > 1. cp (pexpect.spawn('scp ')) supporting files including the remote_script to remotehost:/remote_folder > 2. run remote_script on remote host ( pexpect.spawn('ssh %s@%s "%s"' % (user,host,cmd)) > 3. wait and check until the remote_script was run on remote host. (to check "ps -ef" result on remote hosts) > 4. collect data from remote hosts -- reverse to step 1. > > > I briefly implemented other steps expect step 3. Two options are below. > > option 1: run another script "ps -ef|grep remote_script and output result to a local file, then collected the files to launcher. > > option 2: run pexect.spawn('ssh' ....'ps -e') to get the result directly to laucher console. > But how I can get only the output for "ps -ef" command only? > > I must use the (users, passwords, and hosts) way to do ssh and scp because I may not be allowed to use ssh key on some hosts. Any suggestions or sample code for step 3 or the whole script are appreciated. Thanks. This looks amazingly similar to a pre interview programming assignment was given once. From tina_zy_qian at yahoo.com Tue Oct 16 19:07:43 2018 From: tina_zy_qian at yahoo.com (tina_zy_qian at yahoo.com) Date: Tue, 16 Oct 2018 16:07:43 -0700 (PDT) Subject: check whether a process is still running on remote hosts In-Reply-To: References: Message-ID: <798c4054-f948-42e7-a9ab-1274640ab3d4@googlegroups.com> On Tuesday, October 16, 2018 at 2:22:29 PM UTC-7, Larry.... at gmail.com wrote: > On Tue, Oct 16, 2018 at 5:15 PM tina_zy_qian--- via Python-list > wrote: > > > > I newly learned Python, and I need to wrap up a script to do following. > > > > Env: > > 1: One launcher Linux VM (from where to run the Python script) > > 2. 100+ Linux VM > > > > requirement: > > In general, run a remote_script on remote 100 VMs and get the log files generated to remote hosts back to launcher. > > > > steps > > 1. cp (pexpect.spawn('scp ')) supporting files including the remote_script to remotehost:/remote_folder > > 2. run remote_script on remote host ( pexpect.spawn('ssh %s@%s "%s"' % (user,host,cmd)) > > 3. wait and check until the remote_script was run on remote host. (to check "ps -ef" result on remote hosts) > > 4. collect data from remote hosts -- reverse to step 1. > > > > > > I briefly implemented other steps expect step 3. Two options are below. > > > > option 1: run another script "ps -ef|grep remote_script and output result to a local file, then collected the files to launcher. > > > > option 2: run pexect.spawn('ssh' ....'ps -e') to get the result directly to laucher console. > > But how I can get only the output for "ps -ef" command only? > > > > I must use the (users, passwords, and hosts) way to do ssh and scp because I may not be allowed to use ssh key on some hosts. Any suggestions or sample code for step 3 or the whole script are appreciated. Thanks. > > This looks amazingly similar to a pre interview programming assignment > was given once. Nice to know that. This is my daily work related though. Not interview question from me or to me. From rosuav at gmail.com Tue Oct 16 19:21:20 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 17 Oct 2018 10:21:20 +1100 Subject: check whether a process is still running on remote hosts In-Reply-To: <798c4054-f948-42e7-a9ab-1274640ab3d4@googlegroups.com> References: <798c4054-f948-42e7-a9ab-1274640ab3d4@googlegroups.com> Message-ID: On Wed, Oct 17, 2018 at 10:11 AM tina_zy_qian--- via Python-list wrote: > > On Tuesday, October 16, 2018 at 2:22:29 PM UTC-7, Larry.... at gmail.com wrote: > > This looks amazingly similar to a pre interview programming assignment > > was given once. > > Nice to know that. This is my daily work related though. Not interview question from me or to me. I suggest that you interview Larry for a programming job. Give him this challenge. Take his code, use it. http://dilbert.com/strip/2015-08-01 More seriously, though: You will find your task a LOT easier if (1) you use public key logins rather than passwords, and (2) you break the problem down into individual parts, each of which can be assessed separately, and then write each one on its own. ChrisA From cs at cskk.id.au Tue Oct 16 20:21:36 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 17 Oct 2018 11:21:36 +1100 Subject: check whether a process is still running on remote hosts In-Reply-To: References: Message-ID: <20181017002136.GA70566@cskk.homeip.net> On 16Oct2018 14:14, tina_zy_qian at yahoo.com wrote: >I newly learned Python, and I need to wrap up a script to do following. > >Env: >1: One launcher Linux VM (from where to run the Python script) >2. 100+ Linux VM > >requirement: >In general, run a remote_script on remote 100 VMs and get the log files generated to remote hosts back to launcher. > >steps >1. cp (pexpect.spawn('scp ')) supporting files including the remote_script to remotehost:/remote_folder >2. run remote_script on remote host ( pexpect.spawn('ssh %s@%s "%s"' % (user,host,cmd)) >3. wait and check until the remote_script was run on remote host. (to check "ps -ef" result on remote hosts) >4. collect data from remote hosts -- reverse to step 1. > > >I briefly implemented other steps expect step 3. Two options are below. > >option 1: run another script "ps -ef|grep remote_script and output result to a local file, then collected the files to launcher. > >option 2: run pexect.spawn('ssh' ....'ps -e') to get the result directly to laucher console. >But how I can get only the output for "ps -ef" command only? > >I must use the (users, passwords, and hosts) way to do ssh and scp >because I may not be allowed to use ssh key on some hosts. Any >suggestions or sample code for step 3 or the whole script are >appreciated. Thanks. Have you looked at ansible? It is a Python/ssh library/tool for remote admin. It is almost designed for this kind of thing. Run local script on remote hosts in parallel and wait for them? Tick. Ansible can prompt (once) for a remote ssh password and apply it to all the remote ssh invocations. I _strongly_ recommend you do this with keys though. Passwords are something of a security nightmare. You can be sure that the remote script has run if the ssh which invoked it returned with a zero exit status. If the ssh itself aborts, or the script fails, you get a nonzero status back from ssh. Personally I would be (a) trying to do this without passwords - install keys and (b) using threads to spawn all the remote sshes, have each thread wait for its own ssh, and wait for all the threads. Or reaching for ansible, which has this kind of logic built in. Cheers, Cameron Simpson From dieter at handshake.de Wed Oct 17 01:14:37 2018 From: dieter at handshake.de (dieter) Date: Wed, 17 Oct 2018 07:14:37 +0200 Subject: Is it dangeous when using custom metaclass? References: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> <8564e592-d47d-4146-8ae4-abf03b0674a7@googlegroups.com> Message-ID: <877eihtarm.fsf@handshake.de> jfong at ms4.hinet.net writes: > Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote >> jfong at ms4.hinet.net wrote: >> > class Structure(metaclass=StructureMeta): ... >> > >> > class PolyHeader(Structure): ... >> > >> > As my understanding, the metaclass's __init__ was called when a class was >> > created. In the above example, both the Structure and PolyHeader called it. >> > My question is: because the PolyHeader inherited Structure, is it reasonable >> > for PolyHeader to call this __init__ again? Will it cause any possible >> > trouble? >> >> It's reasonable for both to call it, because they're distinct >> instances of StructureMeta, each of which need to be initialised. > > The PolyHeader is already initialized by inheritance. Is there any way to bypass this __init__? If there were any, you should find it described in metaclass related documentation. Likely, you can ensure that followup calls of "__init__" effectively behave as "no-op"s: let the first call place a marker in the initialized object and check in later calls whether it is already there. From marko at pacujo.net Wed Oct 17 01:56:51 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 17 Oct 2018 08:56:51 +0300 Subject: ESR "Waning of Python" post References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> <87in22pea0.fsf@elektro.pacujo.net> <87lg6xlkgw.fsf@nightsong.com> <87bm7tpp9j.fsf@elektro.pacujo.net> <87h8hllggi.fsf@nightsong.com> Message-ID: <877eihp13w.fsf@elektro.pacujo.net> Paul Rubin : > Marko Rauhamaa writes: >> Emacs occasionally hangs for about a minute to perform garbage >> collection. > > I've never experienced that, especially with more recent versions that I > think do a little bit of heap tidying in the background. Even in the > era of much slower computers I never saw an Emacs GC pause of more than > a second or two unless something had run amuck and exhausted memory. > It's always near imperceptible in my experience now. Is your system > swapping or something? I can't be positive about swapping. I don't remember hearing thrashing. However, I do admit running emacs for months on end and occasionally with huge buffers so the resident size can be a couple of gigabytes. Marko From brian.j.oney at googlemail.com Wed Oct 17 02:06:48 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Wed, 17 Oct 2018 08:06:48 +0200 Subject: ESR "Waning of Python" post In-Reply-To: <877eihp13w.fsf@elektro.pacujo.net> References: <871s8yrjkc.fsf@nightsong.com> <87bm81pii1.fsf@nightsong.com> <86tvlt2c1n.fsf@benfinney.id.au> <87zhvjelo2.fsf@handshake.de> <87bm7zu0d9.fsf@elektro.pacujo.net> <87muriz8oe.fsf@handshake.de> <87murirzt0.fsf@elektro.pacujo.net> <877eij22yo.fsf@handshake.de> <87woqjjwo3.fsf@elektro.pacujo.net> <87tvlmlwlv.fsf@nightsong.com> <87in22pea0.fsf@elektro.pacujo.net> <87lg6xlkgw.fsf@nightsong.com> <87bm7tpp9j.fsf@elektro.pacujo.net> <87h8hllggi.fsf@nightsong.com> <877eihp13w.fsf@elektro.pacujo.net> Message-ID: <95F6A9F0-62C9-497E-8449-060A900980D6@gmail.com> On October 17, 2018 7:56:51 AM GMT+02:00, Marko Rauhamaa wrote: >I can't be positive about swapping. I don't remember hearing thrashing. >However, I do admit running emacs for months on end and occasionally >with huge buffers so the resident size can be a couple of gigabytes. > That's a pretty good stress test for any program, especially one with so much human interaction. From jfong at ms4.hinet.net Wed Oct 17 04:17:56 2018 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Wed, 17 Oct 2018 01:17:56 -0700 (PDT) Subject: Is it dangeous when using custom metaclass? In-Reply-To: References: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> <8564e592-d47d-4146-8ae4-abf03b0674a7@googlegroups.com> <877eihtarm.fsf@handshake.de> Message-ID: dieter at 2018/10/17 UTC+8 PM 1:15:01 wrote: > jfong at ms4.hinet.net writes: > > Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > >> jfong at ms4.hinet.net wrote: > >> > class Structure(metaclass=StructureMeta): ... > >> > > >> > class PolyHeader(Structure): ... > >> > > >> > As my understanding, the metaclass's __init__ was called when a class was > >> > created. In the above example, both the Structure and PolyHeader called it. > >> > My question is: because the PolyHeader inherited Structure, is it reasonable > >> > for PolyHeader to call this __init__ again? Will it cause any possible > >> > trouble? > >> > >> It's reasonable for both to call it, because they're distinct > >> instances of StructureMeta, each of which need to be initialised. > > > > The PolyHeader is already initialized by inheritance. Is there any way to bypass this __init__? > > If there were any, you should find it described in metaclass related documentation. > > Likely, you can ensure that followup calls of "__init__" effectively > behave as "no-op"s: let the first call place a marker in the initialized > object and check in later calls whether it is already there. Hard to find the document of type.__init__. I can only guess it does nothing, at least no thing serious, to avoid trouble the metaclass's __init__ may cause in a class hierarchy:-) From sailamagia at gmail.com Wed Oct 17 10:41:34 2018 From: sailamagia at gmail.com (Saila) Date: Wed, 17 Oct 2018 07:41:34 -0700 (PDT) Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 Message-ID: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Hi Has somebody been able to install SSHLIbrary from sources (all libs with offline installations) on virtual Win 10 for Python 3.6.4? Python 3.6.4 ... [MSC v. 1900 64 bit (AMD 64)] Also Microsoft Visual Studio 2017 is installed (also vc_redist.x64.exe) SSHLinrary worked with Python 2.7 (there wasn't so many dependencies) SSHLIbrary 3.3.1 requires paramiko paramiko-2.4.2.tar.gz requires bcrypt,cryptography, pynacl and pyasn1 and cffi is needed Problems are with PyNaCl-1.3.0.tar.gz and cryptography-2.1.4.tar.gz Installing PyNaCl C:\Tools\PyNaCl-1.3.0>python setup.py install >> log.txt warning: no previously-included files matching '__pycache__\*' found anywhere in distribution warning: no previously-included files matching '.tarvis.yml' etc.. File "setup.py", line 159, in run raise Exception("ERROR": The 'make' utility is missing from PATH") Exception: ERROR: The 'make' utility is missing from PATH Installation of cryptography ends to C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory Hoping that somebody can help and sorry that I didn't feel to write hole messages because development env has connections to web BR Saila From tina_zy_qian at yahoo.com Wed Oct 17 12:49:13 2018 From: tina_zy_qian at yahoo.com (tina_zy_qian at yahoo.com) Date: Wed, 17 Oct 2018 09:49:13 -0700 (PDT) Subject: check whether a process is still running on remote hosts In-Reply-To: References: Message-ID: On Tuesday, October 16, 2018 at 2:14:26 PM UTC-7, tina_z... at yahoo.com wrote: > I newly learned Python, and I need to wrap up a script to do following. > > Env: > 1: One launcher Linux VM (from where to run the Python script) > 2. 100+ Linux VM > > requirement: > In general, run a remote_script on remote 100 VMs and get the log files generated to remote hosts back to launcher. > > steps > 1. cp (pexpect.spawn('scp ')) supporting files including the remote_script to remotehost:/remote_folder > 2. run remote_script on remote host ( pexpect.spawn('ssh %s@%s "%s"' % (user,host,cmd)) > 3. wait and check until the remote_script was run on remote host. (to check "ps -ef" result on remote hosts) > 4. collect data from remote hosts -- reverse to step 1. > > > I briefly implemented other steps expect step 3. Two options are below. > > option 1: run another script "ps -ef|grep remote_script and output result to a local file, then collected the files to launcher. > > option 2: run pexect.spawn('ssh' ....'ps -e') to get the result directly to laucher console. > But how I can get only the output for "ps -ef" command only? > > I must use the (users, passwords, and hosts) way to do ssh and scp because I may not be allowed to use ssh key on some hosts. Any suggestions or sample code for step 3 or the whole script are appreciated. Thanks. Thanks everyone's comments and suggestions! I will give ansible a try later. As for now, I'm coding the scripts myself as a practice to brush up my Python skill. From tjol at tjol.eu Wed Oct 17 13:18:26 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 17 Oct 2018 19:18:26 +0200 Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 In-Reply-To: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> References: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Message-ID: On 2018-10-17 16:41, Saila wrote: > Hi > Has somebody been able to install SSHLIbrary from sources (all libs with offline installations) on virtual Win 10 for Python 3.6.4? > > Python 3.6.4 ... [MSC v. 1900 64 bit (AMD 64)] > > Also Microsoft Visual Studio 2017 is installed (also vc_redist.x64.exe) > > SSHLinrary worked with Python 2.7 (there wasn't so many dependencies) > > SSHLIbrary 3.3.1 requires paramiko > paramiko-2.4.2.tar.gz requires bcrypt,cryptography, pynacl and pyasn1 > and cffi is needed > Problems are with PyNaCl-1.3.0.tar.gz and cryptography-2.1.4.tar.gz > > Installing PyNaCl > C:\Tools\PyNaCl-1.3.0>python setup.py install >> log.txt > warning: no previously-included files matching '__pycache__\*' found anywhere in distribution > warning: no previously-included files matching '.tarvis.yml' > etc.. > File "setup.py", line 159, in run > raise Exception("ERROR": The 'make' utility is missing from PATH") > Exception: ERROR: The 'make' utility is missing from PATH > > Installation of cryptography > ends to > C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory > > Hoping that somebody can help and sorry that I didn't feel to write hole messages because development env has connections to web > BR > Saila > Can't you just install it with pip? py -3 -m pip install PyNaCl From rj.amdphreak at gmail.com Wed Oct 17 22:26:36 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Wed, 17 Oct 2018 21:26:36 -0500 Subject: Advice on law firm Message-ID: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> Anyone know a good US based law firm that specializes in software licenses and class action suits? Sent from Mail for Windows 10 From rj.amdphreak at gmail.com Wed Oct 17 22:36:43 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Wed, 17 Oct 2018 21:36:43 -0500 Subject: Advice on law firm In-Reply-To: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> References: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> Message-ID: <5bc7f1b9.1c69fb81.6a9ac.3f6c@mx.google.com> Correction: specializing in warranty of merchantability, software licenses, and possibly class action suits. Sent from Mail for Windows 10 From: Ryan Johnson Sent: Wednesday, October 17, 2018 9:26 PM To: python-list at python.org Subject: Advice on law firm Anyone know a good US based law firm that specializes in software licenses and class action suits? Sent from Mail for Windows 10 From dieter at handshake.de Thu Oct 18 01:04:02 2018 From: dieter at handshake.de (dieter) Date: Thu, 18 Oct 2018 07:04:02 +0200 Subject: Is it dangeous when using custom metaclass? References: <18849bbb-3bed-4c69-ab6a-cde68b656b2a@googlegroups.com> <8564e592-d47d-4146-8ae4-abf03b0674a7@googlegroups.com> <877eihtarm.fsf@handshake.de> Message-ID: <8736t37sn1.fsf@handshake.de> jfong at ms4.hinet.net writes: > ... > Hard to find the document of type.__init__. I can only guess it does nothing, at least no thing serious, to avoid trouble the metaclass's __init__ may cause in a class hierarchy:-) You always have the possibility to look at the source. All classes have common attributes "__bases__", "__module__", "__name__", "__dict__", .... They must come from somewhere. "type.__init__" could be this place. From me.vinob at gmail.com Thu Oct 18 02:13:30 2018 From: me.vinob at gmail.com (Vinodhini Balusamy) Date: Thu, 18 Oct 2018 17:13:30 +1100 Subject: namedtuples anamoly Message-ID: Hi, I tried using namedtuples and just found a behaviour which I am not able to conclude as correct behaviour. from collections import namedtuple (n, categories) = (int(input()), input().split()) Grade = namedtuple('Grade', categories) Grade.ID = 1 #print(Grade.ID) ob = Grade(10, 50) print(ob.ID) print(ob.MARKS) ob1 = Grade(20, 100) print(ob1.ID) 2 ID MARKS 1 50 1 100 If we set GRADE.ID =1 , it has impact on all variables. Is this behaviour just like class variable and it has global scope. I expected ob.ID and ob1.ID to be 10. Correct me if Iam wrong. Appreciate any quick response. Kind Rgds, Vinu From sailamagia at gmail.com Thu Oct 18 02:28:46 2018 From: sailamagia at gmail.com (Saila) Date: Wed, 17 Oct 2018 23:28:46 -0700 (PDT) Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 In-Reply-To: References: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Message-ID: keskiviikko 17. lokakuuta 2018 20.18.55 UTC+3 Thomas Jollans kirjoitti: > On 2018-10-17 16:41, Saila wrote: > > Hi > > Has somebody been able to install SSHLIbrary from sources (all libs with offline installations) on virtual Win 10 for Python 3.6.4? > > > > Python 3.6.4 ... [MSC v. 1900 64 bit (AMD 64)] > > > > Also Microsoft Visual Studio 2017 is installed (also vc_redist.x64.exe) > > > > SSHLinrary worked with Python 2.7 (there wasn't so many dependencies) > > > > SSHLIbrary 3.3.1 requires paramiko > > paramiko-2.4.2.tar.gz requires bcrypt,cryptography, pynacl and pyasn1 > > and cffi is needed > > Problems are with PyNaCl-1.3.0.tar.gz and cryptography-2.1.4.tar.gz > > > > Installing PyNaCl > > C:\Tools\PyNaCl-1.3.0>python setup.py install >> log.txt > > warning: no previously-included files matching '__pycache__\*' found anywhere in distribution > > warning: no previously-included files matching '.tarvis.yml' > > etc.. > > File "setup.py", line 159, in run > > raise Exception("ERROR": The 'make' utility is missing from PATH") > > Exception: ERROR: The 'make' utility is missing from PATH > > > > Installation of cryptography > > ends to > > C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory > > > > Hoping that somebody can help and sorry that I didn't feel to write hole messages because development env has connections to web > > BR > > Saila > > > > Can't you just install it with pip? > > py -3 -m pip install PyNaCl That is not possible because there isn't connection to www in development environment. It is isolated. Only possiblity is import sources. From __peter__ at web.de Thu Oct 18 03:05:57 2018 From: __peter__ at web.de (Peter Otten) Date: Thu, 18 Oct 2018 09:05:57 +0200 Subject: namedtuples anamoly References: Message-ID: Vinodhini Balusamy wrote: > Hi, > > I tried using namedtuples and just found a behaviour which I am not able > to conclude as correct behaviour. > > from collections import namedtuple > > (n, categories) = (int(input()), input().split()) > Grade = namedtuple('Grade', categories) > Grade.ID = 1 > #print(Grade.ID) > ob = Grade(10, 50) > print(ob.ID) > print(ob.MARKS) > ob1 = Grade(20, 100) > print(ob1.ID) > > 2 > ID MARKS > 1 > 50 > 1 > 100 > > > If we set GRADE.ID =1 , it has impact on all variables. Is this behaviour > just like class variable and it has global scope. It's not *like* a class attribute, it *is* a class attribute. > I expected ob.ID and ob1.ID to be 10. You can access namedtuple members via name and via index. Indexed access is handled by the superclass (tuple), named access by properties. If you overwrite the property definition in the class with a value the property is lost and you'll see the value. There's a namedtuple feature that provides its source for you to explore. So see for yourself: >>> namedtuple("Grade", "id marks", verbose=True) from builtins import property as _property, tuple as _tuple from operator import itemgetter as _itemgetter from collections import OrderedDict class Grade(tuple): 'Grade(id, marks)' __slots__ = () [snip] id = _property(_itemgetter(0), doc='Alias for field number 0') marks = _property(_itemgetter(1), doc='Alias for field number 1') >>> > Correct me if Iam wrong. > Appreciate any quick response. > > Kind Rgds, > Vinu From gherron at digipen.edu Thu Oct 18 03:17:52 2018 From: gherron at digipen.edu (Gary Herron) Date: Thu, 18 Oct 2018 00:17:52 -0700 Subject: namedtuples anamoly In-Reply-To: References: Message-ID: <501351eb-245e-7276-12ab-83d2812cba44@digipen.edu> On 10/17/2018 11:13 PM, me.vinob at gmail.com wrote: > Hi, > > I tried using namedtuples and just found a behaviour which I am not able to > conclude as correct behaviour. > > from collections import namedtuple > > (n, categories) = (int(input()), input().split()) > Grade = namedtuple('Grade', categories) > Grade.ID = 1 > #print(Grade.ID) > ob = Grade(10, 50) > print(ob.ID) > print(ob.MARKS) > ob1 = Grade(20, 100) > print(ob1.ID) > > 2 > ID MARKS > 1 > 50 > 1 > 100 > > > If we set GRADE.ID =1 , Whoa!? Don't do that.? The Grade object created with the namedtuple call is a class, and part of it's internal implementation is stored in Grade.ID.? Try these lines: >>> print(Grade) >>> print(Grade.ID) >>> By reassigning Grade.ID, you are sabotaging the internals of the class.? Without looking at those internals, it's not really a surprise that things stop working after you destroy the ? it so carefully stored in Grade.ID. So now the real question is:? What were you trying to accomplish with the assignment?? Tell us, and let's see if we can find a way to accomplish yor goal without wrecking the internals of the Grade class. Gary Herron > it has impact on all variables. Is this behaviour > just like class variable and it has global scope. > I expected ob.ID and ob1.ID to be 10. > > Correct me if Iam wrong. > Appreciate any quick response. > > Kind Rgds, > Vinu -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From gherron at digipen.edu Thu Oct 18 03:21:50 2018 From: gherron at digipen.edu (Gary Herron) Date: Thu, 18 Oct 2018 00:21:50 -0700 Subject: Advice on law firm In-Reply-To: <5bc7f1b9.1c69fb81.6a9ac.3f6c@mx.google.com> References: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> <5bc7f1b9.1c69fb81.6a9ac.3f6c@mx.google.com> Message-ID: This is a Python related forum, but your question has nothing to do with Python.? While you might get an answer here, I'm sure you could find a better place to post your question. On 10/17/2018 07:36 PM, rj.amdphreak at gmail.com wrote: > Correction: specializing in warranty of merchantability, software licenses, and possibly class action suits. > > Sent from Mail for Windows 10 > > From: Ryan Johnson > Sent: Wednesday, October 17, 2018 9:26 PM > To: python-list at python.org > Subject: Advice on law firm > > Anyone know a good US based law firm that specializes in software licenses and class action suits? > > Sent from Mail for Windows 10 > > -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From acharbly at gmail.com Thu Oct 18 03:28:39 2018 From: acharbly at gmail.com (Prahallad Achar) Date: Thu, 18 Oct 2018 10:28:39 +0300 Subject: Advice on law firm In-Reply-To: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> References: <5bc7ef5a.1c69fb81.bc06c.d594@mx.google.com> Message-ID: if NO-ANS: print (" Its Python forum ") elif ANS: print (" Personal mail to Mr.Ryan") else: print (" Ryan kindly use the appropriate forum to discuss your topic") On Thu, Oct 18, 2018 at 5:27 AM Ryan Johnson wrote: > Anyone know a good US based law firm that specializes in software licenses > and class action suits? > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list > From tjol at tjol.eu Thu Oct 18 03:30:25 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 18 Oct 2018 09:30:25 +0200 Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 In-Reply-To: References: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Message-ID: <46583adb-7d12-08f8-28d0-f9c68b383395@tjol.eu> On 18/10/2018 08:28, Saila wrote: > keskiviikko 17. lokakuuta 2018 20.18.55 UTC+3 Thomas Jollans kirjoitti: >> Can't you just install it with pip? >> >> py -3 -m pip install PyNaCl > > That is not possible because there isn't connection to www in development environment. It is isolated. Only possiblity is import sources. > I see. If installing binary packages is acceptable (which, as you're using Windows, it must be?), you should still be able to install the binary packages (wheels) with pip if you download the files for your OS/Python version from PyPI and move them to the airgapped machine. Many packages are a lot harder to build from source on Windows than they should be. Maybe pyNaCl is one of them. This *might* be of interest: https://mail.python.org/pipermail/python-list/2018-October/737725.html ---- Looking back at your error messages: > Installation of cryptography > ends to > C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory This is the typical situation when trying to compile bindings for third-party libraries (in this case: openssl). You need the library and its development headers somewhere where setuptools can find them. I imagine you have to install openssl first, and then copy the files to some particular place, or somehow tell python how to find it. I don't know enough about Python on Windows to help there. From Cecil at decebal.nl Thu Oct 18 05:30:41 2018 From: Cecil at decebal.nl (Cecil Westerhof) Date: Thu, 18 Oct 2018 11:30:41 +0200 Subject: Twython has a problem with latest urllib3 Message-ID: <87efcn1u0u.fsf@munus.decebal.nl> I use Twython to post on Twitter. Yesterday I upgraded urllib3 from 1.23 to 1.24. Since then when I do: from twython import Twython I get: /usr/local/lib/python3.5/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) Should I rollback urllib3, or hope that Twython is updated soon? It looks like that the functionality is not broken. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From tjol at tjol.eu Thu Oct 18 06:05:55 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 18 Oct 2018 12:05:55 +0200 Subject: Twython has a problem with latest urllib3 In-Reply-To: <87efcn1u0u.fsf@munus.decebal.nl> References: <87efcn1u0u.fsf@munus.decebal.nl> Message-ID: <72dd0ec1-0096-a0e4-fa3b-b9ab6a72cb7f@tjol.eu> On 2018-10-18 11:30, Cecil Westerhof wrote: > I use Twython to post on Twitter. Yesterday I upgraded urllib3 from > 1.23 to 1.24. Since then when I do: > from twython import Twython > > I get: > /usr/local/lib/python3.5/dist-packages/requests/__init__.py:91: [...] ^^^^^^^^ It's requests that's complaining, not twy.. sorry I can't say that it sounds too silly. For peace of mind, rolling back urllib3 might be reasonable. If peace of mind is not an issue, then either way everything will probably work. From md.shoaibakhtar2013 at gmail.com Thu Oct 18 10:01:08 2018 From: md.shoaibakhtar2013 at gmail.com (md.shoaibakhtar2013 at gmail.com) Date: Thu, 18 Oct 2018 07:01:08 -0700 (PDT) Subject: "Edit with IDLE" doesn't work any more ? In-Reply-To: References: Message-ID: <2422ce55-687a-4363-9973-24bc79ba4ed6@googlegroups.com> On Friday, April 28, 2017 at 5:37:55 PM UTC+5:30, Yip, Kin wrote: > Hi, > > I'm relatively new with Python3 in Windows 7. I'm using now Python 3.6.1. > > Suddenly right-clicking on a .py file and choose "Edit with IDLE" just doesn't work. > > I've tried to do : > > "c:\program files\python36\pythonw.exe" -m idlelib mypythoncodes.py > > > the IDLE editor just doesn't come up. But if I start the IDLE Shell and then "Open File", the editor is there and > works normally. > > I've tried to uninstall "python launcher" and then repair or modify "python3.6 " in Control Panel/Program and Features. Nothing works ... > > Any help ? I show you my Windows registry at the bottom of this email. > > Kin > > PS: My registry : > > Windows Registry Editor Version 5.00 > > [HKEY_CLASSES_ROOT\Python.File\shell] > > [HKEY_CLASSES_ROOT\Python.File\shell\editwithidle] > "MUIVerb"="&Edit with IDLE" > "Subcommands"="" > > [HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell] > > [HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell\edit36] > "MUIVerb"="Edit with IDLE 3.6 (64-bit)" > > [HKEY_CLASSES_ROOT\Python.File\shell\editwithidle\shell\edit36\command] > @="\"C:\\Program Files\\Python36\\pythonw.exe\" -m idlelib \"%L\" %*" > > [HKEY_CLASSES_ROOT\Python.File\shell\open] > > [HKEY_CLASSES_ROOT\Python.File\shell\open\command] > @="\"C:\\WINDOWS\\py.exe\" \"%L\" %*" > > [HKEY_CLASSES_ROOT\Python.File\shell\Run] > > [HKEY_CLASSES_ROOT\Python.File\shell\Run\command] > @="\"C:\\Windows\\py.exe\" \"%1\" %*" > > [HKEY_CLASSES_ROOT\Python.File\shell\runas] > > [HKEY_CLASSES_ROOT\Python.File\shell\runas\command] > @="\"C:\\Windows\\py.exe\" \"%1\" %*" Hello Brother I got the promblem. I got too frustrated. But now i have solution for it. Just download "api-ms-win-crt-utility-l1-1-0.dll". For this worked. And if this doesnt work download these dll too:- api-ms-win-crt-conio-l1-1-0.dll api-ms-win-crt-convert-l1-1-0.dll api-ms-win-crt-environment-l1-1-0.dll api-ms-win-crt-filesystem-l1-1-0.dll api-ms-win-crt-heap-l1-1-0.dll api-ms-win-crt-locale-l1-1-0.dll api-ms-win-crt-math-l1-1-0.dll api-ms-win-crt-process-l1-1-0.dll api-ms-win-crt-runtime-l1-1-0.dll api-ms-win-crt-stdio-l1-1-0.dll api-ms-win-crt-string-l1-1-0.dll api-ms-win-crt-time-l1-1-0.dll This is it. If the problem continues, then i don't know what to do. I this will Help. From python at mrabarnett.plus.com Thu Oct 18 12:25:53 2018 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 18 Oct 2018 17:25:53 +0100 Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 In-Reply-To: References: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Message-ID: On 2018-10-18 07:28, Saila wrote: > keskiviikko 17. lokakuuta 2018 20.18.55 UTC+3 Thomas Jollans kirjoitti: >> On 2018-10-17 16:41, Saila wrote: >> > Hi >> > Has somebody been able to install SSHLIbrary from sources (all libs with offline installations) on virtual Win 10 for Python 3.6.4? >> > >> > Python 3.6.4 ... [MSC v. 1900 64 bit (AMD 64)] >> > >> > Also Microsoft Visual Studio 2017 is installed (also vc_redist.x64.exe) >> > >> > SSHLinrary worked with Python 2.7 (there wasn't so many dependencies) >> > >> > SSHLIbrary 3.3.1 requires paramiko >> > paramiko-2.4.2.tar.gz requires bcrypt,cryptography, pynacl and pyasn1 >> > and cffi is needed >> > Problems are with PyNaCl-1.3.0.tar.gz and cryptography-2.1.4.tar.gz >> > >> > Installing PyNaCl >> > C:\Tools\PyNaCl-1.3.0>python setup.py install >> log.txt >> > warning: no previously-included files matching '__pycache__\*' found anywhere in distribution >> > warning: no previously-included files matching '.tarvis.yml' >> > etc.. >> > File "setup.py", line 159, in run >> > raise Exception("ERROR": The 'make' utility is missing from PATH") >> > Exception: ERROR: The 'make' utility is missing from PATH >> > >> > Installation of cryptography >> > ends to >> > C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory >> > >> > Hoping that somebody can help and sorry that I didn't feel to write hole messages because development env has connections to web >> > BR >> > Saila >> > >> >> Can't you just install it with pip? >> >> py -3 -m pip install PyNaCl > > That is not possible because there isn't connection to www in development environment. It is isolated. Only possiblity is import sources. > Why not download the appropriate .whl file from PyPI and then install that on your machine? From jsf80238 at gmail.com Thu Oct 18 12:42:38 2018 From: jsf80238 at gmail.com (Jason Friedman) Date: Thu, 18 Oct 2018 10:42:38 -0600 Subject: namedtuples anamoly In-Reply-To: <501351eb-245e-7276-12ab-83d2812cba44@digipen.edu> References: <501351eb-245e-7276-12ab-83d2812cba44@digipen.edu> Message-ID: > > So now the real question is: What were you trying to accomplish with > the assignment? Tell us, and let's see if we can find a way to > accomplish yor goal without wrecking the internals of the Grade class. > > And depending on your answer to that question, the new Data Classes feature in 3.7 may be of interest to you: https://www.python.org/dev/peps/pep-0557/. From rgaddi at highlandtechnology.invalid Thu Oct 18 18:36:43 2018 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Thu, 18 Oct 2018 15:36:43 -0700 Subject: Important Language Choice Considerations Message-ID: https://boingboing.net/2018/10/15/python-falls-from-ceiling-in-b.html Say what you want about performance and linguistic elegance, but Julia almost never falls in through the ceiling. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From rosuav at gmail.com Thu Oct 18 20:02:32 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 19 Oct 2018 11:02:32 +1100 Subject: Important Language Choice Considerations In-Reply-To: References: Message-ID: On Fri, Oct 19, 2018 at 10:57 AM Rob Gaddi wrote: > > https://boingboing.net/2018/10/15/python-falls-from-ceiling-in-b.html > > Say what you want about performance and linguistic elegance, but Julia > almost never falls in through the ceiling. That is notable. But it could be worse. It could have been an ASP... ChrisA From bluebox03 at gmail.com Thu Oct 18 21:30:40 2018 From: bluebox03 at gmail.com (tommy yama) Date: Fri, 19 Oct 2018 10:30:40 +0900 Subject: SSHLibrary (PyNaCl and Cryptography) inst for Python 3.6.4 in Windows 10 In-Reply-To: References: <813b9704-fefe-4a61-8c88-66e2d051d08a@googlegroups.com> Message-ID: It's mentioned that pypi includes what you need. https://pypi.org/project/robotframework-sshlibrary/ On Fri, 19 Oct 2018, 01:28 MRAB, wrote: > On 2018-10-18 07:28, Saila wrote: > > keskiviikko 17. lokakuuta 2018 20.18.55 UTC+3 Thomas Jollans kirjoitti: > >> On 2018-10-17 16:41, Saila wrote: > >> > Hi > >> > Has somebody been able to install SSHLIbrary from sources (all libs > with offline installations) on virtual Win 10 for Python 3.6.4? > >> > > >> > Python 3.6.4 ... [MSC v. 1900 64 bit (AMD 64)] > >> > > >> > Also Microsoft Visual Studio 2017 is installed (also > vc_redist.x64.exe) > >> > > >> > SSHLinrary worked with Python 2.7 (there wasn't so many dependencies) > >> > > >> > SSHLIbrary 3.3.1 requires paramiko > >> > paramiko-2.4.2.tar.gz requires bcrypt,cryptography, pynacl and pyasn1 > >> > and cffi is needed > >> > Problems are with PyNaCl-1.3.0.tar.gz and cryptography-2.1.4.tar.gz > >> > > >> > Installing PyNaCl > >> > C:\Tools\PyNaCl-1.3.0>python setup.py install >> log.txt > >> > warning: no previously-included files matching '__pycache__\*' found > anywhere in distribution > >> > warning: no previously-included files matching '.tarvis.yml' > >> > etc.. > >> > File "setup.py", line 159, in run > >> > raise Exception("ERROR": The 'make' utility is missing from > PATH") > >> > Exception: ERROR: The 'make' utility is missing from PATH > >> > > >> > Installation of cryptography > >> > ends to > >> > C:\Program Files (x86)\Microsoft Visual > Studio\2017\VC\Tools\MSVC14.11.25503\bin\HostX86\x64\cl.exe /c /nologo > /.... build\temp.win-amd64-3.6\Release\_openssl.c(493): fatal error C1083: > Cannot open include file: 'openssl/opensslv.h': No such file or directory > >> > > >> > Hoping that somebody can help and sorry that I didn't feel to write > hole messages because development env has connections to web > >> > BR > >> > Saila > >> > > >> > >> Can't you just install it with pip? > >> > >> py -3 -m pip install PyNaCl > > > > That is not possible because there isn't connection to www in > development environment. It is isolated. Only possiblity is import sources. > > > Why not download the appropriate .whl file from PyPI and then install > that on your machine? > -- > https://mail.python.org/mailman/listinfo/python-list > From wegge at wegge.dk Fri Oct 19 03:03:31 2018 From: wegge at wegge.dk (Anders Wegge Keller) Date: Fri, 19 Oct 2018 09:03:31 +0200 Subject: PEP 394 Message-ID: <20181019090331.443ad113@linuxawk.wegge.dk> Short and simple: Do you expect PEP 394 to change status or recommendation when official support for Python2 ends in 13? months time, or at least some time thereafter? For those that don't have the habit of memorizing PEPs, 394 is the one stating * python2 will refer to some version of Python 2.x. * python3 will refer to some version of Python 3.x. * for the time being, all distributions should ensure that python, if installed, refers to the same target as python2, unless the user deliberately overrides this or a virtual environment is active. -- //Wegge From me.vinob at gmail.com Fri Oct 19 03:41:03 2018 From: me.vinob at gmail.com (Vinodhini Balusamy) Date: Fri, 19 Oct 2018 18:41:03 +1100 Subject: namedtuples anamoly In-Reply-To: References: <501351eb-245e-7276-12ab-83d2812cba44@digipen.edu> Message-ID: Thanks everyone for promptly answering my question. Answer to Gary's question, I haven't used named tuples and tried it. The way the tuple subclass getting created plus the property features i wasn't much aware of. But now i am very clear, how I set ID object and changed the interface to access ID attribute. What i actually tried to do is get the field names and values at run-time like below, mark = [Grade._make(input().split()).MARKS] print(mark) Without knowing the internals, i tried setting it directly first. The above code works well getting both ID and MARKS as inputs and creates a list of MARKS only if I loop through that same line. Thanks for all the help. Much appreciated. Regards, Vinu On Fri, Oct 19, 2018 at 3:48 AM Jason Friedman wrote: > > > > So now the real question is: What were you trying to accomplish with > > the assignment? Tell us, and let's see if we can find a way to > > accomplish yor goal without wrecking the internals of the Grade class. > > > > And depending on your answer to that question, the new Data Classes > feature in 3.7 may be of interest to you: > https://www.python.org/dev/peps/pep-0557/. > -- > https://mail.python.org/mailman/listinfo/python-list > From marko at pacujo.net Fri Oct 19 06:06:59 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 19 Oct 2018 13:06:59 +0300 Subject: PEP 394 References: <20181019090331.443ad113@linuxawk.wegge.dk> Message-ID: <87ftx2merg.fsf@elektro.pacujo.net> Anders Wegge Keller : > * python2 will refer to some version of Python 2.x. Untrue for macOS. > * python3 will refer to some version of Python 3.x. Untrue for macOS, ArchLinux, RHEL and CentOS. > * for the time being, all distributions should ensure that python, if > installed, refers to the same target as python2, unless the user > deliberately overrides this or a virtual environment is active. Should, would, could. Marko From sharan.basappa at gmail.com Fri Oct 19 11:05:28 2018 From: sharan.basappa at gmail.com (Sharan Basappa) Date: Fri, 19 Oct 2018 08:05:28 -0700 (PDT) Subject: logging output Message-ID: <77036bd9-fac1-492f-8583-f00603cd35c3@googlegroups.com> I am loading a csv file using Pandas and then logging it back into another file using logging module. Here is one sample line from input file: - 1117838570 2005.06.03 R02-M1-N0-C:J12-U11 2005-06-03-15.42.50.675872 R02-M1-N0-C:J12-U11 RAS KERNEL INFO instruction cache parity error corrected Here the sample line from logging output 0 - 1117838570 2005.06.03 R02-M1-N0-C:J12-U11 20... The lines seems to be same but logging module seems to be cutting down additional columns towards the end (see "..." characters). Am I missing something? below is the full code listing: import sys import pandas as pd import numpy as np import logging #Create and configure logger logging.basicConfig(filename="debug.log", filemode='w', format='%(asctime)s %(message)s') logger = logging.getLogger() logger.setLevel(logging.DEBUG) data_df = pd.read_csv("BGL_MERGED.log", nrows=100, header=None, delimiter=r'\s"') #data_df = pd.read_csv("BGL_MERGED.log") logger.debug("data frame %s \n", data_df) From wegge at wegge.dk Fri Oct 19 11:32:38 2018 From: wegge at wegge.dk (Anders Wegge Keller) Date: Fri, 19 Oct 2018 17:32:38 +0200 Subject: logging output In-Reply-To: <77036bd9-fac1-492f-8583-f00603cd35c3@googlegroups.com> References: <77036bd9-fac1-492f-8583-f00603cd35c3@googlegroups.com> Message-ID: <20181019173238.7ef4c830@linuxawk.wegge.dk> P? Fri, 19 Oct 2018 08:05:28 -0700 (PDT) Sharan Basappa skrev: ... > delimiter=r'\s"') #data_df = pd.read_csv("BGL_MERGED.log") > logger.debug("data frame %s \n", data_df) Do this help? -- //Wegge From abrault at mapgears.com Fri Oct 19 11:51:00 2018 From: abrault at mapgears.com (Alexandre Brault) Date: Fri, 19 Oct 2018 11:51:00 -0400 Subject: PEP 394 In-Reply-To: <87ftx2merg.fsf@elektro.pacujo.net> References: <20181019090331.443ad113@linuxawk.wegge.dk> <87ftx2merg.fsf@elektro.pacujo.net> Message-ID: On 2018-10-19 06:06 AM, Marko Rauhamaa wrote: > Anders Wegge Keller : >> * python2 will refer to some version of Python 2.x. > Untrue for macOS. > >> * python3 will refer to some version of Python 3.x. > Untrue for macOS, ArchLinux, RHEL and CentOS. > >> * for the time being, all distributions should ensure that python, if >> installed, refers to the same target as python2, unless the user >> deliberately overrides this or a virtual environment is active. > Should, would, could. > Some platforms not being 394-compliant doesn't change what PEP-394 says. From tjol at tjol.eu Fri Oct 19 12:02:47 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 19 Oct 2018 18:02:47 +0200 Subject: PEP 394 In-Reply-To: <87ftx2merg.fsf@elektro.pacujo.net> References: <20181019090331.443ad113@linuxawk.wegge.dk> <87ftx2merg.fsf@elektro.pacujo.net> Message-ID: <42ad04a8-914d-ca76-04ae-9a8a76bf712e@tjol.eu> On 2018-10-19 12:06, Marko Rauhamaa wrote: > Anders Wegge Keller : >> * python2 will refer to some version of Python 2.x. > > Untrue for macOS. > >> * python3 will refer to some version of Python 3.x. > > Untrue for macOS, ArchLinux, RHEL and CentOS. Sure it's true for *EL (it's just that python3 might not be installed by default even on EL7) > >> * for the time being, all distributions should ensure that python, if >> installed, refers to the same target as python2, unless the user >> deliberately overrides this or a virtual environment is active. > > Should, would, could. From marko at pacujo.net Fri Oct 19 12:38:49 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 19 Oct 2018 19:38:49 +0300 Subject: PEP 394 References: <20181019090331.443ad113@linuxawk.wegge.dk> <87ftx2merg.fsf@elektro.pacujo.net> <42ad04a8-914d-ca76-04ae-9a8a76bf712e@tjol.eu> Message-ID: <87zhv9lwme.fsf@elektro.pacujo.net> Thomas Jollans : > On 2018-10-19 12:06, Marko Rauhamaa wrote: >> Anders Wegge Keller : >>> * python3 will refer to some version of Python 3.x. >> >> Untrue for macOS, ArchLinux, RHEL and CentOS. > > Sure it's true for *EL (it's just that python3 might not be installed by > default even on EL7) The newest versions of RHEL and CentOS don't provide Python3 at all. Red Hat says the upcoming RHEL-8 won't have Python2 at all. I'm guessing it *will* provide Python3. Marko From tjol at tjol.eu Fri Oct 19 13:10:41 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 19 Oct 2018 19:10:41 +0200 Subject: PEP 394 In-Reply-To: <87zhv9lwme.fsf@elektro.pacujo.net> References: <20181019090331.443ad113@linuxawk.wegge.dk> <87ftx2merg.fsf@elektro.pacujo.net> <42ad04a8-914d-ca76-04ae-9a8a76bf712e@tjol.eu> <87zhv9lwme.fsf@elektro.pacujo.net> Message-ID: On 19/10/2018 18:38, Marko Rauhamaa wrote: > Thomas Jollans : > >> On 2018-10-19 12:06, Marko Rauhamaa wrote: >>> Anders Wegge Keller : >>>> * python3 will refer to some version of Python 3.x. >>> >>> Untrue for macOS, ArchLinux, RHEL and CentOS. >> >> Sure it's true for *EL (it's just that python3 might not be installed by >> default even on EL7) > > The newest versions of RHEL and CentOS don't provide Python3 at all. > > Red Hat says the upcoming RHEL-8 won't have Python2 at all. I'm guessing > it *will* provide Python3. I suppose you're right. I have a /usr/bin/python3 on my SL7 system, but on closer inspection it turns out that's from EPEL, not SL. From Cecil at decebal.nl Fri Oct 19 13:24:10 2018 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 19 Oct 2018 19:24:10 +0200 Subject: Twython has a problem with latest urllib3 References: <87efcn1u0u.fsf@munus.decebal.nl> Message-ID: <871s8lrgsl.fsf@munus.decebal.nl> Cecil Westerhof writes: > I use Twython to post on Twitter. Yesterday I upgraded urllib3 from > 1.23 to 1.24. Since then when I do: > from twython import Twython > > I get: > /usr/local/lib/python3.5/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24) or chardet (3.0.4) doesn't match a supported version! > RequestsDependencyWarning) > > Should I rollback urllib3, or hope that Twython is updated soon? > > It looks like that the functionality is not broken. It was not Twython, but requests which is used by Twython. There is a newer version of requests now and the problem is solved. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From ben+python at benfinney.id.au Fri Oct 19 21:57:45 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 20 Oct 2018 12:57:45 +1100 Subject: PEP 394 References: <20181019090331.443ad113@linuxawk.wegge.dk> Message-ID: <86d0s52xd2.fsf@benfinney.id.au> Anders Wegge Keller writes: > Short and simple: Do you expect PEP 394 to change status The status of PEP 394 today is ?Active?. What change of status would you expect in this Informational PEP? > or recommendation when official support for Python2 ends in 13? months > time, or at least some time thereafter? The criterion will not, IIUC, be the end of official PSF support for Python 2. Rather, the criteria will include (at least) an insignificant number of remaining Python 2 installations in the wild. How that will be measured, I don't know, but *actual usage* of Python 2 is much more the measurement to be made, before deprecating backward compatibility in the command name. -- \ ?My house is on the median strip of a highway. You don't really | `\ notice, except I have to leave the driveway doing 60 MPH.? | _o__) ?Steven Wright | Ben Finney From wegge at wegge.dk Sat Oct 20 03:47:25 2018 From: wegge at wegge.dk (Anders Wegge Keller) Date: Sat, 20 Oct 2018 09:47:25 +0200 Subject: PEP 394 In-Reply-To: <86d0s52xd2.fsf@benfinney.id.au> References: <20181019090331.443ad113@linuxawk.wegge.dk> <86d0s52xd2.fsf@benfinney.id.au> Message-ID: <20181020094725.2b8ab932@linuxawk.wegge.dk> P? Sat, 20 Oct 2018 12:57:45 +1100 Ben Finney skrev: > Anders Wegge Keller writes: > > > Short and simple: Do you expect PEP 394 to change status > > The status of PEP 394 today is ?Active?. What change of status would you > expect in this Informational PEP? One possible change would be that it would become archived, ceased to be, bereft of life, resting in peace or maybe even retired. I don't have any particular status change I want to see; I merely ask what other experienced python developers expect to happen. -- //Wegge From pjmclenon at gmail.com Sat Oct 20 08:24:37 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Sat, 20 Oct 2018 05:24:37 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> Message-ID: <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: > On 2018-10-14 00:13, pjmclenon at gmail.com wrote: > > On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > >> ?> 1st is this script is from a library module online open source > >> > >> If it's open source, why didn't you show the link to the soruce? > >> I assume your code is this: > >> > >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py > >> > >> And self.collFile is opened here: > >> > >> https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 > >> > >> You need to add `encoding='utf-8'` argument. > > > > > > > > hello i used this recommandtion in one of my projects in python and it worked fine im wrting today cuz i have this same unicode error in a slighty differn file code line and i added encoding utf 8 but i still get the same error > > > > here is my line of code > > > > with open(join("docs", path)) as f: > > > > where can i add the encoding="utf8" line?? > > does anyone on this forum happen to know?? > > > > ok thank you jessica > > > with open(join("docs", path), encoding="utf-8") as f: hello MRAB and google forum i have a sort of decode error it seems now very close to the line in my script which you solved for my 2 previous encode errors in python 3 the error now is ************** UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte ***************** and it seems to refer to my code line: *********** data = f.read() *************** which is part of this block of code ******************** # Read content of files for path in files: with open(join("docs", path), encoding="utf-8") as f: #with open(join("docs", path)) as f: data = f.read() process_data(data) *********************************************** would the solution fix be this? ********************** data = f.read(), decoding = "utf-8" #OR data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong?? thxz for any solutions im in python 3 jessica From hjp-python at hjp.at Sat Oct 20 08:38:19 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 20 Oct 2018 14:38:19 +0200 Subject: Python indentation (3 spaces) In-Reply-To: References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> <20181015193154.5gm64rasvigp2ess@hjp.at> Message-ID: <20181020123819.i2lkgraqvdf7ryex@hjp.at> On 2018-10-16 06:37:56 +1100, Chris Angelico wrote: > On Tue, Oct 16, 2018 at 6:34 AM Peter J. Holzer wrote: > > On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote: > > > On 13-10-18 09:37, Peter J. Holzer wrote: > > > > On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: > > > >> On 08-10-18 19:43, Peter J. Holzer wrote: > > > >>> In practice it doesn't work in my experience. There is always someone in > > > >>> a team who was "just testing that new editor" and replaced all tabs > > > >>> with spaces (or vice versa) or - worse - just some of them. > > > >> Isn't that caugth in the process of commiting to version control? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Underlined to emphasize the context. > > > > Tabs are easy to catch. If a file contains a tab, reject it. > > > > > > > > Spaces aren't, because spaces are everywhere. > > > > > > Spaces that replaced a tab by accident, are easy to catch too. They are all > > > those lines that show up when you do a diff with the previous version that > > > shouldn't show up. > > > > And where is the AI that decides which lines in a diff are should show > > up? > > > > Whether a line in a diff should or should not show up seems to me to be > > even harder to determine than whether a tab fits the syntax. > > > > If there's a change, it shows up. If there's no change, it doesn't show up. > > Ergo, if you accidentally replace a tab with spaces, it's a change, > and it shows up. If any change "shows up" (i.e., is rejected by the pre-commit hook of your version control system) you can't change anything which makes using a version control system rather pointless. So you still need to distinguish between "intended changes" and "unintended changes". Simply rejecting changes which only affect leading whitespace won't work either since you may have accidentatlly changed the leading whitespace while intentionally changing something else in the line (false negative) or you may have intentionally changed leading whitespace to correct and earlier indentation error which wasn't caught (false positive). So that still looks like a non-trivial problem to me which is better solved by humans during code review than by some commit-hook. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Sat Oct 20 08:47:28 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 20 Oct 2018 14:47:28 +0200 Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> Message-ID: <20181020124728.uinypazev22uojye@hjp.at> On 2018-10-20 05:24:37 -0700, pjmclenon at gmail.com wrote: > On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: > > with open(join("docs", path), encoding="utf-8") as f: > > hello MRAB and google forum I feel somewhat excluded by this salutaton, as I'm not MRAB and I don't read this on Google Groups, but I'll answer anyway ;-). > i have a sort of decode error it seems now very close to the line in my script > which you solved for my 2 previous encode errors in python 3 > > the error now is > ************** > UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte [...] > would the solution fix be this? > ********************** > data = f.read(), decoding = "utf-8" #OR > data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong?? 0xB0 isn't a valid ASCII character, so you'll get a decoding error for open(..., encoding="ascii"), too. You will have to find out the correct encoding for your file and use that. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From python at mrabarnett.plus.com Sat Oct 20 11:39:12 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 20 Oct 2018 16:39:12 +0100 Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: <20181020124728.uinypazev22uojye@hjp.at> References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> <20181020124728.uinypazev22uojye@hjp.at> Message-ID: <431b2a8a-551f-0dba-6044-4691e9395352@mrabarnett.plus.com> On 2018-10-20 13:47, Peter J. Holzer wrote: > On 2018-10-20 05:24:37 -0700, pjmclenon at gmail.com wrote: >> On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: >> > with open(join("docs", path), encoding="utf-8") as f: >> >> hello MRAB and google forum > > I feel somewhat excluded by this salutaton, as I'm not MRAB and I don't > read this on Google Groups, but I'll answer anyway ;-). > Well, I am MRAB, and I'm not on Google Groups either! :-) >> i have a sort of decode error it seems now very close to the line in my script >> which you solved for my 2 previous encode errors in python 3 >> >> the error now is >> ************** >> UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte > > [...] > >> would the solution fix be this? >> ********************** >> data = f.read(), decoding = "utf-8" #OR >> data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong?? > > 0xB0 isn't a valid ASCII character, so you'll get a decoding error for > open(..., encoding="ascii"), too. > > You will have to find out the correct encoding for your file and use > that. > I concur; it appears that the file isn't encoded in UTF-8, or ASCII either (valid ASCII is also valid UTF-8). From tjreedy at udel.edu Sat Oct 20 13:00:08 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 20 Oct 2018 13:00:08 -0400 Subject: PEP 394 In-Reply-To: <20181019090331.443ad113@linuxawk.wegge.dk> References: <20181019090331.443ad113@linuxawk.wegge.dk> Message-ID: On 10/19/2018 3:03 AM, Anders Wegge Keller wrote: > Short and simple: Do you expect PEP 394 to change status or > recommendation when official support for Python2 ends in 13? months time, or > at least some time thereafter? > > For those that don't have the habit of memorizing PEPs, 394 is the one > stating > > * python2 will refer to some version of Python 2.x. > * python3 will refer to some version of Python 3.x. > * for the time being, all distributions should ensure that python, if > installed, refers to the same target as python2, unless the user > deliberately overrides this or a virtual environment is active. This only applies to *nix. On Windows, there is a better solution: the py launcher. > py # launches the most most recent version installed* > py -x # launches the most recent x.y > py -x.y # launches x.y if installed, else lists installed versions * At first, 2.x took precedence over 3.x, but this has since been switched. I believe at least one core developer is working to port this to *nix. I believe at least some core developers hope that this will make 394 obsolete. -- Terry Jan Reedy From tjreedy at udel.edu Sat Oct 20 13:23:17 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 20 Oct 2018 13:23:17 -0400 Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> Message-ID: On 10/20/2018 8:24 AM, pjmclenon at gmail.com wrote: > On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: > i have a sort of decode error > UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte > ***************** > and it seems to refer to my code line: > *********** > data = f.read() > *************** > which is part of this block of code > ******************** > # Read content of files > for path in files: > with open(join("docs", path), encoding="utf-8") as f: > #with open(join("docs", path)) as f: > data = f.read() > process_data(data) > *********************************************** > > would the solution fix be this? > ********************** > data = f.read(), decoding = "utf-8" #OR > data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong?? Both statements are invalid syntax. The encoding is set in the open statement. What you need to find out: is '0xb0' a one-byte error or is 'utf-8' the wrong encoding? Things I might do: 1. Change the encoding in open() to 'ascii' and see if the exception message still refers to position 83064 or if there is a non-ascii character earlier in the file. The latter would mean that there is at least one earlier non-ascii sequence that was decoded as uft-8. This would suggest that 'utf-8' might be correct and that the '0xb0' byte is an error. 2. In the latter case, add "errors='handler'", where 'handler' is something other than the default 'strict'. Look in the doc or see help(open) for alternatives. 3. In open(), replace "encoding='utf-8'" with "mode='rb'" so that f.read() creates data as bytes instead of a text string. Then print, say, data[83000:83200] to see the context of the non-ascii byte. 4. Change to encoding in open() to 'latin-1'. The file will then be read as text without error, even if latin-1 is the wrong encoding. -- Terry Jan Reedy From nad at python.org Sat Oct 20 13:37:57 2018 From: nad at python.org (Ned Deily) Date: Sat, 20 Oct 2018 13:37:57 -0400 Subject: [RELEASE] Python 3.7.1 and 3.6.7 are now available Message-ID: On behalf of the Python development community and the Python 3.7 release team, we are pleased to announce the availability of Python 3.7.1. Python 3.7.1 is the first maintenance release of the newest feature release of the Python language. You can find Python 3.7.1 here: https://www.python.org/downloads/release/python-371/ See the What?s New In Python 3.7 document for more information about the many new features and optimizations included in the 3.7 series. Detailed information about the changes made in 3.7.1 can be found in its change log: https://docs.python.org/3.7/whatsnew/3.7.html https://docs.python.org/3.7/whatsnew/changelog.html#python-3-7-1-final We are also happy to announce the availability of Python 3.6.7, the next maintenance release of Python 3.6: https://www.python.org/downloads/release/python-367/ Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. -- Ned Deily nad at python.org -- [] From hasan.diwan at gmail.com Sat Oct 20 14:00:36 2018 From: hasan.diwan at gmail.com (Hasan Diwan) Date: Sat, 20 Oct 2018 11:00:36 -0700 Subject: [Python-Dev] [RELEASE] Python 3.7.1 and 3.6.7 are now available In-Reply-To: References: Message-ID: Congratulations to all involved..... -- H On Sat, 20 Oct 2018 at 10:58, Ned Deily wrote: > > On behalf of the Python development community and the Python 3.7 release > team, we are pleased to announce the availability of Python 3.7.1. Python > 3.7.1 is the first maintenance release of the newest feature release of > the Python language. You can find Python 3.7.1 here: > https://www.python.org/downloads/release/python-371/ > > See the What?s New In Python 3.7 document for more information about the > many new features and optimizations included in the 3.7 series. Detailed > information about the changes made in 3.7.1 can be found in its change log: > https://docs.python.org/3.7/whatsnew/3.7.html > https://docs.python.org/3.7/whatsnew/changelog.html#python-3-7-1-final > > We are also happy to announce the availability of Python 3.6.7, the next > maintenance release of Python 3.6: > https://www.python.org/downloads/release/python-367/ > > Thanks to all of the many volunteers who help make Python Development and > these releases possible! Please consider supporting our efforts by > volunteering yourself or through organization contributions to the Python > Software Foundation. > > -- > Ned Deily > nad at python.org -- [] > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/hasan.diwan%40gmail.com -- OpenPGP: https://sks-keyservers.net/pks/lookup?op=get&search=0xFEBAD7FFD041BBA1 If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest. Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest. Sent from my mobile device Envoye de mon portable From pacqa100 at yahoo.com.au Sat Oct 20 21:19:58 2018 From: pacqa100 at yahoo.com.au (Peter) Date: Sun, 21 Oct 2018 12:19:58 +1100 Subject: PEP 394 In-Reply-To: <20181020094725.2b8ab932@linuxawk.wegge.dk> References: <20181019090331.443ad113@linuxawk.wegge.dk> <86d0s52xd2.fsf@benfinney.id.au> <20181020094725.2b8ab932@linuxawk.wegge.dk> Message-ID: I'd imagine the PEP would stay as active, but changed so that: python2 -> always refers to python v2 python3 -> always refers to python v3 python -> which currently refers to python v2 will change to point to python v3 I don't know when the core team would be considering this. The PEP was last updated in April this year, so it's clearly still active. I would imagine this change would happen when python v2 ends updates at end of 2019, although I personally would like to see it happen earlier. Peter L On 20/10/2018 6:47 PM, Anders Wegge Keller wrote: > P? Sat, 20 Oct 2018 12:57:45 +1100 > Ben Finney skrev: >> Anders Wegge Keller writes: >> >>> Short and simple: Do you expect PEP 394 to change status >> The status of PEP 394 today is ?Active?. What change of status would you >> expect in this Informational PEP? > One possible change would be that it would become archived, ceased to be, > bereft of life, resting in peace or maybe even retired. > > I don't have any particular status change I want to see; I merely ask > what other experienced python developers expect to happen. > From rosuav at gmail.com Sat Oct 20 21:57:05 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Oct 2018 12:57:05 +1100 Subject: PEP 394 In-Reply-To: References: <20181019090331.443ad113@linuxawk.wegge.dk> <86d0s52xd2.fsf@benfinney.id.au> <20181020094725.2b8ab932@linuxawk.wegge.dk> Message-ID: On Sun, Oct 21, 2018 at 12:41 PM Peter via Python-list wrote: > > I'd imagine the PEP would stay as active, but changed so that: > > python2 -> always refers to python v2 > python3 -> always refers to python v3 > python -> which currently refers to python v2 will change to point to > python v3 That would have a lot of very annoying considerations for shebangs. As such, it's highly unlikely that this will become the recommendation until LONG after 2020. ChrisA From pjmclenon at gmail.com Sun Oct 21 07:33:24 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Sun, 21 Oct 2018 04:33:24 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: Message-ID: <64ce7e71-2906-4539-a26f-5a2978e7bfa6@googlegroups.com> On Thursday, January 29, 2009 at 11:24:46 AM UTC-5, Anjanesh Lekshminarayanan wrote: > Im reading a file. But there seems to be some encoding error. > > >>> f = open(filename) > >>> data = f.read() > Traceback (most recent call last): > File "", line 1, in > data = f.read() > File "C:\Python30\lib\io.py", line 1724, in read > decoder.decode(self.buffer.read(), final=True)) > File "C:\Python30\lib\io.py", line 1295, in decode > output = self.decoder.decode(input, final=final) > File "C:\Python30\lib\encodings\cp1252.py", line 23, in decode > return codecs.charmap_decode(input,self.errors,decoding_table)[0] > UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position > 10442: character maps to > > The string at position 10442 is something like this : > "query":"0 1??? \u2021 0\u201a0 \u2021??? "," > > So what encoding value am I supposed to give ? I tried f = > open(filename, encoding="cp1252") but still same error. I guess > Python3 auto-detects it as cp1252 > -- > Anjanesh Lekshmnarayanan hello peter, mrab and terry thank you all for answering i decided to use the last option by terry....latin -1....cuz it seemed the easiest to try it does work but i read somewhere if im not wrong ..that this is not really the advised thing to do ....but also my file was just simple text....i did see some weird caracters...and maybe that caused the utf-8 error..but i dont know how to post a pic here to show the caracters in my text file...but anyway for now i guess i will keep this setting..but not sure why this seems to be not the ideal thing to do with encoding at latin -1 , which is extened ascii right?/..and thats 256 options?/..and even with the unknown caraters i found in the file..isnt utf-8 like over 1 million options? thzx alot forum Jessica From sukurcf at gmail.com Sun Oct 21 08:36:40 2018 From: sukurcf at gmail.com (Siva Sukumar Reddy) Date: Sun, 21 Oct 2018 18:06:40 +0530 Subject: Python Enhancement Proposal for List methods Message-ID: Hey everyone, I am really new to Python contribution community want to propose below methods for List object. Forgive me if this is not the format to send an email. 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the occurrences of an element in the list instead of writing a new list comprehension in place. 2. *list.replace( item_to_be_replaced, new_item, number_of_occurrences )*: which replaces the occurrences of an element in the list till specific number of occurrences of that element. The number_of_occurrences can defaulted to 0 which will replace all the occurrences in place. 3. *list.removeall( item_to_be_removed )*: which removes all the occurrences of an element in a list in place. What do you think about these features? Are they PEP-able? Did anyone tried to implement these features before? Please let me know. Thank you, Sukumar From eryksun at gmail.com Sun Oct 21 11:00:13 2018 From: eryksun at gmail.com (eryk sun) Date: Sun, 21 Oct 2018 10:00:13 -0500 Subject: PEP 394 In-Reply-To: References: <20181019090331.443ad113@linuxawk.wegge.dk> Message-ID: On 10/20/18, Terry Reedy wrote: > > On Windows, there is a better solution: the py launcher. > > py # launches the most most recent version installed* > > py -x # launches the most recent x.y > > py -x.y # launches x.y if installed, else lists installed versions > > * At first, 2.x took precedence over 3.x, but this has since been switched. The py launcher still prefers Python 2 for scripts that have a virtual shebang, such as #!python and #!/usr/bin/python. From pjmclenon at gmail.com Sun Oct 21 14:33:03 2018 From: pjmclenon at gmail.com (pjmclenon at gmail.com) Date: Sun, 21 Oct 2018 11:33:03 -0700 (PDT) Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to In-Reply-To: References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> Message-ID: <95b12145-6e34-4ab3-935a-1b5e6fe61a46@googlegroups.com> On Saturday, October 20, 2018 at 1:23:50 PM UTC-4, Terry Reedy wrote: > On 10/20/2018 8:24 AM, pjmclenon at gmail.com wrote: > > On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote: > > > i have a sort of decode error > > UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte > > ***************** > > and it seems to refer to my code line: > > *********** > > data = f.read() > > *************** > > which is part of this block of code > > ******************** > > # Read content of files > > for path in files: > > with open(join("docs", path), encoding="utf-8") as f: > > #with open(join("docs", path)) as f: > > data = f.read() > > process_data(data) > > *********************************************** > > > > would the solution fix be this? > > ********************** > > data = f.read(), decoding = "utf-8" #OR > > data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong?? > > Both statements are invalid syntax. The encoding is set in the open > statement. > > What you need to find out: is '0xb0' a one-byte error or is 'utf-8' the > wrong encoding? Things I might do: > > 1. Change the encoding in open() to 'ascii' and see if the exception > message still refers to position 83064 or if there is a non-ascii > character earlier in the file. The latter would mean that there is at > least one earlier non-ascii sequence that was decoded as uft-8. This > would suggest that 'utf-8' might be correct and that the '0xb0' byte is > an error. > > 2. In the latter case, add "errors='handler'", where 'handler' is > something other than the default 'strict'. Look in the doc or see > help(open) for alternatives. > > 3. In open(), replace "encoding='utf-8'" with "mode='rb'" so that > f.read() creates data as bytes instead of a text string. Then print, > say, data[83000:83200] to see the context of the non-ascii byte. > > 4. Change to encoding in open() to 'latin-1'. The file will then be > read as text without error, even if latin-1 is the wrong encoding. > > > > -- > Terry Jan Reedy hello terry just want to add that i tried also setting in notepad ++ encoding to utf-8 from ansi and then i encoded utf-8 in my file but i got same error then i tried encoding ascii in my file and it worked so encdoong ascii and latin-1 work not sure why utf-8 gives an error when thats the most wide all caracters inclusive right?/ thxz jessica From marko at pacujo.net Sun Oct 21 14:48:04 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 21 Oct 2018 21:48:04 +0300 Subject: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to References: <7f780736-291f-4c65-b677-171691e326f7@googlegroups.com> <20180610212936.GA42086@cskk.homeip.net> <029a41c6-620f-4d25-8324-01b74176d6c0@googlegroups.com> <7425a311-8e50-4eac-9828-4ce7e137f08d@googlegroups.com> <0a323416-cde8-2ac2-bfa5-f755df91701c@mrabarnett.plus.com> <071b38c4-7037-4d5c-9404-c46cddd71dfb@googlegroups.com> <95b12145-6e34-4ab3-935a-1b5e6fe61a46@googlegroups.com> Message-ID: <874ldfkufv.fsf@elektro.pacujo.net> pjmclenon at gmail.com: > not sure why utf-8 gives an error when thats the most wide all caracters > inclusive right?/ Not all sequences of bytes are legal in UTF-8. For example, >>> b'\x80'.decode("utf-8") Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte Not all sequences of bytes are legal in ASCII, either. However, all sequences of bytes are legal in Latin-1 (among others). Of course, decoding with Latin-1 gives you gibberish unless the data really is Latin-1. But you'll never get a UnicodeDecodeError. Marko From lutz.horn at posteo.de Mon Oct 22 05:29:59 2018 From: lutz.horn at posteo.de (Lutz Horn) Date: Mon, 22 Oct 2018 11:29:59 +0200 Subject: Python Enhancement Proposal for List methods In-Reply-To: References: Message-ID: <20181022092959.GD5247@lutz-pc.ecm4u.intra> On Sun, Oct 21, 2018 at 06:06:40PM +0530, Siva Sukumar Reddy wrote: > 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the > occurrences of an element in the list instead of writing a new list > comprehension in place. Try this: >>> l = [1, 3, 4, 5, 6, 5, 4, 3, 2, 1] >>> def replace(l, old, new): ... try: ... while True: ... l[l.index(old)] = new ... except ValueError: ... pass ... ... >>> replace(l, 5, 55) >>> l [1, 3, 4, 55, 6, 55, 4, 3, 2, 1] Functions like this are simple to implement. There is no need to add them to the stdlib. Lutz From __peter__ at web.de Mon Oct 22 05:44:19 2018 From: __peter__ at web.de (Peter Otten) Date: Mon, 22 Oct 2018 11:44:19 +0200 Subject: Python Enhancement Proposal for List methods References: Message-ID: Siva Sukumar Reddy wrote: > I am really new to Python contribution community want to propose below > methods for List object. Forgive me if this is not the format to send an > email. > > 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the > occurrences of an element in the list instead of writing a new list > comprehension in place. > 2. *list.replace( item_to_be_replaced, new_item, number_of_occurrences )*: > which replaces the occurrences of an element in the list till specific > number of occurrences of that element. The number_of_occurrences can > defaulted to 0 which will replace all the occurrences in place. > 3. *list.removeall( item_to_be_removed )*: which removes all the > occurrences of an element in a list in place. > > What do you think about these features? > Are they PEP-able? Did anyone tried to implement these features before? > Please let me know. You can easily implement those as functions. def list_replace(items, old, new, count=None): indices = (i for i, v in enumerate(items) if v == old) if count is not None: indices = itertools.islice(indices, count) for index in indices: items[index] = new def list_removeall(items, value): for index in reversed(range(len(items))): if items[index] == value: del items[index] To promote them to methods of a built-in class you need to provide use-cases that are both frequent and compelling, I think. So what are your use-cases? From ahmed1n1n1n1n at gmail.com Mon Oct 22 06:07:08 2018 From: ahmed1n1n1n1n at gmail.com (contact@blake2.net) Date: Mon, 22 Oct 2018 13:07:08 +0300 Subject: hello I need the code of md6 hash Message-ID: <5bcda14d.1c69fb81.2eedd.c624@mx.google.com> ?? ??????? ?? ?????? ?? Windows 10 --- ??? ?? ?????? ?? ??? ??? ?????? ?????????? ?? ????????? ?????? ?????? ????? ???? ?????????. https://www.avast.com/antivirus From rosuav at gmail.com Mon Oct 22 11:03:55 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 23 Oct 2018 02:03:55 +1100 Subject: Python Enhancement Proposal for List methods In-Reply-To: <20181022092959.GD5247@lutz-pc.ecm4u.intra> References: <20181022092959.GD5247@lutz-pc.ecm4u.intra> Message-ID: On Mon, Oct 22, 2018 at 11:20 PM Lutz Horn wrote: > > On Sun, Oct 21, 2018 at 06:06:40PM +0530, Siva Sukumar Reddy wrote: > > 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the > > occurrences of an element in the list instead of writing a new list > > comprehension in place. > > Try this: > > >>> l = [1, 3, 4, 5, 6, 5, 4, 3, 2, 1] > >>> def replace(l, old, new): > ... try: > ... while True: > ... l[l.index(old)] = new > ... except ValueError: > ... pass > ... > ... > >>> replace(l, 5, 55) > >>> l > [1, 3, 4, 55, 6, 55, 4, 3, 2, 1] > > Functions like this are simple to implement. There is no need to add > them to the stdlib. > And simple to get wrong, hence my recommendation for a recipe in the docs. For example, your replace() function will get into an infinite loop if old and new compare equal to each other. It's also going to start the search over from the beginning every time it finds something, which is wasteful. ChrisA From Joseph.Schachner at Teledyne.com Mon Oct 22 12:16:40 2018 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Mon, 22 Oct 2018 16:16:40 +0000 Subject: Python Enhancement Proposal for List methods In-Reply-To: References: Message-ID: I agree with others that I don't see a compelling need to add these to Python, since they are all easy to implement in a few lines. But what I really want to say is that Python tries hard to be easily readable and easily understood, by any reader. List.removeall( ) that does not remove all elements, but all occurrences of a value passed to it, does not seem to me to meet that goal. Even if you implement this as a function I encourage to think of a better name than removeall. --- Joseph S. -----Original Message----- From: Siva Sukumar Reddy Sent: Sunday, October 21, 2018 8:37 AM To: python-list at python.org; python-ideas at python.org Subject: Python Enhancement Proposal for List methods Hey everyone, I am really new to Python contribution community want to propose below methods for List object. Forgive me if this is not the format to send an email. 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the occurrences of an element in the list instead of writing a new list comprehension in place. 2. *list.replace( item_to_be_replaced, new_item, number_of_occurrences )*: which replaces the occurrences of an element in the list till specific number of occurrences of that element. The number_of_occurrences can defaulted to 0 which will replace all the occurrences in place. 3. *list.removeall( item_to_be_removed )*: which removes all the occurrences of an element in a list in place. What do you think about these features? Are they PEP-able? Did anyone tried to implement these features before? Please let me know. Thank you, Sukumar From bgailer at gmail.com Mon Oct 22 12:24:00 2018 From: bgailer at gmail.com (Bob Gailer) Date: Mon, 22 Oct 2018 12:24:00 -0400 Subject: Python Enhancement Proposal for List methods In-Reply-To: <20181022092959.GD5247@lutz-pc.ecm4u.intra> References: <20181022092959.GD5247@lutz-pc.ecm4u.intra> Message-ID: Many of the features of python were added not out of need but rather for convenience. If need were the only criteria we could immediately get rid of comprehensions, since they can be written as a series of for loops, the same can be said for many other newer features. Python is all about making the programming experience easier and more productive. Expanding replace from just strings to other sequences such as as lists makes sense. The cost in time and effort to add this to python is trivial. I say go for it. From brian.j.oney at googlemail.com Mon Oct 22 12:35:19 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Mon, 22 Oct 2018 18:35:19 +0200 Subject: email automation Message-ID: <1540226119.18459.1.camel@gmail.com> Dear List, I would like to send out custom automated replies to email. In the future, I would like to be able to integrate nltk and fuzzy matching if necessary. After some basic research I have a few options: 1. Grapple with OpenEMM (interesting software, has python library, still alive and kicking, a bit overkill for my use-case); 2. build on the examples in 'Automate the boring stuff'; 3. forget about it. Please tell me about any possible alternatives I missed. Kind regards, Brian From rj.amdphreak at gmail.com Tue Oct 23 03:28:18 2018 From: rj.amdphreak at gmail.com (Ryan Johnson) Date: Tue, 23 Oct 2018 02:28:18 -0500 Subject: email automation In-Reply-To: <1540226119.18459.1.camel@gmail.com> References: <1540226119.18459.1.camel@gmail.com> Message-ID: <5bcecd93.1c69fb81.6c874.1726@mx.google.com> Consider a web service API?Not really sure about where you want to evaluate your incoming emails, but perhaps MailChimp could help. https://mailchimp.com/features/marketing-automation/ There are a bunch of ways to automate things with web services now, using Zapier. https://mailchimp.com/features/marketing-automation/ Your question opens a big pandora?s box. If you use web svc with API, either expect them to provide a library in your language, or expect them to send a structured data file over the internet, like json. For web connection, use urllib. For json use json module. On windows: py -m pip install urllib json Sent from Mail for Windows 10 From: Brian Oney via Python-list Sent: Monday, October 22, 2018 11:37 AM To: python-list at python.org Subject: email automation Dear List, I would like to send out custom automated replies to email. In the future, I would like to be able to integrate nltk and fuzzy matching if necessary. After some basic research I have a few options: 1. Grapple with OpenEMM (interesting software, has python library, still alive and kicking, a bit overkill for my use-case); 2. build on the examples in 'Automate the boring stuff'; 3. forget about it. Please tell me about any possible alternatives I missed. Kind regards, Brian -- https://mail.python.org/mailman/listinfo/python-list From tjol at tjol.eu Tue Oct 23 04:04:52 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 23 Oct 2018 10:04:52 +0200 Subject: email automation In-Reply-To: <1540226119.18459.1.camel@gmail.com> References: <1540226119.18459.1.camel@gmail.com> Message-ID: <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> On 22/10/2018 18:35, Brian Oney via Python-list wrote: > Dear List, > > I would like to send out custom automated replies to email. In the future, I > would like to be able to integrate nltk and fuzzy matching if necessary. > > After some basic research I have a few options: > > 1. Grapple with OpenEMM (interesting software, has python library, still alive and kicking, a bit overkill for my use-case); > 2. build on the examples in 'Automate the boring stuff'; >From briefly skimming the relevant section, it looks like this gives some examples with smtplib and imaplib. That sounds like a good place to start! If you happen to have a server (VPS, Raspberry Pi, PC, whatever) running a full MTA that you can forward your emails to, you could feed the relevant messages to your script directly with the help of procmail, rather than polling an IMAP server. > 3. forget about it. > > Please tell me about any possible alternatives I missed. > > Kind regards, > Brian > From ali.r.keles at gmail.com Tue Oct 23 05:31:16 2018 From: ali.r.keles at gmail.com (=?UTF-8?B?QWxpIFLEsXphIEtFTEXFng==?=) Date: Tue, 23 Oct 2018 10:31:16 +0100 Subject: email automation In-Reply-To: <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> References: <1540226119.18459.1.camel@gmail.com> <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> Message-ID: On Tue, 23 Oct 2018 at 09:07, Thomas Jollans wrote: > > After some basic research I have a few options: > > > > 1. Grapple with OpenEMM (interesting software, has python library, still alive and kicking, a bit overkill for my use-case); > > 2. build on the examples in 'Automate the boring stuff'; > > From briefly skimming the relevant section, it looks like this gives > some examples with smtplib and imaplib. That sounds like a good place to > start! > > If you happen to have a server (VPS, Raspberry Pi, PC, whatever) running > a full MTA that you can forward your emails to, you could feed the > relevant messages to your script directly with the help of procmail, > rather than polling an IMAP server. +1 I experienced procmail and worked like a charm for me, in a case like yours. My script was parsing emails to grab some URIs of binary objects and queue them to be processed later. You can easily trigger a python script and do whatever you need in that script. If it is a long term process, you should just parse email and use queues for the rest. -- -- Ali R?za Kele? From brian.j.oney at googlemail.com Tue Oct 23 07:58:27 2018 From: brian.j.oney at googlemail.com (Brian J. Oney) Date: Tue, 23 Oct 2018 13:58:27 +0200 Subject: email automation In-Reply-To: References: <1540226119.18459.1.camel@gmail.com> <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> Message-ID: <1540295907.2859.6.camel@gmail.com> On Tue, 2018-10-23 at 10:31 +0100, Ali R?za KELE? wrote: > On Tue, 23 Oct 2018 at 09:07, Thomas Jollans wrote: > > > After some basic research I have a few options: > > >? > > > ?????1. Grapple with OpenEMM (interesting software, has python library, still alive and kicking, a bit overkill for my use-case); > > > ?????2. build on the examples in 'Automate the boring stuff'; > >? > > From briefly skimming the relevant section, it looks like this gives > > some examples with smtplib and imaplib. That sounds like a good place to > > start! > >? > > If you happen to have a server (VPS, Raspberry Pi, PC, whatever) running > > a full MTA that you can forward your emails to, you could feed the > > relevant messages to your script directly with the help of procmail, > > rather than polling an IMAP server. >? > +1 >? > I experienced procmail and worked like a charm for me, in a case like > yours. My script was parsing emails to grab some URIs of binary > objects and queue them to be processed later. >? > You can easily trigger a python script and do whatever you need in > that script. If it is a long term process, you should just parse email > and use queues for the rest. >? Thank you for the insights. The developer of procmail says to avoid it, as the last update was in 2001. Supposedly there are also some security concerns. The mail server does some pretty good filtering already. I made the mistake of being vague about the problem. Let me specify. ? - General Problem: too many emails to answer with due care ????- Technical Problem 1: can't be run on mail server. ????- Technical Problem 2: answers needed in 2 and possibly 4 languages. ????- Future Problem 3: don't have resources to maintain the solution forever ????- Future Problem 4: software may be running in many different countries ??????with different languages and legal frameworks. ? - Goal: lighten the load? ????- Potential: many emails pose questions to information already on the ??????website. ? - Potential solution: automate personalized replies with relevant ????information. Nonetheless, barring a tip to an existing solution, I will be rolling my own. Off the top of my head, I image the setup being eerily similar to a flask website. I would rely on smtplib, imaplib, nltk, pyzmail, and jinja2. Draft Algorithm: ? 1. read mail ? 2. tokenize body's contents ? 3. apply logic to determine answer ? 4. render appropriate answer template ? 5. send email ? 6. refile email maildog/ ? app.py ? answer_logic/ ????english.csv ????german.csv ????french.csv ? maildog/ ????__init__.py ????send_mail.py ????read_mail.py ????refile_mail.py ????decide_answer.py ? templates/ ????base.html ????base.txt ????info.html ????info.txt ????schedule.html ????schedule.txt ? tests/ ????test_answer_common_email.py ????test_explain_upcoming_schedule.py ????test_read_email.py Somehow I think someone smarter already solved this niche case. A part of me wants to delve into OpenEMM. The rest wants to write code. Now that it seems that I will be writing this. What is the recommended way to set up a timer. I know 2 system options, systemd timers and cron jobs. I prefer the former for the handy logging options. What about a python solution? What would the advantage of a python queue be over a systemd timer? I guess that's an apples an oranges comparison. In my case I most likely would have a raspberry pi running a python script to read and possibly answer any emails. Thanks again for the tips. Regards, Brian From tjol at tjol.eu Tue Oct 23 11:12:05 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 23 Oct 2018 17:12:05 +0200 Subject: email automation In-Reply-To: <1540295907.2859.6.camel@gmail.com> References: <1540226119.18459.1.camel@gmail.com> <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> <1540295907.2859.6.camel@gmail.com> Message-ID: <0dc8e364-fdf2-60bf-d6f9-81014c6fc347@tjol.eu> On 2018-10-23 13:58, Brian J. Oney via Python-list wrote: > Now that it seems that I will be writing this. What is the recommended way to > set up a timer. I know 2 system options, systemd timers and cron jobs. I > prefer the former for the handy logging options. What about a python solution? celery? From asad.hasan2004 at gmail.com Tue Oct 23 11:18:48 2018 From: asad.hasan2004 at gmail.com (Asad) Date: Tue, 23 Oct 2018 20:48:48 +0530 Subject: How to compare timestamps in python In-Reply-To: References: Message-ID: Hi All , I have just playing with python , I am stuck for the following problem : file1 : Patching tool version 12.1.0.2.0 Production on Fri Feb 23 01:10:28 2018 Bootstrapping registry and package to current versions...done statement ERR-2001: table is corrupt check for cause could not determine the current status. Patching tool version 12.1.0.2.0 Production on Fri Feb 23 01:10:58 2018 file2 : LOG file opened at 02/03/18 01:11:05 DUP-05004: statement1 DUP-05007: statement2 LOG file opened at 02/03/18 01:11:14 DUP-05004: statement1 DUP-05007: statement2 LOG file opened at 02/23/18 01:10:33 DUP-05004: statement1 DUP-05007: statement2 I need to look for the ERR-2001 in file1 if it matches then go to file2 and print the message nearest to the timestamp found in file1 within two minutes of range . 1) What regex I use get the timestamp from file 1 and then file 2 ? 2) How to I acheive so in this case file1 Start: Fri Feb 23 01:10:28 2018 End time : Fri Feb 23 01:10:58 2018 check in file 2 nearest to file1 end time : 02/23/18 01:10:33 Thanks in advance, -- Asad Hasan +91 9582111698 -- Asad Hasan +91 9582111698 From python at mrabarnett.plus.com Tue Oct 23 15:32:46 2018 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 23 Oct 2018 20:32:46 +0100 Subject: How to compare timestamps in python In-Reply-To: References: Message-ID: <00ee8bae-8202-99b2-81e2-8c69d763c3a7@mrabarnett.plus.com> On 2018-10-23 16:18, Asad wrote: > Hi All , > > I have just playing with python , I am stuck for the following > problem : > > file1 : > Patching tool version 12.1.0.2.0 Production on Fri Feb 23 01:10:28 2018 > > Bootstrapping registry and package to current versions...done > statement ERR-2001: table is corrupt check for cause > > could not determine the current status. > > Patching tool version 12.1.0.2.0 Production on Fri Feb 23 01:10:58 2018 > > file2 : > > LOG file opened at 02/03/18 01:11:05 > > DUP-05004: statement1 > DUP-05007: statement2 > > > LOG file opened at 02/03/18 01:11:14 > > DUP-05004: statement1 > > DUP-05007: statement2 > > > LOG file opened at 02/23/18 01:10:33 > > DUP-05004: statement1 > > DUP-05007: statement2 > > I need to look for the ERR-2001 in file1 if it matches then go to file2 and > print the message nearest to the timestamp found in file1 within two > minutes of range . > > > 1) What regex I use get the timestamp from file 1 and then file 2 ? > > 2) How to I acheive > so in this case file1 Start: Fri Feb 23 01:10:28 2018 > End time : Fri Feb 23 01:10:58 2018 > check in file 2 nearest to file1 end time : 02/23/18 01:10:33 > > Thanks in advance, > The datetime in file1 matches this regex: \b\w{3} \w{3} \d+ \d{2}:\d{2}:\d{2} \d{4}\b When you have the datetime string, you need to parse it with datetime.datetime.strptime; that needs to be given the format that describes the datetime: %a %b %d %H:%M:%S %Y The datetime in file2 matches this regex: \b\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}\b and the format for datetime.datetime.strptime is: %m/%d/%y %H:%M:%S Finding the nearest date/time is simple: calculate the difference between the 2 datetimes (which will return a datetime.timedelta) and pick the one with the smallest absolute (abs(...)) value of its .total_seconds() method. From ftg at lutix.org Wed Oct 24 04:58:30 2018 From: ftg at lutix.org (ftg at lutix.org) Date: Wed, 24 Oct 2018 08:58:30 +0000 Subject: Function factory? Message-ID: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> Hello everyone, I have 2 functions whose aim is to read a pdf file, the first one manages an uploaded file, the another one fecth a remote one (via an url). They are quite the same: ######################## def handle_uploaded_file(path,file): #if os.path.isfile(path + '/' + file.name): # file.name = '_' + file.name destination = open(path + '/' + file.name, 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() if check_file(path,file.name): return True else: return False def handle_remote_file(url,path,file_name=''): if not file_name: file_name = url.split('/')[-1] with urllib.request.urlopen(url) as response: with open(path + '/' + file_name, 'wb+') as out_file: shutil.copyfileobj(response, out_file) if check_file(path,file_name): return True else: return False #################### I am wondering about the way I could rationalize those 2 functions. I have read about function factory and maybe it crosses my need. Do you have some advices? Thanks, best regards From tjol at tjol.eu Wed Oct 24 06:30:44 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 24 Oct 2018 12:30:44 +0200 Subject: Function factory? In-Reply-To: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> References: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> Message-ID: <708470b7-0d09-1ab1-8049-82d9300df075@tjol.eu> On 2018-10-24 10:58, ftg at lutix.org wrote: > if check_file(path,file_name): > return True > else: > return False Replace this with a simple return check_file(path, file_name) and now your functions share one line, and one that simply calls another function at that. From python at mrabarnett.plus.com Wed Oct 24 11:37:49 2018 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 24 Oct 2018 16:37:49 +0100 Subject: Function factory? In-Reply-To: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> References: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> Message-ID: On 2018-10-24 09:58, ftg at lutix.org wrote: > Hello everyone, > > I have 2 functions whose aim is to read a pdf file, the first one manages an uploaded file, the another one fecth a remote one (via an url). > They are quite the same: > ######################## > def handle_uploaded_file(path,file): > #if os.path.isfile(path + '/' + file.name): > # file.name = '_' + file.name > > destination = open(path + '/' + file.name, 'wb+') > for chunk in file.chunks(): > destination.write(chunk) > destination.close() > if check_file(path,file.name): > return True > else: > return False > > def handle_remote_file(url,path,file_name=''): > if not file_name: > file_name = url.split('/')[-1] > > with urllib.request.urlopen(url) as response: > with open(path + '/' + file_name, 'wb+') as out_file: > shutil.copyfileobj(response, out_file) > if check_file(path,file_name): > return True > else: > return False > #################### > > I am wondering about the way I could rationalize those 2 functions. > I have read about function factory and maybe it crosses my need. > > Do you have some advices? > > Thanks, best regards > Replace: destination = open(path + '/' + file.name, 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() with: with open(path + '/' + file.name, 'wb+') as destination: for chunk in file.chunks(): destination.write(chunk) From __peter__ at web.de Wed Oct 24 13:04:02 2018 From: __peter__ at web.de (Peter Otten) Date: Wed, 24 Oct 2018 19:04:02 +0200 Subject: Function factory? References: <41ad7b93eb28d002fc1d9b4aea96ac3b@webmail.lutix.org> Message-ID: ftg at lutix.org wrote: > Hello everyone, > > I have 2 functions whose aim is to read a pdf file, the first one manages > an uploaded file, the another one fecth a remote one (via an url). They > are quite the same: > ######################## > def handle_uploaded_file(path,file): > #if os.path.isfile(path + '/' + file.name): > # file.name = '_' + file.name > > destination = open(path + '/' + file.name, 'wb+') > for chunk in file.chunks(): > destination.write(chunk) > destination.close() > if check_file(path,file.name): > return True > else: > return False > > def handle_remote_file(url,path,file_name=''): > if not file_name: > file_name = url.split('/')[-1] > > with urllib.request.urlopen(url) as response: > with open(path + '/' + file_name, 'wb+') as out_file: > shutil.copyfileobj(response, out_file) > if check_file(path,file_name): > return True > else: > return False > #################### > > I am wondering about the way I could rationalize those 2 functions. > I have read about function factory and maybe it crosses my need. > > Do you have some advices? I don't see how a factory can help here; maybe you can instead factor out common code into a helper function? Example: def handle_uploaded_file(fileobj, destfolder): return _handle_file(fileobj, destfolder, fileobj.name) def handle_remote_file(url, destfolder): with urllib.request.urlopen(url) as response: return _handle_file(response, destfolder, url) def _handle_file(instream, destfolder, filename): destfile = os.path.join(destfolder, posixpath.basename(filename)) with open(destfile, "wb") as outstream: shutil.copyfileobj(instream, outstream) return check_file(destfile) From patrickkidd at gmail.com Thu Oct 25 00:27:21 2018 From: patrickkidd at gmail.com (Patrick Stinson) Date: Wed, 24 Oct 2018 21:27:21 -0700 Subject: Building on windows and installing to prefix Message-ID: <67CFFD9C-8F96-4EF3-9656-AA13FBD8B9C4@gmail.com> Hello! I am having trouble finding out how to build python from source and then install it to a path prefix, as you can on unix. I have looked at the options in ?PCBuild\build.bat -h? and in readme.txt, and on google, but no dice. I have VS 2017. Thanks! -Patrick From iamybj at icloud.com Thu Oct 25 01:14:06 2018 From: iamybj at icloud.com (iamybj at icloud.com) Date: Wed, 24 Oct 2018 22:14:06 -0700 (PDT) Subject: recommends of redesign OO feature of python !!! Message-ID: I am an engineer of java and c#, I want to some personal projects in free time, and I choose python. After try python, I hava some suggestion. The first thing is that python?s class is not well designed than other programming languages. Using dictionary as data model is the 20th century style, but now is 21t century.We usually use strong typed class to express a data model. For example, the code presentation of a person in Java/c++/c# may be: public class Person { public String name; public String email; public int age; } The corresponding Python code: class Person: def __init__(self): self.name = None self.email = None self.gage = None It is very strange to define instance members of a class in constructor.Even the OOP feature of PHP is very like Java. Python's dynamic feature has lost control. Second, python is too complex. Python is an old programming language.At that time, enterprise programming style is very popular, witch like making simple things become complex, so force the costumer to pay more money.But now is WWW and Internet and Linux time, people like simple production and simple programming styles. Every new programming language wants to keep simple. Third, python is too slow. At the old enterprise programming time, performance is not a critical feature. If software runs too slow, customer have to pay more money to enterprise software company to buy new hardware. Time changed, performance is very important now. Because the complex of python, the pypy project process very slow, and not widely used by people. Totally speaking, simple and performance are mostly required by this times. I suggest the python team should stop any new work, and start to rebuild a new python with simple grammar and better performance. From rosuav at gmail.com Thu Oct 25 01:19:40 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 25 Oct 2018 16:19:40 +1100 Subject: recommends of redesign OO feature of python !!! In-Reply-To: References: Message-ID: On Thu, Oct 25, 2018 at 4:16 PM iamybj--- via Python-list wrote: > > I am an engineer of java and c#, I want to some personal projects in free time, and I choose python. > > After try python, I hava some suggestion. > > The first thing is that python?s class is not well designed than other programming languages. > Using dictionary as data model is the 20th century style, but now is 21t century.We usually use strong typed class to express a data model. > For example, the code presentation of a person in Java/c++/c# may be: > public class Person { > public String name; > public String email; > public int age; > } > The corresponding Python code: > class Person: > def __init__(self): > self.name = None > self.email = None > self.gage = None > It is very strange to define instance members of a class in constructor.Even the OOP feature of PHP is very like Java. Python's dynamic feature has lost control. > > Second, python is too complex. > Python is an old programming language.At that time, enterprise programming style is very popular, witch like making simple things become complex, so force the costumer to pay more money.But now is WWW and Internet and Linux time, people like simple production and simple programming styles. Every new programming language wants to keep simple. > > Third, python is too slow. > At the old enterprise programming time, performance is not a critical feature. If software runs too slow, customer have to pay more money to enterprise software company to buy new hardware. > Time changed, performance is very important now. Because the complex of python, the pypy project process very slow, and not widely used by people. > > Totally speaking, simple and performance are mostly required by this times. I suggest the python team should stop any new work, and start to rebuild a new python with simple grammar and better performance. > There's actually a version of Python that's less dynamic, more restrictive in its class syntax, and (often) higher performance. It's called C. ChrisA From dieter at handshake.de Thu Oct 25 02:41:58 2018 From: dieter at handshake.de (dieter) Date: Thu, 25 Oct 2018 08:41:58 +0200 Subject: recommends of redesign OO feature of python !!! References: Message-ID: <87a7n2plxl.fsf@handshake.de> iamybj--- via Python-list writes: > I am an engineer of java and c#, I want to some personal projects in free time, and I choose python. > > After try python, I hava some suggestion. > > The first thing is that python?s class is not well designed than other programming languages. > Using dictionary as data model is the 20th century style, but now is 21t century.We usually use strong typed class to express a data model. > For example, the code presentation of a person in Java/c++/c# may be: > public class Person { > public String name; > public String email; > public int age; > } > The corresponding Python code: > class Person: > def __init__(self): > self.name = None > self.email = None > self.gage = None > It is very strange to define instance members of a class in constructor. Nothing prevents you from using class Person: name = None email = None gage = None You can also have typed instance members (with help of some other packages), e.g.: from zope.schema import String, Int from zope.schema.fieldproperty import FieldProperty class Person: name = FieldProperty(String(u'Name')) email = FieldProperty(String(u'Email')) gage = FieldProperty(Int(u'Gage')) This gives you even more control than the simple types you know from other languages. E.g. "gage" could be defined as gage = FieldProperty(Int(u'Gage', min=0)) To force "gage" to be an integer >= 0. > ... > Second, python is too complex. I have implemented large projects in assembler, Algol, C, C++, Java and Python. I achieved the highest productivity as a developper with Python. In addition, Python is far less complex than e.g. C++. The strong typing of C++ forces it to define the incredible complex concept "template" to build general purpose data structure libraries. Due to its dynamic typing, this is trivial in Python. My projects typically gain much from the use of multiple inheritance. This allows to implement single features in so called mixin classes which can easily be integrated via inheritance in any context that needs the feature. Something, I dearly miss in Java. > Python is an old programming language.At that time, enterprise programming style is very popular, witch like making simple things become complex, so force the costumer to pay more money.But now is WWW and Internet and Linux time, people like simple production and simple programming styles. Every new programming language wants to keep simple. In fact, I am developing internet applications - and I much prefer Python over Java in this domain. > Third, python is too slow. Python can be slow at runtime. Mostly, it does not matter. If it does, you can implement performance critical portions in C/C++. The Python C API is far easier to use than Java's JNI for such tasks. In addition, "cython" (a Python++ to C compiler) can avoid the direct use of Python's C API, thus making optimizations even easier. You could argue that Java's JIT compilers often do quite a good job in optimizing performance critical code, thus often avoiding the need to optimize manually. One point for Java. > ... > Totally speaking, simple and performance are mostly required by this times. I suggest the python team should stop any new work, and start to rebuild a new python with simple grammar and better performance. Obviously, you do not like Python. Thus, stay with Java/C++/C#. I, on the other side, do like Python (far better than C++ and Java) and I hope your suggestion remains unheard. From armand.foucault at telecom-bretagne.eu Thu Oct 25 02:49:59 2018 From: armand.foucault at telecom-bretagne.eu (armand.foucault at telecom-bretagne.eu) Date: Thu, 25 Oct 2018 08:49:59 +0200 Subject: =?ISO-8859-1?Q?Re=A0:_recommends_of_redesi?= =?ISO-8859-1?Q?gn_OO_feature_of_python_!!!?= References: Message-ID: <20181025065001.D815381721@zproxy120.enst.fr> If performance is at stake, then Python might not be the best choice. When you pick Python, it's for its other qualities. This being said, unless you're writing software for a plane, you're not very likely to need that much performance... as long as you code well. As for your statement that Python is too complex, I'm curious to read what you mean exactly. Python programs are way shorter than those written in those industrials OOP languages, so I'm assuming you're not talking about that. One can even compare the formal grammars of Python and say, Java. I'll leave it to you, but believe me, Python is waaaaay simpler than Java. So what complexity are you referring to? Maybe you'd prefer Haskell's purity? Finallyc regarding your first point, I invite you to check out Python 3.7's dataclasses. --------------------------------------------- Armand FOUCAULT Ing**nieur G**nie Logiciel armand.foucault at telecom-bretagne.eu -------- Message original -------- Objet**: recommends of redesign OO feature of python !!! De**: iamybj--- via Python-list ****: python-list at python.org Cc**: I am an engineer of java and c#, I want to some personal projects in free time, and I choose python. After try python, I hava some suggestion. The first thing is that python***s class is not well designed than other programming languages. Using dictionary as data model is the 20th century style, but now is 21t century.We usually use strong typed class to express a data model. For example, the code presentation of a person in Java/c++/c# may be: public class Person { public String name; public String email; public int age; } The corresponding Python code: class Person: def __init__(self): self.name = None self.email = None self.gage = None It is very strange to define instance members of a class in constructor.Even the OOP feature of PHP is very like Java. Python's dynamic feature has lost control. Second, python is too complex. Python is an old programming language.At that time, enterprise programming style is very popular, witch like making simple things become complex, so force the costumer to pay more money.But now is WWW and Internet and Linux time, people like simple production and simple programming styles. Every new programming language wants to keep simple. Third, python is too slow. At the old enterprise programming time, performance is not a critical feature. If software runs too slow, customer have to pay more money to enterprise software company to buy new hardware. Time changed, performance is very important now. Because the complex of python, the pypy project process very slow, and not widely used by people. Totally speaking, simple and performance are mostly required by this times. I suggest the python team should stop any new work, and start to rebuild a new python with simple grammar and better performance. -- https://mail.python.org/mailman/listinfo/python-list From tjol at tjol.eu Thu Oct 25 05:45:02 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 25 Oct 2018 11:45:02 +0200 Subject: recommends of redesign OO feature of python !!! In-Reply-To: References: Message-ID: <79df36c6-98c3-cd14-d512-63554eee7db7@tjol.eu> On 2018-10-25 07:14, iamybj--- via Python-list wrote: > Using dictionary as data model is the 20th century style, [citation needed] From gbs.deadeye at gmail.com Thu Oct 25 06:38:50 2018 From: gbs.deadeye at gmail.com (=?UTF-8?Q?Andre_M=C3=BCller?=) Date: Thu, 25 Oct 2018 12:38:50 +0200 Subject: recommends of redesign OO feature of python !!! In-Reply-To: <79df36c6-98c3-cd14-d512-63554eee7db7@tjol.eu> References: <79df36c6-98c3-cd14-d512-63554eee7db7@tjol.eu> Message-ID: Troll detected! If you don't like Python, don't use it. Very simple. The concept of Python is good as it is. From antoon.pardon at vub.be Thu Oct 25 06:59:18 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 25 Oct 2018 12:59:18 +0200 Subject: Python indentation (3 spaces) In-Reply-To: <20181020123819.i2lkgraqvdf7ryex@hjp.at> References: <5bba51d7.1c69fb81.e3c4b.abda@mx.google.com> <20181008174322.oudxrqahwicuu6rv@hjp.at> <20181013073744.kpemgmae7wkarvrr@hjp.at> <20181015193154.5gm64rasvigp2ess@hjp.at> <20181020123819.i2lkgraqvdf7ryex@hjp.at> Message-ID: <33abc272-6c8a-34ae-b33f-108a338682cb@vub.be> On 20-10-18 14:38, Peter J. Holzer wrote: > On 2018-10-16 06:37:56 +1100, Chris Angelico wrote: >> On Tue, Oct 16, 2018 at 6:34 AM Peter J. Holzer wrote: >>> On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote: >>>> On 13-10-18 09:37, Peter J. Holzer wrote: >>>>> On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote: >>>>>> On 08-10-18 19:43, Peter J. Holzer wrote: >>>>>>> In practice it doesn't work in my experience. There is always someone in >>>>>>> a team who was "just testing that new editor" and replaced all tabs >>>>>>> with spaces (or vice versa) or - worse - just some of them. >>>>>> Isn't that caugth in the process of commiting to version control? > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Underlined to emphasize the context. > >>>>> Tabs are easy to catch. If a file contains a tab, reject it. >>>>> >>>>> Spaces aren't, because spaces are everywhere. >>>> Spaces that replaced a tab by accident, are easy to catch too. They are all >>>> those lines that show up when you do a diff with the previous version that >>>> shouldn't show up. >>> And where is the AI that decides which lines in a diff are should show >>> up? >>> >>> Whether a line in a diff should or should not show up seems to me to be >>> even harder to determine than whether a tab fits the syntax. >>> >> If there's a change, it shows up. If there's no change, it doesn't show up. >> >> Ergo, if you accidentally replace a tab with spaces, it's a change, >> and it shows up. > If any change "shows up" (i.e., is rejected by the pre-commit hook of > your version control system) you can't change anything which makes using > a version control system rather pointless. I just do a diff between the local version and the "latest" commited version. If lines show up in the diff that don't looked changed, then there is a high probablity someone replaced tabs with spaces. (Especially if there are a lot of those lines.) I regularly do such a diff anyway, because I try to avoid commiting changes that involve multiple issues. And trying to avoid that can't be done automatically either. Maybe for some reason you don't consider this MO as easily catching spaces that accidently replaced tabs. But it is easy enough for me. -- Antooon From cspealma at redhat.com Thu Oct 25 08:47:25 2018 From: cspealma at redhat.com (Calvin Spealman) Date: Thu, 25 Oct 2018 08:47:25 -0400 Subject: recommends of redesign OO feature of python !!! In-Reply-To: References: Message-ID: It does not appear that you actually want to use Python. On Thu, Oct 25, 2018 at 1:15 AM iamybj--- via Python-list < python-list at python.org> wrote: > I am an engineer of java and c#, I want to some personal projects in free > time, and I choose python. > > After try python, I hava some suggestion. > > The first thing is that python?s class is not well designed than other > programming languages. > Using dictionary as data model is the 20th century style, but now is 21t > century.We usually use strong typed class to express a data model. > For example, the code presentation of a person in Java/c++/c# may be: > public class Person { > public String name; > public String email; > public int age; > } > The corresponding Python code: > class Person: > def __init__(self): > self.name = None > self.email = None > self.gage = None > It is very strange to define instance members of a class in > constructor.Even the OOP feature of PHP is very like Java. Python's dynamic > feature has lost control. > > Second, python is too complex. > Python is an old programming language.At that time, enterprise programming > style is very popular, witch like making simple things become complex, so > force the costumer to pay more money.But now is WWW and Internet and Linux > time, people like simple production and simple programming styles. Every > new programming language wants to keep simple. > > Third, python is too slow. > At the old enterprise programming time, performance is not a critical > feature. If software runs too slow, customer have to pay more money to > enterprise software company to buy new hardware. > Time changed, performance is very important now. Because the complex of > python, the pypy project process very slow, and not widely used by people. > > Totally speaking, simple and performance are mostly required by this > times. I suggest the python team should stop any new work, and start to > rebuild a new python with simple grammar and better performance. > -- > https://mail.python.org/mailman/listinfo/python-list > From guru at digitalfantasy.it Thu Oct 25 12:46:19 2018 From: guru at digitalfantasy.it (Daniele Forghieri) Date: Thu, 25 Oct 2018 18:46:19 +0200 Subject: recommends of redesign OO feature of python !!! In-Reply-To: References: Message-ID: Il 25/10/2018 07:14, iamybj--- via Python-list ha scritto: > I am an engineer of java and c#, I want to some personal projects in free time, and I choose python. > After try python, I hava some suggestion. > The first thing is that python?s class is not well designed than other programming languages. Using dictionary as data model is the 20th century style, but now is 21t century.We usually use strong typed class to express a data model.For example, the code presentation of a person in Java/c++/c# may be:public class Person { public String name; public String email; public int age;}The corresponding Python code:class Person: def __init__(self): self.name = None self.email = None self.gage = NoneIt is very strange to define instance members of a class in constructor.Even the OOP feature of PHP is very like Java. Python's dynamic feature has lost control. > Second, python is too complex. Python is an old programming language.At that time, enterprise programming style is very popular, witch like making simple things become complex, so force the costumer to pay more money.But now is WWW and Internet and Linux time, people like simple production and simple programming styles. Every new programming language wants to keep simple. > Third, python is too slow.At the old enterprise programming time, performance is not a critical feature. If software runs too slow, customer have to pay more money to enterprise software company to buy new hardware.Time changed, performance is very important now. Because the complex of python, the pypy project process very slow, and not widely used by people. > Totally speaking, simple and performance are mostly required by this times. I suggest the python team should stop any new work, and start to rebuild a new python with simple grammar and better performance.-- https://mail.python.org/mailman/listinfo/python-list > > I completely agree with you. For this reason I think that you should stop any new work and start to write your own language that, I'm sure, will encompass python in less than six months. With best regards From tomusatov at gmail.com Sat Oct 27 09:17:59 2018 From: tomusatov at gmail.com (Musatov) Date: Sat, 27 Oct 2018 06:17:59 -0700 (PDT) Subject: Accessing clipboard through software built on Python Message-ID: I am wondering if Python could be used to write a program that allows: 1. Highlight some text 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 3. Highlight another string of text 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 THEN 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 I found "pyperclip" and "Tkinter" but I don't know where to start. Thanks, Musatov From torriem at gmail.com Sat Oct 27 11:20:07 2018 From: torriem at gmail.com (Michael Torrie) Date: Sat, 27 Oct 2018 09:20:07 -0600 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> Couple of questions: On 10/27/2018 07:17 AM, Musatov wrote: > I am wondering if Python could be used to write a program that allows: > > 1. Highlight some text > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 This text comes from where? Another application? > 3. Highlight another string of text > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > THEN > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 Gets pasted where? > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 As far as I know it's not possible for an application to directly yank highlighted text from another application. The first application would have to first copy that text to the clipboard (Control-C in that app) and then the second application could grab it from the clipboard (ctrl-hotkey1) and then store it in its own variables. Ctrl-hotkey2 could then push the text back into the clipboard and then you can ctrl-V paste it in the other application. This type of functionality is known often found in clipboard manager programs. > I found "pyperclip" and "Tkinter" but I don't know where to start. Here's another file that demonstrates accessing the clipboard on the Linux, Mac, and Windows: https://github.com/Shizmob/clippy/blob/master/clip.py As for the hotkey stuff, that's also dependent on the operating system. Google for something like "python global hotkey linux" to get an example of how to implement that. From marko at pacujo.net Sat Oct 27 12:12:23 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 27 Oct 2018 19:12:23 +0300 Subject: Accessing clipboard through software built on Python References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> Message-ID: <877ei3fjx4.fsf@elektro.pacujo.net> Michael Torrie : > As far as I know it's not possible for an application to directly yank > highlighted text from another application. That's an age-old pattern in X11. I don't know if Wayland supports it. Application 1 holds a selection (usually highlighted) and Application 2 wants to copy the selection. No clipboard is needed. Application 2 simply asks for the selection. The request is relayed to Application 1, which generates the response: Marko From bgailer at gmail.com Sat Oct 27 12:40:40 2018 From: bgailer at gmail.com (Bob Gailer) Date: Sat, 27 Oct 2018 12:40:40 -0400 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: On Oct 27, 2018 9:20 AM, "Musatov" wrote: > > I am wondering if Python could be used to write a program that allows: > > 1. Highlight some text > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > 3. Highlight another string of text > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > THEN > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > What operating system are you using? If it is Windows I recommend you take a look at a program called autohotkey. > I found "pyperclip" and "Tkinter" but I don't know where to start. > > Thanks, > > Musatov > -- > https://mail.python.org/mailman/listinfo/python-list From tomusatov at gmail.com Sat Oct 27 14:45:47 2018 From: tomusatov at gmail.com (Musatov) Date: Sat, 27 Oct 2018 11:45:47 -0700 (PDT) Subject: Accessing clipboard through software built on Python In-Reply-To: References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> Message-ID: On Saturday, October 27, 2018 at 10:28:00 AM UTC-5, Michael Torrie wrote: > Couple of questions: > On 10/27/2018 07:17 AM, Musatov wrote: > > I am wondering if Python could be used to write a program that allows: > > > > 1. Highlight some text > > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > > This text comes from where? Another application? >From a webpage. > > > 3. Highlight another string of text > > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > > > THEN > > > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > > Gets pasted where? Unto a savable field on another webpage. > > > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > > As far as I know it's not possible for an application to directly yank > highlighted text from another application. The first application would > have to first copy that text to the clipboard (Control-C in that app) > and then the second application could grab it from the clipboard > (ctrl-hotkey1) and then store it in its own variables. Ctrl-hotkey2 > could then push the text back into the clipboard and then you can ctrl-V > paste it in the other application. This type of functionality is known > often found in clipboard manager programs. Yes, I understand but they all involve putting one piece of text unto the clipboard at a time. I want COPYFIELD1 COPYFIELD2 PASTEFIELD1 PASTEFIELD2 Without having to look at the damn clipboard manager! And no more than two hotkey combinations. It would make my job so much easier, and easier for many other workers doing the same job. > > > I found "pyperclip" and "Tkinter" but I don't know where to start. > Here's another file that demonstrates accessing the clipboard on the > Linux, Mac, and Windows: > > https://github.com/Shizmob/clippy/blob/master/clip.py Thank you.> > As for the hotkey stuff, that's also dependent on the operating system. > Google for something like "python global hotkey linux" to get an example > of how to implement that. Ok From tomusatov at gmail.com Sat Oct 27 14:50:11 2018 From: tomusatov at gmail.com (Musatov) Date: Sat, 27 Oct 2018 11:50:11 -0700 (PDT) Subject: Accessing clipboard through software built on Python In-Reply-To: <877ei3fjx4.fsf@elektro.pacujo.net> References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> <877ei3fjx4.fsf@elektro.pacujo.net> Message-ID: <8c232df9-6f27-4f9f-b3fe-4ab4c9a38c26@googlegroups.com> On Saturday, October 27, 2018 at 11:12:35 AM UTC-5, Marko Rauhamaa wrote: > Michael Torrie : > > As far as I know it's not possible for an application to directly yank > > highlighted text from another application. > > That's an age-old pattern in X11. I don't know if Wayland supports it. > > Application 1 holds a selection (usually highlighted) and Application 2 > wants to copy the selection. No clipboard is needed. Application 2 > simply asks for the selection. The request is relayed to Application 1, > which generates the response: > > > > > Marko I work from a web database of users and I continually have to copy email address and user ID to two separate fields on a Salesforce.com page. I go to the webpage, highlight email address then copy. Then go to Salesforce page, and paste. Then go back to the webpage, then copy the User ID. Then go back to Salesforce page, and paste. I think it would be much more efficient to: On webpage, copy emailaddress and user ID. Then go to Salesforce and paste email address and user ID. From tomusatov at gmail.com Sat Oct 27 14:50:53 2018 From: tomusatov at gmail.com (Musatov) Date: Sat, 27 Oct 2018 11:50:53 -0700 (PDT) Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: On Saturday, October 27, 2018 at 11:40:57 AM UTC-5, Bob Gailer wrote: > On Oct 27, 2018 9:20 AM, "Musatov" wrote: > > > > I am wondering if Python could be used to write a program that allows: > > > > 1. Highlight some text > > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > > 3. Highlight another string of text > > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > > > THEN > > > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > > > > What operating system are you using? If it is Windows I recommend you take > a look at a program called autohotkey. > > I found "pyperclip" and "Tkinter" but I don't know where to start. > > > > Thanks, > > > > Musatov > > -- > > https://mail.python.org/mailman/listinfo/python-list I will look at autohotkey. From marko at pacujo.net Sat Oct 27 17:56:06 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 28 Oct 2018 00:56:06 +0300 Subject: Accessing clipboard through software built on Python References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> <877ei3fjx4.fsf@elektro.pacujo.net> <8c232df9-6f27-4f9f-b3fe-4ab4c9a38c26@googlegroups.com> Message-ID: <87y3ajdpft.fsf@elektro.pacujo.net> Musatov : > I work from a web database of users and I continually have to copy email > address and user ID to two separate fields on a Salesforce.com page. > > I go to the webpage, highlight email address then copy. > Then go to Salesforce page, and paste. > Then go back to the webpage, then copy the User ID. > Then go back to Salesforce page, and paste. > > I think it would be much more efficient to: > On webpage, copy emailaddress and user ID. > Then go to Salesforce and paste email address and user ID. Theoretically possible. In practice, probably not so much because both applications must be aware of a special user-id-plus-email-address selection data type. What should be possible, though is: * select the email address with the left mouse button on the web page * middle click on the Salesforce page to copy it there * same for the user name Similarly, drag-and-drop should work. Marko From greg.ewing at canterbury.ac.nz Sat Oct 27 18:40:09 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 28 Oct 2018 11:40:09 +1300 Subject: Accessing clipboard through software built on Python In-Reply-To: References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> Message-ID: Musatov wrote: > From a webpage. Does it always come from the same web site? If so, you may be able to scrape the web page to get the username and address, and then have hot keys for pasting them. -- Greg From tomusatov at gmail.com Sat Oct 27 20:50:28 2018 From: tomusatov at gmail.com (Musatov) Date: Sat, 27 Oct 2018 17:50:28 -0700 (PDT) Subject: Accessing clipboard through software built on Python In-Reply-To: References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> Message-ID: <1bdca80b-5d27-44f6-942e-345ef6813d25@googlegroups.com> Yes, same site every time. From rowen at uw.edu Sun Oct 28 00:21:09 2018 From: rowen at uw.edu (Russell Owen) Date: Sat, 27 Oct 2018 21:21:09 -0700 Subject: Is it possible to connect an awaitable to a Future, basically turning it into a Task? Message-ID: <0001HW.218570B5019A451D7000048792CF@news.gmane.org> I?m using asyncio and I?d like to add an item to an object that others can wait on immediately and which eventually I will want to use to track a coroutine. In other words I want something like: class Info: def __init__(self): self.done_task = asyncio.Future() info = Info() # do other stuff, but eventually coro = ... asyncio.connect_future(coro, info.done_task) I can certainly live without this, it simply requires adding an additional task made with asyncio.ensure_future and using that to set the result of done_task. But it would be a lot more elegant to just have the one future (especially if I have to cancel the wait, as I have to keep the extra task around so I can cancel it). So...just wondering if I missed something. Regards, Russell From info at tundraware.com Sun Oct 28 12:14:54 2018 From: info at tundraware.com (Tim Daneliuk) Date: Sun, 28 Oct 2018 11:14:54 -0500 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: On 10/27/2018 08:17 AM, Musatov wrote: > I am wondering if Python could be used to write a program that allows: > > 1. Highlight some text > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > 3. Highlight another string of text > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > THEN > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > > I found "pyperclip" and "Tkinter" but I don't know where to start. > > Thanks, > > Musatov > I am able to do this with clipboard (pip install clipboard). However, the highlighted text must be copied explicitly: Highlight Ctl-C In Python: TEXT1 = clipboard.paste() Highlight again TEXT2 = clipboard.paste() X actually has several clipboard buffers and it can be tricky to get this going. I don't recall, but either clipboard or pyperclip have a way to get to them all IIRC ... HTH, -Tim From brian.j.oney at googlemail.com Sun Oct 28 13:46:05 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Sun, 28 Oct 2018 18:46:05 +0100 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: You don't have to start from scratch. You don't to do anything other than learn to use anamnesis. I use anamnesis as my clipboard manager. I you can easily tell to get which ever one you want (i.e. the thousandth item). # Inform yourself https://sourceforge.net/projects/anamnesis/ # Install it cd ~/bin/src/ wget -O anamnesis.tar.gz https://sourceforge.net/projects/anamnesis/files/latest/download tar xzf anamnesis.tar.gz ln -sf ~/bin/src/anamnesis-1.0.4/source/anamnesis.py ~/bin/anamnesis # Be happy It hasn't changed in years and that's just fine. I just works. I can access it through the command line when I am in a remote ssh session. Or I have it as a autostarted daemon. It uses sqlite to store all your copied (and selected, if configured) text, which can be slow on a spinning disk. If this turns you off, replace your OS hard drive with an ssd - life's too short. HTH On October 28, 2018 5:14:54 PM GMT+01:00, Tim Daneliuk wrote: >On 10/27/2018 08:17 AM, Musatov wrote: >> I am wondering if Python could be used to write a program that >allows: >> >> 1. Highlight some text >> 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 >> 3. Highlight another string of text >> 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 >> >> THEN >> >> 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 >> 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 >> >> I found "pyperclip" and "Tkinter" but I don't know where to start. >> >> Thanks, >> >> Musatov >> > > >I am able to do this with clipboard (pip install clipboard). > > >However, the highlighted text must be copied explicitly: > >Highlight >Ctl-C > >In Python: > >TEXT1 = clipboard.paste() > >Highlight again > >TEXT2 = clipboard.paste() > >X actually has several clipboard buffers and it can be tricky to get >this going. I don't recall, >but either clipboard or pyperclip have a way to get to them all IIRC >... > >HTH, >-Tim > >-- >https://mail.python.org/mailman/listinfo/python-list From Karsten.Hilbert at gmx.net Sun Oct 28 14:51:30 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Sun, 28 Oct 2018 19:51:30 +0100 Subject: regular expression problem Message-ID: <20181028185130.GA28934@hermes.hilbert.loc> Dear list members, I cannot figure out why my regular expression does not work as I expect it to: #--------------------------- #!/usr/bin/python from __future__ import print_function import re as regex rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$' # it fails if switched around: rx_fails = '\$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$' line = 'junk $$ junk $$ junk' print ('') print ('line:', line) print ('expected: $$') print ('expected: $$') print ('') placeholders_in_line = regex.findall(rx_works, line, regex.IGNORECASE) print('found (works):') for ph in placeholders_in_line: print (ph) print ('') placeholders_in_line = regex.findall(rx_fails, line, regex.IGNORECASE) print('found (fails):') for ph in placeholders_in_line: print (ph) #--------------------------- I am sure I simply don't see the problem ? Thanks, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From akkana at shallowsky.com Sun Oct 28 15:08:22 2018 From: akkana at shallowsky.com (Akkana Peck) Date: Sun, 28 Oct 2018 13:08:22 -0600 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: <20181028190822.GB1302@shallowsky.com> Tim Daneliuk writes: > However, the highlighted text must be copied explicitly: > > Highlight > Ctl-C [ ... ] > X actually has several clipboard buffers and it can be tricky to get this going. I don't recall, > but either clipboard or pyperclip have a way to get to them all IIRC ... To get the highlighted text in X without needing a copy, you want the PRIMARY X selection rather than CLIPBOARD. I think pyperclip can get it (it uses an external program like xsel, and xsel can get any of the three X selections), or you can get the selection using a GUI library like GTK, Qt or Tk. Some examples: https://github.com/akkana/scripts/blob/master/pyclip ...Akkana From info at tundraware.com Sun Oct 28 15:58:03 2018 From: info at tundraware.com (Tim Daneliuk) Date: Sun, 28 Oct 2018 14:58:03 -0500 Subject: Accessing clipboard through software built on Python In-Reply-To: References: <20181028190822.GB1302@shallowsky.com> Message-ID: On 10/28/2018 02:08 PM, Akkana Peck wrote: > Tim Daneliuk writes: >> However, the highlighted text must be copied explicitly: >> >> Highlight >> Ctl-C > [ ... ] >> X actually has several clipboard buffers and it can be tricky to get this going. I don't recall, >> but either clipboard or pyperclip have a way to get to them all IIRC ... > > To get the highlighted text in X without needing a copy, you want the > PRIMARY X selection rather than CLIPBOARD. > > I think pyperclip can get it (it uses an external program like xsel, > and xsel can get any of the three X selections), or you can get the > selection using a GUI library like GTK, Qt or Tk. Some examples: > https://github.com/akkana/scripts/blob/master/pyclip > > ...Akkana > Yes, that sounds right in the distant recesses of my memory :) From info at tundraware.com Sun Oct 28 15:58:24 2018 From: info at tundraware.com (Tim Daneliuk) Date: Sun, 28 Oct 2018 14:58:24 -0500 Subject: Accessing clipboard through software built on Python In-Reply-To: References: <20181028190822.GB1302@shallowsky.com> Message-ID: <00hhaf-lfg.ln1@oceanview.tundraware.com> On 10/28/2018 02:08 PM, Akkana Peck wrote: > Tim Daneliuk writes: >> However, the highlighted text must be copied explicitly: >> >> Highlight >> Ctl-C > [ ... ] >> X actually has several clipboard buffers and it can be tricky to get this going. I don't recall, >> but either clipboard or pyperclip have a way to get to them all IIRC ... > > To get the highlighted text in X without needing a copy, you want the > PRIMARY X selection rather than CLIPBOARD. > > I think pyperclip can get it (it uses an external program like xsel, > and xsel can get any of the three X selections), or you can get the > selection using a GUI library like GTK, Qt or Tk. Some examples: > https://github.com/akkana/scripts/blob/master/pyclip > > ...Akkana > Yes, that sounds right in the distant recesses of my memory :) From tjol at tjol.eu Sun Oct 28 15:58:34 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sun, 28 Oct 2018 20:58:34 +0100 Subject: Accessing clipboard through software built on Python In-Reply-To: <8c232df9-6f27-4f9f-b3fe-4ab4c9a38c26@googlegroups.com> References: <82063b70-1064-0fb8-2ea4-fc61572f2c68@gmail.com> <877ei3fjx4.fsf@elektro.pacujo.net> <8c232df9-6f27-4f9f-b3fe-4ab4c9a38c26@googlegroups.com> Message-ID: <15965661-5c76-c36d-d8c1-a9342c7bfdd4@tjol.eu> On 27/10/2018 20:50, Musatov wrote: > On Saturday, October 27, 2018 at 11:12:35 AM UTC-5, Marko Rauhamaa wrote: >> Michael Torrie : >>> As far as I know it's not possible for an application to directly yank >>> highlighted text from another application. >> >> That's an age-old pattern in X11. I don't know if Wayland supports it. >> >> Application 1 holds a selection (usually highlighted) and Application 2 >> wants to copy the selection. No clipboard is needed. Application 2 >> simply asks for the selection. The request is relayed to Application 1, >> which generates the response: >> >> >> >> >> Marko > > I work from a web database of users and I continually have to copy email address and user ID to two separate fields on a Salesforce.com page. > > I go to the webpage, highlight email address then copy. > Then go to Salesforce page, and paste. > Then go back to the webpage, then copy the User ID. > Then go back to Salesforce page, and paste. > > I think it would be much more efficient to: > On webpage, copy emailaddress and user ID. > Then go to Salesforce and paste email address and user ID. > As this is all on the web, it's probably easier to work in the browser rather than at the display manager level, i.e.: build a browser extension or something instead. You'll almost certainly have easier access to selected text (not in Python, though). Really though you might want to take a step back and take the web page out the the equation completely. Salesforce must have an API, right? And the email addresses you're copying are presented in some regular format you might be able to parse (using beautifulsoup or something)? Or maybe the data source has an API, even? Or a database you can access? Surely, you could write a program that somehow gets (all) the data you want to copy from whatever server you get them from, gives you an opportunity to do whatever checks you have to do by hand, and then feeds the data into the database they go in in the end ? or gives the data to you in a format that makes that last step easy. Right? All I'm saying is: if you're going to try to automate a job, you might as well do it with conviction ^_^ If you insist on getting the selected text with something like autohotkey, my hunch is that the simplest way to do this would be to inject Ctrl+C, wait a moment, and then retrieve the clipboard content. From python at mrabarnett.plus.com Sun Oct 28 16:04:37 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 28 Oct 2018 20:04:37 +0000 Subject: regular expression problem In-Reply-To: <20181028185130.GA28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> Message-ID: On 2018-10-28 18:51, Karsten Hilbert wrote: > Dear list members, > > I cannot figure out why my regular expression does not work as I expect it to: > > #--------------------------- > #!/usr/bin/python > > from __future__ import print_function > import re as regex > > rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$' > # it fails if switched around: > rx_fails = '\$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$' > line = 'junk $$ junk $$ junk' > > print ('') > print ('line:', line) > print ('expected: $$') > print ('expected: $$') > > print ('') > placeholders_in_line = regex.findall(rx_works, line, regex.IGNORECASE) > print('found (works):') > for ph in placeholders_in_line: > print (ph) > > print ('') > placeholders_in_line = regex.findall(rx_fails, line, regex.IGNORECASE) > print('found (fails):') > for ph in placeholders_in_line: > print (ph) > > #--------------------------- > > I am sure I simply don't see the problem ? > Here are some of the steps while matching the second regex. (View this in a monospaced font.) 1: junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ 2: junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ 3: The .*? matches as few characters as possible, initially none. junk $$ junk $$ junk ^ ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ 4: junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ At this point it can't match, so it backtracks. 5: The .*? matches more characters, including the ":". After more matching it's like the following. junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ 6: junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ Again it can't match, so it backtracks. 7: The .*? matches more characters, including the ":". After more matching it's like the following. junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ 8: junk $$ junk $$ junk ^ \$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$ ^ Success! The first choice has matched this: $$ junk $$ From listofactor at mail.ru Sun Oct 28 16:06:13 2018 From: listofactor at mail.ru (listo factor) Date: Sun, 28 Oct 2018 20:06:13 +0000 Subject: zenity substitution Message-ID: <6b009508-3422-65a3-5439-3dc6cc6b5078@mail.ru> Hi all, I'm new to Python, but not to programming. As a teaching exercise, I am converting a bunch of bash shell scripts to Python, so that they can be run on all three OS-es (Linux, Windows, MacOS). The scripts in questions make extensive use of Linux "zenity" dialogs. Is there an equivalent facility in Python 3? If so, what is it? TIA From Karsten.Hilbert at gmx.net Sun Oct 28 16:43:27 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Sun, 28 Oct 2018 21:43:27 +0100 Subject: regular expression problem In-Reply-To: <20181028185130.GA28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> Message-ID: <20181028204326.GC28934@hermes.hilbert.loc> Now that MRAB has shown me the follies of my ways I would like to learn how to properly write the regular expression I need. This part: > rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$' > # it fails if switched around: > rx_fails = '\$<[^<:]+?::.*?::\d+-\d+>\$|\$<[^<:]+?::.*?::\d*?>\$' suggests that I already have a solution. However, in reality this line: > line = 'junk $$ junk $$ junk' can be either way round (match_A, then match_B or the vice versa) which, in turn, will switch the rx_works/rx_fails. Let my try to explain the expression I am actually after (assuming .compile with re.VERBOSE): rx_works = ' \$< # start of match is literal '$<' anywhere inside string [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") \d*? # followed by any number of digits (the max length of placeholder output) >\$ # followed by '>$' | # -- OR (in *either* order) -- \$< # start of match is literal '$<' anywhere inside string [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") # now the difference: \d+-\d+ # followed by one-or-many digits, a '-', and one-or-many digits (this is the *range* from with placeholder output) >\$' # followed by '>$' I want this to work for any number of matches in any order of max-lenght or output-range inside one string. Now, why the [^<:]+? dance ? Because three levels of placeholders $<...::...::>$ $<<...::...::>>$ $<<<...::...::>>>$ need to be nestable inside each other ;-) Anyone able to help ? This seems beyond my current grasp of regular expressions. Thanks, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From Karsten.Hilbert at gmx.net Sun Oct 28 17:04:39 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Sun, 28 Oct 2018 22:04:39 +0100 Subject: regular expression problem In-Reply-To: <20181028204326.GC28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> Message-ID: <20181028210439.GD28934@hermes.hilbert.loc> On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote: > Let my try to explain the expression I am actually after > (assuming .compile with re.VERBOSE): > > rx_works = ' > \$< # start of match is literal '$<' anywhere inside string > [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") > .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") > \d*? # followed by any number of digits (the max length of placeholder output) > >\$ # followed by '>$' > | # -- OR (in *either* order) -- > \$< # start of match is literal '$<' anywhere inside string > [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") > .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") > # now the difference: > \d+-\d+ # followed by one-or-many digits, a '-', and one-or-many digits (this is the *range* from with placeholder output) > >\$' # followed by '>$' Another try: - lines can contain several placeholders - placeholders start and end with '$' - placeholders are parsed in three passes - the pass in which a placeholder is parsed is denoted by the number of '<' and '>' next to the '$': $<...>$ / $<<...>>$ / $<<<...>>>$ - placeholders for different parsing passes must be nestable: $<<<...$<...>$...>>>$ .... (lower=earlier parsing passes will be inside) - the internal structure is "name::options::range" $$ - name will *not* contain '$' '<' '>' ':' - range can be either a length or a "from-until" - a length will be a positive integer (no bounds checking) - "from-until" is: a positive integer, a '-', and a positive integer (no sanity checking) - options needs to be able to contain nearly anything, except '::' Is that sufficiently defined and helpful to design the regular expression ? Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From pacqa100 at yahoo.com.au Sun Oct 28 17:21:48 2018 From: pacqa100 at yahoo.com.au (Peter) Date: Mon, 29 Oct 2018 08:21:48 +1100 Subject: Accessing clipboard through software built on Python In-Reply-To: References: Message-ID: <7748847a-2f21-8dba-ae37-eb0d11fec6a0@yahoo.com.au> On 28/10/2018 12:17 AM, Musatov wrote: > I am wondering if Python could be used to write a program that allows: > > 1. Highlight some text > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > 3. Highlight another string of text > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > THEN > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > > I found "pyperclip" and "Tkinter" but I don't know where to start. > > Thanks, > > Musatov > You might find the GUI automation tool Skiuli or the newer SikuliX programs useful. They can be used to script a GUI and perform operations. http://www.sikuli.org/ If you're on Windows then the COM interface can be useful (if the program you want to copy from supports it). Peter From Karsten.Hilbert at gmx.net Sun Oct 28 17:30:08 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Sun, 28 Oct 2018 22:30:08 +0100 Subject: regular expression problem In-Reply-To: <20181028210439.GD28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: <20181028213007.GE28934@hermes.hilbert.loc> On Sun, Oct 28, 2018 at 10:04:39PM +0100, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' This seems to contradict the "nesting" requirement, but the nesting restriction "earlier parsing passes go inside" makes it possible. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From brian.j.oney at googlemail.com Sun Oct 28 18:57:48 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Sun, 28 Oct 2018 23:57:48 +0100 Subject: regular expression problem In-Reply-To: <20181028210439.GD28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: <1540767468.3387.1.camel@gmail.com> On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote: > [^<:] Would a simple regex work? I mean: ~$ python Python 2.7.13 (default, Sep 26 2018, 18:42:22)? [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> t = '$$' >>> re.findall('[^<>:$]+', t) ['name', 'options', 'range'] You can then interpret what you have extracted afterwards. Maybe if you want to have the single ones grouped you could consider: >>> t = t*2 >>> t '$$$$' >>> re.findall('\$<+([^:]+)::([^:]+)::([^:]+)>+\$', t) [('name', 'options', 'range'), ('name', 'options', 'range')] HTH From tjol at tjol.eu Sun Oct 28 19:10:04 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 29 Oct 2018 00:10:04 +0100 Subject: regular expression problem In-Reply-To: <20181028210439.GD28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: On 28/10/2018 22:04, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' Including > and $ ? From python at mrabarnett.plus.com Sun Oct 28 19:14:15 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 28 Oct 2018 23:14:15 +0000 Subject: regular expression problem In-Reply-To: <20181028210439.GD28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> On 2018-10-28 21:04, Karsten Hilbert wrote: > On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote: > >> Let my try to explain the expression I am actually after >> (assuming .compile with re.VERBOSE): >> >> rx_works = ' >> \$< # start of match is literal '$<' anywhere inside string >> [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") >> .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") >> \d*? # followed by any number of digits (the max length of placeholder output) >> >\$ # followed by '>$' >> | # -- OR (in *either* order) -- >> \$< # start of match is literal '$<' anywhere inside string >> [^<:]+?:: # followed by at least one "character", except '<' or ':', until the next '::' (this is the placeholder "name") >> .*?:: # followed by any number of any "character", until the next '::' (this is the placeholder "options") >> # now the difference: >> \d+-\d+ # followed by one-or-many digits, a '-', and one-or-many digits (this is the *range* from with placeholder output) >> >\$' # followed by '>$' > > Another try: > > - lines can contain several placeholders > > - placeholders start and end with '$' > > - placeholders are parsed in three passes > > - the pass in which a placeholder is parsed is denoted by the number of '<' and '>' next to the '$': > > $<...>$ / $<<...>>$ / $<<<...>>>$ > > - placeholders for different parsing passes must be nestable: > > $<<<...$<...>$...>>>$ > .... > (lower=earlier parsing passes will be inside) > > - the internal structure is "name::options::range" > > $$ > > - name will *not* contain '$' '<' '>' ':' > > - range can be either a length or a "from-until" > > - a length will be a positive integer (no bounds checking) > > - "from-until" is: a positive integer, a '-', and a positive integer (no sanity checking) > > - options needs to be able to contain nearly anything, except '::' > > > Is that sufficiently defined and helpful to design the regular expression ? > How can they be nested inside one another? Is the string scanned, placeholders filled in for that level, and then the string scanned again for the next level? (That would mean that the fill value itself will be scanned in the next pass.) You could try matching the top level, for each match then match the next level, and for each of those matches then match for the final level. Trying to do it all in one regex is usually a bad idea. Keep it simple! (Do you even need to use a regex?) From tjol at tjol.eu Sun Oct 28 19:19:00 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 29 Oct 2018 00:19:00 +0100 Subject: regular expression problem In-Reply-To: <20181028210439.GD28934@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: On 28/10/2018 22:04, Karsten Hilbert wrote: > - options needs to be able to contain nearly anything, except '::' > > Is that sufficiently defined and helpful to design the regular expression ? so options isn't '.*', but more like '(:?[^:]+)*' (Figuring out what additional restriction this imposes is left an an exercise for the reader) From bgailer at gmail.com Sun Oct 28 22:59:49 2018 From: bgailer at gmail.com (Bob Gailer) Date: Sun, 28 Oct 2018 22:59:49 -0400 Subject: zenity substitution In-Reply-To: References: <6b009508-3422-65a3-5439-3dc6cc6b5078@mail.ru> Message-ID: On Oct 28, 2018 10:17 PM, "listo factor via Python-list" < python-list at python.org> wrote: > > Hi all, > I'm new to Python, but not to programming. > > As a teaching exercise, I am converting a bunch of bash shell > scripts to Python, so that they can be run on all three OS-es > (Linux, Windows, MacOS). > > The scripts in questions make extensive use of Linux "zenity" > dialogs. > > Is there an equivalent facility in Python 3? If so, what is it? Look up zenity in Wikipeda. Scroll down to cross-platform script. Bob Gailer From Karsten.Hilbert at gmx.net Mon Oct 29 04:02:32 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 29 Oct 2018 09:02:32 +0100 Subject: regular expression problem In-Reply-To: <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> Message-ID: <20181029080232.GA2262@hermes.hilbert.loc> On Sun, Oct 28, 2018 at 11:14:15PM +0000, MRAB wrote: > > - lines can contain several placeholders > > > > - placeholders start and end with '$' > > > > - placeholders are parsed in three passes > > > > - the pass in which a placeholder is parsed is denoted by the number of '<' and '>' next to the '$': > > > > $<...>$ / $<<...>>$ / $<<<...>>>$ > > > > - placeholders for different parsing passes must be nestable: > > > > $<<<...$<...>$...>>>$ > > .... > > (lower=earlier parsing passes will be inside) > > > > - the internal structure is "name::options::range" > > > > $$ > > > > - name will *not* contain '$' '<' '>' ':' > > > > - range can be either a length or a "from-until" > > > > - a length will be a positive integer (no bounds checking) > > > > - "from-until" is: a positive integer, a '-', and a positive integer (no sanity checking) > > > > - options needs to be able to contain nearly anything, except '::' > > > > > > Is that sufficiently defined and helpful to design the regular expression ? > > > How can they be nested inside one another? > Is the string scanned, placeholders filled in for that level, and then the > string scanned again for the next level? (That would mean that the fill > value itself will be scanned in the next pass.) Exactly. But *different* levels can be nested inside each other. > You could try matching the top level, for each match then match the next > level, and for each of those matches then match for the final level. So I do. > Trying to do it all in one regex is usually a bad idea. Right, I am not trying to do that. I was, however, worried that I need to make the expression not "trip over" fragments of what might seem to constitute part of another placeholder. $<$::15>>$ Pass 1 might fill in to: $<s'::15>>$ and I was worried to make sure the second pass does not stop here: $<s'::15>>$ ^ Logically it should not because >s'::15>>$ does not match ::\d*>>$ but I am not sure how to tell it that :-) Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From Karsten.Hilbert at gmx.net Mon Oct 29 04:05:24 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 29 Oct 2018 09:05:24 +0100 Subject: regular expression problem In-Reply-To: References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> Message-ID: <20181029080524.GB2262@hermes.hilbert.loc> On Mon, Oct 29, 2018 at 12:10:04AM +0100, Thomas Jollans wrote: > On 28/10/2018 22:04, Karsten Hilbert wrote: > > - options needs to be able to contain nearly anything, except '::' > > Including > and $ ? Unfortunately, it might. Even if I assume that earlier passes are "inside", and thusly "filled in" before outer=later passes happen the fillin value might still contain some of :>$. The fillin value will NOT contain a newly generated, matching placeholder definition, though. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From Karsten.Hilbert at gmx.net Mon Oct 29 04:10:55 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 29 Oct 2018 09:10:55 +0100 Subject: regular expression problem In-Reply-To: <20181029080232.GA2262@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> <20181029080232.GA2262@hermes.hilbert.loc> Message-ID: <20181029081054.GC2262@hermes.hilbert.loc> > Right, I am not trying to do that. I was, however, worried > that I need to make the expression not "trip over" fragments > of what might seem to constitute part of another placeholder. > > $<$::15>>$ > > Pass 1 might fill in to: > > $<s'::15>>$ > > and I was worried to make sure the second pass does not stop here: > > $<s'::15>>$ ^ Here, of course. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From Karsten.Hilbert at gmx.net Mon Oct 29 07:04:22 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 29 Oct 2018 12:04:22 +0100 Subject: regular expression problem In-Reply-To: <1540767468.3387.1.camel@gmail.com> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> <1540767468.3387.1.camel@gmail.com> Message-ID: <20181029110422.GE2262@hermes.hilbert.loc> On Sun, Oct 28, 2018 at 11:57:48PM +0100, Brian Oney wrote: > On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote: > > [^<:] > > Would a simple regex work? This brought about the solution. However, not this way: > >>> import re > >>> t = '$$' > >>> re.findall('[^<>:$]+', t) > ['name', 'options', 'range'] because I am not trying to parcel out the placeholder *parts* (but rather the placeholders from a given line). I eventually figured that denoting the parsing stages differently made for easier matching. Rather than $<>$ $<<>>$ $<<<>>>$ do this $1<>1$ $2<>2$ $3<>3$ which makes it way less ambiguous, and more matchable: regexen = [ r'\$1{0,1}<[^<].*?>1{0,1}\$', r'\$2<[^<].*?>2\$', r'\$3<[^<].*?>3\$' ] The [^<] part ("the single < is NOT to be followed directly by another <") is actually superfluous but does protect against legacy document templates still having $<<(<)...(>)>>$ in them. $<>$ is still retained as an alias for $1<>1$ because there is A LOT of them in existing document templates. It is normalized explicitely inside Python before fillin values are generated. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From python at mrabarnett.plus.com Mon Oct 29 13:16:11 2018 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 29 Oct 2018 17:16:11 +0000 Subject: regular expression problem In-Reply-To: <20181029080232.GA2262@hermes.hilbert.loc> References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> <20181029080232.GA2262@hermes.hilbert.loc> Message-ID: On 2018-10-29 08:02, Karsten Hilbert wrote: > On Sun, Oct 28, 2018 at 11:14:15PM +0000, MRAB wrote: > >> > - lines can contain several placeholders >> > >> > - placeholders start and end with '$' >> > >> > - placeholders are parsed in three passes >> > >> > - the pass in which a placeholder is parsed is denoted by the number of '<' and '>' next to the '$': >> > >> > $<...>$ / $<<...>>$ / $<<<...>>>$ >> > >> > - placeholders for different parsing passes must be nestable: >> > >> > $<<<...$<...>$...>>>$ >> > .... >> > (lower=earlier parsing passes will be inside) >> > >> > - the internal structure is "name::options::range" >> > >> > $$ >> > >> > - name will *not* contain '$' '<' '>' ':' >> > >> > - range can be either a length or a "from-until" >> > >> > - a length will be a positive integer (no bounds checking) >> > >> > - "from-until" is: a positive integer, a '-', and a positive integer (no sanity checking) >> > >> > - options needs to be able to contain nearly anything, except '::' >> > >> > >> > Is that sufficiently defined and helpful to design the regular expression ? >> > >> How can they be nested inside one another? >> Is the string scanned, placeholders filled in for that level, and then the >> string scanned again for the next level? (That would mean that the fill >> value itself will be scanned in the next pass.) > > Exactly. But *different* levels can be nested inside each other. > >> You could try matching the top level, for each match then match the next >> level, and for each of those matches then match for the final level. > > So I do. > >> Trying to do it all in one regex is usually a bad idea. > > Right, I am not trying to do that. I was, however, worried > that I need to make the expression not "trip over" fragments > of what might seem to constitute part of another placeholder. > > $<$::15>>$ > > Pass 1 might fill in to: > > $<s'::15>>$ > > and I was worried to make sure the second pass does not stop here: > > $<s'::15>>$ > ^ > > Logically it should not because > > >s'::15>>$ > > does not match > > ::\d*>>$ > > but I am not sure how to tell it that :-) > For something like that, I'd use parsing by recursive descent. It might be worth looking at pyparsing. From Karsten.Hilbert at gmx.net Mon Oct 29 15:26:54 2018 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 29 Oct 2018 20:26:54 +0100 Subject: regular expression problem In-Reply-To: References: <20181028185130.GA28934@hermes.hilbert.loc> <20181028204326.GC28934@hermes.hilbert.loc> <20181028210439.GD28934@hermes.hilbert.loc> <26ea75d4-00f3-bc26-4467-bd9ad6f915cf@mrabarnett.plus.com> <20181029080232.GA2262@hermes.hilbert.loc> Message-ID: <20181029192654.GA2393@hermes.hilbert.loc> On Mon, Oct 29, 2018 at 05:16:11PM +0000, MRAB wrote: > > Logically it should not because > > > > >s'::15>>$ > > > > does not match > > > > ::\d*>>$ > > > > but I am not sure how to tell it that :-) > > > For something like that, I'd use parsing by recursive descent. > > It might be worth looking at pyparsing. I feared as much. However, by slightly changing the boundary conditions I was able to solve the problem :-) Now I am only left with the task to search-replace a bunch of LaTeX templates during the next database upgrade ... Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From stone.zhong at gmail.com Mon Oct 29 20:28:54 2018 From: stone.zhong at gmail.com (Stone Zhong) Date: Mon, 29 Oct 2018 17:28:54 -0700 (PDT) Subject: customer compare in assertEqual Message-ID: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> Hi There, Now I want to make sure my code calls a function foo with an object t, however, foo.assert_called_once_with(t) does not work, since t is a model object and the code may load a different copy of t, so what I really want to test is "It calls foo with t where t.id equals real_t.id, is there a way to do that in python unit test? Thanks, Stone From stone.zhong at gmail.com Mon Oct 29 21:25:17 2018 From: stone.zhong at gmail.com (Stone Zhong) Date: Mon, 29 Oct 2018 18:25:17 -0700 (PDT) Subject: customer compare in assertEqual In-Reply-To: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> References: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> Message-ID: <5596fd0c-bee2-49a8-ae5f-4e622bbe8907@googlegroups.com> On Monday, October 29, 2018 at 5:29:11 PM UTC-7, Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, however, foo.assert_called_once_with(t) does not work, since t is a model object and the code may load a different copy of t, so what I really want to test is "It calls foo with t where t.id equals real_t.id, is there a way to do that in python unit test? > > Thanks, > Stone Tried addTypeEqualityFunc and it does not seems help. From __peter__ at web.de Tue Oct 30 03:52:40 2018 From: __peter__ at web.de (Peter Otten) Date: Tue, 30 Oct 2018 08:52:40 +0100 Subject: customer compare in assertEqual References: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> Message-ID: Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, > however, foo.assert_called_once_with(t) does not work, since t is a model > object and the code may load a different copy of t, so what I really want > to test is "It calls foo with t where t.id equals real_t.id, is there a > way to do that in python unit test? If you don't find any mock-specific solution you can provide a t with a custom equality operator: class U: def __init__(self, id): self.id = id def __eq__(self, other): return self.id == other.id foo.assert_called_once_with(U(42)) This should ensure that real_t.id == 42. From brian.j.oney at googlemail.com Tue Oct 30 08:38:41 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Tue, 30 Oct 2018 13:38:41 +0100 Subject: [ANN] maildog, Re: email automation In-Reply-To: <1540295907.2859.6.camel@gmail.com> References: <1540226119.18459.1.camel@gmail.com> <342c0570-5538-f6f1-9980-1dc87ebf294d@tjol.eu> <1540295907.2859.6.camel@gmail.com> Message-ID: <1540903121.3511.2.camel@gmail.com> On Tue, 2018-10-23 at 13:58 +0200, Brian J. Oney wrote: > On Tue, 2018-10-23 at 10:31 +0100, Ali R?za KELE? wrote: > > On Tue, 23 Oct 2018 at 09:07, Thomas Jollans wrote: > Now that it seems that I will be writing this. So I have gotten so far as to have a little package called 'maildog' working for me. It reads emails and sends customized replies on my behalf. Currently, I have it working for two languages. If you also have to reply to the same email ofter for whatever reason this little puppy may help you write fewer repetive email replies. That's what it does for me. If I have piqued your interest, have a look at https://github.com/oneyb/maildog/ Thank you for the tips. Kind regards Brian From skip.montanaro at gmail.com Tue Oct 30 08:59:05 2018 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 30 Oct 2018 07:59:05 -0500 Subject: Getting Pandas NaT to propagate like NaN Message-ID: I'm trying to take the min and max of a couple Pandas Series objects in the face of NaT. np.minimum and np.maximum work the way I want if the elements are floats. For example: >>> s1 0 0.0 1 1.8 2 3.6 3 5.4 dtype: float64 >>> s2 0 10.0 1 17.0 2 NaN 3 14.0 dtype: float64 >>> np.maximum(s1, s2) 0 10.0 1 17.0 2 NaN 3 14.0 dtype: float64 >>> np.minimum(s1, s2) 0 0.0 1 1.8 2 NaN 3 5.4 dtype: float64 This doesn't work if s1 and s2 are datetime64[ns] objects: >>> s1 0 2199-12-31 1 2199-12-31 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] >>> s2 0 NaT 1 2018-10-30 2 NaT 3 NaT dtype: datetime64[ns] >>> np.maximum(s1, s2) 0 2199-12-31 1 2199-12-31 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] >>> np.minimum(s1, s2) 0 2199-12-31 1 2018-10-30 2 2199-12-31 3 2199-12-31 dtype: datetime64[ns] After doing a bit of reading, I came to realize NaT is only approximately NaN, the latter having a proper floating point representation. Further reading suggested no simple way to have NaT "pollute" these comparisons. What's the correct way to get NaT to propagate in min/max comparisons the way NaN does in a floating point context? Thanks, Skip From stone.zhong at gmail.com Tue Oct 30 22:19:28 2018 From: stone.zhong at gmail.com (Stone Zhong) Date: Tue, 30 Oct 2018 19:19:28 -0700 (PDT) Subject: customer compare in assertEqual In-Reply-To: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> References: <177ea7e6-ad8b-4661-a837-03de4a552c0a@googlegroups.com> Message-ID: On Monday, October 29, 2018 at 5:29:11 PM UTC-7, Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, however, foo.assert_called_once_with(t) does not work, since t is a model object and the code may load a different copy of t, so what I really want to test is "It calls foo with t where t.id equals real_t.id, is there a way to do that in python unit test? > > Thanks, > Stone Thanks Peter, yeah, redefine the __eq__ works well. - Stone From toby at tobiah.org Wed Oct 31 11:53:15 2018 From: toby at tobiah.org (Tobiah) Date: Wed, 31 Oct 2018 08:53:15 -0700 Subject: @staticmethod or def function()? Message-ID: My IDE (pycharm) suggests that I mark my class methods with @staticmethod when they don't use 'self'. Sounds good. I did that then it suggested I had the option to make a regular function instead, at the file level. That's a possibility. I was thinking that I'd leave the method in the class unless it was ever also used by another class. What do you think? From santiago.basulto at gmail.com Wed Oct 31 12:19:28 2018 From: santiago.basulto at gmail.com (Santiago Basulto) Date: Wed, 31 Oct 2018 13:19:28 -0300 Subject: @staticmethod or def function()? In-Reply-To: References: Message-ID: I usually recommend my students to use @classmethod. It's a consistent API with a regular instance method, and receiving the class as first parameter (usually `cls`) is useful if you have to extend your classes. About separating a staticmethod in a regular function, it's mostly a matter of taste and organization. It's hard to say. Your intuition is good though, if you need to use the functionality by several classes, then it's probably not a staticmethod but an external function. On Wed, Oct 31, 2018 at 12:58 PM Tobiah wrote: > My IDE (pycharm) suggests that I mark my class methods > with @staticmethod when they don't use 'self'. Sounds > good. I did that then it suggested I had the option > to make a regular function instead, at the file level. > That's a possibility. I was thinking that I'd leave > the method in the class unless it was ever also used > by another class. What do you think? > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Santiago Basulto.- Up! From __peter__ at web.de Wed Oct 31 12:55:47 2018 From: __peter__ at web.de (Peter Otten) Date: Wed, 31 Oct 2018 17:55:47 +0100 Subject: @staticmethod or def function()? References: Message-ID: Tobiah wrote: > My IDE (pycharm) suggests that I mark my class methods > with @staticmethod when they don't use 'self'. Sounds > good. I did that then it suggested I had the option > to make a regular function instead, at the file level. > That's a possibility. I was thinking that I'd leave > the method in the class unless it was ever also used > by another class. What do you think? What do *you* think? Is your code demonstrably better if you turn the "normal" method into a static method? Do not make changes to your code only to apeace a linter. Regarding more the general question, should I use an instance method, a class method, a static method, or a function? -- that is hard to answer without an idea what the specific task of the function/method is, and how strong the link to the class is. From rgaddi at highlandtechnology.invalid Wed Oct 31 14:08:13 2018 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Wed, 31 Oct 2018 11:08:13 -0700 Subject: @staticmethod or def function()? In-Reply-To: References: Message-ID: On 10/31/18 8:53 AM, Tobiah wrote: > My IDE (pycharm) suggests that I mark my class methods > with @staticmethod when they don't use 'self'.? Sounds > good.? I did that then it suggested I had the option > to make a regular function instead, at the file level. > That's a possibility.? I was thinking that I'd leave > the method in the class unless it was ever also used > by another class.? What do you think? > > > It should be a staticmethod if the code is, while not linked to any instance in particular, still fundamentally inherent to the class itself and of little use outside the context of that class. It should be a stand-alone function if it provides stand-alone functionality. The decision is also almost certainly not worth the amount of thought you're giving it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From marko at pacujo.net Wed Oct 31 15:23:30 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 31 Oct 2018 21:23:30 +0200 Subject: @staticmethod or def function()? References: Message-ID: <871s85ex8t.fsf@elektro.pacujo.net> Peter Otten <__peter__ at web.de>: > Do not make changes to your code only to apeace a linter. Precisely. Don't let a tool drive a show. > Regarding more the general question, should I use an instance method, > a class method, a static method, or a function? -- that is hard to > answer without an idea what the specific task of the function/method > is, and how strong the link to the class is. I just always use regular instance methods. If I really want to "disappear" self, I'll just take the function out of the class. Marko From cs at cskk.id.au Wed Oct 31 17:46:32 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 1 Nov 2018 08:46:32 +1100 Subject: lint appeasement (was: @staticmethod or def function()?) In-Reply-To: <871s85ex8t.fsf@elektro.pacujo.net> References: <871s85ex8t.fsf@elektro.pacujo.net> Message-ID: <20181031214632.GA21934@cskk.homeip.net> On 31Oct2018 21:23, Marko Rauhamaa wrote: >Peter Otten <__peter__ at web.de>: >> Do not make changes to your code only to apeace a linter. > >Precisely. Don't let a tool drive a show. While this is sound for semantic changes (and a function versus a @staticmethod is verging on that), I would point out that cleaning lint is often useful in order to make the linter useful. If the useful lint warnings are buried in a sea of dross, and you want to lint things, then it can be well worth making some changes to clean up noise. Ideally of course the linter should recognise some hooks (typically special comments) to mark particular pieces of code as deliberately not matching the linter's opinions. And certainly I run some linters with various checks tuned or disabled. I'm doing this on an ongoing basis in my libraries as I work on other changes: make the change, debug, then lint, with the linting in distinct commits unless it is tiny. This is gardually bringing consistency to the code and catching the odd bug or rough edge such as "variable set but not used". The end game here is that your lint output should be empty so that when it isn't empty the messages are useful. Cheers, Cameron Simpson From ethan at stoneleaf.us Wed Oct 31 22:56:04 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 31 Oct 2018 19:56:04 -0700 Subject: How much thought to put into various programming decisions? [was: @staticmethod or def function()?] In-Reply-To: References: Message-ID: On 10/31/2018 11:08 AM, Rob Gaddi wrote: > The decision is also almost certainly not worth the amount of > thought you're giving it. When learning something new, hopefully all aspects are given a lot of thought. After learning how all the pieces fit together then most decisions can be made quickly. -- ~Ethan~