> Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters > but it doesn't seem to work like I thought. > > > res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) > uname = res.stdout.read().strip() > > >>> uname > 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011 > i686 i686 i386 GNU/Linux' > > >>> uname.strip(':') > 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011 > i686 i686 i386 GNU/Linux' > > >>> 'www.example.com'.strip('cmowz.') > 'example' > > Thoughts?
Read the documentation. It is excellent and explains this behavior. http://docs.python.org/library/string.html If you are trying to remove ':' from the result of uname what you really want is uname.replace(':','') Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor