Re: Two variable dictionary comprehension

2017-04-02 Thread Gregory Ewing
Deborah Swanson wrote: Oh, come on. That's a fairly obscure citation in the docs, one that would take a good deal of experience and time reading through them to know was there, You seemed to know that there was something called a "dict comprehension". Googling for "python 3 dict comprehension"

Re: Thread within for loop

2017-04-02 Thread dieter
Iranna Mathapati writes: > How to fix it and now i got below error for same script Fixing "timeout" problems is (usually) not a Python question. A "timeout" can have various reasons: * you make something fundamentally wrong - i.e. try to connect to something which is inaccessible (e.g. by "

Re: Behavior of auto in Enum and Flag.

2017-04-02 Thread Oren Ben-Kiki
While "the current behaviour is compliant with what the docs say" is true, saying "as such, I would be disinclined to change the code" misses the point. The current documentation allows for multiple behaviors. The current implementation has an chosen to add an arbitrary undocumented restriction on

Re: Behavior of auto in Enum and Flag.

2017-04-02 Thread Chris Angelico
On Mon, Apr 3, 2017 at 2:49 PM, Oren Ben-Kiki wrote: > "If the exact value is unimportant you may use auto instances and an > appropriate value will be chosen for you." > > Choosing a value that conflicts with BAZ in above cases doesn't seem > "appropriate" for a value that is "unimportant". > > T

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote. on April 02, 2017 7:41 PM > > "Deborah Swanson" writes: > > > Chris Angelico wrote, on April 02, 2017 6:37 PM > > > > > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > > > > Maybe I'm having another "dumb day" [.] > > > > Well, wouldncha know it, I never tried using a col

Traversal help

2017-04-02 Thread R. Bryan Smith
Hello, I am working with Python 3.6. I’ve been trying to figure out a solution to my question for about 40 hrs with no success and hundreds of failed attempts. Essentially, I have bitten off way more than I can chew with processing this file. Most of what follows, is my attempt to inform as

Behavior of auto in Enum and Flag.

2017-04-02 Thread Oren Ben-Kiki
The current behavior of `auto` is to pick a value which is one plus the previous value. It would probably be better if `auto` instead picked a value that is not used by any named member (either the minimal unused value, or the minimal higher than the previous value). That is, in this simple case:

Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson" writes: > Chris Angelico wrote, on April 02, 2017 6:37 PM > > > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > > > Maybe I'm having another "dumb day" […] > > Well, wouldncha know it, I never tried using a colon. That's what I > get for just trying to guess. Yes, guessi

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote, on April 02, 2017 6:38 PM > > "Deborah Swanson" writes: > > > It seems like this should be easy to rewrite as a dict > comprehension: > > > > records_idx = {} > > for idx, label in enumerate(records[0]): > > records_idx[label] = idx > > How about this:: > >

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Chris Angelico wrote, on April 02, 2017 6:37 PM > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > wrote: > > It seems like this should be easy to rewrite as a dict > comprehension: > > > > records_idx = {} > > for idx, label in enumerate(records[0]): > > records_idx[label]

Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson" writes: > It seems like this should be easy to rewrite as a dict comprehension: > > records_idx = {} > for idx, label in enumerate(records[0]): > records_idx[label] = idx How about this:: records_idx = { label: idx for (idx, label) in enumer

Re: Two variable dictionary comprehension

2017-04-02 Thread Chris Angelico
On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson wrote: > It seems like this should be easy to rewrite as a dict comprehension: > > records_idx = {} > for idx, label in enumerate(records[0]): > records_idx[label] = idx > > Maybe I'm having another "dumb day", or maybe I've just bee

Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
It seems like this should be easy to rewrite as a dict comprehension: records_idx = {} for idx, label in enumerate(records[0]): records_idx[label] = idx Maybe I'm having another "dumb day", or maybe I've just been struggling with this (larger) problem for too long, but eveything I

Re: All people deserve respect. Ideas are not people.

2017-04-02 Thread Michael Torrie
On 04/02/2017 06:00 PM, Alex Kaye wrote: > Michael, Thanks for your comment. > > However, If one derails from the core subject > > they need to be in another stream. Alex I think you'll find that the subject line was changed by Ben Finney to reflect the new direction he was taking it, which is

Re: All people deserve respect. Ideas are not people.

2017-04-02 Thread Michael Torrie
On 04/02/2017 05:10 PM, Ben Finney wrote: > > Ideas are not people, and are not innate to the person who holds them. > An idea is not deserving of respect; that respect must not be assumed, > it must be earned. > > More importantly, ideas inform behaviour. That is what makes robust > criticism of

All people deserve respect. Ideas are not people. (was: Text-mode apps)

2017-04-02 Thread Ben Finney
Terry Reedy writes: > On 4/2/2017 12:26 PM, Steve D'Aprano wrote: > > Not all Americans, perhaps not even a majority or a plurality, are Ugly > > Americans, but there are enough of them to screw it up for everyone else. > > Shall we discuss Ugly Australians, or whatever the appropriate epithet >

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Terry Reedy
On 4/2/2017 1:59 PM, Ganesh Pal wrote: > 'someone' wrote Whenever you feel the urge to write range(len(whatever)) -- resist that temptation, and you'll end up with better Python code ;) Thanks for this suggestion but for my better understanding can explain this further even Steve did point th

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Terry Reedy
On 4/2/2017 12:26 PM, Steve D'Aprano wrote: On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote: On 4/1/2017 12:00 PM, Steve D'Aprano wrote: example of the Ugly American. As an American I resent your promotion and perpetuation of an ugly ethno-centric stereotype. I'm glad you didn't try to des

Re: Temporary variables in list comprehensions

2017-04-02 Thread breamoreboy
On Sunday, April 2, 2017 at 1:08:17 AM UTC+1, Robert L. wrote: > I don't believe in western morality, i.e. don't kill civilians or children > The only way to fight a moral war is the Jewish way: Destroy their holy sites. > Kill men, women, and children (and cattle). --- Rabbi Manis Friedman >

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Gene Heskett
On Sunday 02 April 2017 12:26:40 Steve D'Aprano wrote: > On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote: > > On 4/1/2017 12:00 PM, Steve D'Aprano wrote: > >> example of the Ugly American. > > > > As an American I resent your promotion and perpetuation of an ugly > > ethno-centric stereotype. > > I

Re: Temporary variables in list comprehensions

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

Tcp Socket Receive

2017-04-02 Thread specx
Hello, � I have a tcp server coded with python and my packets include a 2 bytes header which is just the length of the following data. The problem is how can I be sure I received 2 bytes and not just one byte. In Qt, I use bytesAvailable function. However, here I just use sock.recv(2) but it can

Cheetah 3.0.0a1

2017-04-02 Thread Oleg Broytman
Hello! I'm happy to announce I revived development of Cheetah. Unfortunately I have to fork the project. I'm pleased to announce version 3.0.0a1, the first alpha of the upcoming release of branch 3.0 of CheetahTemplate3. What's new in CheetahTemplate3 == Contributors

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
> > > Whenever you feel the urge to write range(len(whatever)) -- resist that > temptation, and you'll end up with better Python code ;) > > Thanks for this suggestion but for my better understanding can explain this further even Steve did point the same mistake. > > Instead of artificially blow

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
On Sun, Apr 2, 2017 at 10:35 PM, Steve D'Aprano wrote: > > Why is payment a string? > > Yes it should be int > > > The value salary3 ,salary4,salary4 is to be generated in the loop . Iam > > trying to optimize the above code , by looping as shown below > > In the above example, you have strings

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Steve D'Aprano
On Mon, 3 Apr 2017 02:13 am, Ganesh Pal wrote: > Dear Python friend > > > I have a nested data dictonary in the below format and I need to store > 1000 of entries which are in teh below format > > X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4", > grade="A",payment="200"

Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Peter Otten
Ganesh Pal wrote: > Dear Python friend > > > I have a nested data dictonary in the below format and I need to store > 1000 of entries which are in teh below format > > X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4", > grade="A",payment="200") X['emp_01']['salary4']

In Python and Windows environment how to supress certain key press and send some other key event for it

2017-04-02 Thread Krishnan Shankar
Hi All, I was trying to build a VIM like shortcuts in windows. For example, IF i press CAPSLOCK & h: It should "{Left}" move one to left. If CAPSLOCK & b: It should "{Ctrl Down}{Left}{Ctrl Up}" move one word left etc. I was successful in sending the key event. I used libraries like, 1. pynput 2

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Steve D'Aprano
On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote: > On 4/1/2017 12:00 PM, Steve D'Aprano wrote: > >> example of the Ugly American. > > As an American I resent your promotion and perpetuation of an ugly > ethno-centric stereotype. I'm glad you didn't try to describe it as a *unfair* or *unjustifie

Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
Dear Python friend I have a nested data dictonary in the below format and I need to store 1000 of entries which are in teh below format >>> X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4", grade="A",payment="200") >>> X['emp_01']['salary4'] = dict(sex="f", status="single", exp

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Chris Angelico
On Sun, Apr 2, 2017 at 9:12 PM, bartc wrote: > But people, when unrestrained, will /always/ want to do something that may > not be practical. For example, why bother with the separate concepts > 'filename' and 'file'; just have the file contents /as/ the filename! If > there are no limits on how l

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread bartc
On 01/04/2017 22:35, Marko Rauhamaa wrote: Chris Angelico : there is no way within Python to have a string that can represent two strings, which is what directory separators do. Really? Try: >>> repr(("a", "b")) "('a', 'b')" There! A string that represents two strings. Note, however,

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Marko Rauhamaa
Christian Gollwitzer : > Am 01.04.17 um 19:38 schrieb Steve D'Aprano: >> Next: convince keyboard manufacturers to move the caret from SHIFT-6 >> to a plain, unshifted key. Buggared if I'm going to hit shift every >> time I want to use an absolute path... > > ...which is reality for a lot more peop

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Christian Gollwitzer
Am 01.04.17 um 19:38 schrieb Steve D'Aprano: ^home^steve^document.txt I'm sure I'd get used to it in a few years... Next: convince keyboard manufacturers to move the caret from SHIFT-6 to a plain, unshifted key. Buggared if I'm going to hit shift every time I want to use an absolute path...

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Chris Angelico
On Sun, Apr 2, 2017 at 4:41 PM, Terry Reedy wrote: > On 4/1/2017 12:00 PM, Steve D'Aprano wrote: > >> example of the Ugly American. > > > As an American I resent your promotion and perpetuation of an ugly > ethno-centric stereotype. There are ugly Americans and there are non-ugly Americans. Rick