# adl

Published articles for adl.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Loading Python-Defined Regex Constants in Ruby at Runtime

DevFeed: [Loading Python-Defined Regex Constants in Ruby at Runtime](<https://devfeed.tech/articles/yes-yes-yes-importing-constants-from-python-to-ruby-at-execution-time-28311.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/ruby/2020/04/09/yes-yes-yes-importing-constants-from-python-to-ruby-at-execution-time.html>)

Author: Fuzzygroup

Published: 2020-04-09T00:00:00Z

Content type: tutorial

Language: en

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

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

Tags: [adl](<https://devfeed.tech/tags/adl.md>), [python](<https://devfeed.tech/tags/python.md>), [regular-expressions](<https://devfeed.tech/tags/regular-expressions.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

### AI overview

A Ruby-focused technical post explores ways to reuse Python files that define REGEXES arrays in Ruby at runtime. It discusses failed require and require_relative attempts and considers load() under a shared deployment setup.

### Source excerpt

This is going to fall into the category of "Dancing Bear" coding in that it isn't how well it works or how elegant it is, it is that it, like the bear, dances at all. Here's the problem. Three code bases that live in: ohi_kafka/experts-all (python) ohi_kafka/loader_reddit_to_kafka (ruby) ohi_kafka/loader_twitter_to_kafka (ruby) And a series of code modules that define array of regular expressions in a constant always named REGEXES that live in files named like this: common_invective_anti_semitism.py common_invective_anti_black.py common_invective_anti_lgbtq.py common_invective_anti_islam.py common_invective_anti_woman.py Note: A discussion of why the naming conventions here are this way and why lgbtq is lumped here as one thing is beyond the scope of this blog post (I personally disagree with that but I lost that argument months ago; sorry). These regexes need to be run both in the context of the python code base and the ruby code base. These regexes are defined as arrays of strings such as: REGEXES = [ 'foo', 'Bar' ] The magic in making this work is really, really, really understanding your deployment context, specifically: all code will be deployed on the same machine (it will execute across multiple machines) but since I control deploy, I can ensure that the full code stack is present no Docker for the ruby portion - just pretty vanilla Ruby code executing on a server as a SystemD service Being tricksy, very, very tricksy My first attempt to make this work was to try and use an extension with both require and require_relative: require "../experts-all/common_invective_anti_semitism.py" Traceback (most recent call last): 16: from /Users/sjohnson/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundle:46:in `block in <top (required)>' 15: from /Users/sjohnson/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/bundler/cli.rb:24:in `start' 14: from /Users/sjohnson/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start' 13: fro