Re: for/ if against dict - one liner

2017-11-14 Thread Thomas Jollans
On 2017-11-14 07:29, Stefan Ram wrote: > Andrew Z writes: >> i wonder how do i get the "for" and "if" to work against a dictionary in >> one line? > > dict ={ 1 : "one", 2 : "two", 3 : "three" } > print( *( ( str( key )+ ' ' + str( dict[ key ])) for key in dict if key >= 2 > ), sep='\n' ) > >

Re: from xx import yy (Posting On Python-List Prohibited)

2017-11-14 Thread Lawrence D’Oliveiro
On Monday, November 13, 2017 at 3:18:04 PM UTC+13, bvdp wrote: > I'm having a conceptual mind-fart today. I just modified a bunch > of code to use "from xx import variable" when variable is a global > in xx.py. But, when I change/read 'variable' it doesn't appear to change. 1) Every name in Python

Re: for/ if against dict - one liner

2017-11-14 Thread Vincent Vande Vyvre
Le 14/11/17 à 06:44, Andrew Z a écrit : Hello, i wonder how do i get the "for" and "if" to work against a dictionary in one line? basically i want to "squeeze": dct= [ 1 : "one", 2:"two", 3:"three"] for k, val in dct: if k >= 2: # do magnificent things Thank you AZ Maybe some

Re: for/ if against dict - one liner

2017-11-14 Thread alister via Python-list
On Tue, 14 Nov 2017 00:44:18 -0500, Andrew Z wrote: > Hello, > i wonder how do i get the "for" and "if" to work against a dictionary > in > one line? > > basically i want to "squeeze": > dct= [ 1 : "one", 2:"two", 3:"three"] > for k, val in dct: >if k >= 2: > # do magnificent things

Re: for/ if against dict - one liner

2017-11-14 Thread Thomas Jollans
On 2017-11-14 06:44, Andrew Z wrote: > Hello, > i wonder how do i get the "for" and "if" to work against a dictionary in > one line? > > basically i want to "squeeze": > dct= [ 1 : "one", 2:"two", 3:"three"] > for k, val in dct: Don't you mean dct.items() >if k >= 2: > # do magnific

Re: PySide window does not resize to fit screen

2017-11-14 Thread Heli
Hi Chris and others, I have re-designed my user interface to include layouts and now it fits the screen perfectly. Thanks a lot for all your help on this thread, Best -- https://mail.python.org/mailman/listinfo/python-list

Re: Time travel - how to simplify?

2017-11-14 Thread Ben Finney
Andrew Z writes: > Now i want to get certain number of months. Say, i need 3 months duration > starting from any month in dict. > > so if i start @ 7th: > my_choice =7 > for mnth, value in fut_suffix: > if my_choice >= mnth ># life is great > but if : > my_choice = 12 then my "time

Re: Time travel - how to simplify?

2017-11-14 Thread Ben Finney
Ben Finney writes: > import itertools > > month_values = sorted(list(fut_suffix.keys())) > month_cycle = itertools.cycle(month_values) > > month_choice = 7 > three_months_starting_at_choice = [] > while len(three_months_starting_at_choice) < 3: > this_month = next(

inspecting a callable for the arguments it accepts

2017-11-14 Thread Cameron Simpson
I know that this isn't generally solvable, but I'm wondering if it is partially solvable. I have a task manager which accepts callables, usually functions or generators, and calls them on data items as needed. For reasons which, frankly, suggest user interface ergonomics failure to me it happe

Re: from xx import yy

2017-11-14 Thread Cameron Simpson
On 13Nov2017 08:58, bvdp wrote: On Sunday, November 12, 2017 at 7:18:04 PM UTC-7, bvdp wrote: I'm having a conceptual mind-fart today. I just modified a bunch of code to use "from xx import variable" when variable is a global in xx.py. But, when I change/read 'variable' it doesn't appear to c

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Chris Angelico
On Wed, Nov 15, 2017 at 8:05 AM, Cameron Simpson wrote: > I know that this isn't generally solvable, but I'm wondering if it is > partially solvable. > > I have a task manager which accepts callables, usually functions or > generators, and calls them on data items as needed. For reasons which, > f

Re: Windows10 keyboard interupt

2017-11-14 Thread Lawrence D’Oliveiro
On Wednesday, November 15, 2017 at 3:01:37 AM UTC+13, Kasper Jepsen wrote: > Forgot.. python 2.7 -- https://mail.python.org/mailman/listinfo/python-list

Re: Time travel - how to simplify?

2017-11-14 Thread Rick Johnson
On Tuesday, November 14, 2017 at 1:44:17 PM UTC-6, Ben Finney wrote: > Andrew Z writes: > > > Now i want to get certain number of months. Say, i need 3 months duration > > starting from any month in dict. > > > > so if i start @ 7th: > > my_choice =7 > > for mnth, value in fut_suffix: > > i

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Chris Angelico
On Wed, Nov 15, 2017 at 9:03 AM, Stefan Ram wrote: > Cameron Simpson writes: >>I would like to inspect submitted functions' signatures for suitability at >>submission time, without calling the function. For example to see if this >>function accepts exactly one argument, or to see if it is a gener

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Cameron Simpson
On 15Nov2017 09:12, Chris Angelico wrote: On Wed, Nov 15, 2017 at 8:05 AM, Cameron Simpson wrote: I know that this isn't generally solvable, but I'm wondering if it is partially solvable. I have a task manager which accepts callables, usually functions or generators, and calls them on data it

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Gregory Ewing
Chris Angelico wrote: wants_one_arg.__code__.co_argcount 1 wants_one_arg.__code__.co_varnames ('x',) That will give you some idea, but it's not foolproof -- e.g. if the function has * or ** arguments, it's impossible to tell in general how many arguments it accepts without studying the c

Re: inspecting a callable for the arguments it accepts

2017-11-14 Thread Chris Angelico
On Wed, Nov 15, 2017 at 4:34 PM, Gregory Ewing wrote: > Chris Angelico wrote: > > wants_one_arg.__code__.co_argcount >> >> >> 1 >> > wants_one_arg.__code__.co_varnames >> >> >> ('x',) > > > That will give you some idea, but it's not foolproof -- e.g. > if the function has * or ** arguments