Re: Trying to understand nested loops

2022-08-08 Thread GB
On 08/08/2022 12:59, Dan Purgert wrote: dn wrote: On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: I wonder if someone is pulling our leg as they are sending from an invalid email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the

Re: Trying to understand nested loops

2022-08-08 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 dn wrote: > On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: >> I wonder if someone is pulling our leg as they are sending from an >> invalid email address of "GB " which is >> a bit sick. > > There are a number of folk who use evidently false email

RE: Trying to understand nested loops

2022-08-06 Thread avi.e.gross
Behalf Of Chris Angelico Sent: Saturday, August 6, 2022 8:12 AM To: python-list@python.org Subject: Re: Trying to understand nested loops On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:

Re: Trying to understand nested loops

2022-08-06 Thread Chris Angelico
On Sat, 6 Aug 2022 at 22:39, Richard Damon wrote: > > On 8/6/22 8:12 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > >> On 8/6/22 12:01 AM, Chris Angelico wrote: > >>> On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > On Fri, Aug 5, 2022 at 12:54 PM Grant

Re: Trying to understand nested loops

2022-08-06 Thread Richard Damon
On 8/6/22 8:12 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: On 8/6/22 12:01 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: In C, this doesn't do what it looks like it's suppose

Re: Trying to understand nested loops

2022-08-06 Thread Chris Angelico
On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > >> wrote: > >> > >>> In C, this doesn't do what it looks like it's supposed to do. > >>> > >>

Re: Trying to understand nested loops

2022-08-06 Thread Richard Damon
On 8/6/22 12:01 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: In C, this doesn't do what it looks like it's supposed to do. if (foo) do_this(); and_this(); then_do_this(); It's been quit

Re: Trying to understand nested loops

2022-08-05 Thread Chris Angelico
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > > On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > wrote: > > > In C, this doesn't do what it looks like it's supposed to do. > > > >if (foo) > > do_this(); > > and_this(); > >then_do_this(); > > > It's been quite a while since

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: > In C, this doesn't do what it looks like it's supposed to do. > >if (foo) > do_this(); > and_this(); >then_do_this(); > It's been quite a while since I used C, but with the right compiler flag(s), I think this may be a thing

Re: Trying to understand nested loops

2022-08-05 Thread Mladen Gogala via Python-list
On Fri, 5 Aug 2022 08:34:45 +0100, ojomooluwatolami675 wrote: > Hello, I’m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 > as the answer. Thanks > > var = 0 for i in range(3): > for j

RE: Trying to understand nested loops

2022-08-05 Thread avi.e.gross
I had considered that, Dave. Albeit others did at least put in some three-dot markers to show there was other code between the three lines shown. But the same silly argument they used applies elsewhere. Consider nested calls like: Delta(Gamma(Beta(Alpha))) Now say one of those functions takes

Re: Trying to understand nested loops

2022-08-05 Thread dn
On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: > I wonder if someone is pulling our leg as they are sending from an invalid > email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the OP's had me amused. Such 'hiding' is a matter for t

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:30 PM GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > > > BTW, there is an indentation error in your original post - line 5 should > > line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of

RE: Trying to understand nested loops

2022-08-05 Thread avi.e.gross
r at least that they have spent any serious time learning. -Original Message- From: Python-list On Behalf Of GB Sent: Friday, August 5, 2022 5:57 AM To: python-list@python.org Subject: Re: Trying to understand nested loops On 05/08/2022 08:56, Frank Millman wrote: > BTW, there is an inde

Re: Trying to understand nested loops

2022-08-05 Thread dn
On 06/08/2022 10.50, Dan Stromberg wrote: > On Fri, Aug 5, 2022 at 12:35 AM wrote: ... > Of if you don't have (or want) a debugger, you could change it to: > > var = 0 > for i in range(3): > print('i is', i) > for j in range(-2,-7,-2): > print('j is', j) > var += 1 > print(var) >

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:35 AM wrote: > Hello, I’m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 as > the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-

Re: Trying to understand nested loops

2022-08-05 Thread Mats Wichmann
On 8/5/22 03:56, GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents.  And, the significance of indents is a bi

Re: Trying to understand nested loops

2022-08-05 Thread Grant Edwards
On 2022-08-05, GB wrote: >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of indents is a bit of a minefield for > beginners. As a C begin

Re: Trying to understand nested loops

