Removing For-Loop

2021-05-03 Thread Korn Moffle
Hi, I have been banging my head against the wall - I know I can get rid of for-loop here, but can't figure out how. Please help! I suspect I can do np.sum on the whole adGroup but I am lacking the imagination to visualize it. for ind in range(adGroup.shape[0]): row = adGroup.ilo

RE: Problem running a FOR loop

2020-08-30 Thread Steve
: python-list@python.org Subject: Re: Problem running a FOR loop Steve wrote: > Compiles, no syntax errors however, line 82 seems to run only once > when the FOR loop has completed. > Why is that? All fields are to contain the specifications, not just > the last one. It seems that

Re: Problem running a FOR loop

2020-08-30 Thread Peter Otten
Steve wrote: > Compiles, no syntax errors however, line 82 seems to run only once when > the FOR loop has completed. > Why is that? All fields are to contain the specifications, not just the > last one. It seems that passing the StringVar to the Entry widget is not sufficient to k

Problem running a FOR loop

2020-08-30 Thread Steve
Compiles, no syntax errors however, line 82 seems to run only once when the FOR loop has completed. Why is that? All fields are to contain the specifications, not just the last one. Steve

Re: RFC: For Loop Invariants

2020-04-20 Thread Vincent Vande Vyvre
ot; > seek = {'a','b','c'} > count = sum(1 for a in chars if a in seek) > > So you haven't really changed any semantics - and it seems that this > is far better than fiddling with the for loop syntax. You can use boolean as integer. >>> ch

Re: RFC: For Loop Invariants

2020-04-20 Thread Tony Flury via Python-list
Creating the list is pointless in this case - sum will take any iterable, including a generator expression: chars = "abcaaabkjzhbjacvb" seek = {'a','b','c'} count = sum(1 for a in chars if a in seek) So you haven't really changed any semantics - an

Re: RFC: For Loop Invariants

2020-04-11 Thread Peter J. Holzer
On 2020-04-10 15:44:05 -0500, Elliott Dehnbostel wrote: > *Consider the following trivial for-loop:* > > chars = "abcaaabkjzhbjacvb" > seek = {'a','b','c'} > count = 0 > for a in chars: > if a in seek: > count += 1 &

Re: RFC: For Loop Invariants

2020-04-11 Thread Terry Reedy
On 4/10/2020 4:44 PM, Elliott Dehnbostel wrote: chars = "abcaaabkjzhbjacvb" seek = {'a','b','c'} count = 0for a in chars: if a in seek: count += 1 Why did you repeatly omit the \n after 0? Please paste code that ran Gross. Twice nested for a simple count. Twice indented d

Re: RFC: For Loop Invariants

2020-04-11 Thread Rhodri James
ython community and quite enjoy the more functional features of Python 3, but have I have a peeve about it. I'd like to propose and discuss the following enhancement to Python 3: *Consider the following trivial for-loop:* chars = "abcaaabkjzhbjacvb" seek = {'a','b

Re: RFC: For Loop Invariants

2020-04-10 Thread Souvik Dutta
allowing > for multiple conditions to be inserted in the for loop?? That would make > reading and writing a lot easier. Like the count problem could be rewritten > as > > for (a in chars and ): > > count+=1 > > > > A loop fundamentally has to have an iterable and a

Re: RFC: For Loop Invariants

2020-04-10 Thread Chris Angelico
On Sat, Apr 11, 2020 at 11:04 AM Souvik Dutta wrote: > > How about completely removing the need for an if statement by allowing for > multiple conditions to be inserted in the for loop?? That would make reading > and writing a lot easier. Like the count problem could be rewritten as

Re: RFC: For Loop Invariants

2020-04-10 Thread Souvik Dutta
How about completely removing the need for an if statement by allowing for multiple conditions to be inserted in the for loop?? That would make reading and writing a lot easier. Like the count problem could be rewritten as for (a in chars and ): count+=1 On Sat, 11 Apr, 2020, 6:21 am Chris

Re: RFC: For Loop Invariants

