# Ruby to Python Translation Guide

DevFeed: [Ruby to Python Translation Guide](<https://devfeed.tech/articles/ruby-to-python-translation-guide-28227.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/python/2019/12/11/ruby-to-python-translation-guide.html>)

Author: Fuzzygroup

Published: 2019-12-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [debug](<https://devfeed.tech/topics/debug.md>), [Rails](<https://devfeed.tech/topics/rails.md>)

Tags: [debugging](<https://devfeed.tech/tags/debugging.md>), [guide](<https://devfeed.tech/tags/guide.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [python](<https://devfeed.tech/tags/python.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [translation](<https://devfeed.tech/tags/translation.md>)

## AI overview

A practical guide comparing Ruby idioms with their Python equivalents. It is organized by programming task and includes examples involving debugging, object attributes and methods, hash keys, and JSON parsing. The author notes that the Python examples target Python 3.7 with VirtualEnv on a Mac.

## Source excerpt

Last Update: 12/12/2019 I wrote this guide to different Ruby idioms and how to do them in Python. Organization is alphabetical. This will have to be a continually updated document as I keep finding holes in my Python knowledge and my prior practice of "Learn it / Blog it" simply doesn't put enough things into the same place. I need a single, easily searchable place to store all this random "how to do X cruft". This is written as headings which discuss the problem and then how it is done in Ruby and in Python and then, optionally, a Python context. Hopefully this approach makes it useful to both ruby-ites and python-istas. Note 1: My day to day lingua franca is still Ruby and in a Rails style context where everything is autoloaded. Python to me is a specialized tool for Data Science / Machine Learning. I find that Python: Lacks the elegant simplicity of Ruby Python syntax makes my eyes want to bleed, can we have an underscore character please, how about a colon or some more parentheses Is developer hostile by default Note 2: These are opinions! I am writing them after a craptastic work day so that and lack of sleep may be tilting my opinions more than a bit; I mean I'm right but still ... And please understand that I fundamentally respect that amazing work that Guido did but I find myself in Matz's camp by preference. Still nothing else has the ecosystem that Python does. Note 3: If you disagree with the above, my twitter handle is fuzzygroup and my email is easily discoverable. Let the fun begin ... Note 4: This was initially written in late 2019 so the Python flavor / version is 3.7 using VirtualEnv on a Mac with pip3. Note 5: If there's things you want to see here then actually do let me know. This isn't a planned out document, it is more of a "what made me feel stooopid in Python today" type of thing. Debugging The ruby is: byebug The python is: pdb.set_trace() Getting All Attributes of an Object Most Ruby objects, at least in a Rails context, are generally ActiveRec