2022-08-05 Thread GB
On 05/08/2022 08:56, Frank Millman wrote: BTW, there is an indentation error in your original post - line 5 should line up with line 4. As a Python beginner, I find that Python is annoyingly picky about indents. And, the significance of indents is a bit of a minefield for beginners. For

Re: Trying to understand nested loops

2022-08-05 Thread Dieter Maurer
ojomooluwatolami...@gmail.com wrote at 2022-8-5 08:34 +0100: >Hello, I’m new to learning python and I stumbled upon a question nested loops. For future, more complex, questions of this kind, you might have a look at the module `pdb` in Python's runtime library. It implements a debugg

Re: Trying to understand nested loops

2022-08-05 Thread Weatherby,Gerard
It’s also a poor code example. Doing a pointless double loop is not good instructional practice, especially when simpler alternatives exist. e.g. for i in range(3): for j in range(-2.-7,-2): print(i +j ) — Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biol

Re: Trying to understand nested loops

2022-08-05 Thread Cameron Simpson
On 05Aug2022 09:47, Lars Liedtke wrote: >this looks to me like it might be a piece of homework, as it would be >given by teachers or professors. > >This list has got the rule, that members do not solve other's >homework. Because very often homework is meant to sit down and think >about it. Ver

Re: Trying to understand nested loops

2022-08-05 Thread Frank Millman
On 2022-08-05 9:34 AM, ojomooluwatolami...@gmail.com wrote: Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var

Re: Trying to understand nested loops

2022-08-05 Thread Lars Liedtke
um 09:34 schrieb ojomooluwatolami...@gmail.com: Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 prin

Trying to understand nested loops

2022-08-05 Thread ojomooluwatolami675
Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 print(var) Sent from my iPhone -- https

Re: Enums and nested classes

2022-04-21 Thread Ethan Furman
On 4/21/22 15:00, Greg Ewing wrote: On 20/04/22 10:57 pm, Sam Ezeh wrote: Has anyone here used or attempted to use a nested class inside an enum? If so, how did you find it? (what did you expect to happen and did your expectations align with resulting behaviour etc.) That's a pretty

Re: Enums and nested classes

2022-04-21 Thread Greg Ewing
On 20/04/22 10:57 pm, Sam Ezeh wrote: Has anyone here used or attempted to use a nested class inside an enum? If so, how did you find it? (what did you expect to happen and did your expectations align with resulting behaviour etc.) That's a pretty open-ended question. Is there something

Enums and nested classes

2022-04-20 Thread Sam Ezeh
Hello everyone, Has anyone here used or attempted to use a nested class inside an enum? If so, how did you find it? (what did you expect to happen and did your expectations align with resulting behaviour etc.) Here are two examples describing the situation I'm talking about ``` class

Re: Avoid nested SIGINT handling

2021-11-13 Thread Eryk Sun
On 11/12/21, Mladen Gogala via Python-list wrote: > On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote: > >> Threads aren't the point here - signals happen immediately. > > [snip: description of POSIX signals] > > BTW, that's the case on both Unix/Linux systems and Windows systems. Windows

Re: Avoid nested SIGINT handling

2021-11-13 Thread Chris Angelico
On Sun, Nov 14, 2021 at 4:42 AM Mladen Gogala via Python-list wrote: > > On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote: > > > Threads aren't the point here - signals happen immediately. > > Actually, signals are not delivered immediately. Signals are delivered > the next time the proces

Re: Avoid nested SIGINT handling

2021-11-13 Thread Mladen Gogala via Python-list
On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote: > Threads aren't the point here - signals happen immediately. Actually, signals are not delivered immediately. Signals are delivered the next time the process gets its turn on CPU. The process scheduler will make process runnable and the

Re: Avoid nested SIGINT handling

2021-11-11 Thread Paulo da Silva
Às 06:22 de 11/11/21, Chris Angelico escreveu: > On Thu, Nov 11, 2021 at 5:01 PM Jon Ribbens via Python-list > wrote: >> >> On 2021-11-10, Paulo da Silva wrote: >>> Hi! >>> >>> How do I handle a SIGINT (or any other signal) avoid nesting? >> >> I don't think you need to. Python will only call sig

Re: Avoid nested SIGINT handling

