Re: Nested for loops and print statements
On Tuesday, September 27, 2016 at 2:14:05 PM UTC+8, Cai Gengyang wrote: > We're trying to help, but we need to know more about the > environment you're using to enter your code. > > What operating system are you using? --- OSX Yosemite Version 10.10.2 > > How are you running the interactive interpreter? Are you > using IDLE, or are you running Python in a command window? --- IDLE > > Are you typing code directly into the interactive interpreter, Typing it > directly into IDLE > or are you typing it into a text editor and then copying > and pasting it into the interpreter? > > If you're using a text editor, which one are you using? --- Not using a text > editor > > What *exactly* are you typing on the keyboard to produce > your indentation? Are you pressing the space bar, the > tab key, or some combination of them? Just the space bar, not the tab > key because it gives jumps in spaces that are too large for my liking. > > > > > > > > > On Tuesday, September 27, 2016 at 1:20:17 PM UTC+8, Gregory Ewing wrote: > > Cai Gengyang wrote: > > > I'll still be asking for help here. Please help out a newbie. > > > > We're trying to help, but we need to know more about the > > environment you're using to enter your code. > > > > What operating system are you using? > > > > How are you running the interactive interpreter? Are you > > using IDLE, or are you running Python in a command window? > > > > Are you typing code directly into the interactive interpreter, > > or are you typing it into a text editor and then copying > > and pasting it into the interpreter? > > > > If you're using a text editor, which one are you using? > > > > What *exactly* are you typing on the keyboard to produce > > your indentation? Are you pressing the space bar, the > > tab key, or some combination of them? > > > > -- > > Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
We're trying to help, but we need to know more about the environment you're using to enter your code. What operating system are you using? --- OSX Yosemite Version 10.10.2 How are you running the interactive interpreter? Are you using IDLE, or are you running Python in a command window? --- IDLE Are you typing code directly into the interactive interpreter, Typing it directly into IDLE or are you typing it into a text editor and then copying and pasting it into the interpreter? If you're using a text editor, which one are you using? --- Not using a text editor What *exactly* are you typing on the keyboard to produce your indentation? Are you pressing the space bar, the tab key, or some combination of them? Just the space bar, not the tab key gives too jumps in spaces that are too large for my liking. On Tuesday, September 27, 2016 at 1:20:17 PM UTC+8, Gregory Ewing wrote: > Cai Gengyang wrote: > > I'll still be asking for help here. Please help out a newbie. > > We're trying to help, but we need to know more about the > environment you're using to enter your code. > > What operating system are you using? > > How are you running the interactive interpreter? Are you > using IDLE, or are you running Python in a command window? > > Are you typing code directly into the interactive interpreter, > or are you typing it into a text editor and then copying > and pasting it into the interpreter? > > If you're using a text editor, which one are you using? > > What *exactly* are you typing on the keyboard to produce > your indentation? Are you pressing the space bar, the > tab key, or some combination of them? > > -- > Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Cai Gengyang wrote: I'll still be asking for help here. Please help out a newbie. We're trying to help, but we need to know more about the environment you're using to enter your code. What operating system are you using? How are you running the interactive interpreter? Are you using IDLE, or are you running Python in a command window? Are you typing code directly into the interactive interpreter, or are you typing it into a text editor and then copying and pasting it into the interpreter? If you're using a text editor, which one are you using? What *exactly* are you typing on the keyboard to produce your indentation? Are you pressing the space bar, the tab key, or some combination of them? -- Greg -- https://mail.python.org/mailman/listinfo/python-list
event loop vs threads
how does Python switch execution and maintain context i.e function stack etc,.. for co-routines and why is it less costly than switching threads which almost do the same, and both are handled by Python Interpreter itself(event loop for co-routines and GIL scheduling for threading), so where does the extra overhead for threads come from ? -- Regards Srinivas Devaki Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad) Computer Science and Engineering Department ph: +91 9491 383 249 telegram_id: @eightnoteight -- https://mail.python.org/mailman/listinfo/python-list
Re: How to make a foreign function run as fast as possible in Windows?
On Tue, Sep 27, 2016 at 1:48 AM, wrote: > This function is in a DLL. It's small but may run for days before complete. I > want it > takes 100% core usage. Threading seems not a good idea for it shares the core > with others. Will the multiprocessing module do it? The threads of a process do not share a single core. The OS schedules threads to distribute the load across all cores. However, CPython's global interpreter lock (GIL) does serialize access to the interpreter. If N threads want to use the interpreter, then N-1 threads are blocked while waiting to acquire the GIL. A thread that makes a potentially blocking call to a non-Python API should first release the GIL, which allows another thread to use the interpreter. Calling a ctypes function pointer releases the GIL if the function pointer is from CDLL, WinDLL, or OleDLL (i.e. anything but PyDLL). If your task can be partitioned and executed in parallel, you could use a ThreadPoolExecutor from the concurrent.futures module. Since the task is CPU bound, use os.cpu_count() instead of the default number of threads. https://docs.python.org/3/library/concurrent.futures -- https://mail.python.org/mailman/listinfo/python-list
How to make a foreign function run as fast as possible in Windows?
This function is in a DLL. It's small but may run for days before complete. I want it takes 100% core usage. Threading seems not a good idea for it shares the core with others. Will the multiprocessing module do it? Any suggestion? Thanks ahead. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On Monday, September 26, 2016 at 8:30:34 PM UTC-5, Nathan Ernst wrote: > There's a bug at line 362: > > sup_sheet.write=(s_count,"VM", cell_format); > ---^ > > Like I suggested, you've an errant assignment to sup_sheet.write. > > Also, a couple of notes on style: the terminating semicolons in your code > is unnecessary. It's only needed for multiple statements on a single line. > Please use a single space on each side of a binary operator or assignment - > it improves readability. > > Regards, > > On Mon, Sep 26, 2016 at 8:18 PM, Mohan Mohta wrote: > > > On Monday, September 26, 2016 at 8:08:13 PM UTC-5, MRAB wrote: > > > On 2016-09-27 01:34, Mohan Mohta wrote: > > > > On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: > > > >> On Mon, Sep 26, 2016 at 6:00 PM, MRAB > > wrote: > > > >> > > > >> > On 2016-09-26 23:03, M2 wrote: > > > >> > > > > >> >> Hello > > > >> >> The program is designed to collect different statistics from > > servers > > > >> >> across the network and populate in excel sheet. > > > >> >> Library : xlsxwriter.0.9.3 > > > >> >> > > > >> >> Below is the Snip of code being used > > > [snip] > > > >> >> > > > >> >> Traceback (most recent call last): > > > >> >> File "./turnover_sheet.py", line 398, in > > > >> >> data_population(str(sys.argv[1])); > > > >> >> File "./turnover_sheet.py", line 380, in data_population > > > >> >> data_collection(fqdn,count); > > > >> >> File "./turnover_sheet.py", line 219, in data_collection > > > >> >> sup_sheet.write(s_count,fqdn,cell_format); > > > >> >> TypeError: 'tuple' object is not callable > > > >> >> > > > >> >> I also saw the sheet populated with the first server and when it > > went to > > > >> >> the second server and while populating it considered > > > >> >> sup_sheet.write as a tuple which makes no sense because the rest > > of the > > > >> >> writes are working fine. > > > >> >> > > > >> >> I have no clue why is it doing it ? > > > >> >> Thoughts ? > > > >> >> > > > >> >> I can't see a problem in the part of the code that you've posted. > > > >> > > > > >> > Are there any other lines that use 'sup_sheet'? > > > >> > > > > >> There's nothing wrong with the snippet as shown - the problem must be > > > >> elsewhere. I took the snippet as in the original email and made some > > > >> slight changes to define cell_format, head and table_head & close the > > > >> workbook: > > > >> > > > >> #!/usr/bin/env python > > > [snip] > > > > > > > > But when it picks the second server from the list and starts doing > > what it needs to do then for whatever reason it thinks that this is a tuple > > > > sup_sheet.write(s_count,fqdn,cell_format); > > > > > > > > > > > > Let me know if you need I can load the entire program ( if it helps ) > > > > It is just that it is a still in progress and is a 400+ lines of code. > > > > > > > You could post the code at Pastebin.com to avoid filling people's > > inboxes. > > > > Here you go > > http://pastebin.com/YsbV79XM > > -- > > https://mail.python.org/mailman/listinfo/python-list > > Dang that was it. I was wondering where I was assigning it. No wonder it was thinking sup_sheet.write as a tuple. That was dumb. Well as of semi colon it is just a habit from my old programming style :) And I take your suggestion "Please use a single space on each side of a binary operator or assignment - it improves readability. " Thanks Nathan -- Regards Mohan Mohta -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
There's a bug at line 362: sup_sheet.write=(s_count,"VM", cell_format); ---^ Like I suggested, you've an errant assignment to sup_sheet.write. Also, a couple of notes on style: the terminating semicolons in your code is unnecessary. It's only needed for multiple statements on a single line. Please use a single space on each side of a binary operator or assignment - it improves readability. Regards, On Mon, Sep 26, 2016 at 8:18 PM, Mohan Mohta wrote: > On Monday, September 26, 2016 at 8:08:13 PM UTC-5, MRAB wrote: > > On 2016-09-27 01:34, Mohan Mohta wrote: > > > On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: > > >> On Mon, Sep 26, 2016 at 6:00 PM, MRAB > wrote: > > >> > > >> > On 2016-09-26 23:03, M2 wrote: > > >> > > > >> >> Hello > > >> >> The program is designed to collect different statistics from > servers > > >> >> across the network and populate in excel sheet. > > >> >> Library : xlsxwriter.0.9.3 > > >> >> > > >> >> Below is the Snip of code being used > > [snip] > > >> >> > > >> >> Traceback (most recent call last): > > >> >> File "./turnover_sheet.py", line 398, in > > >> >> data_population(str(sys.argv[1])); > > >> >> File "./turnover_sheet.py", line 380, in data_population > > >> >> data_collection(fqdn,count); > > >> >> File "./turnover_sheet.py", line 219, in data_collection > > >> >> sup_sheet.write(s_count,fqdn,cell_format); > > >> >> TypeError: 'tuple' object is not callable > > >> >> > > >> >> I also saw the sheet populated with the first server and when it > went to > > >> >> the second server and while populating it considered > > >> >> sup_sheet.write as a tuple which makes no sense because the rest > of the > > >> >> writes are working fine. > > >> >> > > >> >> I have no clue why is it doing it ? > > >> >> Thoughts ? > > >> >> > > >> >> I can't see a problem in the part of the code that you've posted. > > >> > > > >> > Are there any other lines that use 'sup_sheet'? > > >> > > > >> There's nothing wrong with the snippet as shown - the problem must be > > >> elsewhere. I took the snippet as in the original email and made some > > >> slight changes to define cell_format, head and table_head & close the > > >> workbook: > > >> > > >> #!/usr/bin/env python > > [snip] > > > > > > But when it picks the second server from the list and starts doing > what it needs to do then for whatever reason it thinks that this is a tuple > > > sup_sheet.write(s_count,fqdn,cell_format); > > > > > > > > > Let me know if you need I can load the entire program ( if it helps ) > > > It is just that it is a still in progress and is a 400+ lines of code. > > > > > You could post the code at Pastebin.com to avoid filling people's > inboxes. > > Here you go > http://pastebin.com/YsbV79XM > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On Monday, September 26, 2016 at 8:08:13 PM UTC-5, MRAB wrote: > On 2016-09-27 01:34, Mohan Mohta wrote: > > On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: > >> On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > >> > >> > On 2016-09-26 23:03, M2 wrote: > >> > > >> >> Hello > >> >> The program is designed to collect different statistics from servers > >> >> across the network and populate in excel sheet. > >> >> Library : xlsxwriter.0.9.3 > >> >> > >> >> Below is the Snip of code being used > [snip] > >> >> > >> >> Traceback (most recent call last): > >> >> File "./turnover_sheet.py", line 398, in > >> >> data_population(str(sys.argv[1])); > >> >> File "./turnover_sheet.py", line 380, in data_population > >> >> data_collection(fqdn,count); > >> >> File "./turnover_sheet.py", line 219, in data_collection > >> >> sup_sheet.write(s_count,fqdn,cell_format); > >> >> TypeError: 'tuple' object is not callable > >> >> > >> >> I also saw the sheet populated with the first server and when it went to > >> >> the second server and while populating it considered > >> >> sup_sheet.write as a tuple which makes no sense because the rest of the > >> >> writes are working fine. > >> >> > >> >> I have no clue why is it doing it ? > >> >> Thoughts ? > >> >> > >> >> I can't see a problem in the part of the code that you've posted. > >> > > >> > Are there any other lines that use 'sup_sheet'? > >> > > >> There's nothing wrong with the snippet as shown - the problem must be > >> elsewhere. I took the snippet as in the original email and made some > >> slight changes to define cell_format, head and table_head & close the > >> workbook: > >> > >> #!/usr/bin/env python > [snip] > > > > But when it picks the second server from the list and starts doing what it > > needs to do then for whatever reason it thinks that this is a tuple > > sup_sheet.write(s_count,fqdn,cell_format); > > > > > > Let me know if you need I can load the entire program ( if it helps ) > > It is just that it is a still in progress and is a 400+ lines of code. > > > You could post the code at Pastebin.com to avoid filling people's inboxes. Here you go http://pastebin.com/YsbV79XM -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On 2016-09-27 01:34, Mohan Mohta wrote: On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > On 2016-09-26 23:03, M2 wrote: > >> Hello >> The program is designed to collect different statistics from servers >> across the network and populate in excel sheet. >> Library : xlsxwriter.0.9.3 >> >> Below is the Snip of code being used [snip] >> >> Traceback (most recent call last): >> File "./turnover_sheet.py", line 398, in >> data_population(str(sys.argv[1])); >> File "./turnover_sheet.py", line 380, in data_population >> data_collection(fqdn,count); >> File "./turnover_sheet.py", line 219, in data_collection >> sup_sheet.write(s_count,fqdn,cell_format); >> TypeError: 'tuple' object is not callable >> >> I also saw the sheet populated with the first server and when it went to >> the second server and while populating it considered >> sup_sheet.write as a tuple which makes no sense because the rest of the >> writes are working fine. >> >> I have no clue why is it doing it ? >> Thoughts ? >> >> I can't see a problem in the part of the code that you've posted. > > Are there any other lines that use 'sup_sheet'? > There's nothing wrong with the snippet as shown - the problem must be elsewhere. I took the snippet as in the original email and made some slight changes to define cell_format, head and table_head & close the workbook: #!/usr/bin/env python [snip] But when it picks the second server from the list and starts doing what it needs to do then for whatever reason it thinks that this is a tuple sup_sheet.write(s_count,fqdn,cell_format); Let me know if you need I can load the entire program ( if it helps ) It is just that it is a still in progress and is a 400+ lines of code. You could post the code at Pastebin.com to avoid filling people's inboxes. -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: > On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > > > On 2016-09-26 23:03, M2 wrote: > > > >> Hello > >> The program is designed to collect different statistics from servers > >> across the network and populate in excel sheet. > >> Library : xlsxwriter.0.9.3 > >> > >> Below is the Snip of code being used > >> #! /usr/bin/python > >> > >> import xlsxwriter > >> import os; > >> import subprocess; > >> import sys; > >> import os.path; > >> > >> > >> workbook=xlsxwriter.Workbook('Turnover_sheet.xlsx'); > >> > >> tools_sheet=workbook.add_worksheet('Citi Tools Verification'); > >> > >> hw_sheet=workbook.add_worksheet('Hardware Verification'); > >> > >> os_sheet=workbook.add_worksheet('OS Verification'); > >> > >> build_spec_sheet=workbook.add_worksheet('Build Specs Verification'); > >> > >> info_sheet=workbook.add_worksheet('Server Handover Info'); > >> > >> stan_sheet=workbook.add_worksheet('Standards'); > >> > >> sup_sheet=workbook.add_worksheet('Support Information'); > >> > >> tools_sheet.write('A3', 'Device Name', table_head); > >> > >> tools_sheet.write('B3', 'Machine Category', table_head); > >> > >> tools_sheet.write('C3', 'OS Platform', table_head); > >> > >> > >> hw_sheet.merge_range('A1:N1', 'Hardware Information', head); > >> > >> hw_sheet.merge_range('A2:A3', 'Device Name', table_head); > >> > >> hw_sheet.merge_range('B2:B3', 'CPU / vCPU Count', table_head); > >> > >> > >> os_sheet.merge_range('A2:A3', 'Server Name', table_head); > >> > >> os_sheet.merge_range('B2:B3', 'Kdump Config', table_head); > >> os_sheet.merge_range('C2:C3', 'Grub Config', table_head); > >> > >> > >> info_sheet.write('A1', 'Server Name', table_head); > >> > >> info_sheet.write('B1', 'Serial Number', table_head); > >> > >> info_sheet.write('C1', 'Backup Type', table_head); > >> > >> > >> stan_sheet.write('A1', 'Item', table_head); > >> > >> stan_sheet.write('B1', 'Standard', table_head); > >> > >> stan_sheet.write('C1', 'Comments', table_head); > >> > >> > >> def data_collection(fqdn,counter): > >> counter=int(counter); > >> red_counter=(int(counter))-2; > >> s_count='A'+str(counter); > >> s_r_count='A'+str(red_counter); > >> tools_sheet.write(s_count,fqdn,cell_format); > >> hw_sheet.write(s_count,fqdn,cell_format); > >> os_sheet.write(s_count,fqdn,cell_format); > >> info_sheet.write(s_r_count,fqdn,cell_format); > >> s_count='D'+str(red_counter); > >> sup_sheet.write(s_count,fqdn,cell_format); > >> > >> I get the following error > >> sup_sheet.write(s_count,fqdn,cell_format); > >> TypeError: 'tuple' object is not callable > >> > >> What I do not understand is why is python thinking sup_sheet.write as > >> tuple. > >> I tired to debug the program and added the following line > >> print "\ts_count is ", type(s_count)," and value",s_count,"\n\tfqdn is ", > >> type(fqdn), " and value is ",fqdn,"\n\tcell_format is ", type(cell_format), > >> " and value is ",cell_format,"\n\t sup_sheet is ",type(sup_sheet)," and > >> value is ",sup_sheet,"\n\n\n"; > >> > >> just before > >> sup_sheet.write(s_count,fqdn,cell_format); > >> > >> And I got the following output: > >> s_count isand value D2 > >> fqdn isand value is Sample1.xyz.com > >> cell_format isand value is > >> > >> sup_sheet isand > >> value is > >> > >> > >> > >> s_count isand value D3 > >> fqdn isand value is sample2.xyz.com > >> cell_format isand value is > >> > >> sup_sheet isand > >> value is > >> > >> > >> > >> Traceback (most recent call last): > >> File "./turnover_sheet.py", line 398, in > >> data_population(str(sys.argv[1])); > >> File "./turnover_sheet.py", line 380, in data_population > >> data_collection(fqdn,count); > >> File "./turnover_sheet.py", line 219, in data_collection > >> sup_sheet.write(s_count,fqdn,cell_format); > >> TypeError: 'tuple' object is not callable > >> > >> I also saw the sheet populated with the first server and when it went to > >> the second server and while populating it considered > >> sup_sheet.write as a tuple which makes no sense because the rest of the > >> writes are working fine. > >> > >> I have no clue why is it doing it ? > >> Thoughts ? > >> > >> I can't see a problem in the part of the code that you've posted. > > > > Are there any other lines that use 'sup_sheet'? > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > There's nothing wrong with the snippet as shown - the problem must be > elsewhere. I took the snippet as in the original email and made some > slight changes to define cell_format, head and table_head & close the > workbook: > > #!/usr/bin/env python > import xlsxwriter > import os; > import subprocess; > import sys; > import os.path; > > workbook = xlsxwriter.Workbook('Turnover_sheet.xlsx'); > cell_format = work
Re: Nested for loops and print statements
On Monday, September 26, 2016 at 9:57:52 PM UTC+1, Cai Gengyang wrote: > Ok it works now: > > >>>for row in range(10): > for column in range(10): >print("*",end="") > > > > > but how is it different from --- > > >>> for row in range(10): >for column in range(10): > print("*",end="") > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Why does the example on top work and the example below doesn't work ? The > only difference is that the "print" statement is one space different from > each other. Forgive me if i can't explain things clearly over the forum > Perhaps you'd be more comfortable on the tutor mailing list https://mail.python.org/mailman/listinfo/tutor Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > On 2016-09-26 23:03, M2 wrote: > >> Hello >> The program is designed to collect different statistics from servers >> across the network and populate in excel sheet. >> Library : xlsxwriter.0.9.3 >> >> Below is the Snip of code being used >> #! /usr/bin/python >> >> import xlsxwriter >> import os; >> import subprocess; >> import sys; >> import os.path; >> >> >> workbook=xlsxwriter.Workbook('Turnover_sheet.xlsx'); >> >> tools_sheet=workbook.add_worksheet('Citi Tools Verification'); >> >> hw_sheet=workbook.add_worksheet('Hardware Verification'); >> >> os_sheet=workbook.add_worksheet('OS Verification'); >> >> build_spec_sheet=workbook.add_worksheet('Build Specs Verification'); >> >> info_sheet=workbook.add_worksheet('Server Handover Info'); >> >> stan_sheet=workbook.add_worksheet('Standards'); >> >> sup_sheet=workbook.add_worksheet('Support Information'); >> >> tools_sheet.write('A3', 'Device Name', table_head); >> >> tools_sheet.write('B3', 'Machine Category', table_head); >> >> tools_sheet.write('C3', 'OS Platform', table_head); >> >> >> hw_sheet.merge_range('A1:N1', 'Hardware Information', head); >> >> hw_sheet.merge_range('A2:A3', 'Device Name', table_head); >> >> hw_sheet.merge_range('B2:B3', 'CPU / vCPU Count', table_head); >> >> >> os_sheet.merge_range('A2:A3', 'Server Name', table_head); >> >> os_sheet.merge_range('B2:B3', 'Kdump Config', table_head); >> os_sheet.merge_range('C2:C3', 'Grub Config', table_head); >> >> >> info_sheet.write('A1', 'Server Name', table_head); >> >> info_sheet.write('B1', 'Serial Number', table_head); >> >> info_sheet.write('C1', 'Backup Type', table_head); >> >> >> stan_sheet.write('A1', 'Item', table_head); >> >> stan_sheet.write('B1', 'Standard', table_head); >> >> stan_sheet.write('C1', 'Comments', table_head); >> >> >> def data_collection(fqdn,counter): >> counter=int(counter); >> red_counter=(int(counter))-2; >> s_count='A'+str(counter); >> s_r_count='A'+str(red_counter); >> tools_sheet.write(s_count,fqdn,cell_format); >> hw_sheet.write(s_count,fqdn,cell_format); >> os_sheet.write(s_count,fqdn,cell_format); >> info_sheet.write(s_r_count,fqdn,cell_format); >> s_count='D'+str(red_counter); >> sup_sheet.write(s_count,fqdn,cell_format); >> >> I get the following error >> sup_sheet.write(s_count,fqdn,cell_format); >> TypeError: 'tuple' object is not callable >> >> What I do not understand is why is python thinking sup_sheet.write as >> tuple. >> I tired to debug the program and added the following line >> print "\ts_count is ", type(s_count)," and value",s_count,"\n\tfqdn is ", >> type(fqdn), " and value is ",fqdn,"\n\tcell_format is ", type(cell_format), >> " and value is ",cell_format,"\n\t sup_sheet is ",type(sup_sheet)," and >> value is ",sup_sheet,"\n\n\n"; >> >> just before >> sup_sheet.write(s_count,fqdn,cell_format); >> >> And I got the following output: >> s_count isand value D2 >> fqdn isand value is Sample1.xyz.com >> cell_format isand value is >> >> sup_sheet isand >> value is >> >> >> >> s_count isand value D3 >> fqdn isand value is sample2.xyz.com >> cell_format isand value is >> >> sup_sheet isand >> value is >> >> >> >> Traceback (most recent call last): >> File "./turnover_sheet.py", line 398, in >> data_population(str(sys.argv[1])); >> File "./turnover_sheet.py", line 380, in data_population >> data_collection(fqdn,count); >> File "./turnover_sheet.py", line 219, in data_collection >> sup_sheet.write(s_count,fqdn,cell_format); >> TypeError: 'tuple' object is not callable >> >> I also saw the sheet populated with the first server and when it went to >> the second server and while populating it considered >> sup_sheet.write as a tuple which makes no sense because the rest of the >> writes are working fine. >> >> I have no clue why is it doing it ? >> Thoughts ? >> >> I can't see a problem in the part of the code that you've posted. > > Are there any other lines that use 'sup_sheet'? > > -- > https://mail.python.org/mailman/listinfo/python-list > There's nothing wrong with the snippet as shown - the problem must be elsewhere. I took the snippet as in the original email and made some slight changes to define cell_format, head and table_head & close the workbook: #!/usr/bin/env python import xlsxwriter import os; import subprocess; import sys; import os.path; workbook = xlsxwriter.Workbook('Turnover_sheet.xlsx'); cell_format = workbook.add_format({}) head = table_head = workbook.add_format({'bold': True}) # snipped the rest data_collection("sample1.xyz.com", 2) data_collection("sample2.xyz.com", 3) workbook.close() This runs cleanly for me with xlsxwriter 0.9.3 on Python 2.7.6. I understand this is a snippet, but it feels like you may be reassigning sup_sheet. Or, possibly assigning to "sup_sheet.w
Re: Socket programming
use > client: > server_address='192.168.2.2' server: > server_name='127.0.0.1' -- https://mail.python.org/mailman/listinfo/python-list
Re: xlsxwriter considering worksheet.write as tuple ???
On 2016-09-26 23:03, M2 wrote: Hello The program is designed to collect different statistics from servers across the network and populate in excel sheet. Library : xlsxwriter.0.9.3 Below is the Snip of code being used #! /usr/bin/python import xlsxwriter import os; import subprocess; import sys; import os.path; workbook=xlsxwriter.Workbook('Turnover_sheet.xlsx'); tools_sheet=workbook.add_worksheet('Citi Tools Verification'); hw_sheet=workbook.add_worksheet('Hardware Verification'); os_sheet=workbook.add_worksheet('OS Verification'); build_spec_sheet=workbook.add_worksheet('Build Specs Verification'); info_sheet=workbook.add_worksheet('Server Handover Info'); stan_sheet=workbook.add_worksheet('Standards'); sup_sheet=workbook.add_worksheet('Support Information'); tools_sheet.write('A3', 'Device Name', table_head); tools_sheet.write('B3', 'Machine Category', table_head); tools_sheet.write('C3', 'OS Platform', table_head); hw_sheet.merge_range('A1:N1', 'Hardware Information', head); hw_sheet.merge_range('A2:A3', 'Device Name', table_head); hw_sheet.merge_range('B2:B3', 'CPU / vCPU Count', table_head); os_sheet.merge_range('A2:A3', 'Server Name', table_head); os_sheet.merge_range('B2:B3', 'Kdump Config', table_head); os_sheet.merge_range('C2:C3', 'Grub Config', table_head); info_sheet.write('A1', 'Server Name', table_head); info_sheet.write('B1', 'Serial Number', table_head); info_sheet.write('C1', 'Backup Type', table_head); stan_sheet.write('A1', 'Item', table_head); stan_sheet.write('B1', 'Standard', table_head); stan_sheet.write('C1', 'Comments', table_head); def data_collection(fqdn,counter): counter=int(counter); red_counter=(int(counter))-2; s_count='A'+str(counter); s_r_count='A'+str(red_counter); tools_sheet.write(s_count,fqdn,cell_format); hw_sheet.write(s_count,fqdn,cell_format); os_sheet.write(s_count,fqdn,cell_format); info_sheet.write(s_r_count,fqdn,cell_format); s_count='D'+str(red_counter); sup_sheet.write(s_count,fqdn,cell_format); I get the following error sup_sheet.write(s_count,fqdn,cell_format); TypeError: 'tuple' object is not callable What I do not understand is why is python thinking sup_sheet.write as tuple. I tired to debug the program and added the following line print "\ts_count is ", type(s_count)," and value",s_count,"\n\tfqdn is ", type(fqdn), " and value is ",fqdn,"\n\tcell_format is ", type(cell_format), " and value is ",cell_format,"\n\t sup_sheet is ",type(sup_sheet)," and value is ",sup_sheet,"\n\n\n"; just before sup_sheet.write(s_count,fqdn,cell_format); And I got the following output: s_count isand value D2 fqdn isand value is Sample1.xyz.com cell_format isand value is sup_sheet isand value is s_count isand value D3 fqdn isand value is sample2.xyz.com cell_format isand value is sup_sheet isand value is Traceback (most recent call last): File "./turnover_sheet.py", line 398, in data_population(str(sys.argv[1])); File "./turnover_sheet.py", line 380, in data_population data_collection(fqdn,count); File "./turnover_sheet.py", line 219, in data_collection sup_sheet.write(s_count,fqdn,cell_format); TypeError: 'tuple' object is not callable I also saw the sheet populated with the first server and when it went to the second server and while populating it considered sup_sheet.write as a tuple which makes no sense because the rest of the writes are working fine. I have no clue why is it doing it ? Thoughts ? I can't see a problem in the part of the code that you've posted. Are there any other lines that use 'sup_sheet'? -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Sure, I just sent in a subscription request to it ... but I'll still be asking for help here. Please help out a newbie. When I master this language I can help other new users too (This is good for the world and for everyone involved). Ideally, Information and education should be free and not locked up by a few academics and institutions. On Tuesday, September 27, 2016 at 6:00:40 AM UTC+8, bream...@gmail.com wrote: > On Monday, September 26, 2016 at 9:57:52 PM UTC+1, Cai Gengyang wrote: > > Ok it works now: > > > > >>>for row in range(10): > > for column in range(10): > >print("*",end="") > > > > > > > > > > but how is it different from --- > > > > >>> for row in range(10): > >for column in range(10): > > print("*",end="") > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > > > Why does the example on top work and the example below doesn't work ? The > > only difference is that the "print" statement is one space different from > > each other. Forgive me if i can't explain things clearly over the forum > > > > Perhaps you'd be more comfortable on the tutor mailing list > https://mail.python.org/mailman/listinfo/tutor > > Kindest regards. > > Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
xlsxwriter considering worksheet.write as tuple ???
Hello The program is designed to collect different statistics from servers across the network and populate in excel sheet. Library : xlsxwriter.0.9.3 Below is the Snip of code being used #! /usr/bin/python import xlsxwriter import os; import subprocess; import sys; import os.path; workbook=xlsxwriter.Workbook('Turnover_sheet.xlsx'); tools_sheet=workbook.add_worksheet('Citi Tools Verification'); hw_sheet=workbook.add_worksheet('Hardware Verification'); os_sheet=workbook.add_worksheet('OS Verification'); build_spec_sheet=workbook.add_worksheet('Build Specs Verification'); info_sheet=workbook.add_worksheet('Server Handover Info'); stan_sheet=workbook.add_worksheet('Standards'); sup_sheet=workbook.add_worksheet('Support Information'); tools_sheet.write('A3', 'Device Name', table_head); tools_sheet.write('B3', 'Machine Category', table_head); tools_sheet.write('C3', 'OS Platform', table_head); hw_sheet.merge_range('A1:N1', 'Hardware Information', head); hw_sheet.merge_range('A2:A3', 'Device Name', table_head); hw_sheet.merge_range('B2:B3', 'CPU / vCPU Count', table_head); os_sheet.merge_range('A2:A3', 'Server Name', table_head); os_sheet.merge_range('B2:B3', 'Kdump Config', table_head); os_sheet.merge_range('C2:C3', 'Grub Config', table_head); info_sheet.write('A1', 'Server Name', table_head); info_sheet.write('B1', 'Serial Number', table_head); info_sheet.write('C1', 'Backup Type', table_head); stan_sheet.write('A1', 'Item', table_head); stan_sheet.write('B1', 'Standard', table_head); stan_sheet.write('C1', 'Comments', table_head); def data_collection(fqdn,counter): counter=int(counter); red_counter=(int(counter))-2; s_count='A'+str(counter); s_r_count='A'+str(red_counter); tools_sheet.write(s_count,fqdn,cell_format); hw_sheet.write(s_count,fqdn,cell_format); os_sheet.write(s_count,fqdn,cell_format); info_sheet.write(s_r_count,fqdn,cell_format); s_count='D'+str(red_counter); sup_sheet.write(s_count,fqdn,cell_format); I get the following error sup_sheet.write(s_count,fqdn,cell_format); TypeError: 'tuple' object is not callable What I do not understand is why is python thinking sup_sheet.write as tuple. I tired to debug the program and added the following line print "\ts_count is ", type(s_count)," and value",s_count,"\n\tfqdn is ", type(fqdn), " and value is ",fqdn,"\n\tcell_format is ", type(cell_format), " and value is ",cell_format,"\n\t sup_sheet is ",type(sup_sheet)," and value is ",sup_sheet,"\n\n\n"; just before sup_sheet.write(s_count,fqdn,cell_format); And I got the following output: s_count isand value D2 fqdn isand value is Sample1.xyz.com cell_format isand value is sup_sheet isand value is s_count isand value D3 fqdn isand value is sample2.xyz.com cell_format isand value is sup_sheet isand value is Traceback (most recent call last): File "./turnover_sheet.py", line 398, in data_population(str(sys.argv[1])); File "./turnover_sheet.py", line 380, in data_population data_collection(fqdn,count); File "./turnover_sheet.py", line 219, in data_collection sup_sheet.write(s_count,fqdn,cell_format); TypeError: 'tuple' object is not callable I also saw the sheet populated with the first server and when it went to the second server and while populating it considered sup_sheet.write as a tuple which makes no sense because the rest of the writes are working fine. I have no clue why is it doing it ? Thoughts ? -- Regards Mohan Mohta -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Cai Gengyang : > What is a tab and what is a space in python and what's the difference > ? > > Which piece of code is indented with tabs and which one is indented > with spaces ? Key questions that Python gurus are having a hard time answering! Equally confusing, you might run into this phantom phenomenon: >>> if True: ... a = 3 File "", line 2 a = 3 ^ SyntaxError: invalid character in identifier It might be useful to have a mode that echoes each input line as seen by Python (repr). Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Ok it works now: >>>for row in range(10): for column in range(10): print("*",end="") but how is it different from --- >>> for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation Why does the example on top work and the example below doesn't work ? The only difference is that the "print" statement is one space different from each other. Forgive me if i can't explain things clearly over the forum On Tuesday, September 27, 2016 at 3:57:18 AM UTC+8, Larry Hudson wrote: > On 09/26/2016 08:25 AM, Cai Gengyang wrote: > > I just wanted to note that sometimes the code works, sometimes it doesn't. > > (even though both are exactly the same code) ... Weird , dum dum dum > > > > It is NOT weird. Python is being consistent, YOU are not. > > These examples are NOT "exactly the same code"! The indenting is different. > Python (correctly) > treats them as being different. > > YOU MUST USE CONSISTENT INDENTING. You MUST always use spaces (the > recommended) or always use > tabs. Never, ever, not at any time, can you mix them. > > (Now, does that emphasize the point enough?) Go back and REWRITE your code > with CONSISTENT > indenting. > > -- > -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On 9/26/2016 12:54 PM, Cai Gengyang wrote: Which piece of code is indented with tabs and which one is indented with spaces ? I told you in my initial answer, where I said, referring to the two indented lines in one 'piece of code', "These indents are 4 spaces and 1 tabs." It is the mixture in one piece of code that is the problem. The tab in your original post has since be converted to (4) spaces. Tabs do not survive in email, sometimes just being deleted. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On 09/26/2016 08:25 AM, Cai Gengyang wrote: I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum It is NOT weird. Python is being consistent, YOU are not. These examples are NOT "exactly the same code"! The indenting is different. Python (correctly) treats them as being different. YOU MUST USE CONSISTENT INDENTING. You MUST always use spaces (the recommended) or always use tabs. Never, ever, not at any time, can you mix them. (Now, does that emphasize the point enough?) Go back and REWRITE your code with CONSISTENT indenting. -- -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Cai Gengyang writes: > What is a tab and what is a space in python and what's the difference > ? Try print('x\tx') in Python to see a tab character between the two x's. For me it looks the same as seven spaces, for you it will also look like some amount of whitespace but it might be a different amount. The two-character sequence \t inside a Python string literal means tab, same as \x09, same as \u0009, same as \N{TAB}, same as \N{HT}. (These sequences need to be inside quotes.) With print('xx\tx'), the tab looks, for me, the same as six spaces. It's funny that way: it's a single character, but it's shown differently depending on it's position on the line. You may get a tab character by pressing the tab key, but it's usual for that key to be smart in some way or used for some other purpose. > Which piece of code is indented with tabs and which one is indented > with spaces ? I've replaced the tabs with # below, and the greater-than signs with @. This may not have been exactly your code any more, but try to imagine a tab in place of each # anyway. for row in range(10): @for column in range(10): @ # print("*",end="") @ # @ SyntaxError: inconsistent use of tabs and spaces in indentation for row in range(10): @ #for column in range(10): @ # print("*",end="") @ It would be better for you to get a better editor that either prevented you from getting into this mess in the first place, or at least showed where the offending characters are. It may be possible to configure your editor to be better. The details depend on what exactly you are using. What are you using? -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On 09/26/2016 06:54 PM, Cai Gengyang wrote: What is a tab and what is a space in python and what's the difference ? Which piece of code is indented with tabs and which one is indented with spaces ? Please do not top-post in this list. Put your text after the message you quote. Tabs and spaces are 2 different characters, tab ASCII code is 9, space ASCII code is 32. You *need* to understand that they are 2 differents characters. The problem come with their representation. 1/ a space is represented by 1 whitespace 2/ a tab is represented by x whitespaces. The number x depends on your text editor. When you want to indent a python block, you put whitespaces on its left to indent it. You can indent using either tabs or spaces. Python does not tell you which one to use, but it tells you to choose *one* method, and stick with it. jm -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On Tue, 27 Sep 2016 01:25 am, Cai Gengyang wrote: > I just wanted to note that sometimes the code works, sometimes it doesn't. > (even though both are exactly the same code) ... Weird , dum dum dum They are not the same code. One of them mixes tabs and spaces for the same indent level, the other does not. Here is a hint how you can tell the difference between lines with tabs and lines with spaces in the Python interactive interpreter: - if you pressed the spacebar repeatedly to get the indent, like SPACEBAR SPACEBAR SPACEBAR SPACEBAR, then the line will be indented with spaces; - if you pressed the tab key to get the indent, like TAB TAB, then the line will be indented with tabs; - if you pressed the tab key first, then spaces, like TAB SPACEBAR, then the line will be indented with a mixture of tabs and spaces. If you are copying code from a text editor, check your editor's settings. Some editors will be configured to insert spaces when you press the tab key. Your first example has: 1st line: no indent 2nd line: seven spaces 3rd line: tab + two spaces Notice that the 2nd and 3rd line start with inconsistent indentation: one uses spaces, the other uses tab. This is bad. Your second example has: 1st line: no indent 2nd line: tab 3rd line: tab + three spaces Notice that the 2nd and 3rd line start with the same indentation: both start with a tab. This is better, it is enough to satisfy the interpreter, but it would be better if you picked one (spaces) or the other (tabs) and ONLY used that. Other wise you will just confuse yourself. But you won't confuse the interpreter. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
What is a tab and what is a space in python and what's the difference ? Which piece of code is indented with tabs and which one is indented with spaces ? On Tuesday, September 27, 2016 at 12:40:16 AM UTC+8, MRAB wrote: > On 2016-09-26 16:25, Cai Gengyang wrote: > > I just wanted to note that sometimes the code works, sometimes it doesn't. > > (even though both are exactly the same code) ... Weird , dum dum dum > > > for row in range(10): > >for column in range(10): > > print("*",end="") > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > for row in range(10): > > for column in range(10): > >print("*",end="") > > > [snip] > > They are not exactly the same code. They are indented differently (tabs > vs spaces), and that matters in Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On 2016-09-26 16:25, Cai Gengyang wrote: I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation for row in range(10): for column in range(10): print("*",end="") [snip] They are not exactly the same code. They are indented differently (tabs vs spaces), and that matters in Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On 09/26/2016 05:25 PM, Cai Gengyang wrote: I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation for row in range(10): for column in range(10): print("*",end="") Here, from itertools import product for row,column in product(range(10), range(10)): print("*", end="") Problem solved :) On a more serious note, they're not the same code, in the same way than print("foo") print("bar") is not the same code than print("foo")print("bar") You're fooled by your editor which displays 2 different characters the same way. Tab or space does matter in python, get over it and move on with your python life. Actually python is a great debugger for misconfigured text editors. jm -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum >>> for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end="") On Monday, September 26, 2016 at 5:36:26 PM UTC+8, Steven D'Aprano wrote: > On Monday 26 September 2016 18:32, Cai Gengyang wrote: > > > These are my attempts --- > > That's nice. Do you have a question? > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > When you indent, press TAB or SPACE but not both. > > This error can only happen if you are use spaces for some lines and tabs for > other lines. Do not do that. Use spaces only or tabs only, never both. > > > > SyntaxError: expected an indented block > > You forgot to indent at all. You must indent with at least one space or one > tab. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Use only spaces, or only tabs, never both. If you use spaces for one line, > then > always use spaces. If you use tabs for one line, then always use tabs. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Same as above. > > > > > > -- > Steven > git gets easier once you get the basic idea that branches are homeomorphic > endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: sphinx (or other means to document python)
On 09/25/2016 03:20 AM, chitt...@uah.edu wrote: On Sunday, September 11, 2016 at 3:56:36 PM UTC-5, chit...@uah.edu wrote: (about being frustrated with sphinx) I _remain_ frustrated - even as I finally figured out how to use it (thanks to a complete example from a friend) sphinx is very picky about spaces, lines - I had a line with some math formula spaces and tabs (after r''' - and sphinx kept ignoring that line when it works, the documentation (my preference is LaTeX) is great - the procedure for embedding the documentation as doctrings can be difficult, at times noweb is considerably simpler - but does not allow for the extraction of docstrings/comments - and does provide for a fairly painless way to combine comments, documentation along with code Hi, Keep in mind sphinx has a greater scope than writing docs from/for python. You could use sphinx to document anything. That why it's not that straightforward to build doc from the source code. Yet it's possible with some scripts available on the internet. But it looks like you've managed to find out. Ultimately, sphinx is designed to write good documentation, and is slightly overkill if you want to build docs only from the source code. But keep in mind that this kind of doc tend to be poor. If you take a look at the python documentation, the paramount of good documentation :) you'll notice it's not generated from the code docstrings. For api reference documentation, the source code is sometimes the best option. jm -- https://mail.python.org/mailman/listinfo/python-list
RE: [E] ANN: asciimatics v1.7.0
Looks cool. Why does it want to install pypiwin32 on my 64bit Linux box? I installed all the requirements separately, but it still wants to install pypiwin32. (pypiwin32 appears to not support Python3) # pip3.5 install asciimatics Collecting asciimatics Using cached asciimatics-1.7.0-py2.py3-none-any.whl Requirement already satisfied (use --upgrade to upgrade): future in /usr/local/lib/python3.5/site-packages (from asciimatics) Requirement already satisfied (use --upgrade to upgrade): pyfiglet>=0.7.2 in /usr/local/lib/python3.5/site-packages (from asciimatics) Requirement already satisfied (use --upgrade to upgrade): Pillow>=2.7.0 in /usr/local/lib/python3.5/site-packages (from asciimatics) Collecting pypiwin32 (from asciimatics) Using cached pypiwin32-219.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-3_afj4p1/pypiwin32/setup.py", line 121 print "Building pywin32", pywin32_version ^ SyntaxError: Missing parentheses in call to 'print' -Original Message- From: Python-list [mailto:python-list-bounces+bill.scherer=verizonwireless@python.org] On Behalf Of Peter Brittain Sent: Saturday, September 24, 2016 11:05 AM To: python-announce-l...@python.org; python-list@python.org Subject: [E] ANN: asciimatics v1.7.0 I am very pleased to announce asciimatics v1.7.0! This is a major update since the last announced version of the package. ## What is asciimatics? Asciimatics is a package to help people create full-screen text UIs (from interactive forms to complex text animations) on Linux, Windows and OSX. It supports python 2 & 3 and is licensed under the Apache Software Foundation License 2.0. ## What’s new? This release includes a `widgets` sub-package to create text User Interfaces, complete with the standard basic set of widgets you would expect for creating forms – e.g. text boxes, check boxes, buttons, etc. Despite its name, asciimatics now fully supports Unicode in utf-8 environments, allowing for non-ASCII input from the keyboard and output to the screen. This is extended to the widgets, so you can use them for languages other than English. A new Plasma renderer was added, continuing the theme of retro special effects. This one can be used to create lava-lamp style animated backgrounds. See the new plasma.py sample for an example of how to use it. A `highlight()` method was added to the Screen to allow you to colour wash parts of the screen as if you were using a highlighter pen. This can be used to highlight or lowlight parts of the screen. For an example, have a look at the shadows on a Frame in the forms.py sample. A complete suite of unit tests and CI builds have been created, to ensure that the code continues to run across all supported environments. Latest results are always available at the project home page. Various other minor enhancements and fixes have gone in. For a complete list have a look at the change log: https://raw.githubusercontent.com/peterbrittain/asciimatics/ master/CHANGES.rst ## Where can I find out more? https://github.com/peterbrittain/asciimatics -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On Monday 26 September 2016 18:32, Cai Gengyang wrote: > These are my attempts --- That's nice. Do you have a question? > SyntaxError: inconsistent use of tabs and spaces in indentation When you indent, press TAB or SPACE but not both. This error can only happen if you are use spaces for some lines and tabs for other lines. Do not do that. Use spaces only or tabs only, never both. > SyntaxError: expected an indented block You forgot to indent at all. You must indent with at least one space or one tab. > SyntaxError: inconsistent use of tabs and spaces in indentation Use only spaces, or only tabs, never both. If you use spaces for one line, then always use spaces. If you use tabs for one line, then always use tabs. > SyntaxError: inconsistent use of tabs and spaces in indentation Same as above. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Cai Gengyang writes: > These are my attempts --- > for row in range(10): > for column in range(10): > print("*",end=" ") > > SyntaxError: inconsistent use of tabs and spaces in indentation What do you type yourself? Could it be that your software starts the second line with a tab automatically and then you type spaces yourself? When I type commands to the Python interpreter, it looks like this: >>> if 1: ...print(1) ... 1 The interpreter inserts the dots below the prompt, and a space, and here I have inserted three more spaces for indentation. The interpreter then ignores those dots and space, and it doesn't seem to let me use any tabs anyway. You are running the interpreter in a different way. That's fine. But what exactly are you doing? (If you are using the spacebar, try the tabulation key instead. If you are using the tabulation key, try the spacebar instead.) -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Steven D'Aprano writes: > P.S. Hey Jussi, is the backspace key on your keyboard broken? Every > time somebody bottom-posts without trimming, a pixie dies... I was annoyed by the top-posted one-liner in response to the last line of Terry's response. I responded in kind and then it was too late. I'm sorry. It was a childish thing to do. Backspace key is fine. I tend to use C-w and C-k for trimming, and they are fine, too. I was the broken part. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
These are my attempts --- >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: expected an indented block >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * On Monday, September 26, 2016 at 4:16:37 PM UTC+8, Steven D'Aprano wrote: > On Monday 26 September 2016 17:21, Jussi Piitulainen wrote: > > > Cai Gengyang writes: > [snip 80 or so lines] > > Reindent your lines. > > In case Cai doesn't know what "reindent" means: > > > It depends on your text editor. At worst, you have to delete all the indents, > and re-enter them, using ONLY spaces, or ONLY tabs, but never mixing them. > > Some text editors may have a command to reindent, or clean indentation, or > fix > indentation, or something similar. > > Or you can use the tabnanny.py program: > > > python -m tabnanny path/to/file.py > > > > P.S. Hey Jussi, is the backspace key on your keyboard broken? Every time > somebody bottom-posts without trimming, a pixie dies... > > > > -- > Steven > git gets easier once you get the basic idea that branches are homeomorphic > endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On Monday 26 September 2016 17:21, Jussi Piitulainen wrote: > Cai Gengyang writes: [snip 80 or so lines] > Reindent your lines. In case Cai doesn't know what "reindent" means: It depends on your text editor. At worst, you have to delete all the indents, and re-enter them, using ONLY spaces, or ONLY tabs, but never mixing them. Some text editors may have a command to reindent, or clean indentation, or fix indentation, or something similar. Or you can use the tabnanny.py program: python -m tabnanny path/to/file.py P.S. Hey Jussi, is the backspace key on your keyboard broken? Every time somebody bottom-posts without trimming, a pixie dies... -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Cai Gengyang writes: > So what do i need to do to correct the error ? > > Regards > > > On Monday, September 26, 2016 at 2:48:16 PM UTC+8, Terry Reedy wrote: >> On 9/26/2016 1:59 AM, Cai Gengyang wrote: >> > Why is it that you need a print() at the end to create the table for >> > example 1: >> > >> > Example 1 --- >> > >> for row in range(10): >> > for column in range(10): >> > print("*",end=" ") >> > # Print a blank line for next row >> > print() >> >> These indents are either 4 or 8 spaces. >> >> The print provides a carriage return. >> Each line ends with a space. >> >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> > * * * * * * * * * * >> >> One can avoid both extra print and spaces with >> >> for row in range(10): >> for column in range(10): >> print("*", end=" " if column<9 else '\n') >> >> # or >> for row in range(10): >> print(' '.join(['*']*10)) >> # or >> print((' '.join(['*']*10)+'\n')*10) >> >> # or >> for row in range(10): >> print('* '*9 + '*') >> # or >> print(('* '*9 + '*\n')*10) >> >> >> > but not for Example 2 --- >> > >> > for row in range(10): >> > print("*",end=" ") >> > >> > * * * * * * * * * * >> > >> > When I try to do example 1 without the print() statement at the end, I get >> > this error : >> > >> > for row in range(10): >> > for column in range(10): >> >print("*",end=" ") >> >> These indents are 4 spaces and 1 tabs. >> >> > SyntaxError: inconsistent use of tabs and spaces in indentation >> >> Because you mixed tabs and spaces. Has nothing to do with print statement. >> >> >> -- >> Terry Jan Reedy Reindent your lines. -- https://mail.python.org/mailman/listinfo/python-list
Python C API: How to debug reference leak?
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
So what do i need to do to correct the error ? Regards On Monday, September 26, 2016 at 2:48:16 PM UTC+8, Terry Reedy wrote: > On 9/26/2016 1:59 AM, Cai Gengyang wrote: > > Why is it that you need a print() at the end to create the table for > > example 1: > > > > Example 1 --- > > > for row in range(10): > > for column in range(10): > > print("*",end=" ") > > # Print a blank line for next row > > print() > > These indents are either 4 or 8 spaces. > > The print provides a carriage return. > Each line ends with a space. > > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > One can avoid both extra print and spaces with > > for row in range(10): > for column in range(10): > print("*", end=" " if column<9 else '\n') > > # or > for row in range(10): > print(' '.join(['*']*10)) > # or > print((' '.join(['*']*10)+'\n')*10) > > # or > for row in range(10): > print('* '*9 + '*') > # or > print(('* '*9 + '*\n')*10) > > > > but not for Example 2 --- > > > > for row in range(10): > > print("*",end=" ") > > > > * * * * * * * * * * > > > > When I try to do example 1 without the print() statement at the end, I get > > this error : > > > > for row in range(10): > > for column in range(10): > > print("*",end=" ") > > These indents are 4 spaces and 1 tabs. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Because you mixed tabs and spaces. Has nothing to do with print statement. > > > -- > Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list