Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-06-01 Thread Peter J. Holzer via Python-list
(Just three words) (Just three words) (Just three words)) Output is often a compromise between readability and precision. > def lispstr(exp): ># "Convert a Python object back into a Lisp-readable string." > if isinstance(exp, list): This won't work for your

Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-05-31 Thread HenHanna via Python-list
;;; Pls tell me about little tricks you use in Python or Lisp. [('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)] ((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that 11252)

Re: Mailing-Lists (pointer)

2023-01-11 Thread Cameron Simpson
On 11Jan2023 19:10, Dieter Maurer wrote: Cameron Simpson wrote at 2023-1-11 08:37 +1100: ... There's a Discourse forum over at discuss.python.org. I use it in "mailing list mode" and do almost all my interactions via email, exactly as I do for python-list. [...] I am also using the Plone `Dis

Re: Mailing-Lists (pointer)

2023-01-11 Thread Dieter Maurer
Cameron Simpson wrote at 2023-1-11 08:37 +1100: > ... >There's a Discourse forum over at discuss.python.org. I use it in >"mailing list mode" and do almost all my interactions via email, exactly >as I do for python-list. Posts come to me and land in the same local >mail folder I use for python-list

Re: Mailing-Lists (pointer)

2023-01-11 Thread Chris Green
Cameron Simpson wrote: > On 10Jan2023 08:45, Chris Green wrote: > >dn wrote: > >> See also the wisdom of enabling comp.lang.python and python-list as > >> 'mirrors', enabling those who prefer one mechanism/client to another, > >> yet maintaining a single 'community'. > >> > >Yes, this is importa

Re: Mailing-Lists (pointer)

2023-01-10 Thread Cameron Simpson
On 10Jan2023 08:45, Chris Green wrote: dn wrote: See also the wisdom of enabling comp.lang.python and python-list as 'mirrors', enabling those who prefer one mechanism/client to another, yet maintaining a single 'community'. Yes, this is important I think. Plus, if possible, if it's decided

Re: Mailing-Lists (pointer)

2023-01-10 Thread Dieter Maurer
Chris Green wrote at 2023-1-10 08:45 +: > ... >Yes, this is important I think. Plus, if possible, if it's decided to >move to a forum format make that accessible by E-Mail. I much prefer a mailing list over an http based service. With mailing lists, all interesting message

Re: Mailing-Lists (pointer)

2023-01-10 Thread Chris Green
dn wrote: [snip] > See also the wisdom of enabling comp.lang.python and python-list as > 'mirrors', enabling those who prefer one mechanism/client to another, > yet maintaining a single 'community'. > Yes, this is important I think. Plus, if possible, if it's decided to move to a forum format

Re: Mailing-Lists (pointer)

2023-01-10 Thread Milan Glacier
On 01/10/23 11:33, dn wrote: On 10/01/2023 08.46, Stefan Ram wrote: If anyone is interested: In "comp.misc", there's a discussion about the use of mailing lists in software development. Subject: An objective criteria for deprecating community platforms (I did not crea

Re: Mailing-Lists (pointer)

2023-01-09 Thread Chris Angelico
On Tue, 10 Jan 2023 at 09:37, dn wrote: > > On 10/01/2023 08.46, Stefan Ram wrote: > >If anyone is interested: In "comp.misc", there's a discussion > > about the use of mailing lists in software development. > >Subject: An objective crite

Re: Mailing-Lists (pointer)

2023-01-09 Thread dn
On 10/01/2023 08.46, Stefan Ram wrote: If anyone is interested: In "comp.misc", there's a discussion about the use of mailing lists in software development. Subject: An objective criteria for deprecating community platforms (I did not create this subject!) (a

Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-04 Thread Paulo da Silva
Às 07:52 de 04/11/22, dn escreveu: On 04/11/2022 07.50, Chris Angelico wrote: On Fri, 4 Nov 2022 at 05:48, Paulo da Silva wrote: Às 05:32 de 03/11/22, Paulo da Silva escreveu: Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! _

Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-04 Thread dn
On 04/11/2022 07.50, Chris Angelico wrote: On Fri, 4 Nov 2022 at 05:48, Paulo da Silva wrote: Às 05:32 de 03/11/22, Paulo da Silva escreveu: Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! ___ class C: def __init__(s

Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-03 Thread Chris Angelico
On Fri, 4 Nov 2022 at 05:48, Paulo da Silva wrote: > > Às 05:32 de 03/11/22, Paulo da Silva escreveu: > > Às 03:24 de 03/11/22, Paulo da Silva escreveu: > >> Hi! > >> > >> And a typing problem again!!! > >> ___ > >> class C: > >> def __init__(self): > >>

Re: typing: property/setter and lists?

2022-11-03 Thread Paulo da Silva
Às 07:55 de 03/11/22, dn escreveu: On 03/11/2022 16.24, Paulo da Silva wrote: class C:  def __init__(self): self.__foos=5*[0]  @property  def foos(self) -> list[int]: return self.__foos  @foos.setter  def foos(self,v: int): self.__foos=[v for __i

Re: typing: property/setter and lists? [RESOLVED]

2022-11-03 Thread Paulo da Silva
Às 18:16 de 03/11/22, Chris Angelico escreveu: On Fri, 4 Nov 2022 at 05:03, Paulo da Silva wrote: Changing def foos(self) -> list[int]: to def foos(self) -> Union[list[int]]: fixes the problem. Not so elegant, however! Wait, what?! Union[X, Y] means "X or Y" Union[X] means "X, but don't

Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-03 Thread Paulo da Silva
Às 05:32 de 03/11/22, Paulo da Silva escreveu: Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! ___ class C:  def __init__(self): self.__foos=5*[0]  @property  def foos(self) -> list[int]: return

Re: typing: property/setter and lists? [RESOLVED]

2022-11-03 Thread Chris Angelico
On Fri, 4 Nov 2022 at 05:03, Paulo da Silva wrote: > Changing def foos(self) -> list[int]: to > def foos(self) -> Union[list[int]]: > fixes the problem. > Not so elegant, however! Wait, what?! Union[X, Y] means "X or Y" Union[X] means "X, but don't complain if it's a @property". Is that how

Re: typing: property/setter and lists? [RESOLVED]

2022-11-03 Thread Paulo da Silva
Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! ___ class C: def __init__(self):     self.__foos=5*[0] @property def foos(self) -> list[int]:     return self.__foos @foos.setter def foos(sel

Re: typing: property/setter and lists?

2022-11-03 Thread Peter Otten
On 03/11/2022 04:24, Paulo da Silva wrote: Hi! And a typing problem again!!! ___ class C: def __init__(self):     self.__foos=5*[0] @property def foos(self) -> list[int]:     return self.__foos @foos.setter def foos(self,v:

Re: typing: property/setter and lists?

2022-11-03 Thread dn
On 03/11/2022 16.24, Paulo da Silva wrote: class C: def __init__(self):     self.__foos=5*[0] @property def foos(self) -> list[int]:     return self.__foos @foos.setter def foos(self,v: int):     self.__foos=[v for __i in self.__foos] c=C() c.foos=5 prin

typing: property/setter and lists?

2022-11-02 Thread Paulo da Silva
Hi! And a typing problem again!!! ___ class C: def __init__(self): self.__foos=5*[0] @property def foos(self) -> list[int]: return self.__foos @foos.setter def foos(self,v: int):

Re: flattening lists

2022-10-12 Thread Antoon Pardon
Op 11/10/2022 om 21:32 schreef SquidBits _: Does anyone else think there should be a flatten () function, which just turns a multi-dimensional list into a one-dimensional list in the order it's in. e.g. [[1,2,3],[4,5,6,7],[8,9]] becomes [1,2,3,4,5,6,7,8,9]. I have had to flatten

Re: flattening lists

2022-10-11 Thread Dan Stromberg
]. > > I have had to flatten lists quite a few times and it's quite tedious to > type out. It feels like this should be something built in to python, anyone > else think this way? > I think the usual argument against putting something like this in the standard library (I hope it wo

Re: flattening lists

2022-10-11 Thread MRAB
On 2022-10-11 21:09, Stefan Ram wrote: r...@zedat.fu-berlin.de (Stefan Ram) writes: . I never understood "yield from" until just now, when I was thinking, "Maybe this could be the piece that fits in here!" PS: If I'm starting to think about it: Having succeeded after using it by trial in

Re: flattening lists

2022-10-11 Thread dn
On 12/10/2022 08.32, SquidBits _ wrote: Does anyone else think there should be a flatten () function, which just turns a multi-dimensional list into a one-dimensional list in the order it's in. e.g. [[1,2,3],[4,5,6,7],[8,9]] becomes [1,2,3,4,5,6,7,8,9]. I have had to flatten lists quite

Re: flattening lists

2022-10-11 Thread Thomas Passin
,[8,9]] becomes [1,2,3,4,5,6,7,8,9]. I have had to flatten lists quite a few times and it's quite tedious to type out. It feels like this should be something built in to python, anyone else think this way? -- https://mail.python.org/mailman/listinfo/python-list

Re: flattening lists

2022-10-11 Thread David Lowry-Duda
ad to flatten lists quite a few times and it's quite tedious to type out. It feels like this should be something built in to python, anyone else think this way? I typically don't mind things that are one liners, especially if the one liner is a list comprehension. def flatten1(inlist)

Re: flattening lists

2022-10-11 Thread Larry Martell
8,9]. > > I have had to flatten lists quite a few times and it's quite tedious to type > out. It feels like this should be something built in to python, anyone else > think this way? x = [[1,2,3],[4,5,6,7],[8,9]] [i for j in x for i in j] [1, 2, 3, 4, 5, 6, 7, 8, 9] -- https:/

flattening lists

2022-10-11 Thread SquidBits _
Does anyone else think there should be a flatten () function, which just turns a multi-dimensional list into a one-dimensional list in the order it's in. e.g. [[1,2,3],[4,5,6,7],[8,9]] becomes [1,2,3,4,5,6,7,8,9]. I have had to flatten lists quite a few times and it's quite tedious to

Re: Timezone jokes (was: All permutations from 2 lists)

2022-03-03 Thread Avi Gross via Python-list
: Chris Angelico To: python-list@python.org Sent: Thu, Mar 3, 2022 12:40 pm Subject: Re: Timezone jokes (was: All permutations from 2 lists) On Fri, 4 Mar 2022 at 03:29, Tim Chase wrote: > > On 2022-03-03 06:27, Grant Edwards wrote: > > On 2022-03-03, Chris Angelico wrote: > > &

Re: Timezone jokes (was: All permutations from 2 lists)

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 03:29, Tim Chase wrote: > > On 2022-03-03 06:27, Grant Edwards wrote: > > On 2022-03-03, Chris Angelico wrote: > > > Awww, I was going to make a really bad joke about timezones :) > > > > As opposed to all the really good jokes about timezones... ;) > > And here I thought yo

Re: All permutations from 2 lists

2022-03-03 Thread Avi Gross via Python-list
Larry, That explanation made more sense and provided context. I fully agree with you that generating the cross product of multiple lists can be messy and large and best avoided. As an example, someone on an R forum presented their version of a way to see what are potential solutions to the

Re: Timezone jokes (was: All permutations from 2 lists)

2022-03-03 Thread Tim Chase
On 2022-03-03 06:27, Grant Edwards wrote: > On 2022-03-03, Chris Angelico wrote: > > Awww, I was going to make a really bad joke about timezones :) > > As opposed to all the really good jokes about timezones... ;) And here I thought you were just Trolling with timezones... https://en.wikipedi

