Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Fri, 25 May 2018 02:45:38 +, Paul wrote: > how often would people here have needed this new operator, if it had > existed? It is common enough that it is a FAQ on the Python website. The list * operator isn't the most heavily used operator, but it does get used a bit. It comes up quite f

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Fri, 25 May 2018 15:30:36 +1000, Cameron Simpson wrote: > So, how to various forms of multidimensional lists play out as code? With my suggestion, we get: x = [0]**3 # one-dimensional y = [[0]**3]**3 # two-dimensional z = [[[0]**3]**3]**3 # three-dimensional Or there's MRAB's suggestion o

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Fri, 25 May 2018 08:11:52 +0200, Stefan Behnel wrote: > Steven D'Aprano schrieb am 25.05.2018 um 04:25: [...] >> You might be right: on further thought, I think I want deep copies, not >> shallow. > > But how would that protocol work then? What would happen with a data > structure like this:

Re: List replication operator

2018-05-24 Thread Stefan Behnel
Steven D'Aprano schrieb am 25.05.2018 um 04:25: > On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote: > >> On 5/24/18 2:17 PM, Steven D'Aprano wrote: > [...] >>> But what do people think about proposing a new list replication with >>> copy operator? >>> >>> [[]]**5 >>> >>> would return

Re: convert a string to a variable

2018-05-24 Thread dieter
bruceg113...@gmail.com writes: > I am trying to convert a string to a variable. > > I got cases 1 & 2 to work, but not cases 3 & 4. > > The print statement in cases 3 & 4 reports the following: > builtins.AttributeError: type object 'animal' has no attribute 'tiger' > > I am stuck on crea

Re: List replication operator

2018-05-24 Thread Cameron Simpson
On 25May2018 02:32, Steven D'Aprano wrote: On Fri, 25 May 2018 08:02:38 +1000, Cameron Simpson wrote: I'm also against the "**" spelling I find, for much the same reasons that people oppose allowing "=" and "==" in the same syntactic location: they're easy to get wrong through typing inaccura

Re: List replication operator

2018-05-24 Thread Cameron Simpson
On 25May2018 02:25, Steven D'Aprano wrote: On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote: On 5/24/18 2:17 PM, Steven D'Aprano wrote: [...] But what do people think about proposing a new list replication with copy operator? [[]]**5 would return a new list consisting of five

Raw string statement (proposal)

2018-05-24 Thread Mikhail V
Hi. I've put some thoughts together, and need some feedback on this proposal. Main question is: Is it convincing? Is there any flaw? My own opinion - there IS something to chase. Still the justification for such syntax is hard. Raw string statement -- Issue - Vast majority

Re: List replication operator

2018-05-24 Thread Paul
how often would people here have needed this new operator, if it had existed? -- https://mail.python.org/mailman/listinfo/python-list

Re: cleaner version of variable, new line

2018-05-24 Thread asa32sd23
On Thursday, May 24, 2018 at 8:51:07 PM UTC-4, asa3...@gmail.com wrote: > hi just seeing if there is a cleaner way to write this. > > s1= "kitti" > s2= 'kitti' > i= 3 > print(s1+ "\n" + "="*i + "^" + "\n" +s2) > > > > kitti > ===^ > kitti more legible that way... thks -- https://mail.python.

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 16:05:32 -0700, Paul wrote: > How would one make a multi-dimensional list now, with truly-separate sub > lists? Is there just no way to do it with the replication operator? Correct. Let's say you want to make a 1-D list with three items initialised to zero. This works brilli

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Fri, 25 May 2018 08:02:38 +1000, Cameron Simpson wrote: > I'm also against the "**" spelling I find, for much the same reasons > that people oppose allowing "=" and "==" in the same syntactic location: > they're easy to get wrong through typing inaccuracy. Do you often write y = 2**x when

Re: why do I get syntax error on if : break

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 19:12:33 -0700, asa32sd23 wrote: > here is the code, i keep getting an error, "break outside loop". if it > is false just exit function break doesn't exit the function, it exits the loop. There is no loop to exit, so it is an error. Believe the compiler when it tells you the

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote: > On 5/24/18 2:17 PM, Steven D'Aprano wrote: [...] >> But what do people think about proposing a new list replication with >> copy operator? >> >> [[]]**5 >> >> would return a new list consisting of five shallow copies of the inner >>

Re: why do I get syntax error on if : break

2018-05-24 Thread boB Stepp
On Thu, May 24, 2018 at 9:12 PM, wrote: > here is the code, i keep getting an error, "break outside loop". if it is > false just exit function > > > def d(idx): > if type(idx) != int: > break > > d('k') "break" (and "continue") are only meaningful inside for or while loops. You do