2020-04-10 Thread Chris Angelico
On Sat, Apr 11, 2020 at 10:32 AM Juergen Brendel wrote: > > > Hello! > > On Fri, 2020-04-10 at 15:44 -0500, Elliott Dehnbostel wrote: > > chars = "abcaaabkjzhbjacvb" > > seek = {'a','b','c'} > > count = 0 > > > > for a in chars if a in seek: count += 1 > > Interesting proposal. However, I'm not su

Re: RFC: For Loop Invariants

2020-04-10 Thread Juergen Brendel
you are left with something worse than two indents: A line break and continuation of a for-loop/if-condition (those are the worst). for my_well_names_variable in some_complex_iterable \ if a_complex_condition_that_needs_to_be_evaluated: count += 1 Or maybe:

Re: RFC: For Loop Invariants

2020-04-10 Thread DL Neil via Python-list
s the following enhancement to Python 3: *Consider the following trivial for-loop:* chars = "abcaaabkjzhbjacvb" seek = {'a','b','c'} count = 0for a in chars: if a in seek: count += 1 Gross. Twice nested for a simple count. Agreed! I

RFC: For Loop Invariants

2020-04-10 Thread Elliott Dehnbostel
nal features of Python 3, but have I have a peeve about it. I'd like to propose and discuss the following enhancement to Python 3: *Consider the following trivial for-loop:* chars = "abcaaabkjzhbjacvb" seek = {'a','b','c'} count = 0for a in chars: i

Re: How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Cameron Simpson
On 10May2019 08:08, Madhavan Bomidi wrote: I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData = [outData; allData] # in MATLAB

Re: How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Rhodri James
On 10/05/2019 16:08, Madhavan Bomidi wrote: Hi, I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData

How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Madhavan Bomidi
Hi, I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData = [outData; allData] # in MATLAB While the ncols are

Re: serial communication error for loop

2018-03-13 Thread MRAB
On 2018-03-14 00:23, Dhileepan Kumar wrote: #!/usr/bin/python import serial import MySQLdb while True: #establish connection to MySQL. You'll have to change this for your database. dbConn = MySQLdb.connect("localhost","root","1234","ifet") or die ("could not connect to database")

Re: serial communication error for loop

2018-03-13 Thread Chris Angelico
On Wed, Mar 14, 2018 at 11:23 AM, Dhileepan Kumar wrote: > > #!/usr/bin/python > > import serial > import MySQLdb > while True: > #establish connection to MySQL. You'll have to change this for your database. > dbConn = MySQLdb.connect("localhost","root","1234","ifet") or die > ("could not

serial communication error for loop

2018-03-13 Thread Dhileepan Kumar
#!/usr/bin/python import serial import MySQLdb while True: #establish connection to MySQL. You'll have to change this for your database. dbConn = MySQLdb.connect("localhost","root","1234","ifet") or die ("could not connect to database") #open a cursor to the database cu

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 12:57:25 PM UTC+5:30, Chris Angelico wrote: > On Mon, Feb 26, 2018 at 5:19 AM, wrote: > > Why we don’t use: > > > > for _ in _ in _ > > > > Instead of > > > > for _ in _: > > for _ in _: > > > > Ex: > > > > Names = ["Arya","Pupun"] > > > > for name in Names

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 6:23:24 AM UTC+5:30, Rick Johnson wrote: > On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote: > > > Ex: > > > > Names = ["Arya","Pupun"] > > > > for name in Names: > >for c in name: > >print(c) > > > > instead use: > > > >

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 6:20:06 AM UTC+5:30, Ian wrote: > On Sun, Feb 25, 2018 at 11:19 AM, wrote: > > Why we don’t use: > > > > for _ in _ in _ > > > > Instead of > > > > for _ in _: > > for _ in _: > > > > Ex: > > > > Names = ["Arya","Pupun"] > > > > for name in Names: > >fo

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 8:51:35 PM UTC+5:30, Ian wrote: > On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote: > > https://docs.python.org/3.6/library/itertools.html#itertools.product > > I don't see how you would use itertools.product to do what the OP > asked for. You could use itertools

