← Home ← Back to /g/

Thread 105741131

31 posts 10 images /g/
Anonymous No.105741131 [Report] >>105741137 >>105741138 >>105741373 >>105741414 >>105742192 >>105742235 >>105742255 >>105742584 >>105742932 >>105743018 >>105743650 >>105744030
i wrote a script that generates picrel. type whatever you want into the terminal and it makes a python file like picrel and runs it. it's like print but needlessly complicated. i mostly did it because i want to write poetry with python
Anonymous No.105741137 [Report] >>105741148 >>105742200
>>105741131 (OP)
Time & money well spent, anon. Are you going to share the source code or keep it for yourself so you get rich?
Anonymous No.105741138 [Report]
>>105741131 (OP)
vim macro as a programming language
Anonymous No.105741148 [Report] >>105741192 >>105741373 >>105742584
>>105741137
i'm feeling generous, and i'm a man of the people, so here is the code. remember me when i'm on the cover of forbes

https://github.com/the-rainmaker86/python-poetry
Anonymous No.105741192 [Report] >>105741197
>>105741148
kys redditor
Anonymous No.105741197 [Report] >>105746474
>>105741192
what makes u think i'm a redditor
Anonymous No.105741373 [Report] >>105741719
>>105741131 (OP)
>>105741148
Here's my poem/haiku. Can you generate something for me? Here's my input:
there were 10 dicks that
op sucked to completion
he was really gay
Anonymous No.105741414 [Report]
>>105741131 (OP)
https://www.perlmonks.org/?node_id=1111395
Anonymous No.105741719 [Report] >>105741994 >>105742207 >>105743650
>>105741373
Anonymous No.105741994 [Report] >>105742046
>>105741719
I asked my friend Google Gemini, the genius, to add support for punctuation.
import keyword
import sys
import re

reserved_words = keyword.kwlist

def sanitize_for_function_name(word):
word = word.replace('.', '_fullstop')
word = word.replace(';', '_semicolon')
word = word.replace(':', '_colon')
word = word.replace('?', '_questionmark')
word = word.replace('!', '_exclamation')
word = word.replace(',', '_comma')
word = word.replace('-', '_dash')
word = re.sub(r'[^a-zA-Z0-9_]', '', word)

return word.lower()

inp_words = sys.argv[1:]
functions_and_words = []

for word in inp_words:
sanitized_word = sanitize_for_function_name(word)
if sanitized_word in reserved_words:
sanitized_word += '_func'

functions_and_words.append((sanitized_word, word))

paren_count = 0

with open('newpoem.py', 'w') as f:
for sanitized_word, original_word in functions_and_words:
paren_count += 1
f.write(f"def {sanitized_word}(x): return '{original_word}' + ' ' + x\n")

for i, (sanitized_word, _) in enumerate(functions_and_words):
if i == 0:
f.write(f'print({sanitized_word}(')
elif i < len(functions_and_words) - 1:
f.write(f"{sanitized_word}(")
else:
f.write(f"{sanitized_word}(''){')'* paren_count}")

print(f"Created newpoem.py with {len(functions_and_words)} functions based on input words.")
print("You can now import this file and use the functions defined in it.")
print("Example usage: from newpoem import word1, word2")
print("Then call the functions like: print(word1('your text here'))")

from newpoem import *
Just
python3 dynamic_poem.py whoop ! zoop ? doop - poop .
Anonymous No.105742046 [Report] >>105742113
>>105741994
i would just get rid of the punctuation, shit like _exclamation ruins the flow
Anonymous No.105742113 [Report] >>105742165
>>105742046
>the flow
okay, M&M
Anonymous No.105742165 [Report] >>105742494 >>105742536
>>105742113
>M&M

jesus
Anonymous No.105742192 [Report]
>>105741131 (OP)
>anon discovers metaprogramming
don't tell the go fags they'll SEETHE
Anonymous No.105742200 [Report]
>>105741137
geg
Anonymous No.105742207 [Report] >>105742210
>>105741719
>is_
garbage
Anonymous No.105742210 [Report] >>105742224
>>105742207
ok FINE i'll add a str.replace
Anonymous No.105742224 [Report]
>>105742210
wait nm that won't work
Anonymous No.105742235 [Report]
>>105741131 (OP)
this seems like something that would be trivial in LISP desu
Anonymous No.105742255 [Report] >>105742303 >>105742567
>>105741131 (OP)
This code isn't maintainable. Please make an enterprise ready version in either C# or Java.
Anonymous No.105742303 [Report]
>>105742255
Kek'd and check'd
Anonymous No.105742494 [Report]
>>105742165
M&M was Eminem's first rap name
Anonymous No.105742536 [Report]
>>105742165
You're actually retarded.
Anonymous No.105742567 [Report]
>>105742255
Anonymous No.105742584 [Report]
>>105741131 (OP)
>>105741148
Upvoted!

Edit: Thanks for the gold, kind stranger!
Anonymous No.105742932 [Report]
>>105741131 (OP)
#!/usr/bin/env perl

for my $fn (qw(op is gay retard)) {
*$fn = sub { print $fn . ' ' };
}
use subs qw(op is gay);

op; is; gay; &retard;
Anonymous No.105743018 [Report] >>105743032
>>105741131 (OP)
Here's a much more efficient oneliner:
>print('OP is a gay retard')

What a waste of time, could've at least added some logic so it would be actually impressive... but normies will be impressed regardless
Anonymous No.105743032 [Report]
>>105743018
It is free open source software, anon. Add it yourself.
Anonymous No.105743650 [Report]
>>105741131 (OP)
>>105741719
based op
Anonymous No.105744030 [Report]
>>105741131 (OP)
you the same fag, OP? >>105740574
Anonymous No.105746474 [Report]
>>105741197
reddit spacing