Re: All permutations from 2 lists

2022-03-03 Thread Rob Cliffe via Python-list
need to use to query a mongodb database. When the values in the dict are all scalar I can pass the dict directly into the query, e.g.: self._db_conn[collection_name].find(query). But if any of the values are lists that does not work. I need to query with something like the cross product of all the

Re: All permutations from 2 lists

2022-03-03 Thread Grant Edwards
On 2022-03-03, Chris Angelico wrote: > On Thu, 3 Mar 2022 at 13:05, gene heskett wrote: >> I take it back, kmail5 had decided it was a different thread. My bad, no >> biscuit. >> > > Awww, I was going to make a really bad joke about timezones :) As opposed to all the really good jokes about time

Re: All permutations from 2 lists

2022-03-03 Thread Larry Martell
ry a mongodb database. When the values in the dict are all scalar I can pass the dict directly into the query, e.g.: self._db_conn[collection_name].find(query). But if any of the values are lists that does not work. I need to query with something like the cross product of all the lists. It's n

Re: All permutations from 2 lists

2022-03-02 Thread Avi Gross via Python-list
asking for something like a function that combines two things a certain way. Initially it sounded like two simple lists of any length and something like this was proposed: [(f, s) for f in os for s in region] It returns a list of tuples, but could just as easily return a list of lists or dictionary

