| |||||||||||
| |||||||||||
The backtick operator in Python and Perl
In Perl, and in shell programs too, the backtick operator causes the enclosed string to be executed as a command and the result (as generated on STDOUT) returned.
In Python, it's different. The backtick operator causes the enclosed expression to be evaluated and returned as a string. See string handling resources - Perl See string handling resources - Python Example - Python # This works as the backticks convert the variable twenty to a string ... twenty = 10 + 10 sentence = "The result is "+`twenty` print sentence # ... but this gives a run time error sentence = "The result is "+twenty print sentence Example - Perl # Reports on the disc utilisation on a Unix of Linux system $abc = `df`; print $abc; (written 2005-05-25 12:48:59) Associated topics are indexed under P205 - Perl - Initial String HandlingY108 - Python - String Handling
Some other Articles
Making programs easy for any user to startHow far should our support go UK Tax payment totals and where the money is spent Gone Racing - Larkhill, Wiltshire The backtick operator in Python and Perl 1 in 48 steel More maps Sales - the alternative close Ordnance Survey - using a 'Get a map' Accommodation and landing pages 1637 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||