Re: How to obtain an up-to-date document of tkinter
On 4/19/2017 8:09 PM, Mok-Kong Shen wrote: How could one obtain an up-to-date document of tkinter. http://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm documents the tcl/tk that tkinter wraps. There are a few things that are not included in tkinter. I ask this question because apparently there are stuffs of tkinter that worked in Python 3.5 but no longer in Python 3.6.1. I don't know of any such. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Test if Script Already Running
On 18Apr2017 19:31, Matt wrote: I have a number of simple scripts I run with cron hourly on Centos linux. I want the script to check first thing if its already running and if so exit. In perl I did it with this at the start of every script: use Fcntl ':flock'; INIT { open LH, $0 or die "Can't open $0 for locking!\nError: $!\n"; flock LH, LOCK_EX | LOCK_NB or die "$0 is already running somewhere!\n"; } How can I do something like this in Python? Others have pointed the way to an exact implementation. For myself, I like mkdir. It is portable. It is atomic. It fails if the target exists. It works over NFS etc. It is easy. os.mkdir('lock') ... do stuff ... os.rmdir('lock') and it is equally doable in a shell script (eg your cron job): if mkdir lockdir then ... do stuff ... rmdir lockdir else echo "lockdir already takens, aborting" >&2 exit 1 fi which means you don't need to fit the lock logic inside every tool, you can just do it in the script that calls them. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
I've likewise mostly been ignoring this thread as it has gotten out of control. At a few jobs ago, I was nearly daily involved with interviewing candidates. Initially, I was point on "culture fit". i.e. how would the potential employee react to having a phone thrown at them (it happened - I worked at a trading shop). Best response to that was "I'd firstly duck, then pick it up and throw it back" - I gave that candidate a go. But, back to the point, when I was doing technical interviews, regardless of the technology/language, I had a single goal: to get the candidate to admit they did not know the answer. The reasoning is simple. I don't want the candidate that thinks they know everything. I want the candidate that knows what they don't know. In the interview, there were tons of bonus points for speculation & what the candidate would do to resolve the question (this is what I was looking for) - a flat I don't know didn't suffice. On Wed, Apr 19, 2017 at 7:52 PM, Deborah Swanson wrote: > > Rupee via Python-list writes: > > > > > I don't think stupid black people or senile old people should be > > > allowable because those are not choosable *behaviors*. But is > > > unable-to-learn old people a choosable behavior? You said that's ok. > > I've mostly been ignoring this thread and its predecessors, and I > probably won't read all the recent posts to it. > > But this bit caught my eye because I hold the opposite opinion about old > people's ability to learn. > > It is a choice. Your noggin doesn't just conk out at a certain age, or > stage in the aging process. There are plenty of examples of scholars and > authors (and many others) who've kept their wits sharp and their minds > fully functional. Some till the day they died, others didn't quite last > the whole way. > > There's two paths to keeping the mind forever alive ("forever" meaning > at least till death, we don't know what comes after that). Both are > almost purely physical. > > One is to use the mind all one's life, and the principle is identical to > "use it or lose it", more commonly heard in athletic circles. But the > mind is like muscle, the more you use it the stronger it gets. And vice > versa. And I'm living proof that if you use your mind hard all your life > (since I was about 3, in my case), you can let it coast for at least a > decade and it will still be there, and it can still learn. Of course > there's a lengthy stage of bringing it out of mothballs, but it can be > done. > > The other path I'm living proof of is the food you eat. The brain > responds badly to chemicals that enter the body, and particularly ones > you ingest in food. And the brain is blood thirsty. It particularly > craves grassfed and pastured red meat, the rarer the better, and organ > meats. I eat all forms of it, but the prize goes to wild red meats - > antelope, venison & wild boar. I'll spare you all the reasons why and > the evidence, but they are very good reasons. > > I've also had university math and science professors who swore by heavy > daily exercise regimes, but I haven't done it and neither have aged > scholars who still had their good minds very late in life, so rigorous > exercise is not a requirement. I have no idea whether it's sufficient to > sustain and grow the mind either, but no doubt it helps. > > So, it is a choice of how you live your life, and how important it is to > you to have a mind worth keeping. I see no reason to accord those people > who didn't care all their lives any special status. > > Oh, and I think it's also a choice whether you are stupid or not, > barring physical abnormalities of the brain. Regardless of age, gender > or race. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
Rurpy via Python-list writes: > You and Chris refused to find any fault with the use of the two > stereotypes under discussion one of which was "unable-to-learn old > people". I expressed absolutely nothing on that topic, so I didn't “refuse to find any fault”. To claim “you said that is okay” is a bald untruth, I said no such thing. You are pointing to *absence of a statement* on a topic and claiming that it is a “refusal to find any fault”. By that logic, you have also “refused to find fault with” my neighbour's mistreatment of their child. How horrible of you! Except, that's not a claim I would make of you. I'll thank you not to do the same of others. -- \ “I have always wished for my computer to be as easy to use as | `\ my telephone; my wish has come true because I can no longer | _o__) figure out how to use my telephone.” —Bjarne Stroustrup | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
The belief that learning is more difficult for older people (was: Bigotry (you win, I give up))
"Deborah Swanson" writes: > But this bit caught my eye because I hold the opposite opinion about > old people's ability to learn. > > It is a choice. The topic is complex, and both “It is entirely determined by your own choices” and “It is in no way determined by your own choices” are false. The NIH article _Regulation of Cerebrovascular Aging_ is a good one on the topic https://www.ncbi.nlm.nih.gov/pubmed/21204352>. In brief: there *are* inevitable processes that advance further as the human body ages, which tend to make learning more difficult. And there *are* choices that most people can make, which can improve that prognosis but not stop it. > So, it is a choice of how you live your life, and how important it is > to you to have a mind worth keeping. I see no reason to accord those > people who didn't care all their lives any special status. That simply isn't supported by the evidence. Human brain function tends to deteriorate past early adulthood. Not everyone is in possession of the precise knowledge at the right stage of life to slow that decline; and of those who do have that knowledge, many are not in a position to effectively take those actions; and of those who do take such action, not all of them will certainly be effective. There are many actions a person can take throughout their life that *may* improve, statistically, the likelihood of slowing the deterioration of brain function in later life. But merely knowing that a person is (a) advanced in age, and (b) experiencing difficulty learning new things, does not justify concluding that person's conscious choices are to blame. How can you dismiss the possibility of forces beyond their control – bad dietary options, bad education options, bad genetic inheritance, bad luck generally – as causing their situation? You cannot reasonably dismiss those factors beyond their control. So no, I'd say it is not acceptable to draw the general conclusion that people's own choices are entirely responsible for how much decline in learning ability they experience. > Oh, and I think it's also a choice whether you are stupid or not, > barring physical abnormalities of the brain. Regardless of age, gender > or race. Well, all deterioration of brain function is in some sense due to “physical abnormalities of the brain”, because normal brain function is healthy by definition. A surprising – and uncomfortably fuzzy-bordered – amount of people's current personality is due to the state of their brain, beyond their conscious control, today and in their past. That control is only ever partial, in varying degrees. An honest response to that fact is to apportion responsibility only for those choices we know the person has control over, to the extent they actually have that control. To people who experience a decline in learning ability as they age, I say: Welcome here, and please keep learning at your own speed. -- \“You don't change the world by placidly finding your bliss — | `\you do it by focusing your discontent in productive ways.” | _o__) —Paul Z. Myers, 2011-08-31 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/19/2017 01:56 PM, Ben Finney wrote: > Rurpy via Python-list writes: > >> I don't think stupid black people or senile old people should be >> allowable because those are not choosable *behaviors*. But is >> unable-to-learn old people a choosable behavior? You said that's ok. > > No, I didn't say that's okay, and I'm not aware of Chris saying it. You and Chris refused to find any fault with the use of the two stereotypes under discussion one of which was "unable-to-learn old people". You defended a poster's use of those stereotypes. That is fairly described as "being ok with". > At this point you've been reading far too much into what isn't there, > and now you're just flatly stating untruths. Per above it was not an untruth and you are flatly stating an untruth by claiming it was. >> Again, I'd really appreciate it if you could clarify. > > Bigotry against people for innate traits is not okay.' That's not clarifying, that's repeating. I asked some specific questions that you are not answering, for example, which of the stereotypes in the list I gave are you ok with and which are you not? Nor is your criteria a very useful given that for many "traits" there is not widespread scientific consensus on whether they are innate (genetic?), cultural, or consciously adopted. The boundary between cultural and conscious is also very fuzzy. > Demanding special respect for a class of ideas is not okay. People are not distinct from their ideas. People internalize ideas and their ideas form part of their identity. When deeply held, we tend to call them beliefs rather than ideas. Thus disrespecting or attacking some ideas is tantamount to attacking the person, at least in the person's view if not your's. This is why you cannot create a forum where no offense is given to anyone. The best you can try to do is try to find some tradeoff that balances freedom of expression and offense. Using stereotypes greatly increases the likelihood of offense. I gave a number of reasons why previously and which I refer you back to. [*1] One particular one I'll reiterate: it doesn't help to say "I mean only the bad ones", the stereotype WILL get applied far beyond the scope you may intend. When you say "ugly americans", the "americans" part creates an implicit contrast with other nationalities and implies that somehow americans are more ugly than people of other nationalities. Yet you have no real evidence of that. There does not even exist a definition of uglinesss in a quantitative sense let alone any metrics of the number of uglies of any nationality.[*2] So you accuse millions of people of an offense with nothing to back it up other than some generalized (and informed by bias) feelings it is true. Given that most americans, like people of any other nationality, don't see themselves as ugly, you offend a large number of people some of whom will dispute your claim. Do you want that discussion on the Python list? This is also why I drew the parallel to the African-American criminal stereotype which, at least in the US, is widely recognized as racist and harmful the entire African-American community even though there are some (disputed) statistics defenders of the stereotype can resort to. In your case, you don't even have that. Now I'm the one who is starting to repeat things so I will leave it at that. > Wringing your own impression out of people's words, and then claiming > that's what they said, is not okay. We've established above that that did not happen. > I hope that clarifies. No, sorry. [*1] https://mail.python.org/pipermail/python-list/2017-April/721281.html [*2] I am sure there is research that addresses this issue but I doubt there is widespread consensus on its consistency or applicability. Regardless, research is seldom used validly in the employment of stereotypes and even less so in the understanding of the stereotype by the recipients. -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/19/2017 05:11 PM, breamore...@gmail.com wrote: This is getting ludicrous. Ben has been using these signatures for years and nobody has said a word. Just because it was challenged before does not mean it was, or is, right / courteous / respectful . Why is it that somebody deliberately starts a thread to cause trouble when there is nothing at all to discuss, the > moderators leap in Do you mean me? Because I'm not wearing my moderator hat. but when people like the RUE keep spewing their crap it takes years to get something done? I wasn't a moderator then, and the other moderators for this list (there are three or four of us) are more tolerant. Please don't give me the nonsense about "the RUE wasn't directly attacking anybody". He was attacking the entire > community with his highly insulting dross, and especially the person responsible for writing PEP 393 and its > inplementation. I agree. I think I even wrote to the moderators about the RUE a couple times. > By the way he's still at it. Not on the Python List he isn't*. The moderators have no control over the usenet portion, so if that's where you get your posts from then you'll still see him. And as a general bulletin: If you have an issue you want the moderators to know about, the email address to use is python-list@python.org with a "-owner" after the "python-list" part. -- ~Ethan~ *At least, I haven't seen the RUE lately -- let us know if he's back at it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
Ethan Furman writes: > Will you be filtering your signature lines, then? Because you cannot > simultaneously be courteous to someone and mock their beliefs. I disagree. Beliefs are courteously mocked in this forum every week, and the forum and this community is healthier for that. -- \ “Actually I made up the term “object-oriented”, and I can tell | `\you I did not have C++ in mind.” —Alan Kay, creator of | _o__)Smalltalk, at OOPSLA 1997 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How to obtain an up-to-date document of tkinter
On Thursday, April 20, 2017 at 1:09:45 AM UTC+1, Mok-Kong Shen wrote: > How could one obtain an up-to-date document of tkinter. I ask this > question because apparently there are stuffs of tkinter that > worked in Python 3.5 but no longer in Python 3.6.1. > > M. K. Shen https://docs.python.org/3/library/tkinter.html Can you please state what worked in 3.5 but doesn't in 3.6? Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On Thursday, April 20, 2017 at 12:41:58 AM UTC+1, Ethan Furman wrote: > On 04/19/2017 03:58 PM, Ben Finney wrote: > > Ethan Furman writes: > > > >> […] asking that you be courteous to those who come here to discuss > >> Python. > > > > On that we can agree. Let's be courteous to people here, and keep > > discussing Python. > > Will you be filtering your signature lines, then? Because you cannot > simultaneously be courteous to someone and mock > their beliefs. > > -- > ~Ethan~ This is getting ludicrous. Ben has been using these signatures for years and nobody has said a word. Why is it that somebody deliberately starts a thread to cause trouble when there is nothing at all to discuss, the moderators leap in, but when people like the RUE keep spewing their crap it takes years to get something done? Please don't give me the nonsense about "the RUE wasn't directly attacking anybody". He was attacking the entire community with his highly insulting dross, and especially the person responsible for writing PEP 393 and its inplementation. By the way he's still at it. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
RE: Bigotry (you win, I give up)
> Rupee via Python-list writes: > > > I don't think stupid black people or senile old people should be > > allowable because those are not choosable *behaviors*. But is > > unable-to-learn old people a choosable behavior? You said that's ok. I've mostly been ignoring this thread and its predecessors, and I probably won't read all the recent posts to it. But this bit caught my eye because I hold the opposite opinion about old people's ability to learn. It is a choice. Your noggin doesn't just conk out at a certain age, or stage in the aging process. There are plenty of examples of scholars and authors (and many others) who've kept their wits sharp and their minds fully functional. Some till the day they died, others didn't quite last the whole way. There's two paths to keeping the mind forever alive ("forever" meaning at least till death, we don't know what comes after that). Both are almost purely physical. One is to use the mind all one's life, and the principle is identical to "use it or lose it", more commonly heard in athletic circles. But the mind is like muscle, the more you use it the stronger it gets. And vice versa. And I'm living proof that if you use your mind hard all your life (since I was about 3, in my case), you can let it coast for at least a decade and it will still be there, and it can still learn. Of course there's a lengthy stage of bringing it out of mothballs, but it can be done. The other path I'm living proof of is the food you eat. The brain responds badly to chemicals that enter the body, and particularly ones you ingest in food. And the brain is blood thirsty. It particularly craves grassfed and pastured red meat, the rarer the better, and organ meats. I eat all forms of it, but the prize goes to wild red meats - antelope, venison & wild boar. I'll spare you all the reasons why and the evidence, but they are very good reasons. I've also had university math and science professors who swore by heavy daily exercise regimes, but I haven't done it and neither have aged scholars who still had their good minds very late in life, so rigorous exercise is not a requirement. I have no idea whether it's sufficient to sustain and grow the mind either, but no doubt it helps. So, it is a choice of how you live your life, and how important it is to you to have a mind worth keeping. I see no reason to accord those people who didn't care all their lives any special status. Oh, and I think it's also a choice whether you are stupid or not, barring physical abnormalities of the brain. Regardless of age, gender or race. -- https://mail.python.org/mailman/listinfo/python-list
How to obtain an up-to-date document of tkinter
How could one obtain an up-to-date document of tkinter. I ask this question because apparently there are stuffs of tkinter that worked in Python 3.5 but no longer in Python 3.6.1. M. K. Shen -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/19/2017 03:58 PM, Ben Finney wrote: Ethan Furman writes: […] asking that you be courteous to those who come here to discuss Python. On that we can agree. Let's be courteous to people here, and keep discussing Python. Will you be filtering your signature lines, then? Because you cannot simultaneously be courteous to someone and mock their beliefs. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
Ethan Furman writes: > […] asking that you be courteous to those who come here to discuss > Python. On that we can agree. Let's be courteous to people here, and keep discussing Python. -- \“Pinky, are you pondering what I'm pondering?” “Wuh, I think | `\ so, Brain, but burlap chafes me so.” —_Pinky and The Brain_ | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Data exchange between python script and bash script
[Disclaimer: I have not fully read this thread. If I'm jumping in with something that's irrelevant for other reasons, please just ignore me] On 19/04/17 22:06, Venkatachalam Srinivasan wrote: On Thursday, April 6, 2017 at 12:55:41 AM UTC+2, Gregory Ewing wrote: sensor_data=$(python execute_sensor_process.py) & I understand your point. But the issue is, I need both the program to be executed continuously. That is one module to control the robot and another module to locate the robot. The location data from one module is required by the other module for the entire execution. If that is the *only* input to the main loop in the bash script, then you can do something like: python execute_sensor_process.py | while read sensor_data do echo "I have sensor data:" $sensor_data done If you have another main loop and you just want to sample the sensor data periodically within that loop, then I'm not being very helpful ;) E. -- https://mail.python.org/mailman/listinfo/python-list
Re: Data exchange between python script and bash script
On Thursday, April 6, 2017 at 12:55:41 AM UTC+2, Gregory Ewing wrote: > Anssi Saari wrote: > > Bash manual explicitly states command substition (the $(...) structure) > > replaces the command with the standard *output* of the command. > > Another problem is your use of '&' here: > > sensor_data=$(python execute_sensor_process.py) & > > The '&' causes the whole command, including the variable > assignment, to be executed in a subshell. So the variable > is only bound in the subshell process and won't be seen > from the main shell process. > > Running the command in the background here is pointless, > since if the shell script needs the variable value for > subsequent processing it will have to wait for the > command to finish. So just get rid of the '&'. > > -- > Greg Hi, I understand your point. But the issue is, I need both the program to be executed continuously. That is one module to control the robot and another module to locate the robot. The location data from one module is required by the other module for the entire execution. And for now, I have solved it by writing the data to a database and read it whenever required. Thanks for your help!!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Data exchange between python script and bash script
On Tuesday, April 4, 2017 at 7:58:56 PM UTC+2, justin walters wrote: > On Tue, Apr 4, 2017 at 10:39 AM, Venkatachalam Srinivasan < > venkatachalam...@gmail.com> wrote: > > > Hi, > > > > Thanks for the answer. I need bash for connecting data exchange between > > two python scripts. To be more specific, data from one script has to be > > passed to the another script. You are right, I don't need the data in the > > bash other than to pass the obtained data to the another script which uses > > the data for further analysis. > > > > Regarding using the json file, I am new to this. A naive question is that > > if the data is too large then is json file is easy to handle? Is json file > > for large data is not computationally expensive? I am not using textfile > > for the same reason of being computationally expensive. > > > > Thanks, > > Venkatachalam Srinivasan > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > It could be expensive to create a dictionary from the json file depending > on the amount of data. > > Alternatively, you could use a Unix socket to transmit the data between > processes > if you're on a linux or OSx machine. This is probably the best option as > you can send the dictionary > object itself. This would eliminate the need for the bash script entirely. > The first script builds the > dictionary object and sends it to the socket. The second script is > listening on the socket and receives > the dictionary object. Python's standard library has built in support for > unix sockets. This means you > can actually run two parallel Python instances and communicate between > them. Assuming that > the first script can build the dictionaries before the second script is > done processing them, you will > probably need some kind of task queue. Celery: http://www.celeryproject.org/ > tends to be a good solution > for this problem. In fact, Celery is probably the simplest option now that > I think about it. > > Another alternative is using a SQLite database which Python has built in > support for. Should be > a bit faster and less memory-intensive. Hi, Thank you for a clearer explanation. I tried with sqlite and now it seems to work fine. Yet, we have to check with the real time system which may pose some problems to the amount of data (I guess). So, until now everything is fine on this. Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Data exchange between python script and bash script
On Wednesday, April 5, 2017 at 2:38:00 PM UTC+2, Anssi Saari wrote: > venkatachalam...@gmail.com writes: > > > For example, the data is printed in > > execute_sensor_process.py as follows: > > > > print >>sys.stderr,sens_data > > > > By printing the data onto sys.stderr and assigning a return variable in the > > bash, I am expecting the data to be assigned. > > > > But this is not happening. > > This part I can answer alhtough I'm not sure it helps with your actual > problems. > > Bash manual explicitly states command substition (the $(...) structure) > replaces the command with the standard *output* of the command. So since > your Python program writes to standard error, you get nothing. Hi, I understand your point. I tried by printing the standard output, but the result was the same. The output of one module is not captured in the bash script using the $(...) operation. So, I have switched to other possibilities of storing the data and accessing it from other program. Thanks for your suggestion. -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/19/2017 01:36 PM, Erik wrote: On 19/04/17 21:25, Ethan Furman wrote: Asking that you not denigrate non-Python ideas on the Python list is not asking for "special respect", I have no idea what you just said! :D Yeah, I try to avoid negative checks in code. How about this? special_respect = False be_courteous = True ideas = [ ('socio-economic', 'capitalism rules!'), ('spiritual', 'religion rules!'), ('political', 'left-wing rules!'), ('python', 'spaces rule!'), ] for area, opinion in ideas: if area != 'python' and be_courteous: continue else: print(opinion) print('non-Python ideas/opinions easily omitted without Special Respect!') -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 19/04/17 21:25, Ethan Furman wrote: Asking that you not denigrate non-Python ideas on the Python list is not asking for "special respect", I have no idea what you just said! :D This is why I dislike code such as: if not no_results(data) != not_valid: pass ... and I've seen lots of that sort of thing (but mostly not in Python code, thankfully). E. -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/19/2017 12:56 PM, Ben Finney wrote: Demanding special respect for a class of ideas is not okay. Asking that you not denigrate non-Python ideas on the Python list is not asking for "special respect", it is asking that you be courteous to those who come here to discuss Python. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
Rurpy via Python-list writes: > I don't think stupid black people or senile old people should be > allowable because those are not choosable *behaviors*. But is > unable-to-learn old people a choosable behavior? You said that's ok. No, I didn't say that's okay, and I'm not aware of Chris saying it. At this point you've been reading far too much into what isn't there, and now you're just flatly stating untruths. > Again, I'd really appreciate it if you could clarify. Bigotry against people for innate traits is not okay. Demanding special respect for a class of ideas is not okay. Wringing your own impression out of people's words, and then claiming that's what they said, is not okay. I hope that clarifies. -- \“It's all in the mind, you know.” —The Goon Show | `\ | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: match.groupdict() into a single dict
On 2017-04-19 14:26, Ganesh Pal wrote: Hello friends, I am learning regex and trying to use this to my scripts I need some suggestion on the below code. I need to match all lines of a file that have a specific pattern and return them as a dictionary. Sample line: 'NODE=ADAM-11: | TIME=2017-04-14T05:27:16-07:00 | COND=Some lovely message | MSG=attempt to record { addr=1,0,17080320:8192 action=xxhello-hell o owner=1:0070:001a::HEAD }, but history information has a different owner: owner: 1:0064:0005::HEAD, actions (new->old): { hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, hello-h ello * 1, none } bh hello_cookie: 8:hello-only bhv | LINSNAP=None | MAP=none with open("/tmp/2.repo","r") as f: for line in f: result = re.search(r'MSG=attempt to record(.*)LINSNAP', line) if result: pdb.set_trace() for pattern in [ r'(?P(\d+,\d+,\d+:\d+))', r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', ]: regex = re.compile(pattern) match = regex.search(line) print ' ', match.groupdict() sample o/p: {'Block': '1,0,17080320:8192'} {'p_owner': '1:0070:001a::HEAD'} {'a_owner': 'owner: 1:0064:0005::HEAD'} Questions 1. I was expecting a single dictionary with all matches every a line , something like below {'Block': '1,0,17080320:8192', 'p_owner': '1:0070:001a::HEAD','a_owner': 'owner: 1:0064:0005::HEAD'} (a) I am thinking to add these element {'Block': '1,0,17080320:8192'} , {'p_owner': '1:0070:001a::HEAD'} ... etc to new dictionary (b) or some better regex may be the for loop is not needed and complied pattern can be better. I am a Linux user and on Python 2.7 , Thanks in advance :) Why would you expect a single dictionary? You're doing 3 separate matches! You could just combine the patterns as alternatives: # The alternatives are matched repeatedly. The final '.' alternative # will consume a character if none of the previous subpatterns match, # ready for the next repeat. subpatterns = [r'(?P(\d+,\d+,\d+:\d+))', r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', '.'] pattern = '(%s)*' % '|'.join(subpatterns) match = re.search(pattern, line) print ' ', match.groupdict() -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On 19/04/2017 17:23, Marko Rauhamaa wrote: bartc : Enough works in that 'pcc' project, in terms of file i/o, that it can still run plenty of useful programs, such as compilers. This might have come up before, but do you have a language specification somewhere? (Nothing formal nor up-to-date. (In the absence of other users, or enough people using programs written in it in used by others, then it is easy for the project to be volatile. Previous, simpler versions I used in the 90s, which were part of a graphics app, /were/ used by others, both the language and the programs I and they wrote. So it had to be more stable. It even had a 350-page manual, created with the same graphics app of course.) I'll try and throw something together, because it could do with it.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry (you win, I give up)
On 04/18/2017 04:34 PM, Chris Angelico wrote: > On Wed, Apr 19, 2017 at 8:28 AM, Ben Finney > wrote: >> Chris Angelico writes: >> >>> The charge has been examined and dropped. Steven did not violate the >>> CoC. Please stop talking as if he has. He *was accused of* violating >>> it, and then found innocent. >> >> Which post are you referring to (can you provide a URL)? I'd like to see >> who came to that conclusion, what their wording was, and what their >> authority was to do so. > > I was referring to your post, in which a fairly solid argument was > made for there being no guilt. Maybe you don't have any specific > authority, but until someone actually acts in a moderatorial role, > solid arguments are plenty authoritative enough for most of us. > Particularly for the newsgroup people, where there is no central > authority at all. Hey Ben and Chris, Forget that last post of mine. On thinking things over I can see now the "judgment" that has been made by your solid arguments and the weakness of my counter arguments. I'm ready to accede to your judgment and I hope you bear me no grudge because oue my failure to see your point immediately. But I am still a little unclear on a couple things which I humbly request you straighten me out on... Is it only the two stereotypes that were discussed, "ugly americans" and "too old to learn" old people that are acceptable? Or are any stereotypes ok? We all know that Jews stick together and accumulate lots of money. (Not all of them of course, maybe not even a majority or plurality of them, I just mean just the ones that fit the stereotype.) Can I use that stereotype? And obviously not to attack or criticize Jews, I would never do that because I am not a bigot. I mean, use it only to point out objectionable behavior like avarice to someone. It's now ok if I call him a "greedy Jew", yes? (And only if he is acting/speaking like one! I know this is not a carte blanche to hurl around ethnic slurs.) Of course there are many, many more stereotypes than just those so if you could give us an idea how to decide which stereotypes are ok and which aren't, I'd really appreciate it. Maybe you could make a list and post it here? This is only scratching the surface but maybe you could use it as a start? culturally insensitive americans rude french people money-hungry jews terrorist moslems criminal or stupid black people unable-to-learn old people senile old people math, science and programming-inept women emotional women racist conservatives racist misogynist violent Trump supporters silly emotion-driven liberals rapist immigrants weak-willed fat people egotistical narcissistic buff people japanese people with bad teeth backward anti-science catholics dirty chinese people I don't think stupid black people or senile old people should be allowable because those are not choosable *behaviors*. But is unable-to-learn old people a choosable behavior? You said that's ok. And emotional women, that's a tough one. Are they emotional because of choice or hormones? Also, I'm assuming we can all use stereotypes now but maybe that's wrong. Could it be that only Steven is allowed to use them? Or Steven, Ben, Chris and some other thought-leaders of this group? Or maybe it's only people who have been members for a certain length of time or a certain number of posts? Again, I'd really appreciate it if you could clarify. I apologize for all the questions and sorry for sounding like a silly emotion-driven liberal before! -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
bartc : > Enough works in that 'pcc' project, in terms of file i/o, that it can > still run plenty of useful programs, such as compilers. This might have come up before, but do you have a language specification somewhere? Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Bigotry and hate speech on the python mailing list
On 04/18/2017 04:34 PM, Chris Angelico wrote: > On Wed, Apr 19, 2017 at 8:28 AM, Ben Finney > wrote: >> Chris Angelico writes: >> >>> The charge has been examined and dropped. Steven did not violate the >>> CoC. Please stop talking as if he has. He *was accused of* violating >>> it, and then found innocent. >> >> Which post are you referring to (can you provide a URL)? I'd like to see >> who came to that conclusion, what their wording was, and what their >> authority was to do so. > > I was referring to your post, in which a fairly solid argument was > made for there being no guilt. Maybe you don't have any specific > authority, but until someone actually acts in a moderatorial role, > solid arguments are plenty authoritative enough for most of us. > Particularly for the newsgroup people, where there is no central > authority at all. Perhaps you missed this rebuttal to Mr. Finney's "solid" argument? https://mail.python.org/pipermail/python-list/2017-April/721281.html Perhaps you also failed to notice that neither Mr. Finney nor you chose to dispute that rebuttal? Denial: a person is faced with a fact that is too uncomfortable to accept and rejects it instead, insisting that it is not true despite what may be overwhelming evidence. [*2] Not saying I presented /overwhelming/ evidence but to simply wave it away and pretend it doesn't exist? To simply declare, we prevailed? Mr, Finney made *one* argument: that comparing someone's behavior to the ugly american stereotype is not bigotry because a stereotype represents only people that exhibit the same deservedly criticizable behavior. I showed that was faulty in multiple ways. In your own words: "go read it." I get your acceptance of the ugly american stereotype. After all, we all have prejudices (liberals too [*2]) so it's understandable in these post-Trump times that we might be blind to our own prejudice when it comes to America bashing or closely related Trump bashing, especially when surrounded by like-minded people. But when someone attacks a poster's opinion, that some recent additions to Python might be a detriment to readability, by suggesting he is too old to understand them, with no consideration of any other explanations?! That's no different than disagreeing with someone who says drug jail sentences are too long, with: you sound like one of those black drug-dealers. And you both think that's ok?! I'm aghast. Go right ahead and judge yourself and Steven within the CoC. I don't accept that "judgment" any more than I accept former Alabama Governor George Wallace's defense of segregation. [*1] https://en.wikipedia.org/wiki/Denial [*2] https://www.psychologicalscience.org/news/releases/politics-and-prejudice-insights-from-psychological-science.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On 19/04/2017 15:35, Chris Angelico wrote: On Wed, Apr 19, 2017 at 11:46 PM, bartc wrote: You'd be surprised how easy it is to be non-OS-neutral. I misread that as 'easy to be OS-neutral'. If I turn it around, you're saying it is easy to be OS-specific. But we know that! And that is the problem. It's not so simple. By OS-neutral I mean code that doesn't depend on special features of either OS (Ie. Windows and Linux). Not conditional code that does either Windows stuff or Linux stuff. Which means, therefore, that you either can't have any file system facilities, or must transparently expose them to the application. You also will have a lot of trouble making cross-platform subprocess functionality. Even sockets, which are notionally the same on all platforms, have a lot of little differences. To be truly OS-neutral, you basically have to be either nerfed to nothing, or so thin you're doing nothing. Enough works in that 'pcc' project, in terms of file i/o, that it can still run plenty of useful programs, such as compilers. (See from line 3357 of pcc64.c for example; a list of functions that are patched in to the host rather linked to an external msvcrt or libc.so shared library.) In this project, the only OS-specifics it really needs are: Windows: use LoadLibrary/GetProcAddr, and msvcrt.dll Linux: use dlopen/dlsym, and libc.so.6 which wouldn't be hard to arrange. Any other specifics are in the domain of the user programs (different libraries for screen i/o for example). However, getting it to choose between one of those two pairs of functions is trivial, compared with the dependencies of a a typical open source project. (I've just downloaded CPython sources from your github link, and the first thing I see is an 18,000 line 'configure' script (somewhat bigger than my entire C compiler). This doesn't run on Windows, not without importing most of Linux via cygwin or MSYS. But the sources do now appear to support a Windows build: Step 1: Download Visual Studio Express 2015 Last time I looked, it seemed to be a 5GB to 11GB download (GB not MB!). Nevertheless I start the process to get a better idea. It says: "Visual Studio requires .NET Framework 4.6 or higher." Here where I start to think it might be easier to download all the Linux stuff after all! As, with my track record, I could download tons of stuff, and it still won't work. FWIW, my mcc64.c file compiles to a 0.2MB executable which is capable of compiling that pcc64.c interpreter (I think it does it in 50msec for good measure; Tiny C will also do it instantly). /That/ is how simple things should be, and can be. Cue a million excuses for why things have to be the way they are...) -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On Wed, Apr 19, 2017 at 11:46 PM, bartc wrote: >> You'd be surprised how easy it is to be non-OS-neutral. > > It's not so simple. By OS-neutral I mean code that doesn't depend on special > features of either OS (Ie. Windows and Linux). Not conditional code that > does either Windows stuff or Linux stuff. > Which means, therefore, that you either can't have any file system facilities, or must transparently expose them to the application. You also will have a lot of trouble making cross-platform subprocess functionality. Even sockets, which are notionally the same on all platforms, have a lot of little differences. To be truly OS-neutral, you basically have to be either nerfed to nothing, or so thin you're doing nothing. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On 19/04/2017 12:27, Chris Angelico wrote: On Wed, Apr 19, 2017 at 8:33 PM, bartc wrote: [Warning: this is nothing to do with Python.] My interpreter is on github as /one/ C source file (a link would be inappropriate here). People can compile it with -O3 or -O2 if they wish. It's a bit simpler than building CPython, and OS-neutral; that was deliberate. Then send me a link, and I'll try to compile it. You'd be surprised how easy it is to be non-OS-neutral. Have you compiled it on the three major platforms of today (Lin/Win/Mac)? It should work on Windows and Linux, but I've only tested with gcc and Tiny C recently. I don't have a Mac. The original link was for 32-bits, as that tended to be faster, but I've redone versions for both: click on either pcc32.c or pcc64.c here (and do what you have to do to download to your machine): https://github.com/bartg/langs/tree/master/qlang Build instructions are in the sources, but are basically just: gcc pcc64.c -opcc -lm Test using: ./pcc hello # .q is assumed I provide hello.q, or you can key it in; create a file hello.q with: proc start = println "Hello, World" end To test on something bigger, download mc.qa (a composite of 27 .q files), and try that: ./pcc mc.qa (mc.qa is an entire compiler for my static language; it should (byte-code) compile instantly then give usage instructions. To try it, copy hello.q to hello.m - the two languages conveniently have the same syntax - then try: ./pcc mc.qa hello # defaults to .asm output I think ./pcc mc.qa /c64 hello # hello.m to hello.c I think it took 10ms to compile the 23Kloc of mc.qa to byte-code on my current machine.) If you want another example of a trivial-to-build project, try: https://github.com/bartg/langs/blob/master/bccproj/mcc64.c This is my C compiler in one source file (although not finished). Also OS-neutral (to run; however generated code runs on Win64). This is how I wish other people would distributed their open source projects! > You'd be surprised how easy it is to be non-OS-neutral. It's not so simple. By OS-neutral I mean code that doesn't depend on special features of either OS (Ie. Windows and Linux). Not conditional code that does either Windows stuff or Linux stuff. This means the 'pcc' program above is restricted (it needs either LoadLibrary/GetProcAddr or dlopen/dlsym to be able to access external libraries, although essential functions are patched in). -- bartc -- https://mail.python.org/mailman/listinfo/python-list
match.groupdict() into a single dict
Hello friends, I am learning regex and trying to use this to my scripts I need some suggestion on the below code. I need to match all lines of a file that have a specific pattern and return them as a dictionary. Sample line: 'NODE=ADAM-11: | TIME=2017-04-14T05:27:16-07:00 | COND=Some lovely message | MSG=attempt to record { addr=1,0,17080320:8192 action=xxhello-hell o owner=1:0070:001a::HEAD }, but history information has a different owner: owner: 1:0064:0005::HEAD, actions (new->old): { hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, none, hello-hello * 1, none, hello-h ello * 1, none } bh hello_cookie: 8:hello-only bhv | LINSNAP=None | MAP=none with open("/tmp/2.repo","r") as f: for line in f: result = re.search(r'MSG=attempt to record(.*)LINSNAP', line) if result: pdb.set_trace() for pattern in [ r'(?P(\d+,\d+,\d+:\d+))', r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))', ]: regex = re.compile(pattern) match = regex.search(line) print ' ', match.groupdict() sample o/p: {'Block': '1,0,17080320:8192'} {'p_owner': '1:0070:001a::HEAD'} {'a_owner': 'owner: 1:0064:0005::HEAD'} Questions 1. I was expecting a single dictionary with all matches every a line , something like below {'Block': '1,0,17080320:8192', 'p_owner': '1:0070:001a::HEAD','a_owner': 'owner: 1:0064:0005::HEAD'} (a) I am thinking to add these element {'Block': '1,0,17080320:8192'} , {'p_owner': '1:0070:001a::HEAD'} ... etc to new dictionary (b) or some better regex may be the for loop is not needed and complied pattern can be better. I am a Linux user and on Python 2.7 , Thanks in advance :) Regards, Ganesh -- https://mail.python.org/mailman/listinfo/python-list
Re: Looping [was Re: Python and the need for speed]
Op 16-04-17 om 19:07 schreef Terry Reedy: > On 4/16/2017 11:35 AM, Michael Torrie wrote: >> On 04/16/2017 07:57 AM, bartc wrote: >>> But people just don't want it. >>> >>> /That/ is what surprises me, when people reject things that to me are >>> no-brainers. > > Whereas to me, it is a no-brainer that we are better off *without* > multiple while/loop constructs. > >> I simply don't care about these missing loop constructs. > > I do ;-) I consider the current simplicity a feature. > > > Python works >> great for what I use it for, and apparently works well for many people. > > The great majority* of 'repetition with variation' is sequentially > processing items from a collection. Python does that nicely with 'for > item in collection: process(item)'. While-loops take care of > everthing else. Not really, unless you count on the break statement. But if you count on that, you don't even need a while, you can start a for loop with a generator that never stops and use breaks. There was a time something like the following was seriously considered for introduction in the language. do part1 while condition: part2 which would be equivalent to the following: while True: part1 if not condition: break part2 But suddenly this was no longer considered. I still wish they had followed through. I think such a construct comes up often enough, to have such a loop construct. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
Chris Angelico : > On Wed, Apr 19, 2017 at 8:33 PM, bartc wrote: > You'd be surprised how easy it is to be non-OS-neutral. Have you > compiled it on the three major platforms of today (Lin/Win/Mac)? Generally, I don't try to be OS-neutral because 1. I need it for Linux only 2. I don't have Windows and Mac machines to test stuff on 3. Windows and Linux are completely different system-programming-wise Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On Wed, Apr 19, 2017 at 8:33 PM, bartc wrote: > My interpreter is on github as /one/ C source file (a link would be > inappropriate here). People can compile it with -O3 or -O2 if they wish. > It's a bit simpler than building CPython, and OS-neutral; that was > deliberate. Then send me a link, and I'll try to compile it. You'd be surprised how easy it is to be non-OS-neutral. Have you compiled it on the three major platforms of today (Lin/Win/Mac)? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and the need for speed
On 19/04/2017 01:07, Erik wrote: On 19/04/17 00:33, bartc wrote: [Talking about an interpreter that is /not/ for Python] With the sort of lower level programs I write (in another dynamic language not Python), such an assembly layer improved performance 2-3 times over using 100% HLL compiled using C and gcc-O3. Did you give the C compiler enough hints though? If writing native C then I can spend a lot of time tweaking different things, and probably I could get a worthwhile improvement. But I doubt it would be double the speed. But I anyway generate the C code from another language and I don't want it tied to a particular compiler or be full of specific pragmas and such, unless necessary. I don't need to because I can always bring out the asm version! [However that only works on Win64 platform. I use C for portability.] Also, remember that -O3 might (and by that I mean probably will! ;)) make your code larger. If you have some specific core areas of your interpreter that are now large enough to cause instruction cache misses then a smaller -O2 (or even -Os) compiled version might perform better on your hardware. My interpreter is on github as /one/ C source file (a link would be inappropriate here). People can compile it with -O3 or -O2 if they wish. It's a bit simpler than building CPython, and OS-neutral; that was deliberate. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list
EuroPython 2017: Discounted flights available
This year the Lufthansa group is our preferred airline for EuroPython. The co-operation provides a 5-10% discount for flights to the conference going to Bologna and Florence. *** https://ep2017.europython.eu/en/location/come-to-rimini/ *** Airlines include Lufthansa, Swiss, Austrian, Belgium Airlines and Eurowings. To book a discounted flight please visit https://www.lufthansa.com/de/en/Meetings-and-Events-Delegates and enter the access code ITZJQRN in the “Access to Your Special Lufthansa Offer” area at the bottom. This will open an online booking platform that will automatically calculate the discount offered or provide you with an even better offer if another promotional fare is available. It’s the first time we cooperate with an airline for travel so you can spend more money on ice cream in Rimini. Enjoy, -- EuroPython 2017 Team http://ep2017.europython.eu/ http://www.europython-society.org/ PS: Please forward or retweet to help us reach all interested parties: https://twitter.com/europython/status/854605615590764544 Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Version 2.1 of my natural language text steganography scheme
Version 2.1 of my natural language text steganography scheme WORDLISTTEXTSTEGANOGRAPHY, having left behind a few initial shortcomings and tiny problems stemming e.g from version incompatibilities of Python, is available on my new home page: http://mok-kong-shen.de. M. K. Shen -- https://mail.python.org/mailman/listinfo/python-list