Re: cleaner version of variable, new line

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 17:50:53 -0700, asa32sd23 wrote: > hi just seeing if there is a cleaner way to write this. > > s1= "kitti" > s2= 'kitti' > i= 3 > print(s1+ "\n" + "="*i + "^" + "\n" +s2) s = "kitti" i = 3 print(s, "="*i + "^", s, sep='\n') -- Steve -- https://mail.python.org/mailma

why do I get syntax error on if : break

2018-05-24 Thread asa32sd23
here is the code, i keep getting an error, "break outside loop". if it is false just exit function def d(idx): if type(idx) != int: break d('k') -- https://mail.python.org/mailman/listinfo/python-list

Re: cleaner version of variable, new line

2018-05-24 Thread MRAB
On 2018-05-25 01:50, asa32s...@gmail.com wrote: hi just seeing if there is a cleaner way to write this. s1= "kitti" s2= 'kitti' i= 3 print(s1+ "\n" + "="*i + "^" + "\n" +s2) kitti ===^ kitti When printing, I'd probably just go for something clear and simple: print(s1) print("=" * i + "

Re: Usenet Gateway

2018-05-24 Thread Michael Torrie
On 05/24/2018 08:20 AM, Grant Edwards wrote: > But you had to jump through hoops with procmail and server/client side > filtering to get there. True, but it takes maybe 30 seconds for each new list I sign up for, and then it's out of sight, out of mind. I already do a ton of filtering on my inbox

Re: Usenet Gateway

2018-05-24 Thread Michael Torrie
On 05/24/2018 07:01 AM, Steven D'Aprano wrote: > On Thu, 24 May 2018 05:44:26 -0600, Michael Torrie wrote: > >> I agree web forums really suck for any kind of multi-user conversation. > > Oh good. Because the Python core-devs are talking about moving to > Github's web interface instead of email.

Re: Usenet Gateway

2018-05-24 Thread Michael Torrie
On 05/24/2018 07:10 AM, Chris Green wrote: > A *thread* yes, but not a whole list. I.e. if you read this using > mail/IMAP you can mark a thread read but you can't mark *all* Python > list messages read in one go can you? With tin/Usenet I look at > the list of new subjects in the Python group

Re: List replication operator

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 11:24:41 -0700, Rob Gaddi wrote: > On 05/24/2018 11:17 AM, Steven D'Aprano wrote: [...] >> But what do people think about proposing a new list replication with >> copy operator? >> >> [[]]**5 >> >> would return a new list consisting of five shallow copies of the inner >>

Re: Scripts not downloading Version 3.6.5

2018-05-24 Thread Terry Reedy
On 5/24/2018 11:31 AM, Chester Davies via Python-list wrote: Hi! Yesterday I downloaded the latest version of Python, after some fiddling around with some command line, getting Python to open files etc, it wasn't able to find various pillows, so after a while, I decided to call it a night. I w

cleaner version of variable, new line

2018-05-24 Thread asa32sd23
hi just seeing if there is a cleaner way to write this. s1= "kitti" s2= 'kitti' i= 3 print(s1+ "\n" + "="*i + "^" + "\n" +s2) > kitti ===^ kitti -- https://mail.python.org/mailman/listinfo/python-list

Re: List replication operator

2018-05-24 Thread MRAB
On 2018-05-25 00:05, Paul wrote: How would one make a multi-dimensional list now, with truly-separate sub lists? Is there just no way to do it with the replication operator? IE, would I just have to do X = [[], [], [], [], []] or perhaps write a function to insert new sub lists into a list,

Re: List replication operator

2018-05-24 Thread Ben Finney
Paul writes: > How would one make a multi-dimensional list now, with truly-separate sub > lists? Is there just no way to do it with the replication operator? IE, > would I just have to do > X = [[], [], [], [], []] The expressions in a comprehension are evaluated each time through. So this is

Re: List replication operator

2018-05-24 Thread Paul
How would one make a multi-dimensional list now, with truly-separate sub lists? Is there just no way to do it with the replication operator? IE, would I just have to do X = [[], [], [], [], []] or perhaps write a function to insert new sub lists into a list, or...? Thanks > Paul C. > > -- h

convert a string to a variable

2018-05-24 Thread bruceg113355
I am trying to convert a string to a variable. I got cases 1 & 2 to work, but not cases 3 & 4. The print statement in cases 3 & 4 reports the following: builtins.AttributeError: type object 'animal' has no attribute 'tiger' I am stuck on creating variables that can be accessed as follows

Re: List replication operator

2018-05-24 Thread Cameron Simpson
On 24May2018 18:17, Steven D'Aprano wrote: Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[0].append(1) py> x [[1], [1], [1], [1], [1]

Re: Some Issues on Tagging Text

2018-05-24 Thread Cameron Simpson
First up, thank you for a well described problem! Remarks inline below. On 24May2018 03:13, Subhabrata Banerjee wrote: I have a text as, "Hawaii volcano generates toxic gas plume called laze PAHOA: The eruption of Kilauea volcano in Hawaii sparked new safety warnings about toxic gas on the Bi