2021-11-10 Thread Chris Angelico
On Thu, Nov 11, 2021 at 5:01 PM Jon Ribbens via Python-list wrote: > > On 2021-11-10, Paulo da Silva wrote: > > Hi! > > > > How do I handle a SIGINT (or any other signal) avoid nesting? > > I don't think you need to. Python will only call signal handlers in > the main thread, so a handler can't b

Re: Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Às 21:55 de 10/11/21, Jon Ribbens escreveu: > On 2021-11-10, Paulo da Silva wrote: >> Hi! >> >> How do I handle a SIGINT (or any other signal) avoid nesting? > > I don't think you need to. Python will only call signal handlers in > the main thread, so a handler can't be executed while another han

Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Hi! How do I handle a SIGINT (or any other signal) avoid nesting? Does this work? class STATUS: InInt=False def SIGINT_handler(sn,f): if STATUS.InInt: return STATUS.InInt=True process_int() STATUS.InInt=False Thanks for any suggestions. Paulo -- https:/

Re: Avoid nested SIGINT handling

2021-11-10 Thread Jon Ribbens via Python-list
On 2021-11-10, Paulo da Silva wrote: > Hi! > > How do I handle a SIGINT (or any other signal) avoid nesting? I don't think you need to. Python will only call signal handlers in the main thread, so a handler can't be executed while another handler is running anyway. -- https://mail.python.org/mai

Re: Making command-line args available to deeply-nested functions

2021-09-10 Thread Loris Bennett
George Fischhof writes: > George Fischhof ezt írta (időpont: 2021. aug. 29., V, > 21:27): > >> >> >> Loris Bennett ezt írta (időpont: 2021. aug. >> 26., Cs, 16:02): >> >>> George Fischhof writes: >>> >>> [snip (79 lines)] >>> >>> >> > Hi, >>> >> > >>> >> > Also you can give a try to click and

Re: Making command-line args available to deeply-nested functions

2021-08-31 Thread George Fischhof
George Fischhof ezt írta (időpont: 2021. aug. 29., V, 21:27): > > > Loris Bennett ezt írta (időpont: 2021. aug. > 26., Cs, 16:02): > >> George Fischhof writes: >> >> [snip (79 lines)] >> >> >> > Hi, >> >> > >> >> > Also you can give a try to click and / or typer packages. >> >> > Putting args

Re: Making command-line args available to deeply-nested functions

2021-08-29 Thread George Fischhof
Loris Bennett ezt írta (időpont: 2021. aug. 26., Cs, 16:02): > George Fischhof writes: > > [snip (79 lines)] > > >> > Hi, > >> > > >> > Also you can give a try to click and / or typer packages. > >> > Putting args into environment variables can be a solution too > >> > All of these depends on s

Re: Making command-line args available to deeply-nested functions

2021-08-26 Thread Loris Bennett
George Fischhof writes: [snip (79 lines)] >> > Hi, >> > >> > Also you can give a try to click and / or typer packages. >> > Putting args into environment variables can be a solution too >> > All of these depends on several things: personal preferences, colleagues >> / >> > firm standards, the p

Re: Making command-line args available to deeply-nested functions

2021-08-23 Thread George Fischhof
021 at 11:54:00 UTC+2, Loris Bennett wrote: > >> >> Hi, > >> >> > >> >> TL;DR: > >> >> > >> >> If I have a command-line argument for a program, what is the best way > >> >> of making this available to a deeply-nested[1] fu

Re: Making command-line args available to deeply-nested functions

2021-08-23 Thread Loris Bennett
t; >> >> >> If I have a command-line argument for a program, what is the best way >> >> of making this available to a deeply-nested[1] function call without >> >> passing the parameter through every intermediate function? >> > >> > To not

Re: Making command-line args available to deeply-nested functions

2021-08-21 Thread George Fischhof
am, what is the best way > >> of making this available to a deeply-nested[1] function call without > >> passing the parameter through every intermediate function? > > > > To not pass arguments you need shared state ("global variables"): and > > option

Making command-line args available to deeply-nested functions

2021-08-20 Thread Loris Bennett
Hi, TL;DR: If I have a command-line argument for a program, what is the best way of making this available to a deeply-nested[1] function call without passing the parameter through every intermediate function? Long version: If I have, say, a command-line program to send an email with a

Re: Making command-line args available to deeply-nested functions

2021-08-20 Thread Loris Bennett
Julio Di Egidio writes: > On Friday, 20 August 2021 at 11:54:00 UTC+2, Loris Bennett wrote: >> Hi, >> >> TL;DR: >> >> If I have a command-line argument for a program, what is the best way >> of making this available to a deeply-nested[1] function