Re: All permutations from 2 lists

2022-03-02 Thread Chris Angelico
On Thu, 3 Mar 2022 at 13:05, gene heskett wrote: > I take it back, kmail5 had decided it was a different thread. My bad, no > biscuit. > Awww, I was going to make a really bad joke about timezones :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: All permutations from 2 lists

2022-03-02 Thread gene heskett
y I want just the other list. What I am > > >>>>> doing is > > >>>>> building a list to pass to a mongodb query. If region is empty > > >>>>> then I > > >>>>> want to query for just the items in the os list. I guess

Re: All permutations from 2 lists

2022-03-02 Thread gene heskett
On Wednesday, 2 March 2022 17:46:49 EST Larry Martell wrote: > On Wed, Mar 2, 2022 at 5:31 PM Joel Goldstick wrote: > > On Wed, Mar 2, 2022 at 5:07 PM Larry Martell wrote: > > > On Wed, Mar 2, 2022 at 5:00 PM Cameron Simpson wrote: > > > > On 02Mar2022 08:29, Larry Martell wrote: > > > > >O

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
On Wed, Mar 2, 2022 at 5:31 PM Joel Goldstick wrote: > > On Wed, Mar 2, 2022 at 5:07 PM Larry Martell wrote: > > > > On Wed, Mar 2, 2022 at 5:00 PM Cameron Simpson wrote: > > > > > > On 02Mar2022 08:29, Larry Martell wrote: > > > >On Tue, Mar 1, 2022 at 7:32 PM Rob Cliffe > > > >wrote: > > >