Re: List replication operator

2018-05-24 Thread MRAB
On 2018-05-24 20:12, Ned Batchelder wrote: On 5/24/18 2:17 PM, Steven D'Aprano wrote: Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[

Re: List replication operator

2018-05-24 Thread Ned Batchelder
On 5/24/18 2:17 PM, Steven D'Aprano wrote: Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[0].append(1) py> x [[1], [1], [1], [1], [1]]

Re: List replication operator

2018-05-24 Thread Rob Gaddi
On 05/24/2018 11:17 AM, Steven D'Aprano wrote: Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[0].append(1) py> x [[1], [1], [1], [1],

List replication operator

2018-05-24 Thread Steven D'Aprano
Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[0].append(1) py> x [[1], [1], [1], [1], [1]] The reason for this behaviour is that * do

Scripts not downloading Version 3.6.5

2018-05-24 Thread Chester Davies via Python-list
Hi! Yesterday I downloaded the latest version of Python, after some fiddling around with some command line, getting Python to open files etc, it wasn't able to find various pillows, so after a while, I decided to call it a night. I went to finish it off today, and discovered my computer had up

Scripts not downloading Version 3.6.5

2018-05-24 Thread Chester Davies via Python-list
Hi! Yesterday I downloaded the latest version of Python, after some fiddling around with some command line, getting Python to open files etc, it wasn't able to find various pillows, so after a while, I decided to call it a night. I went to finish it off today, and discovered my computer had up

Re: Usenet Gateway

2018-05-24 Thread Chris Green
José María Mateos wrote: > On Thu, May 24, 2018, at 09:10, Chris Green wrote: > > > Yes I can mark an entire thread as "read" in IMAP. > > > > > A *thread* yes, but not a whole list. I.e. if you read this using > > mail/IMAP you can mark a thread read but you can't mark *all* Python > > list mes

Re: Usenet Gateway

2018-05-24 Thread José María Mateos
On Thu, May 24, 2018, at 09:10, Chris Green wrote: > > Yes I can mark an entire thread as "read" in IMAP. > > > A *thread* yes, but not a whole list. I.e. if you read this using > mail/IMAP you can mark a thread read but you can't mark *all* Python > list messages read in one go can you? With t

Re: Usenet Gateway

2018-05-24 Thread Grant Edwards
On 2018-05-24, Michael Torrie wrote: > On 05/23/2018 12:03 PM, Grant Edwards wrote: >> But IMO email pales in comparison to NNTP when there are more than a >> few messages per day per group. > > This is not my experience at all. I used to use Usenet back in the day, > but for nearly the last two

Re: Usenet Gateway

2018-05-24 Thread Chris Green
Michael Torrie wrote: > Comparing to IMAP and Thunderbird: > > On 05/23/2018 04:39 PM, Chris Green wrote: > > Well from other comments here it seems I'm not alone but anyway:- > > > > Proper threading etc. is built in > > check. > > > > > It's automatically archived and one can search

Re: Usenet Gateway

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 05:44:26 -0600, Michael Torrie wrote: > I agree web forums really suck for any kind of multi-user conversation. Oh good. Because the Python core-devs are talking about moving to Github's web interface instead of email. Because Github is the future :-) https://circleci.com/bl

Re: Usenet Gateway

2018-05-24 Thread Michael Torrie
Comparing to IMAP and Thunderbird: On 05/23/2018 04:39 PM, Chris Green wrote: > Well from other comments here it seems I'm not alone but anyway:- > > Proper threading etc. is built in check. > > It's automatically archived and one can search back through > threads for old postings,

Re: Usenet Gateway

2018-05-24 Thread Michael Torrie
On 05/23/2018 12:03 PM, Grant Edwards wrote: > Yes. NNTP and NNTP clients were designed from the ground up to deal > with ongoing discussions shared by large groups of people posting lots > of messages, and they're _very_ good at. > > Email was designed for one person sending one message to anoth

Some Issues on Tagging Text

2018-05-24 Thread subhabangalore
I have a text as, "Hawaii volcano generates toxic gas plume called laze PAHOA: The eruption of Kilauea volcano in Hawaii sparked new safety warnings about toxic gas on the Big Island's southern coastline after lava began flowing into the ocean and setting off a chemical reaction. Lava haze is

Re: how to get INDEX count, or last number of Index

2018-05-24 Thread bartc
On 24/05/2018 03:37, Terry Reedy wrote: On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, U

Re: Usenet Gateway

2018-05-24 Thread Gregory Ewing
Ned Batchelder wrote: On 5/23/18 12:03 PM, Gene Heskett wrote: Brain damaged by facebook, AOL, M$, Google, yahoo yadda yadda into thinking that webmail and forums are the only game in town? Please avoid accusing others of being brain damaged, even if it was meant in a humorous context. :( I