Re: Load averages and Python threads on different Linux cloud provider setup
On May 31, 10:22 pm, Chris Angelico wrote: > On Tue, May 31, 2011 at 9:25 PM, Mohanaraj Gopala Krishnan > > wrote: > > Any suggestion on why the load would be a lot higher or how I could > > debug this further is greatly appreciated. > > First off, an easy question: Is system load low and comparable on both > systems when this script is _not_ running? Yes, they both are are < 0.5 (for all averages) and comparable. > > Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Simple problem with GUI!!
Hello Guys, I am a beginner with Python programming and would like to implement some GUI functionalities along with my main work. So I was trying to implement one basic program (available from books). Here is the code, import Tkinter TopLevelWindowObj = Tkinter.Tk() # Creating a root window QuitObj = Tkinter.Button(TopLevelWindowObj, text = "QUIT", command = TopLevelWindowObj.quit) # Creating a Button QuitObj.pack() # Positioning the button Tkinter.mainloop() # So, this is a code to display a window with a "QUIT" button and by clickign the button the entire window is closed. When I execute this program, the window does not close down but the window is completely disabled and after a few seconds I get the following message in a message window, ** Message box name - Microsoft Visual C++ Runtime Library Runtime Error! program...\Python22\core\lib\site-packages\Pythonwin\Pythonwin.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. At the end I had to close down my entire python compiler. I am using Python compiler with following specs in Windows XP OS. Pythonwin - Python IDE and GUI Framework for Windows. PythonWin 2.2.1 (#34, Feb 25 2003, 11:29:09) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond Please let me know why is this happening and also if I am missing something in the way of programming. Thanks in advance. Cheers, Mohan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
Hi Kaushal, Other than "Core Python" by Chun, also try "Python: How To Program" by Dietel & Dietel. It is one of the good books for bigginers. Good Luck, Mohan. On Nov 6, 10:00 am, "kaushal" <[EMAIL PROTECTED]> wrote: > Hi > > How do i start Learning Python,is there any reference material which I > can refer since I dont have > any programming experience > > Thanks and Regards > > Kaushal -- http://mail.python.org/mailman/listinfo/python-list
How do I edit a PythonWin path to import custom built modules???
Hi Guys, I've been using the following IDE, "Pythonwin - Python IDE and GUI Framework for Windows. Copyright 1994-2001 Mark Hammond " With respect to my work, I had created my own modules (.py files) in drives and folders other than the python root. I know that if I need to import these modules, I need to specify the path of the directory where I've put my modules. I've tried the "Edit Python Path" sub menu in the menu "Tools" of PythonWin, but I could not add a new path i.e.- D:\\\\ATS. Could any one please let me know how could I add a new path to access my own modules. Thanks in advance, Mohan Swaminathan. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I edit a PythonWin path to import custom built modules???
BartlebyScrivener wrote: > mohan wrote: > > > I had created my own modules (.py files) in > > drives and folders other than the python root. > > Probably easiest if you keep them all in one place. Then add that > "place" to your path by going into Control > Panel|System|Advanced|Environment Variables and adding the path to the > path variable. > > Hope that helps. > > rd Thanks rd, I tried your advice, by adding a new path to the "System Variable" section. It still does not work. I don't understand how could PythonWin interpreter would look for new folders when we have not yet updated the path in the interpreter. I'm sorry I might be mising something here as i'm not too familiar with these things. Any further ideas?? Regards, Mohan. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I edit a PythonWin path to import custom built modules???
BartlebyScrivener wrote: > Gabriel Genellina wrote: > > > > import sys > > print sys.path > > and see what's there. > > Yup. Did that before. That's what I mean. The d:\\python is there and > it doesn't come from the PythonPath in my windows registry. Maybe it > scans for any directory with python in the name? > > ['', 'C:\\WINDOWS\\system32\\python24.zip', 'd:\\python', > 'C:\\Python24\\DLLs', 'C:\\Python24\\lib', > 'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', > 'C:\\Python24\\Lib\\site-packages\\pythonwin', 'C:\\Python24', > 'C:\\Python24\\lib\\site-packages', > 'C:\\Python24\\lib\\site-packages\\win32', > 'C:\\Python24\\lib\\site-packages\\win32\\lib', > 'C:\\Python24\\lib\\site-packages\\wx-2.7.1-msw-ansi'] > > rd Hi rd, To revert back to my question, I wanted to add a new path to my PythonWin IDE to access modules which are in folders other than normal python paths. Here, I need to put my modules in different folders since it is a request of the user. I tried to create a new PYTHONPATH in the environmental variables section, which did not work . So, is there any way where I can temporarily append the new path/s, where the PythonWin interpreter would look during run time and discard after the interpreter is closed. For example, my main program "ATS.py" will be put in the folder D:\\dSPACE\ATS\ and my modules will be put in other folders inside the folder ATS, D:\\dSPACE\ATS\ Level Regulation, D:\\dSPACE\ATS\ Curve Detection and so on. So, I would like to tell the interpreter to look in to these folders to import the modules. Is that possible??? Regards, Mohan -- http://mail.python.org/mailman/listinfo/python-list
Using with CSV library in Python 2.2!!!
Hi Guys, I'm back one more basic question, this time on using CSV (Comma Seperated Value) library with Python 2.2. At my workplace I have Python 2.2 installed and am using PythonWin 2.2.1 IDE from Mark Hammond. I want to use the CSV library module for reading data from the .csv files and when I try to import the module, I get the error "CSV module is not found". The reason, CSV module is missing from the Python root directories. Now my first question is, 1. Does Python 2.2 come with CSV library module or not? If yes, have I lost it somewhere?? 2. If Python 2.2 does not come with CSV module, is it possible to add the CSV module to the Python root and start working?? 3. If yes, where do I get this module from?? Would be glad to have an answer for these questions. Thanks in advance. Cheers, Mohan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using with CSV library in Python 2.2!!!
[EMAIL PROTECTED] wrote: > mohan> 1. Does Python 2.2 come with CSV library module or not? If yes, > mohan>have I lost it somewhere?? > > As the docs for the csv module indicate, it was new in 2.3. > > mohan> 2. If Python 2.2 does not come with CSV module, is it possible to > mohan>add the csv module to the Python root and start working?? > > You might find that it will work with 2.2, though you might have to make > some source code changes to _csv.c to get it to compile. > > mohan> 3. If yes, where do I get this module from?? > > You can get both csv.py and _csv.c via ViewCVS: > > > http://svn.python.org/view/*checkout*/python/tags/r236/Modules/_csv.c?content-type=text%2Fplain&rev=52574 > > http://svn.python.org/view/*checkout*/python/tags/r236/Lib/csv.py?content-type=text%2Fplain&rev=52574 > > Skip Hi Skip, Thanks man. What kind of source code changes should I do to "_csv.c" file , have you any idea on that too?? Otherwise upgrading to Python 2.4 would be the easiest choice. Thanks again. cheers, Mohan. -- http://mail.python.org/mailman/listinfo/python-list
help on python regular expression named group
Dear All, Here is my script : #!/usr/bin/python import re # A string. logs = "date=2012-11-28 time=21:14:59" # Match with named groups. m = re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))", logs) # print print m.groupdict() Output: {'date': '2012-11-28', 'datetime': '*date=2012-11-28 time=21:14:59*', 'time': '21:14:59'} Required output : == {'date': '2012-11-28', 'datetime': '*2012-11-28 21:14:59*', 'time': '21:14:59'} need help to correct the below regex (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))" so that It will have : 'datetime': '2012-11-28 21:14:59' instead of 'datetime': 'date=2012-11-28 time=21:14:59' any help would be greatly appreciated Thanks Mohan L -- http://mail.python.org/mailman/listinfo/python-list
Re: help on python regular expression named group
On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau wrote: > On 16 July 2013 07:55, Mohan L wrote: > > > > Dear All, > > > > Here is my script : > > > > #!/usr/bin/python > > import re > > > > # A string. > > logs = "date=2012-11-28 time=21:14:59" > > > > # Match with named groups. > > m = > > > re.match("(?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))", > > logs) > > > > # print > > print m.groupdict() > > > > Output: > > > > > > {'date': '2012-11-28', 'datetime': 'date=2012-11-28 time=21:14:59', > 'time': > > '21:14:59'} > > > > > > Required output : > > == > > > > {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time': > > '21:14:59'} > > > > need help to correct the below regex > > > > (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))" > > > > so that It will have : 'datetime': '2012-11-28 21:14:59' instead of > > 'datetime': 'date=2012-11-28 time=21:14:59' > > > > any help would be greatly appreciated > > Why do you need to do this in a single Regex? Can't you just " > ".join(..) the date and time? > I using another third party python script. It takes the regex from configuration file. I can't write any code. I have to do all this in single regex. Thanks Mohan L -- http://mail.python.org/mailman/listinfo/python-list
pip and distutils
I have created a source distribution using distutils which specifies external packages using: setup( ..., requires = ['Foo (>= 0.7)', 'Bar (>= 2.4.5)'], ... ) When I use pip to install this distribution, I find that it does not automatically install the packages Foo and Bar. What extra step do I need to perform to have pip automatically install the "required" packages? I am using Python 3.2.3. --Vraj -- http://mail.python.org/mailman/listinfo/python-list
Python Training
Hi, We are an IT Training company located in Bangalore, Chennai and Coimbatore. We provide Python training with Placement Assistance. For more details, email to mo...@cgonsoft.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Training
On Apr 7, 2:21 pm, Mohan kumar wrote: > Hi, > We are an IT Training company located in Bangalore, Chennai and > Coimbatore. We provide Python training with Placement Assistance. For > more details, email to mo...@cgonsoft.com We also provide Online Training. -- http://mail.python.org/mailman/listinfo/python-list
RE: Where is the latest step by step guide to use Jython to compilePython into Java?
David, As per my knowledge, You can’t find steps to convert python into java anywhere. 1) I am not expert in python, but familiar with Java. Python by default uses python-vm and converts into byte code, which is not compatible with JVM byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is executing python on top of JVM, by doing that, we can make use of java library inside python and/or vice versa. 2) Python is dynanmic programming (but strongly typed), java is static-typed language. Currently it is not possible to convert python into java, since python types are dynamically identified, not identified during compilation. Regards Mohan From: python-list-bounces+mohan.narayanaswamy-2=sc@python.org [mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf Of David Shi Sent: Monday, June 04, 2012 10:36 PM To: python-list@python.org Subject: Where is the latest step by step guide to use Jython to compilePython into Java? Hello, Where is the latest step by step guide to use Jython to compile Python into Java? I found that it was very confusing by reading not updated text. Please help. Regards. David This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions. -- http://mail.python.org/mailman/listinfo/python-list
RE: Where is the latest step by step guide to use Jython to compilePython into Java?
David, Thanks for the link, here that compilation steps won’t produce java code, but it could create .class file (or jar). Regards Mohan From: David Shi [mailto:davidg...@yahoo.co.uk] Sent: Monday, June 04, 2012 11:35 PM To: Narayanaswamy, Mohan Cc: python-list@python.org Subject: Re: Where is the latest step by step guide to use Jython to compilePython into Java? Mohan, Please see the following link as an example. http://www.ssec.wisc.edu/~tomw/visadtutor/compile.html I just can not make any success with some of these instructions. Compiling your Python code with jythonc I do not know whether I downloaded a wrong version of Jythonc? Or, got mismatched software or instructions. Please provide assistance, by providing the tested software and instructions. Regards. David From: "Narayanaswamy, Mohan" To: David Shi Cc: python-list@python.org Sent: Monday, 4 June 2012, 15:56 Subject: RE: Where is the latest step by step guide to use Jython to compilePython into Java? David, As per my knowledge, You can’t find steps to convert python into java anywhere. 1) I am not expert in python, but familiar with Java. Python by default uses python-vm and converts into byte code, which is not compatible with JVM byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is executing python on top of JVM, by doing that, we can make use of java library inside python and/or vice versa. 2) Python is dynanmic programming (but strongly typed), java is static-typed language. Currently it is not possible to convert python into java, since python types are dynamically identified, not identified during compilation. Regards Mohan From: python-list-bounces+mohan.narayanaswamy-2=sc@python.org [mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf Of David Shi Sent: Monday, June 04, 2012 10:36 PM To: python-list@python.org Subject: Where is the latest step by step guide to use Jython to compilePython into Java? Hello, Where is the latest step by step guide to use Jython to compile Python into Java? I found that it was very confusing by reading not updated text. Please help. Regards. David This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions. This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://ww
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: 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 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
text mining
anotology using text mining in python pls any one one described fo me -- https://mail.python.org/mailman/listinfo/python-list
[pyinotify] help required to send only one mail for chunk of events
Hi All, I am using the bellow script to watch directories. Using 20 seconds to aggregate together a larger chunk of events and enabled coalescing of events. I wanted to send an email notification with content of logfile after 15 mins on any change. The idea is I want to send only one mail for chunk of events.Say for example, I want to send only one email when some one extract a tar.gz file in watched directory. I can write method to send email (say send_mail) which accept content of logfile. But I am not sure How to integrate it with below code so that my send_mail method get triggered only once for chunk of events. Any help will be really appreciated. Thanks for your time and efforts. Here is code: #!/usr/bin/env python import sys try: import pyinotify except: print "pyinotify not installed" sys.exit(1) import datetime from ConfigParser import SafeConfigParser class MyEventHandler(pyinotify.ProcessEvent): log = "" flog = None def process_IN_CREATE(self, event): """ This method processes a specific type of event: IN_CREATE. event is an instance of Event. """ self.write_msg("CREATING", event.pathname) def process_IN_DELETE(self, event): """ This method processes a specific type of event: IN_DELETE. event is an instance of Event. """ self.write_msg("DELETING", event.pathname) def process_IN_MODIFY(self, event): """ This method processes a specific type of event: IN_MODIFY. event is an instance of Event. """ self.write_msg("MODIFIED", event.pathname) def process_IN_OPEN(self, event): """ This method processes a specific type of event: IN_OPEN. event is an instance of Event. """ self.write_msg("OPENED", event.pathname) def process_IN_ACCESS(self, event): """ This method processes a specific type of event: IN_ACCESS. event is an instance of Event. """ self.write_msg("ACCESSED", event.pathname) def process_IN_ATTRIB(self, event): """ This method processes a specific type of event: IN_ATTRIB. event is an instance of Event. """ self.write_msg("ATTRIB", event.pathname) def process_IN_DELETE_SELF(self, event): """ This method processes a specific type of event: IN_DELETE_SELF. event is an instance of Event. """ self.write_msg("DELETE_SELF", event.pathname) def process_IN_MOVED_FROM(self, event): """ This method processes a specific type of event: IN_MOVED_FROM. event is an instance of Event. """ self.write_msg("FILE MOVED FROM", event.pathname) def process_IN_MOVED_TO(self, event): """ This method processes a specific type of event: IN_MOVED_TO. event is an instance of Event. """ try: msg = event.src_pathname + " -> " + event.pathname except: msg = event.pathname self.write_msg("FILE MOVED INTO", msg) def openlog(self, logfile): """ This method opens log file in append mode. """ self.log = logfile self.flog = file(self.log, 'a') def write_msg(self, event, msg): """ This method writes evens in logfile as well as stdout. """ out_msg = self.generate_timestamp() + "\t" + event + ": " + msg + "\n" if len(self.log) > 0: self.flog.write(out_msg) self.flog.flush() print "LOGGED", out_msg else: print "NOT LOGGED", out_msg def generate_timestamp(self): """ This method generate and return timestamp for log. Timestamp format is /MM/DD-HH:MM:SS. """ d = datetime.datetime.now() datestr = "%d/%.2d/%.2d-%.2d:%.2d:%.2d" % (d.year, d.month, d.day, d.hour, d.minute, d.second) return datestr def main(): parser = SafeConfigParser() parser.read('/etc/mywatcherscript.ini') ### The watch manager stores the watches and provides operations on watches ### wm = pyinotify.WatchManager() ### List of watched events. To specify two or more events just orize them ### mask = pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY # List of watch path #watched_path_list=['/var/log','/tmp'] watched_path_list=parser.get('mywatcherscript', 'watched_path_list').split(',') pid_file_name=parser.get('mywatcherscript', 'pid_file_name') logfile=parser.get('mywatcherscript', 'logfile') # Add watch(s) on the provided path(s) with associated flag value. # Parameters: # path - Path to watch, the path can either be a file or a directory. #Also accepts a sequence (list) of paths. # mask (int) - Bitmask of events. # rec (bool) - Recursively add watches from path on all its subdirectories. # auto_add (bool) - Automatically add watches on newly created directories in watched parent directory. # # Returns: dict of {str: int} # dict of paths associated to watch descriptors. wm.add_watch(watched_path_list, mask, rec=True, auto_add=True) # event handler eh = MyEventHandler() eh.openlog(logfile) # notifier # Put an arbitrary large value (20 seconds) to aggregate together a larger # chunk of events. For instance if you repeat several times a given action # on the same file its events will be coalesced into a single event and only # one event of this type will be reported (for this period). notifier = pyinotify.Notifier(wm, eh, read_freq=20) #notifier = pyinotify.Notifier(wm, eh) # Enable coalescing of events. notifier.c
subprocess : AttributeError: 'Popen' object has no attribute 'read'
Hello, I am trying to grep the keyword (which I got from report_file ) from report_file I tried multiple ways but am unable to get it to work. Below are the methods I tried. fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() g_info=subprocess.Popen('cat report_file| grep -i '+var1, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' +++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=os.command(cmd) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : The Code executes but the output is in screen and does not get stored in a variable. I am interested if I can achieve the same result with subprocess calls + fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True). g_info=g_info.stdout.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error AttributeError: 'Popen' object has no attribute 'read' fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd=['cat','report_file','|','grep','-i',serv_name] g_info=subprocess.Popen(cmd) g_info.wait() try : g_info=g_info.stdout.readlines() print g_info except AttributeError : pass g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : Nothing gets printed out -- https://mail.python.org/mailman/listinfo/python-list
Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'
On Thursday, January 3, 2019 at 1:49:31 PM UTC-6, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > > > Hello, > > I am trying to grep the keyword (which I got from report_file ) from > > report_file > > > > I tried multiple ways but am unable to get it to work. > > How about, instead, you simply open the file and iterate through it, > looking for the keyword? 'grep' is irrelevant, and definitely 'cat' is > a waste of effort. Python code doesn't have to be written as a less > terse form of bash. > > ChrisA I am no expert in python but I found grep is lot faster in than the methods of reading files from python point me to direction if you know of anything faster I would appreciate it. -- https://mail.python.org/mailman/listinfo/python-list
Help to understand the data structure
Hi All, I am using get_devices_list method from this module: https://github.com/Tufin/pytos/blob/master/pytos/securetrack/helpers.py. Here is my two like code and output looks like: https://pastebin.com/K9KBeqYL I am not able to manage to further loop the data to print below output: devicename1 10 devicename2 11 devicename3 12 I spend quit some time still not able to figure out how to parse. Can some one through some light on how to phrase it. -- Thanks & Regards Mohan L -- https://mail.python.org/mailman/listinfo/python-list
Re: Help to understand the data structure
Hi All, Please ignore it, I was able to figure out it. for dev in devlist: print (dev.name, dev.id) -- Thanks & Regards Mohan L On Fri, Sep 27, 2019 at 8:41 PM Mohan L wrote: > Hi All, > > I am using get_devices_list method from this module: > https://github.com/Tufin/pytos/blob/master/pytos/securetrack/helpers.py. > Here is my two like code and output looks like: > https://pastebin.com/K9KBeqYL > > > I am not able to manage to further loop the data to print below output: > > > devicename1 10 > > devicename2 11 > > devicename3 12 > > > I spend quit some time still not able to figure out how to parse. Can some > one through some light on how to phrase it. > > > -- > Thanks & Regards > Mohan L > > > -- https://mail.python.org/mailman/listinfo/python-list
compare two list of dictionaries
Dear All, I have two list of dictionaries like below: In the below dictionaries the value of ip can be either hostname or ip address. output1=[ {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, {'count': 4, 'ip': 'xxx.xx.xxx.2'}, {'count': 8, 'ip': 'xxx.xx.xxx.3'}, {'count': 10, 'ip': 'xxx.xx.xxx.4'}, {'count': 212, 'ip': 'hostname1'}, {'count': 27, 'ip': 'hostname2'}, {'count': 513, 'ip': 'hostname3'}, {'count': 98, 'ip': 'hostname4'}, {'count': 1, 'ip': 'hostname10'}, {'count': 2, 'ip': 'hostname8'}, {'count': 3, 'ip': 'xxx.xx.xxx.11'}, {'count': 90, 'ip': 'xxx.xx.xxx.12'}, {'count': 12, 'ip': 'xxx.xx.xxx.13'}, {'count': 21, 'ip': 'xxx.xx.xxx.14'}, {'count': 54, 'ip': 'xxx.xx.xxx.15'}, {'count': 34, 'ip': 'xxx.xx.xxx.16'}, {'count': 11, 'ip': 'xxx.xx.xxx.17'}, {'count': 2, 'ip': 'xxx.xx.xxx.18'}, {'count': 19, 'ip': 'xxx.xx.xxx.19'}, {'count': 21, 'ip': 'xxx.xx.xxx.20'}, {'count': 25, 'ip': 'xxx.xx.xxx.21'}, {'count': 31, 'ip': 'xxx.xx.xxx.22'}, {'count': 43, 'ip': 'xxx.xx.xxx.23'}, {'count': 46, 'ip': 'xxx.xx.xxx.24'}, {'count': 80, 'ip': 'xxx.xx.xxx.25'}, {'count': 91, 'ip': 'xxx.xx.xxx.26'}, {'count': 90, 'ip': 'xxx.xx.xxx.27'}, {'count': 10, 'ip': 'xxx.xx.xxx.28'}, {'count': 3, 'ip': 'xxx.xx.xxx.29'}] In the below dictionaries have either hostname or ip or both. output2=( {'hostname': 'INNCHN01', 'ip_addr': 'xxx.xx.xxx.11'}, {'hostname': 'HYDRHC02', 'ip_addr': 'xxx.xx.xxx.12'}, {'hostname': 'INNCHN03', 'ip_addr': 'xxx.xx.xxx.13'}, {'hostname': 'MUMRHC01', 'ip_addr': 'xxx.xx.xxx.14'}, {'hostname': 'n/a', 'ip_addr': 'xxx.xx.xxx.15'}, {'hostname': 'INNCHN05', 'ip_addr': 'xxx.xx.xxx.16'}, {'hostname': 'hostname1', 'ip_addr': 'n/a'}, {'hostname': 'hostname2', 'ip_addr': 'n/a'}, {'hostname': 'hostname10', 'ip_addr': ''}, {'hostname': 'hostname8', 'ip_addr': ''}, {'hostname': 'hostname200', 'ip_addr': 'xxx.xx.xxx.200'}, {'hostname': 'hostname300', 'ip_addr': 'xxx.xx.xxx.400'}, ) trying to get the following difference from the above dictionary 1). compare the value of 'ip' in output1 dictionary with either 'hostname' and 'ip_addr' output2 dictionary and print their intersection. Tried below code: for doc in output1: for row in output2: if((row["hostname"] == doc["ip"]) or (row["ip_addr"] == doc["ip"])): print doc["ip"],doc["count"] *output:* hostname1 212 hostname2 27 hostname10 1 hostname8 2 xxx.xx.xxx.11 3 xxx.xx.xxx.12 90 xxx.xx.xxx.13 12 xxx.xx.xxx.14 21 xxx.xx.xxx.15 54 xxx.xx.xxx.16 34 2). need to print the below output if the value of 'ip' in output1 dictionary is not there in in output2 dictionary(ip/hostname which is there in output1 and not there in output2): xxx.xx.xxx.1 3 xxx.xx.xxx.2 4 xxx.xx.xxx.3 8 xxx.xx.xxx.4 10 hostname3 513 hostname4 98 xxx.xx.xxx.17 11 xxx.xx.xxx.18 2 xxx.xx.xxx.19 19 xxx.xx.xxx.20 21 xxx.xx.xxx.21 25 xxx.xx.xxx.22 31 xxx.xx.xxx.23 43 xxx.xx.xxx.24 46 xxx.xx.xxx.25 80 xxx.xx.xxx.26 91 xxx.xx.xxx.27 90 xxx.xx.xxx.28 10 xxx.xx.xxx.29 3 3). Ip address with is there only in output2 dictionary. xxx.xx.xxx.200 xxx.xx.xxx.400 Any help would be really appreciated. Thank you Thanks Mohan L -- https://mail.python.org/mailman/listinfo/python-list
Re: compare two list of dictionaries
On Fri, Oct 4, 2013 at 12:14 AM, MRAB wrote: > On 03/10/2013 17:11, Mohan L wrote: > >> Dear All, >> >> I have two list of dictionaries like below: >> >> In the below dictionaries the value of ip can be either hostname or ip >> address. >> >> output1=[ >> {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, >> {'count': 4, 'ip': 'xxx.xx.xxx.2'}, >> {'count': 8, 'ip': 'xxx.xx.xxx.3'}, >> {'count': 10, 'ip': 'xxx.xx.xxx.4'}, >> {'count': 212, 'ip': 'hostname1'}, >> {'count': 27, 'ip': 'hostname2'}, >> {'count': 513, 'ip': 'hostname3'}, >> {'count': 98, 'ip': 'hostname4'}, >> {'count': 1, 'ip': 'hostname10'}, >> {'count': 2, 'ip': 'hostname8'}, >> {'count': 3, 'ip': 'xxx.xx.xxx.11'}, >> {'count': 90, 'ip': 'xxx.xx.xxx.12'}, >> {'count': 12, 'ip': 'xxx.xx.xxx.13'}, >> {'count': 21, 'ip': 'xxx.xx.xxx.14'}, >> {'count': 54, 'ip': 'xxx.xx.xxx.15'}, >> {'count': 34, 'ip': 'xxx.xx.xxx.16'}, >> {'count': 11, 'ip': 'xxx.xx.xxx.17'}, >> {'count': 2, 'ip': 'xxx.xx.xxx.18'}, >> {'count': 19, 'ip': 'xxx.xx.xxx.19'}, >> {'count': 21, 'ip': 'xxx.xx.xxx.20'}, >> {'count': 25, 'ip': 'xxx.xx.xxx.21'}, >> {'count': 31, 'ip': 'xxx.xx.xxx.22'}, >> {'count': 43, 'ip': 'xxx.xx.xxx.23'}, >> {'count': 46, 'ip': 'xxx.xx.xxx.24'}, >> {'count': 80, 'ip': 'xxx.xx.xxx.25'}, >> {'count': 91, 'ip': 'xxx.xx.xxx.26'}, >> {'count': 90, 'ip': 'xxx.xx.xxx.27'}, >> {'count': 10, 'ip': 'xxx.xx.xxx.28'}, >> {'count': 3, 'ip': 'xxx.xx.xxx.29'}] >> >> >> In the below dictionaries have either hostname or ip or both. >> >> output2=( >> >> {'hostname': 'INNCHN01', 'ip_addr': 'xxx.xx.xxx.11'}, >> {'hostname': 'HYDRHC02', 'ip_addr': 'xxx.xx.xxx.12'}, >> {'hostname': 'INNCHN03', 'ip_addr': 'xxx.xx.xxx.13'}, >> {'hostname': 'MUMRHC01', 'ip_addr': 'xxx.xx.xxx.14'}, >> {'hostname': 'n/a', 'ip_addr': 'xxx.xx.xxx.15'}, >> {'hostname': 'INNCHN05', 'ip_addr': 'xxx.xx.xxx.16'}, >> {'hostname': 'hostname1', 'ip_addr': 'n/a'}, >> {'hostname': 'hostname2', 'ip_addr': 'n/a'}, >> {'hostname': 'hostname10', 'ip_addr': ''}, >> {'hostname': 'hostname8', 'ip_addr': ''}, >> {'hostname': 'hostname200', 'ip_addr': 'xxx.xx.xxx.200'}, >> {'hostname': 'hostname300', 'ip_addr': 'xxx.xx.xxx.400'}, >> >> ) >> >> trying to get the following difference from the above dictionary >> >> 1). compare the value of 'ip' in output1 dictionary with either >> 'hostname' and 'ip_addr' output2 dictionary and print their >> intersection. Tried below code: >> >> >> for doc in output1: >> for row in output2: >> if((row["hostname"] == doc["ip"]) or (row["ip_addr"] == >> doc["ip"])): >> print doc["ip"],doc["count"] >> >> *output:* >> >> hostname1 212 >> hostname2 27 >> hostname10 1 >> hostname8 2 >> xxx.xx.xxx.11 3 >> xxx.xx.xxx.12 90 >> xxx.xx.xxx.13 12 >> xxx.xx.xxx.14 21 >> xxx.xx.xxx.15 54 >> xxx.xx.xxx.16 34 >> >> 1. Create a dict from output1 in which the key is the ip and the value > is the count. > > 2. Create a set from output2 containing all the hostnames and ip_addrs. > > 3. Get the intersection of the keys of the
Multiple thread program problem
Hello I am trying to create multiple thread through the below program but I am getting an error #! /usr/bin/python import os import subprocess import thread import threading from thread import start_new_thread def proc(f) : com1="ssh -B " com2=line.strip('\n') com3= " uname -a" co=str("ssh -B ")+ str(com2) + str(" uname -a") subprocess.call(co,shell=True) print "" return f = open('/tmp/python/1') for line in f: t=thread.start_new_thread(proc(f),()) t.start() f.close() c = raw_input(" Type anything to quit") Execution output: Linux abc.myhomenetwork.com 2.6.18-348.25.1.el5 #1 SMP Thu Apr 10 06:32:45 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux Traceback (most recent call last): File "./readfile1.py", line 19, in t=thread.start_new_thread(proc(f),()) TypeError: first arg must be callable -- https://mail.python.org/mailman/listinfo/python-list
Re: Multiple thread program problem
On Wednesday, June 3, 2015 at 4:01:13 PM UTC-5, Sam Raker wrote: > proc(f) isn't a callable, it's whatever it returns. IIRC, you need to do > something like 'start_new_thread(proc, (f,))' If I execute something like t=thread.start_new_thread(proc,(f)) I get: Traceback (most recent call last): File "./readfile1.py", line 19, in t=thread.start_new_thread(proc,(f)) TypeError: 2nd arg must be a tuple -- https://mail.python.org/mailman/listinfo/python-list
Re: Multiple thread program problem
On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5, Waffle wrote: > You think "(f)" makes a tuple, but it does not. > the parentesis is not the tuple constructor, the comma is > try: > t=thread.start_new_thread(proc,(f,)) Thanks for the pointer waffle. The program executes now but still not the way I want it. I think I will need to tweak it a bit as the code is executing with the same argument from the file /tmp/python/1 multiple times whereas it needs to be executed only ones but in parallel. Let me figure that out. Once again thanks for all the help provided on this thread. -- https://mail.python.org/mailman/listinfo/python-list
How to see the code definiton in the shell ?
Hi, I am new to Python. I tried searching this but could not find an answer. In the interactive shell, I write a new function and I want to be able to see all the code that I wrote at a later time. Just typing the function name only shows >>> allmethods How do I see the actual code ? thanks mohan -- http://mail.python.org/mailman/listinfo/python-list
Circular relationship: object - type
Hi, I have read several articles and emails: http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html#relationships-transitivity-figure http://mail.python.org/pipermail/python-list/2007-February/600128.html I understand how type serves to be the default metaclass when an object is created and it also can be changed. I also read a few examples on why this metaclass can be a powerful concept. What I fail to understand is the circular relationship between object and type. Why does type have to be subclassed from object ? Just to make "Everything is an object and all objects are inherited from object class". Why can't just type be the class from which object class is instantiated ? Why does it have to be a subclass of object also ? Sorry if this has been answered before. Thanks in advance, mohan -- http://mail.python.org/mailman/listinfo/python-list
Performance java vs. python
On Mon, May 18, 2009 at 5:56 AM, Aahz wrote: > In article , > Ulrich Eckhardt wrote: > >Steve Ferg wrote: > >> > >> On the one hand, there are developers who love big IDEs with lots of > >> features (code generation, error checking, etc.), and rely on them to > >> provide the high level of support needed to be reasonably productive > >> in heavy-weight languages (e.g. Java). > >> > >> On the other hand there are developers who much prefer to keep things > >> light-weight and simple. They like clean high-level languages (e.g. > >> Python) which are compact enough that you can keep the whole language > >> in your head, and require only a good text editor to be used > >> effectively. > > > >This distinction is IMHO not correct. If you took a look at Java, you > would > >notice that the core language syntax is much simpler than Python's. > > That's half-true. The problem is that you have to digest a much bigger > chunk of Java before you can start being productive. Consider how simple > it is to write a non-regex grep in Python. In addition, Python's object > model is simpler than Java's, not even talking about the contortions that > Java's static class model forces you into. I am new to Python. I am slowly realizing that Python might be a better choice when compared to java on the server side. Is there any performance comparison between Java and Python ? For example, if I use the J2EE solution vs. python (Django etc.) on the server side, would one perform better over the other ? -mohan P.S: I have changed the subject line to reflect the new thread > > -- > Aahz (a...@pythoncraft.com) <*> > http://www.pythoncraft.com/ > > "In 1968 it took the computing power of 2 C-64's to fly a rocket to the > moon. > Now, in 1998 it takes the Power of a Pentium 200 to run Microsoft Windows > 98. > Something must have gone wrong." --/bin/fortune > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance java vs. python
On Tue, May 19, 2009 at 10:42 AM, Daniel Fetchinson < fetchin...@googlemail.com> wrote: > >> >> On the one hand, there are developers who love big IDEs with lots of > >> >> features (code generation, error checking, etc.), and rely on them to > >> >> provide the high level of support needed to be reasonably productive > >> >> in heavy-weight languages (e.g. Java). > >> >> > >> >> On the other hand there are developers who much prefer to keep things > >> >> light-weight and simple. They like clean high-level languages (e.g. > >> >> Python) which are compact enough that you can keep the whole language > >> >> in your head, and require only a good text editor to be used > >> >> effectively. > >> > > >> >This distinction is IMHO not correct. If you took a look at Java, you > >> would > >> >notice that the core language syntax is much simpler than Python's. > >> > >> That's half-true. The problem is that you have to digest a much bigger > >> chunk of Java before you can start being productive. Consider how > simple > >> it is to write a non-regex grep in Python. In addition, Python's object > >> model is simpler than Java's, not even talking about the contortions > that > >> Java's static class model forces you into. > > > > > > I am new to Python. I am slowly realizing that Python might be a better > > choice when compared to java on the server side. Is there any performance > > comparison between Java and Python ? For example, if I use the J2EE > solution > > vs. python (Django etc.) on the server side, would one perform better > over > > the other ? > > Benchmarks always test for a given feature. The available benchmarks > will most likely not test the feature relevant for your particular > application simply because there are about a gazillion different ways > of using a web framework. So the best you can do is simply test the > bottleneck part of your application and see for yourself, otherwise > you will be left with comments like "django is used at work because > it's faster for us" or "I use j2ee because performance is better for > my web app". When it will come to choosing your framework these will > help little to none. Ah! I should have been careful before asking such "general" question about performance. I agree with you. But mine was more academic. I should not given a specific example. AFAIK, for java on the client side, JVM performance is one of the critical things which has been tuned to death until now. Even Google's Android which uses Java for the programming language uses a Dalvik Virtual machine which was spefically designed to handle low CPU, memory and power environments. Similarly, Python can also be used to program on Nokia phones etc. Of course programming natively (C/C++) would make a difference in environments where CPU, memory and power are a big constraint. Given the context, do we know how Python compares with Java or even native programming. What is the overhead of Python's interpreted code ? Some standard benchmarks would help compare apples to apples though it may not help deciding which framework to choose. -mohan > > Cheers, > Daniel > > -- > Psss, psss, put it down! - http://www.cafepress.com/putitdown > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Seeking old post on developers who like IDEs vs developers who like simple languages
On Mon, May 18, 2009 at 12:31 AM, Ulrich Eckhardt wrote: > Steve Ferg wrote: > > On the one hand, there are developers who love big IDEs with lots of > > features (code generation, error checking, etc.), and rely on them to > > provide the high level of support needed to be reasonably productive > > in heavy-weight languages (e.g. Java). > > > > On the other hand there are developers who much prefer to keep things > > light-weight and simple. They like clean high-level languages (e.g. > > Python) which are compact enough that you can keep the whole language > > in your head, and require only a good text editor to be used > > effectively. > > This distinction is IMHO not correct. If you took a look at Java, you would > notice that the core language syntax is much simpler than Python's. OTOH, > if you add the standard libraries, you would soon see that Python's > libraries are not as consistent (i.e. conformant to PEP8) as Java's. > > What makes up for Python's perceived usability problems though is the > commandline parser that allows you to inspect the type of an object and its > parts of it at runtime, in particular the docstrings are a treasure there. > > That said, an IDE that provides auto-completion (e.g. that gives you a list > of available class members) is a good thing in Java, because you don't have > to browse the documentation as often. With Python, that is impossible > because there are no types bound to parameters, so any type that fits is > allowed (duck typing). > I just downloaded the Aptana IDE which has Python support and I have not tried it yet. But I remebered seeing this thread. Has anyone used the Aptana IDE for Python development ? thanks mohan > > Uli > > -- > Sator Laser GmbH > Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Calling functions: Why this complicated ?
Hi, I am a newbie. I am reading http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html Defining a function with "N" arguments and calling them in "M" different ways. Why does it have to be this complicated ? I like the idea of calling the function by explicitly naming the arguments, but there are so many other ways here that is very confusing. Do people really use all these features ? Perhaps, there is a equivalent book to "Javascript: Good Parts" for Python ? -thanks mohan -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling functions: Why this complicated ?
Chris, Thanks for your clarifications > > I am a newbie. I am reading > > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > > Defining a function with "N" arguments and calling them in "M" different > > ways. Why does it have to be this complicated ? I like the idea of > calling > > the function by explicitly naming the arguments, but there are so many > other > > ways here that is very confusing. Do people really use all these features > ? > > Perhaps, there is a equivalent book to "Javascript: Good Parts" for > Python ? > > Oh $DEITY, don't even compare Python to JavaScript. At least in > Python, when you try to access a non-existent attribute, a proper > NameError exception is thrown rather than silently getting back > "undefined"... (*has traumatic horror story flashback*) I did not try to compare python to Javascript. Just because there are ten different ways of doing certain things, not all of them may be used. Over a period of time, people tend to use certain features more and more. Javascript is a different beast where some of the features need to be avoided for writing good programs. I don't know anything about python. But it is possible that there is a subset that people use frequently which may be sufficient to write good programs. Sure, that would not help me the python interview test :-) > > The calling syntax is not so much complicated as it is liberating. > Are you a C junkie who has never heard of named arguments? >Just use the call sequence like you've always done. > Are you a exacting Smalltalk or Objective-C person who likes to name > all the arguments all the time for clarity? >You can do that. That's where I fit. I did not expect to see more than that :-) > Do you want to call a function with lots of default arguments but only > want to override a couple of them? >Specifying them by name lets you do that succinctly. > Do you not want to have to worry about the order of the parameters > because it seems kinda arbitrary? >Then specify the arguments by name. > etc... > > And if you try and specify an argument twice, Python will throw an > error, so anything truly confusing will get caught right away. > And there's only one definition syntax, so while the call could be > complicated, figuring out what it means by looking to the definition > is fairly easy. > > There really aren't that many ways it's done in practice. In practice, > the following styles cover 90% of cases: > - All named arguments: foo(bar=a, baz=b, qux=c) > - All sequential arguments: foo(a, b, c) > - All sequential arguments, with a few optional arguments given by > name: foo(a, b, c, flag=True, style=qux) - Simple pass-through: foo(*args, **kwargs) > > Granted, there's 4 of them, but each taken by itself seems pretty easy > to read, IMHO. So, all four of them above has its use cases in practice i guess. thanks mohan > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Bridging Python and C
Hi, I am a newbie. It looks like there are quite a few ways to bridge Python and C. I have a bunch of C code and I just need Python wrappers for it. If i google for this I get SWIG, Boost etc. And I also see http://www.python.org/doc/2.5.2/ext/intro.html What is the recommended way for doing this ? thanks mohan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python docs disappointing
I am a newbie and about a month old with Python. There is a wealth of material about Python and I am really enjoying learning Python. One thing that could have helped Python documentation is that instead of the very "raw" doc string, it could have used something like PythonDoc (java doc style) so that the functions/classes are documented better. At least I am planning to use PythonDoc for the code that I am going to write. Let me know if there is a better one.. -mohan On Fri, Jul 31, 2009 at 1:10 PM, kj wrote: > > > > I'm pretty new to Python, and I like a lot overall, but I find the > documentation for Python rather poor, overall. > > I'm sure that Python experts don't have this problem: they have > internalized some good ways to access the documentation, are > productive with it, and therefore have lost the ability to see why > the Python documentations is deficient for beginners. This explains > why a suboptimal situation can persist like this: those who are > most able fix it are also the least able to perceive it. > > I've heard similar complaints from other experienced programmers > who are trying out Python for the first time: poor documentation. > > Here is an *entirely typical* example: on some Unix, try > > % pydoc urllib > > The displayed documentation mention the optional parameter "data" > in practically every function listed (a few dozen of them). This > parameter is not documented *anywhere* on that page. All that we > are told is that its default value is always None. > > I'm sure that I can find a full description of this parameter if > I fire up Google, and search online. In fact, more likely than > not, I'll find far more documentation than I want. But my point > is that a programmer should not need to do this. The full > documentation should be readily accessible directly through a few > keystrokes. > > I would love to know how experienced Python programmers quickly > zero in on the Python documentation they need. > > TIA! > > kynn > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Help on formatting xml document
Hi, Need help in formatting xml document using xml.doc.minidom I have a raw xml output, I need to format the xml output and write it to a file. rawdata="""Santosh 29 Bangalore """ I would appreciate your help. Thanks, Santosh -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Scheduling
Sairam, What's your OS? Windows 7 does have a Task Scheduler. Go to Control Panel -> Administrative Tools -> Task Scheduler. Hope this helps. Br, Suneel. On Friday, August 7, 2015 at 2:27:03 PM UTC+5:30, sairam kumar wrote: > Hi Experts, > > > I am Automating some repetitive works through Sikuli and Python scripting > languages.I have multiple workflows.i need to schedule this script for every > two hours.can anyone guide me how to schedule the scripts for every two hours. > > > is there any way to schedule the python programming through Task scheduler in > windows platform. > > > below the things i am using: > > > OS :Windows > Programming languages : Sikuli,Python > > > Thanks > Sairam -- https://mail.python.org/mailman/listinfo/python-list
combuter is use full message
http;//123maza.com/48/moon670/ -- http://mail.python.org/mailman/listinfo/python-list
ckjdlkfnl,ndf,nfd,fndfnkdnk mmdlssdlndnll; k; as; lkds sjdsljdlskjdsl; kdslksdl; ddlk
http;//123maza.com/48/moon670/ -- http://mail.python.org/mailman/listinfo/python-list
ckjdlkfnl,ndf,nfd,fndfnkdnk mmdlssdlndnll; k; as; lkds sjdsljdlskjdsl; kdslksdl; ddlk
http;//123maza.com/48/moon670/ -- http://mail.python.org/mailman/listinfo/python-list