<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Random Ramblings</title><link>https://blog.foundev.pro/tags/Python.html</link><description>Recent content in Python on Random Ramblings</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 23 Feb 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.foundev.pro/tags/Python/index.xml" rel="self" type="application/rss+xml"/><item><title>Quick IP scan without nmap</title><link>https://blog.foundev.pro/2021/02/23/quick-ip-scan-without-nmap.html</link><pubDate>Tue, 23 Feb 2021 00:00:00 +0000</pubDate><guid>https://blog.foundev.pro/2021/02/23/quick-ip-scan-without-nmap.html</guid><description>&lt;h1&gt;Quick IP scan without nmap&lt;/h1&gt;&#10;&lt;p&gt;So nmap isn&amp;rsquo;t always available to figure out what devices are up on your local network or where they may have moved too after you installed that new router but python is usually around.&#10;This script will ping your local network for ip addresses. It is as basic as you can get and does not work on Windows. Some day I would like to make a better version of this, when I do, I will&#10;link it back to here. In the meantime this maybe useful.&lt;/p&gt;</description></item><item><title>Adventures in Meta programming in Python</title><link>https://blog.foundev.pro/2010/01/08/adventures-in-meta-programming-in-python-im-class-import-getattribute.html</link><pubDate>Fri, 08 Jan 2010 05:03:00 +0000</pubDate><guid>https://blog.foundev.pro/2010/01/08/adventures-in-meta-programming-in-python-im-class-import-getattribute.html</guid><description>&lt;h1&gt;Adventures in Meta programming in Python&lt;/h1&gt;&#10;With my recent work in Python win32 programming I&amp;rsquo;ve had a real need for AAA style mocking framework. Unable to find anything that I&amp;rsquo;ve been completely happy with I started my own simple mocking framework and got to learn some Python style meta programming&amp;nbsp; in the process. I&amp;rsquo;ve found out a lot about the depth of the Python 2.x object model over the last 2 weeks and here are some of the nicer things I&amp;rsquo;ve found (updated as per Chris Taveres below):&#10;&lt;h3 id="function_class--myclassfooim_class"&gt;function_class = MyClass.foo.im_class&lt;/h3&gt;&#10;&lt;p&gt;This is useful if you pass in an instance method  somewhere and you want to be able to access its attached class.  Decorators on instance methods normally use this, but I needed it to get a nicer syntax on my asserts, I wanted this:&lt;/p&gt;</description></item><item><title>Python Web Framework Series – Pylons: Part 5 Testing Models</title><link>https://blog.foundev.pro/2009/07/02/python-web-framework-series-pylons-part-5-testing-models.html</link><pubDate>Thu, 02 Jul 2009 20:09:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/07/02/python-web-framework-series-pylons-part-5-testing-models.html</guid><description>&lt;h1&gt;"Python Web Framework Series – Pylons: Part 5 Testing Models"&lt;/h1&gt;&#10;UPDATE: was an error caught by Govind (who is turning out to be my unofficial proofreader). I&amp;#8217;ve made a correction in the thread mapping for &amp;#8220;dateadded&amp;#8221; property in the _previous_ article. If this you are caught up with and _error indicating there is no dateadded property on thread_ make sure to edit your **model\_\_init\_\_.py** file to match the previous article and rebuild your db so that everything is happy. Please bear with me as I hone my tutorial writing skill set.&#10;&lt;p&gt;When we last left of with our Pylons forum we had a had just successfully created a post, and then could immediately retrieve that same post. However, we kind of skimped on the testing story so lets fill in the gaps and do some refactoring as a bonus.&lt;/p&gt;</description></item><item><title>Python Web Framework Series – Pylons: Part 3 Views with Mako</title><link>https://blog.foundev.pro/2009/06/25/python-web-framework-series-pylons-part-3-views-with-mako.html</link><pubDate>Thu, 25 Jun 2009 04:53:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/06/25/python-web-framework-series-pylons-part-3-views-with-mako.html</guid><description>&lt;h1&gt;"Python Web Framework Series – Pylons: Part 3 Views with Mako"&lt;/h1&gt;&#10;This is a huge post and I should have split this into several smaller ones so please bear with me while I get my series format tweaked. We last left off with &lt;a href="https://blog.foundev.pro/2009/06/24/python-web-framework-series-pylons-part-2-controllers-and-views.html" target="_blank"&gt;Controllers, Views and Testing&lt;/a&gt; with a basic test, basic view and basic controller.&amp;nbsp; Now with our basic scaffold built we can focus on making our views reusable, dynamic, and more pleasant to look at.&#10;&lt;h3 id="first-things-first"&gt;First things first&lt;/h3&gt;&#10;&lt;p&gt;First before we dive too deeply into Mako, lets setup a default home page by doing the following:&lt;/p&gt;</description></item><item><title>Python Web Framework Series – Pylons: Part 2 Controllers, Views and Testing</title><link>https://blog.foundev.pro/2009/06/24/python-web-framework-series-pylons-part-2-controllers-and-views.html</link><pubDate>Wed, 24 Jun 2009 13:22:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/06/24/python-web-framework-series-pylons-part-2-controllers-and-views.html</guid><description>&lt;h1&gt;"Python Web Framework Series – Pylons: Part 2 Controllers, Views and Testing"&lt;/h1&gt;&#10;We last left off with &lt;a target="_blank" href="https://blog.foundev.pro/2009/06/23/python-web-framework-series-pylons-part-1-getting-started.html"&gt;Getting Started&lt;/a&gt; and having created our &amp;ldquo;pylonsforum&amp;rdquo; project and generated our first controller.&#10;&lt;p&gt;Source for home.py&lt;/p&gt;&#10;&lt;p&gt;``&lt;/p&gt;&#10;&lt;div class="wlWriterEditableSmartContent" style="padding-bottom: 0px;margin: 0px;padding-left: 0px;padding-right: 0px;float: none;padding-top: 0px"&gt;&#10;&lt;div style="font-family:consolas,lucida console,courier,monospace"&gt;&#10;&lt;span style="color: #0000ff"&gt;import&lt;/span&gt;&amp;nbsp;logging&amp;nbsp;&lt;/p&gt; &#10;&lt;p&gt;&#10;&lt;span style="color: #0000ff"&gt;from&lt;/span&gt;&amp;nbsp;pylons&amp;nbsp;&lt;span style="color: #0000ff"&gt;import&lt;/span&gt;&amp;nbsp;request,&amp;nbsp;response,&amp;nbsp;session,&amp;nbsp;tmpl_context&amp;nbsp;&lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&amp;nbsp;c&amp;nbsp;&lt;br /&gt; &lt;span style="color: #0000ff"&gt;from&lt;/span&gt;&amp;nbsp;pylons.controllers.util&amp;nbsp;&lt;span style="color: #0000ff"&gt;import&lt;/span&gt;&amp;nbsp;abort,&amp;nbsp;redirect_to&amp;nbsp;&#10;&lt;/p&gt;&#10;&lt;p&gt;&#10;&lt;span style="color: #0000ff"&gt;from&lt;/span&gt;&amp;nbsp;pylonsforum.lib.base&amp;nbsp;&lt;span style="color: #0000ff"&gt;import&lt;/span&gt;&amp;nbsp;BaseController,&amp;nbsp;render&amp;nbsp;&#10;&lt;/p&gt;&#10;&lt;p&gt;&#10; log&amp;nbsp;=&amp;nbsp;logging.getLogger(__name__)&amp;nbsp;&#10;&lt;/p&gt;&#10;&lt;p&gt;&#10;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style="color: #2b91af"&gt;HomeController&lt;/span&gt;(BaseController):&amp;nbsp;&#10;&lt;/p&gt;&#10;&lt;p&gt;&#10; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff"&gt;def&lt;/span&gt;&amp;nbsp;index(self):&amp;nbsp;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;#&amp;nbsp;Return&amp;nbsp;a&amp;nbsp;rendered&amp;nbsp;template&amp;nbsp;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;#return&amp;nbsp;render(&amp;#8216;/home.mako&amp;#8217;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;#&amp;nbsp;or,&amp;nbsp;return&amp;nbsp;a&amp;nbsp;response&amp;nbsp;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style="color: #a31515"&gt;&amp;#8216;Hello&amp;nbsp;World&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &#10;&lt;p&gt;&#10; Source for test_home.py&lt;code&gt;&lt;/code&gt;&#10;&lt;/p&gt;</description></item><item><title>Python Web Framework Series – Pylons: Part 1 Getting Started</title><link>https://blog.foundev.pro/2009/06/23/python-web-framework-series-pylons-part-1-getting-started.html</link><pubDate>Tue, 23 Jun 2009 14:00:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/06/23/python-web-framework-series-pylons-part-1-getting-started.html</guid><description>&lt;h1&gt;Python Web Framework Series – Pylons: Part 1 Getting Started&lt;/h1&gt;&#10;This article assumes you have &lt;a target="_blank" href="http://www.python.org/download/"&gt;Python 2.6&lt;/a&gt; and &lt;a target="_blank" href="http://pypi.python.org/pypi/setuptools"&gt;Setuptools&lt;/a&gt; already installed on your machine and that you&amp;rsquo;re install SQL Alchemy 0.54 and Pylons 0.97&#10;&lt;h3 id="overview"&gt;Overview&lt;/h3&gt;&#10;&lt;p&gt;Pylons is a component based MVC web framework. It, like a lot of more recent MVC frameworks, is borrowing some ideas and concepts from rails  in a less “opinionated “ way.&lt;/p&gt;&#10;&lt;p&gt;Out of the box Pylons has a preference for using &lt;a target="_blank" href="http://www.sqlalchemy.org/"&gt;SQL Alchemy&lt;/a&gt; for ORM (similar to NHibernate in philosophy) and &lt;a target="_blank" href="http://www.makotemplates.org/"&gt;Mako&lt;/a&gt; template engine (uses Python code for markup) .  Now if you prefer &lt;a target="_blank" href="http://www.sqlobject.org/"&gt;SQLObject&lt;/a&gt; , or the &lt;a target="_blank" href="http://elixir.ematia.de/trac/wiki"&gt;Elixer&lt;/a&gt; dialect of SQL Alchemy for ORM and &lt;a target="_blank" href="http://genshi.edgewall.org/"&gt;Genshi&lt;/a&gt; template engine pylons supports them all (and others).  More importantly this means you have choice down the road to match your personal preferences or particular project complexity needs.&lt;/p&gt;</description></item><item><title>Python Web Framework Series</title><link>https://blog.foundev.pro/2009/06/22/python-web-framework-series.html</link><pubDate>Mon, 22 Jun 2009 13:31:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/06/22/python-web-framework-series.html</guid><description>&lt;h1&gt;Python Web Framework Series&lt;/h1&gt;&#10;I've wanted to dive more in depth into Python's web frameworks for some time and get to know them the way I know Castle Monorail.&#10;&lt;p&gt;What better way to learn something in depth than to have to know it well enough to show to someone else.Therefore, I plan on posting a relatively in depth walkthrough of Pylons (and if the interest is there Django and Turbogears as well).&lt;/p&gt;</description></item><item><title>IronPython how cool it is</title><link>https://blog.foundev.pro/2009/05/28/ironpython-how-cool-it-is.html</link><pubDate>Thu, 28 May 2009 05:08:00 +0000</pubDate><guid>https://blog.foundev.pro/2009/05/28/ironpython-how-cool-it-is.html</guid><description>&lt;h1&gt;IronPython how cool it is&lt;/h1&gt;&#10;*EDIT: this is an old post copied over from my [old blog on Los Techies](https://lostechies.com/ryansvihla/2009/05/28/ironpython-how-cool-it-is/), I have kept it here for archival reasons.*&#10;&lt;p&gt;Briefly, &lt;a href="http://www.codeplex.com/IronPython"&gt;IronPython&lt;/a&gt; is an implementation of Python in the .Net runtime. This allows you access to .Net framework goodness while programming in a dynamic language. The current stable version 2.0.1 maps to CPython 2.5.This allows me to do fun fun things like use my python project to access a c# project. follows is a python script using Pinsor and accessing a .net dll.&lt;/p&gt;</description></item></channel></rss>