• Henning Makholm (unregistered) in reply to old guy
    old guy:
    "Standard FORTRAN77 (and earlier) allowed no whitespace"

    I don't remember it like that at all and I wrote a lot of FORTRAN77 on HP/MPE, CDC/Cyber, PDP/11, VAX/VMS and Multics. Are you sure ?

    I think it meant "Fortran 77 allowed programs to be written without whitespace between words", not "Fortran 77 did not allow whitespace in programs".

  • (cs) in reply to D-Coder
    D-Coder:
    frits:
    D-Coder:
    Matt Westwood:
    I want to die.
    We all want you to die, Matt.

    Take Nagesh with you if you can. Thanks!

    Aw c'mon, I love Matt. Long live Matt! Not sure if my endorsement is helpful...
    Since Matt seems to reflexively oppose whatever the previous post was... maybe your endorsement will be helpful.

    I do not! Er ...

  • (cs) in reply to Henning Makholm
    Henning Makholm:
    Childish:
    Standard FORTRAN77 (and earlier) allowed no whitespace between tokens.
    Because, as originally envisaged, programmers would produce code in manuscript that was then keyed into the computers by low-paid typists. Having intraline whitespace be significant was thought to invite too many errors when the punch operator who didn't know the language misunderstood the programmer's spacing.
    But the manuscript was generally written on coding forms that made the spacing explicit, e.g. http://www.w3.org/2010/Talks/01-08-steven-ten-euro-computer/FortranCodingForm.png or http://upload.wikimedia.org/wikipedia/commons/2/2b/FortranCodingForm.agr.jpg.
  • (cs) in reply to DaveK
    DaveK:
    Henning Makholm:
    Childish:
    Standard FORTRAN77 (and earlier) allowed no whitespace between tokens.
    Because, as originally envisaged, programmers would produce code in manuscript that was then keyed into the computers by low-paid typists. Having intraline whitespace be significant was thought to invite too many errors when the punch operator who didn't know the language misunderstood the programmer's spacing.
    But the manuscript was generally written on coding forms that made the spacing explicit, e.g. http://www.w3.org/2010/Talks/01-08-steven-ten-euro-computer/FortranCodingForm.png or http://upload.wikimedia.org/wikipedia/commons/2/2b/FortranCodingForm.agr.jpg.

    I was going to say, "Come on! Coding forms were obsolete by the time Fortran 77 came out!" but then I distinctly remember using the damn things in 1978 ... I tell you guys, you can not believe the excitement and relief to finally be able to enter code at teleprinters (that's like computer terminals with a stack of fan-feed paper instead of a screen).

  • The Lord of Cheese (unregistered) in reply to jspenguin
    jspenguin:
    Wow... that's so bad I was compelled to fix it...
    def genpassword(wlc, maxchar, txt, verbose):
        wlclen = len(wlc)
        txtfile = open(txt, 'w')
        for i in xrange(wlclen ** maxchar):
            word = ""
            for j in xrange(maxchar):
                word = wlc[i % wlclen] + word
                i /= wlclen
            if verbose:
                print word
            txtfile.write(word + '\n')
        txtfile.close()
    

    The beauty of the original function is that if (wlc[-1] != '9zZzZZ'[List - 1]), then the function will generate a file with (len(wlc) ** 15) lines: assuming wlc is alphanumeric, this would be 221073919720733357899776 lines.

    You actually took the time to figure this out? I looked at it and almost crapped my pants. Luckily, I pulled them down in time and just got a big pile of poo on the seat of my chair.

  • JolleSax (unregistered) in reply to Silfax
    Silfax:
    JolleSax:
    It shows pretty clearly though why they call it Python though.

    Is it that it's full of snakes that can bite you in the ass if not careful?

    I think that can happen in any language.

    Nope. It's just a snake of code. See it wibble wobble over the screen, it's almost cute :)
  • dan the man (unregistered) in reply to Some damn Yank
    Some damn Yank:
    CAPTCHA: esse - Enjoy my comments, or esse!

    Repeat after me: sum, esse, fui, futurus

  • (cs) in reply to Orclev
    Orclev:
    PedanticCurmudgeon:
    ubersoldat:
    This is stupid in any language, but this shows that crappy programmers use Python too and not only VB or PHP.
    Indeed. That is why I advocate the use of "difficult" languages like Haskell, Common Lisp or Factor. The sort of programmer who writes today's WTF wouldn't be able to get anything to work in those languages.

    Interestingly enough I was just thinking something similar. Of course the down side to such massively difficult to learn languages (spoken as someone who is nearly proficient enough in Haskell to say so), is that while you're learning it you still write a lot of code that if not quite at the level of WTF exhibited here is at least still considered a minor WTF by someone proficient in the language.

    Haskell, as a language or logic, is very easy. It has a very nice interpretation as a logic.

    Haskell, as a platform, is difficult because the language's ease and clarity allow the programmer to define complex constructs in mind-bendingly generic ways. It can be hard to figure out when to write generic tools versus when to use them. Haskell is hard the same way logic or category theory are.

    All of these are easier than keeping a picture of a program's state (or even a few of its variables) in your mind.

    Learning Haskell has some other issues, since things like memory management are platform dependent. You need to read the compiler documentation to figure some things out.

  • Mrcl (unregistered) in reply to Raniz

    More like O(no!)

  • kbh (unregistered) in reply to shash

    from itertools import combinations plm = ['a','s','d','f','1']

    passwords = [[''.join(i) for i in combinations(plm, r)] for r in xrange(2, len(plm))]

    It works ...

  • teratorn (unregistered)

    What, no unit tests?

  • (cs) in reply to QJo
    QJo:
    Chris:
    Surley the Python thing is barely here nor there - if you were *going* to write like this, you'd indent pretty much the same in languages like Java or C#?

    On the contrary. I've seen work from a programmer who refused to use indentation at all because "all that white space is wasteful." And no, his code was rarely as streamlined and efficient as the example included (he eschewed loops for a similar reason, and refused to use subroutines because, as he said, the overhead of handling the stack may significantly slow operation down, or something). Fortunately I was not required to work for long on the same project.

    Heh. I've encountered one that still insisted on having variable names as short as possible to save space and memory. I think this was relevant in some early versions of C, depending on the compiler, but I don't think it matters nowaday.

  • (cs)

    Behold: A reimplementation. Why anyone would actually want this function is beyond me, but at least it's cleaner than the original

    import itertools
    
    def genpassword(wlc, maxchar, txt, list_, verbose):
    	file = open(txt, 'w')
    	breakcond = {' 9zZzZZ'[list_]} if list_ else None
    	def incomplete(x):
    		x = ''.join(x)
    		if verbose: print(x)
    		file.write(x + '\n')
    		return set(x) != breakcond
    	list(itertools.takewhile(incomplete, itertools.product(wlc, repeat=maxchar)))
    	file.close()
    
  • zxq9 (unregistered) in reply to JDege

    You, sir. Not quite my hero, but close. Not that anyone but the two of us gets why; does this sadden me?

  • Veky (unregistered) in reply to Mike

    Argh. Please learn about repeat keyword argument to itertools.product. :-P

  • (nodebb)

    so nice

    Addendum 2024-05-20 22:19: Web scraping just got a lot easier with a new API I found that can bypass bot protection measures on websites. This API learn more leverages cutting-edge technology to replicate human browsing patterns, which helps it evade detection and access data smoothly. It's been incredibly effective for my needs, allowing me to scrape websites that were previously off-limits due to their stringent security protocols. This discovery is proving to be an invaluable asset in my data collection efforts!

Leave a comment on “Python Charmer”

Log In or post as a guest

Replying to comment #:

« Return to Article