0

Trying out the new "Ruby Mode" in Python 3.9, but am having trouble getting it working:

Simple script in mymodule:

puts "Hello World"

Expected output when executing the file in ruby mode ("rb") was for "Hello World" printed on stdout, but I'm getting an error:

>>> with open("mymodule", mode="rb") as f:
...     for line in f:
...         exec(line)
...
Traceback (most recent call last):
  File "<string>", line 1
    puts "Hello World"
                     ^
SyntaxError: invalid syntax

It looks like the lines are being correctly parsed as rb"ruby style lines", so it's clearly not open at fault:

>>> line.strip() == rb'puts "Hello World"'
True

What's wrong here? That must be a bug in exec, right?

wim
  • 338,267
  • 99
  • 616
  • 750
  • 3
    what is this `Ruby Mode`? can you post a link about this? I can't find any info – gold_cy Apr 01 '20 at 18:40
  • 4
    I'm voting to close this question as off-topic because it's an April Fools joke and April Fools is over. – gerrit Apr 09 '20 at 12:20

1 Answers1

2

Running a file in Ruby mode has to be lead by a Ruby shebang. Try using:

#!/usr/april/fools/ruby
puts "Hello World"
James
  • 32,991
  • 4
  • 47
  • 70