Re: How to expand and flatten a nested of list of dictionaries of varied lengths?

2020-10-18 Thread dn via Python-list
If I may, a couple of items of list-etiquette (polite behavior), as I understand them: 1 please reply to the list (cf only myself) because @Mats (who responded earlier) and others on this list are much smarter than me, and might be able to help you more quickly 2 top-posting seems to take the fo

Re: How to expand and flatten a nested of list of dictionaries of varied lengths?

2020-10-18 Thread Mats Wichmann
On 10/18/20 2:09 PM, Shaozhong SHI wrote: > Even worse is that, in some cases, an addition called serviceRatings as a > key occur with new data unexpectedly. > > How to produce a robust Python/Panda script to coping with all these? > > Regards, > > David > > u'historicRatings': [{u'overall': {u

Re: How to expand and flatten a nested of list of dictionaries of varied lengths?

2020-10-18 Thread dn via Python-list
On 19/10/2020 09:09, Shaozhong SHI wrote: Even worse is that, in some cases, an addition called serviceRatings as a key occur with new data unexpectedly. "Even worse" than what? Do you need to keep a list of acceptable/applicable/available keys? (and reject or deal with others in some alternat

How to expand and flatten a nested of list of dictionaries of varied lengths?

2020-10-18 Thread Shaozhong SHI
Even worse is that, in some cases, an addition called serviceRatings as a key occur with new data unexpectedly. How to produce a robust Python/Panda script to coping with all these? Regards, David u'historicRatings': [{u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Require

Re: When creating a nested dictionary of dataframes, how can I name a dictionary based on a list name of the dataframe?

2020-06-07 Thread Aaron
Thank you for the help! Based on your response/recommendation, I am thinking that my entire approach to solving my problem is very poor. I am trying to pull slices from a dataframe, store them in a nested dictionary, retrieve them, perform calculations, store the results in the same nested

Re: When creating a nested dictionary of dataframes, how can I name a dictionary based on a list name of the dataframe?

2020-06-07 Thread Peter Otten
Aaron wrote: > When creating a nested dictionary of dataframes, how can I name a > dictionary based on a list name of the dataframe? > > Given the following: > > # START CODE > import pandas as pd > > cars = {'Brand': ['Honda Civic',&#x

When creating a nested dictionary of dataframes, how can I name a dictionary based on a list name of the dataframe?

2020-06-06 Thread Aaron
When creating a nested dictionary of dataframes, how can I name a dictionary based on a list name of the dataframe? Given the following: # START CODE import pandas as pd cars = {'Brand': ['Honda Civic','Toyota Corolla'], 'Price': [22000,2500

iterate through an irregular nested list in Python

2020-03-07 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello'

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'o

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in adva

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello'

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in adva

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'o

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in adva

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello'

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'o

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in adva

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'o

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['h

Re: Nested Loop Code Help

2020-01-26 Thread DL Neil via Python-list
have tried everything in my knowledge, but cannot fix the problem. Thanks for any help in advance. for x in range ( 0, 10):    stars = 'x'    count = 0 while count < x:    stars = stars + 'x'    count = count + 1    print (stars) These loops are serial, ie one after the other

Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon
cannot fix the problem. Thanks for any help in advance. for x in range ( 0, 10):    stars = 'x'    count = 0 while count < x:    stars = stars + 'x'    count = count + 1    print (stars) These loops are serial, ie one after the other, and not "nested" (one 'in

Re: Nested Loop Code Help

2020-01-26 Thread DL Neil via Python-list
count < x: stars = stars + 'x' count = count + 1 print (stars) These loops are serial, ie one after the other, and not "nested" (

Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon
On 1/26/20 6:11 PM, Greg Ewing wrote: On 27/01/20 4:15 am, ferzan saglam wrote: for x in range ( 0, 10):    stars = 'x'    count = 0 By the way, this 'for' loop is unnecessary. The end result is just to give initial values to three names. You don't need a loop at all for that, just three assign

Re: Nested Loop Code Help

2020-01-26 Thread Greg Ewing
On 27/01/20 4:15 am, ferzan saglam wrote: for x in range ( 0, 10): stars = 'x' count = 0 By the way, this 'for' loop is unnecessary. The end result is just to give initial values to three names. You don't need a loop at all for that, just three assignment statements.

Re: Nested Loop Code Help

2020-01-26 Thread Richard Damon
mes (for starting values of count = 0, 1, 2, 3, 4, 5, 6, 7, 8 Think about what you wanted to do and what the code actually did. The first for x in range (0, 10) doesn't really do what I think you wanted, did you mean for the second loop to be nested in it? If you do nest the seco

Re: Nested Loop Code Help

2020-01-26 Thread ferzan saglam
On Sunday, January 26, 2020 at 3:26:40 PM UTC, Dan Purgert wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > ferzan saglam wrote: > > Hello people, I have written the code below which works fine, but it > > has one small problem. Instead of printing one (x) on the first line, > > it p

Re: Nested Loop Code Help

2020-01-26 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 ferzan saglam wrote: > Hello people, I have written the code below which works fine, but it > has one small problem. Instead of printing one (x) on the first line, > it prints two. > I have tried everything in my knowledge, but cannot fix the problem

Nested Loop Code Help

2020-01-26 Thread ferzan saglam
Hello people, I have written the code below which works fine, but it has one small problem. Instead of printing one (x) on the first line, it prints two. I have tried everything in my knowledge, but cannot fix the problem. Thanks for any help in advance. for x in range ( 0, 10):

Re: Extract sentences in nested parentheses using Python

2019-12-05 Thread A S
On Tuesday, 3 December 2019 23:48:21 UTC+8, Peter Otten wrote: > A S wrote: > > > On Tuesday, 3 December 2019 01:01:25 UTC+8, Peter Otten wrote: > >> A S wrote: > >> > >> I think I've seen this question before ;) > >> > >> > I a

Re: Extract sentences in nested parentheses using Python

2019-12-05 Thread A S
-problem or assignment. (in which case, we'd appreciate > being told that you/OP is asking for help with "homework") > > > >> I am trying to extract all strings in nested parentheses (along with the > >> parentheses itself) in my .txt file. P

Re: Extract sentences in nested parentheses using Python

2019-12-03 Thread Peter Otten
A S wrote: > On Tuesday, 3 December 2019 01:01:25 UTC+8, Peter Otten wrote: >> A S wrote: >> >> I think I've seen this question before ;) >> >> > I am trying to extract all strings in nested parentheses (along with >> > the parentheses i

Re: Extract sentences in nested parentheses using Python

2019-12-03 Thread A S
On Tuesday, 3 December 2019 01:01:25 UTC+8, Peter Otten wrote: > A S wrote: > > I think I've seen this question before ;) > > > I am trying to extract all strings in nested parentheses (along with the > > parentheses itself) in my .txt file. Please see the sample .

Re: Extract sentences in nested parentheses using Python

2019-12-02 Thread DL Neil via Python-list
lp with "homework") I am trying to extract all strings in nested parentheses (along with the parentheses itself) in my .txt file. Please see the sample .txt file that I have used in this example here: (https://drive.google.com/open?id=1UKc0ZgY9Fsz5O1rSeBCLqt5dwZkMaQgr). I have trie

Re: Extract sentences in nested parentheses using Python

2019-12-02 Thread Peter Otten
A S wrote: I think I've seen this question before ;) > I am trying to extract all strings in nested parentheses (along with the > parentheses itself) in my .txt file. Please see the sample .txt file that > I have used in this example here: > (https://drive.g

Extract sentences in nested parentheses using Python

2019-12-02 Thread A S
I am trying to extract all strings in nested parentheses (along with the parentheses itself) in my .txt file. Please see the sample .txt file that I have used in this example here: (https://drive.google.com/open?id=1UKc0ZgY9Fsz5O1rSeBCLqt5dwZkMaQgr). I have tried and done up three different

Re: how to exit from a nested loop in python

2019-02-09 Thread DL Neil
1) <= g[-1]: if (Temp[i]['cost'][j] <= (run_parameters.PSD): -- When this condition is true i want to break the nested loop and start from the begining served_count +=1 A.T[i]["First_index"]= s

Re: how to exit from a nested loop in python

2019-02-08 Thread Rurpy via Python-list
for s in range(g[0], g[-1]): > if (s+req_slots[j]-1) <= g[-1]: > if (Temp[i]['cost'][j] <= (run_parameters.PSD): -- When > this condition is true i want to break the nested loop and start from the > begining >

Re: how to exit from a nested loop in python

2019-02-08 Thread Peter Otten
if (s+req_slots[j]-1) <= g[-1]: > if (Temp[i]['cost'][j] <= (run_parameters.PSD): -- > When this condition is true i want to break the nested > loop and start from the begining >

how to exit from a nested loop in python

2019-02-07 Thread Kaka
Temp[i]['cost'][j] <= (run_parameters.PSD): -- When this condition is true i want to break the nested loop and start from the begining served_count +=1 A.T[i]["First_index"]= s A.T[i]["Last_index"]= s+re

Re: clever exit of nested loops

2018-09-27 Thread Gregory Ewing
Neal Becker wrote: but it does violate the principle "Exceptions should be used for exceptional conditions). Python doesn't really go in for that philosophy. Exceptions are often used for flow control, e.g. StopIteration. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: clever exit of nested loops

2018-09-27 Thread Thomas Jollans
On 2018-09-26 21:06, Mark Lawrence wrote: > > To me the Ned Batchelder presentation > https://www.youtube.com/watch?v=EnSu9hHGq5o "Loop like a Native" is the > definitive way on how to deal with loops in Python. > Hear, hear. Great talk. -- https://mail.python.org/mailman/listinfo/python-list

Re: clever exit of nested loops

2018-09-27 Thread Neal Becker
in range(10): >>> print(f'\tj: {j}') >>> for k in range(10): >>> print(f'\t\tk: {k}') >>> >>> if condition(i, j, k): >>> raise Break >>> except Break: >>> pass >>> >> >> For all such

Re: clever exit of nested loops

2018-09-27 Thread Christian Gollwitzer
Remember the requirement is very simple, to 'break out of a nested loop' (and usually this will be to break out of the outermost loop). What you're looking is a statement which is a minor variation on 'break'. Which is exactly what it does. "raise Break" is

Re: clever exit of nested loops

2018-09-27 Thread John Ladasky
On Wednesday, September 26, 2018 at 12:50:20 AM UTC-7, vito.d...@gmail.com wrote: > I have "abused" the "else" clause of the loops to makes a break "broke" more > loops I did this once upon a time. In recent years, when I start writing tricky nested loop

Re: clever exit of nested loops

2018-09-26 Thread Mark Lawrence
On 26/09/18 08:50, vito.detul...@gmail.com wrote: Hi Today I've added a couple of lines in my source code, and I'm very ashamed of it. it "runs", and I know what it does (for now), but it's "too clever". I have "abused" the "else" clause of the loops to makes a break "broke" more loops f

Re: clever exit of nested loops

2018-09-26 Thread Peter Otten
vito.detul...@gmail.com wrote: > Hi > Today I've added a couple of lines in my source code, and I'm very ashamed > of it. it "runs", and I know what it does (for now), but it's "too > clever". I have "abused" the "else" clause of the loops to makes a break > "broke" more loops > > > for i in

Re: clever exit of nested loops

2018-09-26 Thread Chris Angelico
On Wed, Sep 26, 2018 at 5:56 PM wrote: > > Hi > Today I've added a couple of lines in my source code, and I'm very ashamed of > it. > it "runs", and I know what it does (for now), but it's "too clever". > I have "abused" the "else" clause of the loops to makes a break "broke" more > loops > > >

clever exit of nested loops

2018-09-26 Thread vito . detullio
Hi Today I've added a couple of lines in my source code, and I'm very ashamed of it. it "runs", and I know what it does (for now), but it's "too clever". I have "abused" the "else" clause of the loops to makes a break "broke" more loops for i in range(10): print(f'i: {i}') f

Re: Enum with nested classes or with types as members

2018-09-12 Thread Ben Finney
Ethan Furman writes: > I'm asking because in doing some work on Enum it became apparent to me > that having nested classes was not a smooth, satisfying experience, > and I'm considering treating them the same way as methods (they will > no longer be converted into members

Enum with nested classes or with types as members

2018-09-11 Thread Ethan Furman
Greetings! So the stdlib Enum has been around for a few years now. Has anyone written an enum that either had types as members: class Types(Enum): Int = int Str = str or that had nested classes: class Types(Enum): class Contained(Enum): circle = 1

Re: Saving application configuration to the ini file respecting order of sections/options and providing mechanism for (nested) complex objects

2018-08-22 Thread zljubisic
Thanks. As I can see python 3.7 is the best option. Thank you very very muchs for the code as well. Best regards. -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >