@Calvin'sHobbies Thanks :) I'm very much in favour of keeping the popularity contests, but I'm also aware that they have flaws and I'd like to see continued discussion about potential improvements. Ideally we'd have a way of measuring the popularity without using Q&A votes. On golf challenges I upvote solutions with good explanations - the voting is independent of the winning criterion. With pop cons voting for different purposes are all combined. I still think it works surprisingly well though.
I love BATCH, despite its shocking lack of functional commands, despite even due to its lack of non-integer support. Why? Because this works:
SET var=SET
%var% i=0
This would evaluate to:
SET var=SET
SET i=0
Fantastic, isn't it? I've used this technique in a BATCH program before, because it...
I'm from PPCG so I was making an esolang and I decided to write it in Python. Eventually it went from an esolang to an OEIS (Online Encyclopedia of Integer Sequences) lookup tool. I'm very new to Python.
Essentially this program takes an OEIS sequence number (e.g. 55 for sequence A000055) and t...
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool th...
𝔼𝕊𝕄𝕚𝕟, 11 chars / 14 bytes
⟮ɕṡ+ᶈ0)ď⧺ḁ;
Try it here (Firefox only).
I'm not sure if copy blocks ⟮ (which, quite literally, "copy pieces of code") are considered "reading source code," but if invalid, I'll be willing to delete the submission.
Explanation
Quine framework: ⟮ɕṡ+ᶈ0
⧺ḁ incre...
King of Prussia is a census-designated place in Upper Merion Township, Montgomery County, Pennsylvania, United States. As of the 2010 census, its population was 19,936. The community took its name in the 18th century from a local tavern named the King of Prussia Inn, which was named after King Frederick II of Prussia. Like the rest of Montgomery County, King of Prussia continues to experience rapid development. The second-largest shopping mall in the United States in terms of space and size (nearly 3 million square feet), the King of Prussia Mall, is located here. Also located here is the h...
import*:
Please avoid importing all modules at all costs. Import each module you use separately
Regex ಠ_ಠ
Regex is evil, the worst. seriously. stop it. right now. kill python.exe right now and change it.
You use beautifulsoup, a dom parsing library, literally a few lines later, but you choo...
Redundant code
print """This is the OEIS lookup tool
You haven't entered the sequence""" % (LANGNAME)
This can easily become
print "This is the OEIS lookup tool\nYou haven't entered the sequence"
You accidentally left some residual code from Putt in there.
♫ Let's all hop on the co...
Jolf, 4 bytes
Q«Q«
Q double (string)
« begin matched string
Q« capture that
This transpiles to square(`Q«`) (I accidentally did string doubling in the square function), which evaluates to Q«Q«. Note that q is the quining function in Jolf, not Q ;).
Observation:
Say your code looks like this:
codeA();
while(conditionAsFunction){
codeB();
}
codeC();
This is equivalent to:
codeA();
(function(c){
codeB();
if(c()) setTimeout(arguments.callee,1,c);
else codeC();
})(conditionAsFunction);
I've come across at least three ways to print to stderr:
import sys
print >> sys.stderr, 'spam'
sys.stderr.write('spam\n')
from __future__ import print_function
print('spam', file=sys.stderr)
It seems to contradict zen of Python #13 †, so what's the preferred way to do it? Are there an...
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: exceptions must be old-style classes or derived from BaseException, not str
cat, 0 - ∞ characters
UNIX cat is a programming language with no syntax. The output of any program in cat language is the source code itself.
"you can't just read the source file and print it"
I am not doing that! It's the language itself, it's the cat interpreter who does it.
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
>>>
@Downgoat I was a bit wrong, actually. match looks for the pattern at the start of the string.
>>> re.match(r'(\d)', 'a1b')
>>> help(re.match)
Help on function match in module re:
match(pattern, string, flags=0)
Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found.
>>> re.search(r'(\d)', 'a1b').group()
'1'
Using your language of choice, golf a quine.
No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.
Points for:
Smallest code (in characters)
Most obfuscated/obscure s...