3 ms·
In this case "one line" doesn't mean much. You could have a 1mb file in one line. Nowadays a "line" is between 80-140 characters.
by ricardobeat 15y ago
In this case "one line" doesn't mean much. You could have a 1mb file in one line. Nowadays a "line" is between 80-140 characters.
- rplnt 15y agoYou are not entirely right. In python, one line means something as it is only one statement (as mentioned above). Author is also strict about not using eval -- with eval you could snuck multiple lines into one line (using \n in the evaluated string).
- worldimperator 15y agoLast time when I used python I could separate statements with a semicolon and put as many as i want in a line. Did that change ? ;-)
- lightcatcher 15y agoThis did not change, but the author also didn't use semicolons. As stated many times above, this is a single Python expression.
- rplnt 15y agoI'm not sure you can write function definitions, (nested) loops and other things that rely on indentation in single line using semicolons. At least I never managed to do that.
- worldimperator 15y agoYou can do it with lambdas, but it's going to be absurdly ugly: http://blog.sigfpe.com/2008/09/on-writing-python-one-liners.html http://blog.sigfpe.com/2008/09/on-writing-python-one-liners....
- cjfont 15y agoI reckon that the challenge involved in reducing the problem to one line (as in one single Python statement) has little to do with how many characters long it is.