Skip to main content

Posts

Showing posts with the label with

Calling xslt template with param tag by pran sukh on Python Hunter

In XSLT we may need to use same template for different xml data tags, and also there might be a situation where we need to send some special instructions to template tag to act upon give condition or value and produce/process the xml data. Data.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="XSLT.xsl"?> <lists> <ol> <li> the </li> <li> cat </li> <ol> <li> sat </li> <li> on </li> <li> the </li> </ol> <li> mat </li> </ol> </lists> XSLT.xsl 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 <?xml version='1.0'?> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" ...

Understanding "with" keyword in python, on Python Hunter

J ust like anything in python, keyword "with" is introduced in python to make the things little easy. Imagine a situation where you have to manage the resources e.g opening file and closing them after the code is executed on file. To achieve this sort of task we have to write the code as follow:      Download   But if you do it often you could do this as follow to make the code reusable: Download But why do you need to do this when you know that you have to execute the only for once.  To answer this question  python-dev team finally came up with following approach: Download  Note:- Make sure you have "file.txt" and python code file in same dir. The "with"  keyword replaces the try finally block. "with" keyword executes the openFileClass() context manager and internally calls the __enter__(self) method, and whatever is being returned from __enter__(self) method is being stored in tar...