Popular recipes tagged "patterns" but not "singleton"http://code.activestate.com/recipes/tags/patterns-singleton/2016-12-06T20:37:30-08:00ActiveState Code RecipesConvert wildcard text files to PDF with xtopdf (e.g. report*.txt) (Python) 2016-12-06T20:37:30-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580727-convert-wildcard-text-files-to-pdf-with-xtopdf-eg-/ <p style="color: grey"> Python recipe 580727 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/globbing/">globbing</a>, <a href="/recipes/tags/patterns/">patterns</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/wildcard/">wildcard</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to convert all text files matching a filename wildcard to PDF, using the xtopdf PDF creation toolkit. For example, if you specify report<em>.txt as the wildcard, all files in the current directory that match report</em>.txt, will be converted to PDF, each in a separate PDF file. The original text files are not changed.</p> <p>Here is a guide to installing and using xtopdf:</p> <p><a href="http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html" rel="nofollow">http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html</a></p> <p>More details on running the program, and sample output, are available here:</p> <p><a href="http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html" rel="nofollow">http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html</a></p> Observer Pattern (Python) 2013-03-09T10:03:10-08:00Mauro B. Bianchttp://code.activestate.com/recipes/users/4185493/http://code.activestate.com/recipes/578484-observer-pattern/ <p style="color: grey"> Python recipe 578484 by <a href="/recipes/users/4185493/">Mauro B. Bianc</a> (<a href="/recipes/tags/cascade/">cascade</a>, <a href="/recipes/tags/observer/">observer</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/pattern/">pattern</a>, <a href="/recipes/tags/patterns/">patterns</a>, <a href="/recipes/tags/setattr/">setattr</a>, <a href="/recipes/tags/__setattr__/">__setattr__</a>). Revision 2. </p> <p>This is a Python implementation of the observer pattern described by Gamma et. al. It defines a one-to many dependency between objects so that when one object changes state, all its dependents (i.e. observers) are notified and updated automatically.</p> <p>My adaptation gets rid of the need to use specific functions to set the data (and to call Notify) and allows you to be notified for ANY attribute you set. It is possible to specify a list of attributes which should not trigger a notification. In case you need the opposite, it is very easy to invert the behavior of the code.</p> <p>The example should output: Creating data1 without notification for attrs name &amp; surname <br /> Creating data2 without notification for attr age <br /> Setting data1.name=Heather - Notification unnecessary <br /> Setting data1.num=333 - Notification expected <br /> Observer1: Subject Heather has updated attr num to 333 <br /> Setting data2.name=Molly - Notification expected <br /> Observer2: Subject Molly has updated attr name to Molly <br /> Setting data2.age=28 - Notification unnecessary <br /> Setting data2.eyecolor=blue - Notification expected <br /> Observer2: Subject Molly has updated attr eyecolor to blue </p>