Re: For Loop Dilema [python-list]

2018-02-26 Thread Ian Kelly
On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote: > https://docs.python.org/3.6/library/itertools.html#itertools.product I don't see how you would use itertools.product to do what the OP asked for. You could use itertools.chain.from_iterable, though: py> names = ['Jack', 'Susan'] py> list(chai

Re: For Loop Dilema [python-list]

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 5:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c) B

Re: For Loop Dilema [python-list]

2018-02-25 Thread INADA Naoki
https://docs.python.org/3.6/library/itertools.html#itertools.product On Mon, Feb 26, 2018 at 3:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print

Re: For Loop Dilema [python-list]

2018-02-25 Thread Rick Johnson
On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote: > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c) Hmm. Why stop there? bit = ["kibbles"] bits = [bit, bit

Re: For Loop Dilema [python-list]

2018-02-25 Thread Ian Kelly
On Sun, Feb 25, 2018 at 11:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c)

For Loop Dilema [python-list]

2018-02-25 Thread arya . kumar2494
Why we don’t use: for _ in _ in _ Instead of for _ in _: for _ in _: Ex: Names = ["Arya","Pupun"] for name in Names: for c in name: print(c) instead use: for c in name in Names: print(c) -- https://mail.python.org/mailman/listinfo/python-list

Re: Introducing the "for" loop

2017-10-10 Thread Peter Otten
Stefan Ram wrote: > Which advice do you refer to? Teach the parts that are most useful first, i. e. for loops over anything but range rather than while loops. -- https://mail.python.org/mailman/listinfo/python-list

Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 03:58 am, Terry Reedy wrote: > No built-in function is an instance of FunctionType > >>> isinstance(compile, FunctionType) > False Ah yes, thanks Terry, I forgot that builtin functions have a distinct type. [...] > FunctionType == function defined by def statement or lambda

Re: Introducing the "for" loop

2017-10-07 Thread Chris Angelico
On Sun, Oct 8, 2017 at 3:58 AM, Terry Reedy wrote: > No built-in function is an instance of FunctionType isinstance(compile, FunctionType) > False isinstance(print, FunctionType) > False type(compile) > type(int.bit_length) > > > > FunctionType == function defined by def stat

Re: Introducing the "for" loop

2017-10-07 Thread Terry Reedy
On 10/7/2017 5:09 AM, Steve D'Aprano wrote: On Fri, 6 Oct 2017 11:44 pm, ROGER GRAYDON CHRISTMAN wrote: Despite the documentation, I would still be tempted to say that range is a function. Taking duck-typing to the meta-level, every time I use range, I use its name followed by a pair of parenth

Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
On Fri, 6 Oct 2017 11:44 pm, ROGER GRAYDON CHRISTMAN wrote: > Despite the documentation, I would still be tempted to say that range is a > function. > Taking duck-typing to the meta-level, every time I use range, I use its name > followed > by a pair of parentheses enclosing one to three parameter

Re: callable values (was: Introducing the "for" loop)

2017-10-06 Thread Steve D'Aprano
On Sat, 7 Oct 2017 03:25 am, Stefan Ram wrote: > FWIW, in my course notes, I have coined a special word for > this: > > A /prelate/ (German: "Prälat") is a callable value (object). In English, prelate is a kind of priest, a senior clergyman and dignitary. I don't know whether German make

Re: Introducing the "for" loop

2017-10-06 Thread Terry Reedy
On 10/6/2017 8:44 AM, ROGER GRAYDON CHRISTMAN wrote: Despite the documentation, I would still be tempted to say that range is a function. It is, *according* to the documentation. Built-in classes are included in Library Reference, Ch. 2, Built-in Functions. Changing that to "Built-in Funct

Re: Introducing the "for" loop

2017-10-06 Thread Paul Moore
On 6 October 2017 at 13:44, ROGER GRAYDON CHRISTMAN wrote: > Despite the documentation, I would still be tempted to say that range is a > function. > Taking duck-typing to the meta-level, every time I use range, I use its name > followed > by a pair of parentheses enclosing one to three parameters