Re: All permutations from 2 lists

2022-03-02 Thread Joel Goldstick
On Wed, Mar 2, 2022 at 5:07 PM Larry Martell wrote: > > On Wed, Mar 2, 2022 at 5:00 PM Cameron Simpson wrote: > > > > On 02Mar2022 08:29, Larry Martell wrote: > > >On Tue, Mar 1, 2022 at 7:32 PM Rob Cliffe > > >wrote: > > >> I think itertools.product is what you need. > > >> Example program: >

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
On Wed, Mar 2, 2022 at 5:00 PM Cameron Simpson wrote: > > On 02Mar2022 08:29, Larry Martell wrote: > >On Tue, Mar 1, 2022 at 7:32 PM Rob Cliffe wrote: > >> I think itertools.product is what you need. > >> Example program: > >> > >> import itertools > >> opsys = ["Linux","Windows"] > >> region =

Re: All permutations from 2 lists

2022-03-02 Thread Cameron Simpson
On 02Mar2022 08:29, Larry Martell wrote: >On Tue, Mar 1, 2022 at 7:32 PM Rob Cliffe wrote: >> I think itertools.product is what you need. >> Example program: >> >> import itertools >> opsys = ["Linux","Windows"] >> region = ["us-east-1", "us-east-2"] >> print(list(itertools.product(opsys, region)

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
n is empty then I >>>>> want to query for just the items in the os list. I guess I can test >>>>> for the lists being empty, but I'd like a solution that handles that >>>>> as down the road there could be more than just 2 lists. &g

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
ws', 'us-east-1'), ('Windows', 'us-east-2')] There are probably use cases where you want the iterator and others where you want the list comprehension. I think the itertools looks nice and it's easier to generalize it to N=3,4,5,... lists than writing out `

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
rtools.product(os,region)) [('Linux', 'us-east-1'), ('Linux', 'us-east-2'), ('Windows', 'us-east-1'), ('Windows', 'us-east-2')] There are probably use cases where you want the iterator and others where you want the list c

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
>>>>> building a list to pass to a mongodb query. If region is empty then I > >>>>> want to query for just the items in the os list. I guess I can test > >>>>> for the lists being empty, but I'd like a solution that handles that > >>>

Re: All permutations from 2 lists

2022-03-02 Thread Antoon Pardon
guess I can test for the lists being empty, but I'd like a solution that handles that as down the road there could be more than just 2 lists. How about the following: Keep a list of your lists you want to permute over. Like the following: permutation_elements = [["Linux","Windows

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
n Pardon > >>> wrote: > >>>> Op 2/03/2022 om 14:27 schreef Larry Martell: > >>>>> On Tue, Mar 1, 2022 at 7:21 PM<2qdxy4rzwzuui...@potatochowder.com> > >>>>> wrote: > >>>>>> On 2022-03-01 at 19:12:

Re: All permutations from 2 lists

2022-03-02 Thread Antoon Pardon
uui...@potatochowder.com>wrote: On 2022-03-01 at 19:12:10 -0500, Larry Martellwrote: If I have 2 lists, e.g.: os = ["Linux","Windows"] region = ["us-east-1", "us-east-2"] How can I get a list of tuples with all possible permutations? So for

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
7:21 PM<2qdxy4rzwzuui...@potatochowder.com> > >>> wrote: > >>>> On 2022-03-01 at 19:12:10 -0500, > >>>> Larry Martell wrote: > >>>> > >>>>> If I have 2 lists, e.g.: > >>>>> > >>>>> os = [&

Re: All permutations from 2 lists

2022-03-02 Thread Antoon Pardon
have 2 lists, e.g.: os = ["Linux","Windows"] region = ["us-east-1", "us-east-2"] How can I get a list of tuples with all possible permutations? So for this example I'd want: [("Linux", "us-east-1"), ("Linux", "us-ea

Re: All permutations from 2 lists

2022-03-02 Thread Joel Goldstick
; > > > > > > > > > > Op 2/03/2022 om 14:27 schreef Larry Martell: > > > > > On Tue, Mar 1, 2022 at 7:21 PM<2qdxy4rzwzuui...@potatochowder.com> > > > > > wrote: > > > > >> On 2022-03-01 at 19:12:10

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
t; > > On Tue, Mar 1, 2022 at 7:21 PM<2qdxy4rzwzuui...@potatochowder.com> > > > > wrote: > > > >> On 2022-03-01 at 19:12:10 -0500, > > > >> Larry Martell wrote: > > > >> > > > >>> If I have 2 lists, e.g.: > > &g

Re: All permutations from 2 lists

2022-03-02 Thread Joel Goldstick
> > >> On 2022-03-01 at 19:12:10 -0500, > > >> Larry Martell wrote: > > >> > > >>> If I have 2 lists, e.g.: > > >>> > > >>> os = ["Linux","Windows"] > > >>> region = ["us-east-1", &qu

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
On Wed, Mar 2, 2022 at 8:37 AM Antoon Pardon wrote: > > > Op 2/03/2022 om 14:27 schreef Larry Martell: > > On Tue, Mar 1, 2022 at 7:21 PM<2qdxy4rzwzuui...@potatochowder.com> wrote: > >> On 2022-03-01 at 19:12:10 -0500, > >> Larry Martell wrote: > >&g

Re: All permutations from 2 lists

2022-03-02 Thread Antoon Pardon
Op 2/03/2022 om 14:27 schreef Larry Martell: On Tue, Mar 1, 2022 at 7:21 PM<2qdxy4rzwzuui...@potatochowder.com> wrote: On 2022-03-01 at 19:12:10 -0500, Larry Martell wrote: If I have 2 lists, e.g.: os = ["Linux","Windows"] region = ["us-east-1", &

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
le, I'm not sure of the > correct technical term). > If you only want to use the result once you can write e.g. > > for ops, reg in itertools.product(opsys, region): > etc. > > If you need it more than once, you can convert it to a list (or tuple), > as above. > Best

Re: All permutations from 2 lists

2022-03-02 Thread Larry Martell
On Tue, Mar 1, 2022 at 7:21 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-03-01 at 19:12:10 -0500, > Larry Martell wrote: > > > If I have 2 lists, e.g.: > > > > os = ["Linux","Windows"] > > region = ["us-east-1"

Re: All permutations from 2 lists

2022-03-02 Thread Chris Angelico
On Wed, 2 Mar 2022 at 19:34, Peter Otten <__pete...@web.de> wrote: > > On 02/03/2022 01:32, Rob Cliffe via Python-list wrote: > > > itertools.product returns an iterator (or iterable, I'm not sure of the > > correct technical term). > > There's a simple test: > > iter(x) is x --> True # iterator >

Re: All permutations from 2 lists

2022-03-02 Thread Peter Otten
On 02/03/2022 01:32, Rob Cliffe via Python-list wrote: itertools.product returns an iterator (or iterable, I'm not sure of the correct technical term). There's a simple test: iter(x) is x --> True # iterator iter(x) is x --> False # iterable So: >>> from itertools import product >>> p =

Re: All permutations from 2 lists

2022-03-01 Thread Rob Cliffe via Python-list
ect technical term). If you only want to use the result once you can write e.g.     for ops, reg in itertools.product(opsys, region):         etc. If you need it more than once, you can convert it to a list (or tuple), as above. Best wishes Rob Cliffe On 02/03/2022 00:12, Larry Martell wrote:

Re: All permutations from 2 lists

2022-03-01 Thread 2QdxY4RzWzUUiLuE
On 2022-03-01 at 19:12:10 -0500, Larry Martell wrote: > If I have 2 lists, e.g.: > > os = ["Linux","Windows"] > region = ["us-east-1", "us-east-2"] > > How can I get a list of tuples with all possible permutations? > > So for th

All permutations from 2 lists

2022-03-01 Thread Larry Martell
If I have 2 lists, e.g.: os = ["Linux","Windows"] region = ["us-east-1", "us-east-2"] How can I get a list of tuples with all possible permutations? So for this example I'd want: [("Linux", "us-east-1"), ("Linux", &quo

Re: One-liner to merge lists?

2022-02-27 Thread Peter Otten
t(chain(*d.values())) a ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] Is there a simpler way? itertools.chain is a good option, as it scales well to arbitrary numbers of lists (and you're guaranteed to iterate over them all just once as you c

Re: One-liner to merge lists?

2022-02-27 Thread Chris Angelico
'bbb', 'ccc', 'fff', 'ggg'] > >>> > >>> I can do this - > >>> > >>>>>> a = [] > >>>>>> for v in d.values(): > >>> ... a.extend(v) > >>> ... > >>>>

Re: One-liner to merge lists?

2022-02-27 Thread MRAB
do this - a = [] for v in d.values(): ... a.extend(v) ... a ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] I can also do this - from itertools import chain a = list(chain(*d.values())) a ['aaa', 'bbb', 'ccc', '

Re: One-liner to merge lists?

2022-02-27 Thread Barry Scott
['aaa', 'bbb', 'ccc', 'fff', 'ggg'] >> >> I can also do this - >> >>>>> from itertools import chain >>>>> a = list(chain(*d.values())) >>>>> a >> ['aaa', 'bbb', 

Re: One-liner to merge lists?

2022-02-26 Thread Chris Angelico
On Sun, 27 Feb 2022 at 16:35, Dan Stromberg wrote: > > > On Fri, Feb 25, 2022 at 3:15 PM Chris Angelico wrote: >> >> But ultimately, that's still the same as sum(), and it's no more >> readable than chain(), so I'd still be inclined to go with chain and >> then wrap it in a function if you need t

Re: One-liner to merge lists?

2022-02-26 Thread Dan Stromberg
On Fri, Feb 25, 2022 at 3:15 PM Chris Angelico wrote: > But ultimately, that's still the same as sum(), and it's no more > readable than chain(), so I'd still be inclined to go with chain and > then wrap it in a function if you need the clarity. > "Need" the clarity? Please tell me you don't th

Re: One-liner to merge lists?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 10:05, Albert-Jan Roskam wrote: >Was also thinking about reduce, though this one uses a dunder method: >from functools import reduce >d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} >print(reduce(list.__add__, list(d.values( If you don't want to use th

Re: One-liner to merge lists?

2022-02-25 Thread Albert-Jan Roskam
If you don't like the idea of 'adding' strings you can 'concat'enate: >>> items = [[1,2,3], [4,5], [6]] >>> functools.reduce(operator.concat, items) [1, 2, 3, 4, 5, 6] >>> functools.reduce(operator.iconcat, items, []) [1, 2, 3, 4, 5, 6] The latter is the functio

Re: One-liner to merge lists?

2022-02-23 Thread Peter Otten
  >>> a = []   >>> for v in d.values(): ...   a.extend(v) ...   >>> a ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] I can also do this -   >>> from itertools import chain   >>> a = list(chain(*d.values()))   >&

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
On 2022-02-22 5:45 PM, David Raymond wrote: Is there a simpler way? d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} [a for b in d.values() for a in b] ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] Now that's what I was looking for. I am not saying that I will use it, but as an academic exercis

Re: One-liner to merge lists?

2022-02-22 Thread Avi Gross via Python-list
27;, 'ggg', 666, 'e', 'u', 'a', 'o', 'i'] The quest for a one-liner sometimes forgets that a typical function call is also a one-liner, with the work hidden elsewhere, often in a module written in python or mainly in C and so on. I suspect m

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 15:04, Dan Stromberg wrote: > > On Tue, Feb 22, 2022 at 7:46 AM David Raymond > wrote: > > > > Is there a simpler way? > > > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > > >>> [a for b in d.values() for a in b] > > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > > >>> >

Re: One-liner to merge lists?

2022-02-22 Thread Dan Stromberg
On Tue, Feb 22, 2022 at 7:46 AM David Raymond wrote: > > Is there a simpler way? > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > >>> [a for b in d.values() for a in b] > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > >>> > I like that way best. But I'd still: 1) use a little more descriptive

Re: One-liner to merge lists?

2022-02-22 Thread Avi Gross via Python-list
am NOT saying this is a good way but that it is sort of a one-liner. There are good reasons I do not see people doing things this way! -Original Message- From: Frank Millman To: python-list@python.org Sent: Tue, Feb 22, 2022 4:19 am Subject: One-liner to merge lists? Hi all I think t

RE: One-liner to merge lists?

2022-02-22 Thread David Raymond
> Is there a simpler way? >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} >>> [a for b in d.values() for a in b] ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] >>> -- https://mail.python.org/mailman/listinfo/python-list

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
t;>> for v in d.values(): > >> ... a.extend(v) > >> ... > >> >>> a > >> ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > >> > >> I can also do this - > >> > >> >>&

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
n d.values(): ... a.extend(v) ... >>> a ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] I can also do this - >>> from itertools import chain >>> a = list(chain(*d.values())) >>> a ['aaa', 'bbb

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
a = [] > >>> for v in d.values(): > ... a.extend(v) > ... > >>> a > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > > I can also do this - > > >>> from itertools import chain > >>> a = list

One-liner to merge lists?

2022-02-22 Thread Frank Millman
Hi all I think this should be a simple one-liner, but I cannot figure it out. I have a dictionary with a number of keys, where each value is a single list - >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} I want to combine all values into a single list - >>> ans = ['aaa', 'bbb', 'ccc'

Re: Unpacking lists in a f string

2022-02-09 Thread Kirill Ratkin
Hi. Try this: f"foo {','.join([f'{a} {b}' for a,b in list(zip(l1,l2))])} bar" 09.02.2022 21:13, Paulo da Silva пишет: Às 02:17 de 09/02/22, Paulo da Silva escreveu: Hi! Let's say I have two lists of equal length but with a variable number of elements. For

Re: Unpacking lists in a f string

2022-02-09 Thread Paulo da Silva
Às 02:17 de 09/02/22, Paulo da Silva escreveu: Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c'] l2=['j','k','l'] I want to build a string like this "foo a

Re: Unpacking lists in a f string

2022-02-09 Thread David Lowry-Duda
l list of things that want to be done (and natural ways to perform them) 1. pair items in the lists (using list comprehension), 2. format the pairs (using an f-string), 3. separate the pairs with commas (using join), and 4. incorporate surrounding "foo" "bar" text. (using an f-st

Re: Unpacking lists in a f string

2022-02-09 Thread Python
Paulo da Silva wrote: Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c'] l2=['j','k','l'] I want to build a string like this "foo a j, b k, c l bar" I

Unpacking lists in a f string

2022-02-09 Thread Paulo da Silva
Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c'] l2=['j','k','l'] I want to build a string like this "foo a j, b k, c l bar" Is it possible to achie

Re: A Newspaper for Python Mailing Lists

2022-01-21 Thread Abdur-Rahmaan Janhangeer
On the news side i was wrong as newsletters have been covering it since long on a monthly basis, but not as in depth as it should be but awesome job though. Else i have been going through early archives but the quality of postings are not very great. The mailing lists have made awesome progress

Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Abdur-Rahmaan Janhangeer
nd remains mailing lists / discuss platforms. A look at the archives and you can see publishing interesting mails. Something you don't have with newsletters. The main aim of it is getting myself updated with discussions and pep status and sharing it with the world. Something i feel i was n

Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Dan Stromberg
There's also Python Weekly: https://www.pythonweekly.com/ On Sat, Jan 8, 2022 at 10:29 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Well yes XD though LWN covers Py topics well when it wants > > > 1. Yes sure, did not expect RSS interest > 2. Excuse my blunder, will do! > > > --

Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Abdur-Rahmaan Janhangeer
<https://www.pythonkitchen.com> github <https://github.com/Abdur-RahmaanJ> Mauritius On Sun, Dec 26, 2021 at 8:40 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Greetings lists, > > I have started a newspaper (not newsletter) focused > on interesting reads on

Re: A Newspaper for Python Mailing Lists

2022-01-11 Thread Peter J. Holzer
On 2022-01-11 12:38:44 -0800, Paul Bryan wrote: > Subscribed. 🙂️ Same. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challe

Re: A Newspaper for Python Mailing Lists

2022-01-11 Thread Paul Bryan
Subscribed. 🙂️ On Wed, 2022-01-12 at 00:35 +0400, Abdur-Rahmaan Janhangeer wrote: > Added RSS: > > 2.0 unless later versions have some advantages: > > https://pyherald.com/rss.xml > > Kind Regards, > > Abdur-Rahmaan Janhangeer > about | blog  > github > Mauritius > -- https://mail.python.or

Re: A Newspaper for Python Mailing Lists

2022-01-11 Thread Abdur-Rahmaan Janhangeer
Added RSS: 2.0 unless later versions have some advantages: https://pyherald.com/rss.xml Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius > -- https://mail.python.org/ma

Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Paul Bryan
> > > On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote: > > > I have started a newspaper (not newsletter) focused > > > on interesting reads on Python mailing lists. Don't tag > > > on the fact that holiday seasons are the worst times for >

Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Abdur-Rahmaan Janhangeer
ewsletter) focused > > on interesting reads on Python mailing lists. Don't tag > > on the fact that holiday seasons are the worst times for > > launch according to marketing folks, I started this to note > > down interesting mails. This might also be a great way to

Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Peter J. Holzer
On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote: > I have started a newspaper (not newsletter) focused > on interesting reads on Python mailing lists. Don't tag > on the fact that holiday seasons are the worst times for > launch according to marketing folks, I sta

  1   2   3   4   5   6   7   8   9   10   >