Here's the most convoluted “Hello World!” script I could come up with (in response to this). I don't know if it works. I've proven it correct, but I haven't tested it.

from random import choice
from itertools import count
from zlib import crc32
import sys
any(crc32(h)==472456355 and not sys.stdout.write(h) for h in(''.join(choice('! edHlorW')for _ in '.'*12)for _ in count()))

I promise my production code is (marginally) more readable this this…

This blog post was posted to It's All Geek to Me on Wednesday July 1st, 2009 at 8:59PM
 

2 Responses to "I take it back, this is the most inneficient code ever"

  • Martin Chilvers
    July 21st, 2009, 10:27 a.m.

    I think this might beat it…

    """ The Envisage version of the old chestnut. """


    # Standard library imports.
    import logging

    # Enthought library imports.
    from enthought.envisage.api import Application, ExtensionPoint, Plugin
    from enthought.traits.api import List, Str


    # Create a log file.
    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler(file('hello_world.log', 'w')))
    logger.setLevel(logging.DEBUG)


    class HelloWorld(Plugin):
    """ The 'Hello World' plugin.

    This plugin offers a single extension point 'greetings' which is a list of
    greetings, one of which is used to produce the '<greeting> World' message
    when the plugin is started.

    """

    # This tells us that the plugin offers the 'greetings' extension point,
    # and that plugins that want to contribute to it must each provide a list
    # of strings (Str).
    greetings = ExtensionPoint(
    List(Str), id='greetings', desc='Greetings for "Hello World"'
    )

    # Plugin's have two important lifecyle methods, 'start' and 'stop'. These
    # methods are called automatically by Envisage when the application is
    # started and stopped respectively.
    def start(self):
    """ Start the plugin. """

    # Standard library imports.
    #
    # We put this import here just to emphasize that it is only used in
    # this specific plugin.
    import random

    print random.choice(self.greetings), 'World!'

    return


    class Greetings(Plugin):
    """ A plugin that contributes to the 'greetings' extension point. """

    # This tells us that the plugin contributes the value of this trait to the
    # 'greetings' extension point.
    greetings = List(["Hello", "G'day"], contributes_to='greetings')


    class MoreGreetings(Plugin):
    """ Another plugin that contributes to the 'greetings' extension point. """

    # This tells us that the plugin contributes the value of this trait to the
    # 'greetings' extension point.
    greetings = List(contributes_to='greetings')

    # This shows how you can use a standard trait initializer to populate the
    # list dynamically.
    def _greetings_default(self):
    """ Trait initializer. """

    extensions = [
    'The %s application says %s' % (self.application.id, greeting)

    for greeting in ['Bonjour', 'Hola']
    ]

    return extensions


    # Application entry point.
    if __name__ == '__main__':

    # Create the application.
    #
    # An application is simply a collection of plugins. In this case we
    # specify the plugins explicitly, but the mechanism for finding plugins
    # is configurable by setting the application's 'plugin_manager' trait.
    application = Application(
    id='hello.world', plugins=[HelloWorld(), Greetings(), MoreGreetings()]
    )

    # Run it!
    application.run()
  • Nathan Ostgard
    August 18th, 2009, 12:23 a.m.

    Haha, Knuth reference? :)

Leave a Comment

You can use bbcode in the comment: e.g. [b]This is bold[/b], [url]http://www.willmcgugan.com[/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...

My Tweets

Will McGugan

My name is Will McGugan. I am an unabashed geek, an author, a hacker and a Python expert – amongst other things!

Search for Posts
Possibly related posts
Tags
Popular Tags
 
Archives
2010
 
Recent Comments
This is very true, i believe that people need to be able to use a domain if they register it, ...
Hehe Thats a good tatoo idea ;) Have a nice day Joel
- Joel Shapiro on Powered by Ubuntu
Weirdly enough i am a junior dev on an internship. I am @ work and i was way too bored/out ...
I love the idea of locidesktop, and even more the minimal UI. Hope you'll keep it up!
Many thanks! I tried several solutions but the only one that worked was yours.
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan