Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

BBCode is not a meme

Name: Anonymous 2008-12-05 10:54

#!/usr/bin/env python
#
# bbcoder.py -- Generate enterprise grade forum posts.
#
# Copyright (C) 2008  Anonymous
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to
# the Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor
# Boston, MA  02110-1301, USA
#

import sys
import random

_codes = ('spoiler','sub','sup','b','u','o','i')

def random_bb(r):
     return _codes[r.randint(0,len(_codes)-1)]

def _main(argv=None):
    try:
        if not argv:
            argv = sys.argv
        stack = list()
        r = random.Random()
        for j in argv[1:]:
            for i in j.split():
                t = random_bb(r)
                stack.append(t)
                sys.stdout.write('[%s]%s ' % (t,i))
        for i in reversed(stack):
            sys.stdout.write('[/%s]' % i)
        sys.stdout.write('\n')
        return 0
    except IndexError:
        sys.stderr.write('you may provide me something to work on, fag.\n')

if __name__ == '__main__':
    sys.exit(_main())

Name: Anonymous 2008-12-05 10:56

Is this print() compatible?

Name: Anonymous 2008-12-05 11:00

I see artifacts.

Name: Anonymous 2008-12-05 12:29

[u]ENTERPRISE QUALITY FORUM POSTS[/u][

Name: Anonymous 2008-12-05 12:32

>>1
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to

Where's my GPL?

Name: Anonymous 2008-12-05 13:49

    return _codes[r.randint(0,len(_codes)-1)]
terrible. you should use randrange instead, then you wouldn't have to dick around with subtracting 1.
randint is deprecated for a reason

Name: Anonymous 2008-12-05 13:53

def random_bb(r):
     return _codes[r.randint(0,len(_codes)-1)]
from random import choice
lrn2python

Name: Anonymous 2008-12-05 13:54

>>6
You too, retard. Terrible!

Name: Anonymous 2008-12-05 14:27


tabs
    are
        better
            then
                spaces

Name: Anonymous 2008-12-05 14:38

>>9
I hope that the fact that then got highlighted rings a bell to you.

Name: Anonymous 2008-12-05 15:24

>>10
It means Shiichan has a Touring-complete grammar parser.  I also believe it has enough of an algorithm that half of the posts in /prog/ are generated by Shiichan based on our previous posts.

hax my anus

Name: Anonymous 2008-12-05 16:36

Better implementation (patch)


--- bbcode.py    2008-12-05 22:31:11.000000000 +0100
+++ bbcode.py_new    2008-12-05 22:31:04.000000000 +0100
@@ -22,30 +22,26 @@
 #
 
 import sys
-import random
+from random import choice
 
 _codes = ('spoiler','sub','sup','b','u','o','i')
 
-def random_bb(r):
-     return _codes[r.randint(0,len(_codes)-1)]
-
 def _main(argv=None):
     try:
         if not argv:
             argv = sys.argv
         stack = list()
-        r = random.Random()
         for j in argv[1:]:
             for i in j.split():
-                t = random_bb(r)
+                t = choice(_codes)
                 stack.append(t)
                 sys.stdout.write('[%s]%s ' % (t,i))
-        for i in reversed(stack):
-            sys.stdout.write('[/%s]' % i)
-        sys.stdout.write('\n')
+        end = ''.join(['[/%s]' % i for i in reversed(stack)])
+        sys.stdout.write(end + '\n')
         return 0
     except IndexError:
         sys.stderr.write('you may provide me something to work on, fag.\n')
+        return 1
 
 if __name__ == '__main__':
     sys.exit(_main())

Name: Anonymous 2008-12-05 16:44

>>12
        if not argv:
            argv = sys.argv

lolwut

        stack = list()
lolwut

        end = ''.join(['[/%s]' % i for i in reversed(stack)])
lolwut

        return 0
lolwut

        return 1
lolwut

_
lolwut

Actually, your operational logic doesn't make much sense, either, but I assume it does what you want it to do.

Name: Anonymous 2008-12-05 16:59

>>13

Maybe you simply don't use python... this is the true way of the pythonista.


The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Name: Anonymous 2008-12-05 17:17

>>14
Maybe you simply don't use python... this is the true way of the pythonista.
You don't understand Python.

Name: Anonymous 2008-12-05 17:21

この子のおちんちんをなめたい

Name: Anonymous 2008-12-05 17:56

ENTERPRISE-GRADE LIMIT TEST

Name: Anonymous 2008-12-05 18:12

>>15
Thwow him to the floor!

Name: Anonymous 2008-12-05 18:54

>>18
Stop it, you're making me mad.

Name: Anonymous 2008-12-05 20:43

>>19

Shut your goddamn maouth!

Name: Anonymous 2008-12-05 21:13

Name: Anonymous 2008-12-05 23:09

/* bbgen r1 -- Anonymous -- PUBLIC DOMAIN */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char *tags[10] = { "aa","b","i","m","o","s","u","sub","sup","spoiler"};

int bain(int argc, char **argv) {
 int i,j;
 if(argc<1)
  return 0;
 if(argc<2)
  return printf("%s ",*argv);
 i=rand()%20;
 j=rand()%argc;
 if(i<10)
  printf("[%s]",tags[i]);
 bain(j,argv);
 bain(argc-j,argv+j);
 if(i<10)
  printf("[/%s]",tags[i]);
}

int main(int argc, char **argv) {
 srand(time(0));
 return bain(argc-1,argv+1);
}

Name: Anonymous 2008-12-06 7:44

>>22
ANONIX QUALITY

Name: ​​​​​​​​​​ 2010-10-22 2:30

Don't change these.
Name: Email:
Entire Thread Thread List