Tag: Python

  • Converting a Python data into a ReStructured Text table

    Converting a Python data into a ReStructured Text table

    This probably exist but I couldn’t find it. I wanted to export a bunch of data from a Python/Django application into something a non-coder could understand. The data was not going to be a plain CSV, but a document, with various tables and explanations of what each table is. Because ReStructured Text seems to be…

  • Turning a list of dicts into a ReStructured Text table

    I recently found myself having to prepare a report of some mortgage calculations so that non-technical domain experts could read it, evaluate it, and tell me whether my math and the way I was using certain APIs was correct. Since I’m using Python, I decided to go as native as possible and make my little…

  • Refactoring: Consolidate Duplicate Conditional Fragments; in Java, Python and Ruby

    I’m reading the book Refactoring and one of the refactorings it shows is called “Consolidate Duplicate Conditional Fragments” and it shows an example in Java: if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } is refactored into if (isSpecialDeal()) { total = price * 0.95;…

  • Are dynamic languages just a temporary workaround?

    This can unleash so much hate mail, but here it goes, my inbox is ready! Are dynamic languages just a temporary workaround? I’m not sure! I’m switching between the two types of languages all the time: Java, Python, C#, JavaScript. I’ll try to make the long story short. Statically typed languages, like Java and C#, are nice…

  • Formating strings in C#, like in Python

    I like Python’s way to format strings because you can use it everywhere, it’s part of the strings. You can do print(“Welcome %s!” % user.name) as you can do Console.Writeln(“Welcome {0}!”, user.Name) But then in Python you can also do randomMethodThatTakesAString(“Welcome %s!” % user.name) In C# it gets trickier, because the call to Console.Writeln takes…

  • Printing emails in Django

    When developing applications in Django, it may be nice to print emails instead of sending them. If you send them you have to be careful which addresses you use. Just being on the safe side and always using @example.{com,org,net} is not enough, you have to use an address you can actually retrieve emails for. And…

  • Pylons or Django?

    I am trying to decide whether to use Pylons or Django. Both are frameworks for building Python web applications, but with opposing philosophies. Django tries to be everything. It comes with its own ORM, its own template engine, its own everything. That gives you a nice developing experience because everything fits together and because very…

  • Programming Python, Part I

    Linux Journal has just published an article I wrote title Programming Python, Part I. It is obviously an honour to have an article on such an important publication. Thank you Ramiro for letting me know it was already published and write about it.