Re: Introducing the "for" loop

2017-10-06 Thread ROGER GRAYDON CHRISTMAN
On Thu, Oct 5, 2017 7:45 PM, breamore...@gmail.com wrote: > On Friday, October 6, 2017 at 2:05:58 AM UTC+1, Irv Kalb wrote: >> >> The range function is discussed after that. >> > >FWIW range isn't a function in Python 3. From https://docs.python.org/3/library/functions.html#func-range "Rathe

Re: Introducing the "for" loop

2017-10-05 Thread breamoreboy
On Friday, October 6, 2017 at 2:05:58 AM UTC+1, Irv Kalb wrote: > > The range function is discussed after that. > FWIW range isn't a function in Python 3. From https://docs.python.org/3/library/functions.html#func-range "Rather than being a function, range is actually an immutable sequence

Re: Introducing the "for" loop

2017-10-05 Thread Irv Kalb
function). Irv PS: I teach the while loop way before I teach the for loop. That's because I use while loops to show how to allow the user to do things like play a small game over and over until the user says that they want to quit. I introduce the for loop only after teaching about li

Re: Introducing the "for" loop

2017-10-05 Thread Bill
se the range in the first for loop. I never intended to use »range«. But I also will not use lists. Very early in the course, I teach numeric and string literals: 1, 2.3, 'abc' then come operators, functions and »if«, »while« and »try«. But neither »range« nor lists have bee

Re: Introducing the "for" loop

2017-10-05 Thread Peter Otten
r-loops. >>>>Why? >>The easy answer here is to not use the range in the first for loop. > > I never intended to use »range«. But I also will not use lists. > > Very early in the course, I teach numeric and string literals: > > 1, 2.3, 'abc' >

Multiple try expect in a for loop

2017-08-22 Thread Ganesh Pal
Hello python friends, I need a suggestion on the below piece of code . I have for loop and I need to do the below i.e create 100 of queue ,open ,and append some data to a data structure. Is multiple try except the way to go or any other idea's. I feel that there is a better way to

Re: python nmap for loop

2017-06-14 Thread Skip Montanaro
> I'm trying to make the following code work: > ... It seems fairly clear that you've posted code which couldn't possibly run (missing a closing quote and right paren). Let me suggest: 1. You copy and paste directly from a Python (or IPython/Jupyter/IDLE) session, including prompts and output. 2

python nmap for loop

2017-06-14 Thread SS
I'm trying to make the following code work: import os, sys app=['host1', 'host2', 'host3'] for i in app: os.system('nmap -p 22 -P0 %s | grep open 2>&1 > /dev/null && echo "%s up" I've tried many different iterations of the os.system call, how to make this work? TIA -- https://mail.pytho

Re: closing image automatically in for loop , python

2017-04-12 Thread William Ray Wing
> On Apr 12, 2017, at 7:18 AM, Masoud Afshari wrote: > > Dear all > > I have several *.sfd files which created by a simulation code. I wrote a > program containing a for Loop which reads each time one .sfd file and plot > the requested Parameters. I have two request:

Re: closing image automatically in for loop , python

2017-04-12 Thread Frank Miles
On Wed, 12 Apr 2017 04:18:45 -0700, Masoud Afshari wrote: > filename ="Ex_resample" +'_sdf_'+ str(n)+'.dat' > with open(filename, 'rb') as f: #read binary file data = np.fromfile(f, > dtype='float64', count=nx*ny) #float64 for Double precision float numbers > Ex = np.reshape(data, [ny, nx], ord

closing image automatically in for loop , python

2017-04-12 Thread Masoud Afshari
Dear all I have several *.sfd files which created by a simulation code. I wrote a program containing a for Loop which reads each time one .sfd file and plot the requested Parameters. I have two request: 1- my Problem is that for Showing successive Images in for Loop I have to Close the

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: Thread within for loop

