Re: list index out of range Error , need to fix it or ignore it

2016-02-28 Thread Oscar Benjamin
On 27 February 2016 at 16:50, Ganesh Pal wrote: > Iam on python 2.6 and Linux , I need input on the below program , > here is the spinet of my program It would be much better if you presented a complete program here. Otherwise the missing parts will confuse people. See: http://sscce.org/ > file

Re: list index out of range Error , need to fix it or ignore it

2016-02-28 Thread Steven D'Aprano
On Sun, 28 Feb 2016 03:50 am, Ganesh Pal wrote: > Iam on python 2.6 and Linux , I need input on the below program , > here is the spinet of my program > > > filename='/tmp2/2.txt' > > def check_file(): > """ > Run the command parallel on all the machines , if there is a > file named /

Re: list index out of range Error , need to fix it or ignore it

2016-02-28 Thread Ganesh Pal
>> > what is run(...) > The run (_ is a wrapper it uses suprocess.Popen and returns stdout ,error and extitcod e > not a good idea to have catchall exception how to fix this ? > >> > return False >> > if __name__ == '__main__': >> > main() >> > >> -- >> > copy and paste your tr

Re: list index out of range Error , need to fix it or ignore it

2016-02-27 Thread Joel Goldstick
On Sat, Feb 27, 2016 at 12:01 PM, Ganesh Pal wrote: > changed baddr="" to file ="" in the example program , sorry for the typo > > > filename='/tmp2/2.txt' > > > > def check_file(): > don't use global filename. just pass filename into check_file def check_file(filename): > > """ > > R

Re: list index out of range Error , need to fix it or ignore it

2016-02-27 Thread Ganesh Pal
changed baddr="" to file ="" in the example program , sorry for the typo > filename='/tmp2/2.txt' > > def check_file(): > """ > Run the command parallel on all the machines , if there is a > file named /tmp/file2.txt extract file2.txt > > """ > global filename > file = '' >

list index out of range Error , need to fix it or ignore it

2016-02-27 Thread Ganesh Pal
Iam on python 2.6 and Linux , I need input on the below program , here is the spinet of my program filename='/tmp2/2.txt' def check_file(): """ Run the command parallel on all the machines , if there is a file named /tmp/file2.txt extract file2.txt """ global filename bad

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Terry Reedy
On 9/25/2010 3:53 AM, deluxstar wrote: The traceback is: 2010-09-25 10:50:38+0300 [-] Traceback (most recent call last): 2010-09-25 10:50:38+0300 [-] File "../appsrv/lqcommon.py", line 983, in getPRMS 2010-09-25 10:50:38+0300 [-] File "/usr/lib/python2.6/inspect.py", line 931, in getouterfra

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Wolfgang Rohdewald
On Samstag 25 September 2010, Steven D'Aprano wrote: > My guess is that you've copied the .pyc file onto the server, > BUT there is also an older version of the .py file there as > well. Because the modification date is older than that of the > .pyc file, Python executes the compiled code from the

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Steven D'Aprano
On Sat, 25 Sep 2010 00:53:13 -0700, deluxstar wrote: > The traceback is: > 2010-09-25 10:50:38+0300 [-] Traceback (most recent call last): > 2010-09-25 10:50:38+0300 [-] File "../appsrv/lqcommon.py", line 983, > in getPRMS > 2010-09-25 10:50:38+0300 [-] File "/usr/lib/python2.6/inspect.py", >

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread deluxstar
e code works on local development environment both on linux > > and windows. When checked in to production environment, > > inspect.currentframe() or inspect.stack() function gives "List index > > out of range error". > > > When I googled, I found only one clue o

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-24 Thread Peter Otten
ect.currentframe() or inspect.stack() function gives "List index > out of range error". > > When I googled, I found only one clue of copying pyc files: > http://forum.webfaction.com/viewtopic.php?pid=16808 > > Why inspect modules gives this error? OR Is there another wa

inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-24 Thread deluxstar
= inspect.getouterframes(curframe, 2) calframe[1][0].f_locals['variable'] This sample code works on local development environment both on linux and windows. When checked in to production environment, inspect.currentframe() or inspect.stack() function gives "List index out of range error". Whe

Re: "list index out of range" error

2006-09-20 Thread Tuomas
sam wrote: I gues: no_lines=len(list_initial) > for j in range(0, no_lines): range returns 0, 1, 2, ..., no_lines-1 > > k = 0 > while k < no_lines: > sorted_check = 0 > if list_initial[k] < list_initial[k+1]: When j gets its last value (no_lines-1) k has the same va

Re: "list index out of range" error

2006-09-20 Thread sam
gabriel, > Now that your main problem is gone, just a few comments: > - python lists know their length, so you don't need explicit no_lines > and no_lines_2 > - list_initial.remove(temp_str) is fairly slow - it has to *scan* the > list to locate temp_str. Just keep its index instead, and use del >

Re: "list index out of range" error

2006-09-20 Thread Gabriel Genellina
At Wednesday 20/9/2006 19:39, sam wrote: thanks again for your help. that sorted out something that had really been bugging me. Now that your main problem is gone, just a few comments: - python lists know their length, so you don't need explicit no_lines and no_lines_2 - list_initial.remove(t

Re: "list index out of range" error

2006-09-20 Thread Ben Finney
"sam" <[EMAIL PROTECTED]> writes: > hey everybody, this is my first time posting here. i'm pretty new to > python and programming in general (as you'll soon work out for > yourselves...) On behalf of the entire Python community, *thank you* for putting this disclaimer only in the body of your mes

Re: "list index out of range" error

2006-09-20 Thread sam
for what it's worth. and it is approx. five times quicker than the bubblesort i wrote to begin with on a 286-word highly unordered list, so i wasn't wasting my time after all... __ import time file_input = open('wordlist.txt', 'r

Re: "list index out of range" error

2006-09-20 Thread sam
yes, yes, of course, thank you. not sure what i thought i was doing there. i'll see if i can get it running now... -- http://mail.python.org/mailman/listinfo/python-list

Re: "list index out of range" error

2006-09-20 Thread Marc 'BlackJack' Rintsch
; list_initial[k+1]: > temp_str = list_initial[k+1] > sorted_check = 1 > k += 1 > > list_initial.remove(temp_str) > list_final.append(temp_str) > no_lines -= 1 > > if sorted_check == 0: > break > > problem

Re: "list index out of range" error

2006-09-20 Thread sam
actually, that little bit of code i wrote is obscenely wrong anyway, so please don't bother analyzing the flow. any insight into the "list index out of range" error would still be welcome, though. -- http://mail.python.org/mailman/listinfo/python-list

"list index out of range" error

2006-09-20 Thread sam
itial[k] elif list_initial[k] > list_initial[k+1]: temp_str = list_initial[k+1] sorted_check = 1 k += 1 list_initial.remove(temp_str) list_final.append(temp_str) no_lines -= 1 if sorted_check == 0: break problem is, i keep gett