2017-04-01 Thread Iranna Mathapati
Hi , How to fix it and now i got below error for same script *runtimeerror threads can only be started once then* *Thanks,* On Sat, Apr 1, 2017 at 1:15 PM, dieter wrote: > Iranna Mathapati writes: > > ... > > Exception in thread Thread-5: > > Traceback (most recent call last): > > ... > >

Re: Thread within for loop

2017-04-01 Thread dieter
Iranna Mathapati writes: > ... > Exception in thread Thread-5: > Traceback (most recent call last): > ... > File > "/auto/n3k-qa/CODC/ianandan/pyATS2.7/lib/python2.7/site-packages/pexpect/__init__.py", > line 1466, in expect_list > timeout, searchwindowsize) > File > "/auto/n3k-qa/CODC/ian

Thread within for loop

2017-04-01 Thread Iranna Mathapati
Hi team, I tried to run fallowing run, *jobs = []* *sniffer1 = threading.Thread(target=validate_traffic_stats_dy,args= (FT_item_dy,RT_item_dy,forward_path_list_dy,return_path_list_dy,nat_type_list_dy,pkt_dy_1,))* *jobs.append(sniffer1)* *sniffer2 = threading.Thr

RE: for loop iter next if file bad

2016-12-21 Thread Joaquin Alzola
>def return_files(file_list): >""" >Take a list of files and return file when called. > >Calling function to supply attributes >""" >for file in file_list: >with open(os.path.join(dir_path, file), 'rb') as fd: >if os.stat(fd.name).st_size == 0: >

Re: for loop iter next if file bad

2016-12-21 Thread Sayth Renshaw
Ah yes. Thanks ChrisA http://www.tutorialspoint.com/python/python_loop_control.htm The continue Statement: The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop an

Re: for loop iter next if file bad

2016-12-21 Thread Chris Angelico
On Wed, Dec 21, 2016 at 8:47 PM, Sayth Renshaw wrote: > def return_files(file_list): > """ > Take a list of files and return file when called. > > Calling function to supply attributes > """ > for file in file_list: > with open(os.path.join(dir_path, file), 'rb') as fd:

for loop iter next if file bad

2016-12-21 Thread Sayth Renshaw
Hi I am looping a list of files and want to skip any empty files. I get an error that str is not an iterator which I sought of understand but can't see a workaround for. How do I make this an iterator so I can use next on the file if my test returns true. Currently my code is. for dir_path, s

Re: Iteration, while loop, and for loop

2016-10-27 Thread Veek M
Elizabeth Weiss wrote: > words=["hello", "world", "spam", "eggs"] > counter=0 > max_index=len(words)-1 > > while counter<=max_index: > word=words[counter] > print(word + "!") > counter=counter + 1 while 0 < 10: get 0'th element do something with element increment 0 to 1 (repeat) words[0

Re: How make the judge with for loop?

2016-10-16 Thread alister
On Sat, 15 Oct 2016 22:23:29 -0700, 380162267qq wrote: > c="abcdefghijk" > len=len(c) > n is a int sb=[[] for i in range(n)] > > while (i < len) { > for (int j = 0; j < n && i < len; j++) > sb[j].append(c[i++]); > for (int j = n-2; j >= 1 && i < len; j--) // >

Re: How make the judge with for loop?

2016-10-16 Thread Peter Otten
would be helpful, too. What follows are mechanical translations of what I think your original C code does. (1) You can use a while loop to replace C's for # example: first for loop j = ; while j < n and i < length: sb[j].append(chars[i]) i += 1 j += 1 which shoul

Re: How make the judge with for loop?

2016-10-16 Thread Steven D'Aprano
On Sunday 16 October 2016 16:23, 38016226...@gmail.com wrote: > c="abcdefghijk" > len=len(c) > n is a int > sb=[[] for i in range(n)] > > while (i < len) { > for (int j = 0; j < n && i < len; j++) > sb[j].append(c[i++]); > for (int j = n-2; j >= 1 && i < len; j--)

How make the judge with for loop?

2016-10-15 Thread 380162267qq
c="abcdefghijk" len=len(c) n is a int sb=[[] for i in range(n)] while (i < len) { for (int j = 0; j < n && i < len; j++) sb[j].append(c[i++]); for (int j = n-2; j >= 1 && i < len; j--) // sb[j].append(c[i++]); } How to translate to python? I tried

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-10 Thread Ho Yeung Lee
I updated the code in msdn forum, I calculated from the end of file Discover file 4550 takes a long time to run, Assume it runs a whole day a file, 4550 days I guess need 12 years to finish full combination if only run at home. Hope Python sympy can be faster than cmaple in Amazon instance --

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Ho Yeung Lee
Sorry my calculation is wrong, it should have around 14 billions of combinations after using program to count. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread meInvent bbird
https://social.msdn.microsoft.com/Forums/vstudio/en-US/5f0a9a51-a256-4671-a5fc-e213949e7204/how-to-refactor-3-nested-for-loop-into-smaller-for-loop-assume-each-of-them-independent?forum=csharpgeneral since when i dsolve a differential ideal used near 5GB memory for one ideal , i feel that i

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Chris Angelico
On Mon, Oct 10, 2016 at 9:40 AM, Marko Rauhamaa wrote: > Chris Angelico : >> Yeah, if it's just for progress status. Of course, that does assume >> that the run() function doesn't have anything particularly costly in >> it. If it does, well, dis gonna take a while > > Dealing with multigigabyt

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Marko Rauhamaa
Chris Angelico : > Yeah, if it's just for progress status. Of course, that does assume > that the run() function doesn't have anything particularly costly in > it. If it does, well, dis gonna take a while Dealing with multigigabyte data streams is not over the top nowadays. Marko -- https:/

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Chris Angelico
On Mon, Oct 10, 2016 at 4:57 AM, BartC wrote: > On 09/10/2016 18:33, Jussi Piitulainen wrote: >> >> Chris Angelico writes: >> >>> On Mon, Oct 10, 2016 at 12:26 AM, Dennis Lee Bieber wrote: {This response is delayed as I'm waiting for the program to complete so I can get the run

How to split a large nested for loop and distribute to hundreds of Amazon instance to run this kind of Python code?

2016-10-09 Thread Ho Yeung Lee
https://social.msdn.microsoft.com/Forums/vstudio/en-US/5f0a9a51-a256-4671-a5fc-e213949e7204/how-to-refactor-3-nested-for-loop-into-smaller-for-loop-assume-each-of-them-independent?forum=csharpgeneral I wrote a algorithm to split for loop to generate maplesoft code for limited memory Assume I

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread BartC
On 09/10/2016 18:33, Jussi Piitulainen wrote: Chris Angelico writes: On Mon, Oct 10, 2016 at 12:26 AM, Dennis Lee Bieber wrote: {This response is delayed as I'm waiting for the program to complete so I can get the run time} {Well... it's been near 24 hours and still merrily scrolling sums on m

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Jussi Piitulainen
Chris Angelico writes: > On Mon, Oct 10, 2016 at 12:26 AM, Dennis Lee Bieber wrote: >> {This response is delayed as I'm waiting for the program to complete so I >> can get the run time} >> {Well... it's been near 24 hours and still merrily scrolling sums on my >> console -- so I'm going to kill th

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Chris Angelico
On Mon, Oct 10, 2016 at 12:26 AM, Dennis Lee Bieber wrote: > {This response is delayed as I'm waiting for the program to complete so I > can get the run time} > {Well... it's been near 24 hours and still merrily scrolling sums on my > console -- so I'm going to kill the running program} Eight BIL

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-09 Thread Gregory Ewing
Chris Angelico wrote: Fascinating! What about: except sys.intern('type error') ? Or does interning of strings not exist yet :) Even if it was, I don't think there was any guarantee that the "official" strings representing those exceptions would be interned. You were supposed to use the provide

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
On Sun, 9 Oct 2016 12:53 pm, Chris Angelico wrote: >> They're caught by identity, though - "except 'type error'" fails to >> catch TypeError, and vice versa. > > Fascinating! What about: except sys.intern('type error') ? Or does > interning of strings not exist yet :) >>> intern Unhandled except

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
On Sun, 9 Oct 2016 05:45 am, Random832 wrote: > On Sat, Oct 8, 2016, at 07:29, Steve D'Aprano wrote: >> The oldest version I have access to is the *extremely* primitive 0.9. Not >> surprisingly, it doesn't have xrange -- but it lacks a lot of things, >> including globals(), map(), named exceptions

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Chris Angelico
On Sun, Oct 9, 2016 at 5:45 AM, Random832 wrote: > On Sat, Oct 8, 2016, at 07:29, Steve D'Aprano wrote: >> The oldest version I have access to is the *extremely* primitive 0.9. Not >> surprisingly, it doesn't have xrange -- but it lacks a lot of things, >> including globals(), map(), named excepti

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Random832
On Sat, Oct 8, 2016, at 07:29, Steve D'Aprano wrote: > The oldest version I have access to is the *extremely* primitive 0.9. Not > surprisingly, it doesn't have xrange -- but it lacks a lot of things, > including globals(), map(), named exceptions, "" strings ('' is okay), > exponentiation, and mor

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Random832
On Sat, Oct 8, 2016, at 06:12, BartC wrote: > The OP's code however is a good demonstration of how crazy Python's > original for-range loop was: you need to construct a list of N elements > just to be able to count to N. How many years was it until xrange was > introduced? Python 1.4 had it, an

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Alain Ketterlin
meInvent bbird writes: > how to refactor nested for loop into smaller for loop assume each of them > independent? > > because memory is not enough > > for ii in range(1,2000): > for jj in range(1,2000): > for kk in range(1,2000): > print run(ii,jj,kk) n =

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
On Sat, 8 Oct 2016 09:12 pm, BartC wrote: > The OP's code however is a good demonstration of how crazy Python's > original for-range loop was: you need to construct a list of N elements > just to be able to count to N. How many years was it until xrange was > introduced? Python 1.4 (that's 1996)

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread BartC
On 08/10/2016 11:54, Chris Angelico wrote: On Sat, Oct 8, 2016 at 9:12 PM, BartC wrote: On 08/10/2016 11:03, Chris Angelico wrote: On Sat, Oct 8, 2016 at 8:58 PM, meInvent bbird wrote: how to refactor nested for loop into smaller for loop assume each of them independent? because memory

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Chris Angelico
On Sat, Oct 8, 2016 at 9:12 PM, BartC wrote: > On 08/10/2016 11:03, Chris Angelico wrote: >> >> On Sat, Oct 8, 2016 at 8:58 PM, meInvent bbird >> wrote: >>> >>> how to refactor nested for loop into smaller for loop assume each of them >>> i

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread BartC
On 08/10/2016 11:03, Chris Angelico wrote: On Sat, Oct 8, 2016 at 8:58 PM, meInvent bbird wrote: how to refactor nested for loop into smaller for loop assume each of them independent? because memory is not enough for ii in range(1,2000): for jj in range(1,2000): for kk in range(1,2000

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Chris Angelico
On Sat, Oct 8, 2016 at 8:58 PM, meInvent bbird wrote: > how to refactor nested for loop into smaller for loop assume each of them > independent? > > because memory is not enough > > for ii in range(1,2000): > for jj in range(1,2000): > for kk in range(1,2000): >

how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread meInvent bbird
how to refactor nested for loop into smaller for loop assume each of them independent? because memory is not enough for ii in range(1,2000): for jj in range(1,2000): for kk in range(1,2000): print run(ii,jj,kk) -- https://mail.python.org/mailman/listinfo/python-list

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Albert-Jan Roskam
t: Tuesday, October 4, 2016 7:00:48 AM To: python-list@python.org Subject: Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior) On Tuesday 04 October 2016 14:51, Michael Torrie wrote: > On 10/03/2016 08:21 PM, Steve D'Aprano wrote: >> On Tue, 4 Oct 2016

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Steven D'Aprano
On Tuesday 04 October 2016 14:51, Michael Torrie wrote: > On 10/03/2016 08:21 PM, Steve D'Aprano wrote: >> On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote: >> >>> There is that old, but false, saying that the only intuitive interface >>> is the nipple. Turns out everything, even that, is learn

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Gregory Ewing
On Mon, 3 Oct 2016 10:57:27 -0700 (PDT), sohcahto...@gmail.com declaimed the following: > My car is similar, but the R is actually to the left of 1. It looks like this: R 1 3 5 +-+-+-+ 2 4 6 Mine is actually like that too, but it feels like you're doing the same thing in both cases -- push l

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 08:21 PM, Steve D'Aprano wrote: > On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote: > >> There is that old, but false, saying that the only intuitive interface >> is the nipple. Turns out everything, even that, is learned > > Citation required. Sure, just ask a nursing woman. >

Re: Assignment versus binding [was Re: unintuitive for-loop behavior]

2016-10-03 Thread Rustom Mody
On Tuesday, October 4, 2016 at 8:11:41 AM UTC+5:30, Steve D'Aprano wrote: > On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote: > > > Steve D'Aprano writes: > >> Why shouldn't people say that binding and assignment are the same > >> thing in Python? What's the difference? > > > > Outside Python

Assignment versus binding [was Re: unintuitive for-loop behavior]

2016-10-03 Thread Steve D'Aprano
On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote: > Steve D'Aprano writes: >> Why shouldn't people say that binding and assignment are the same >> thing in Python? What's the difference? > > Outside Python, (lambda x : f(x)) is said to "bind" x. It's different > from assigning a new value to

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Steve D'Aprano
On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote: > There is that old, but false, saying that the only intuitive interface > is the nipple.  Turns out everything, even that, is learned Citation required. Of course many things are intuitive/instinctive, e.g. breathing, but as far as *interfaces*

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Gregory Ewing
BartC wrote: On 03/10/2016 12:53, Marko Rauhamaa wrote: Well, it could be worse. This layout is pretty traditional: 1 3 5 | | | +--+--+ | | | 2 4 R Yes, you get a funny grinding sound when attempting to change from 5th to '6th' at 70mph/110kph. Fortunately it doe

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 11:57 AM, sohcahto...@gmail.com wrote: > Surprisingly, despite driving that previous car for 13 years, the switch was > incredibly easy. I've never accidentally gone to sixth gear instead of > reverse, or forgotten to shift into sixth on the highway. Also, accidentally > going in

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 03:10 AM, Gregory Ewing wrote: > Rustom Mody wrote: >> My new car goes in reverse when I put it in first gear but only on full-moon >> nights with the tank on reserve when the left light is blinking > > OT aside: When I went to take my current car (a manual) > for a test drive, I ha

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread sohcahtoa82
On Monday, October 3, 2016 at 2:11:12 AM UTC-7, Gregory Ewing wrote: > Rustom Mody wrote: > > My new car goes in reverse when I put it in first gear but only on > > full-moon > > nights with the tank on reserve when the left light is blinking > > OT aside: When I went to take my current car (a m

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread breamoreboy
On Monday, October 3, 2016 at 5:41:23 PM UTC+1, BartC wrote: > On 03/10/2016 16:03, wrote: > > On Monday, October 3, 2016 at 12:53:55 PM UTC+1, Marko Rauhamaa wrote: > >> Gregory Ewing: > >> > >>> Turns out the only difference between first and reverse on that model > >>> is whether you lift up a l

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread BartC
On 03/10/2016 16:03, breamore...@gmail.com wrote: On Monday, October 3, 2016 at 12:53:55 PM UTC+1, Marko Rauhamaa wrote: Gregory Ewing: Turns out the only difference between first and reverse on that model is whether you lift up a little ring on the shaft of the gear lever prior to engagement.

  1   2   3   4   5   6   7   8   9   10   >