Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess using Jython, you can do anything with Python that you can do in Java.</p> <p>Conversely, Python has the PyPy compiler, which is pretty cool - a virtual machine with multiple backeds (Java Runtime, LLVM, .net, and Python IIRC), multiple garbage collectors, multiple implementations (Stackless), etc. I know Java has a big choice of virtual machines, but the growth of PyPy is amazing, due to it being written in RPython - a fairly productive language.</p> <p>Also, can a Java do this, in 1 file and less that 20 lines, with no library imports? Obviously both languages have libraries that can do this, but I'm just talking about the flexibility of the languages.</p> <pre><code>class Logger(object): # boilerplate code def log(self,level,msg,*args,**kwargs): # *args, **kwargs = flexible arguments self._log(level,msg,*args,**kwargs) # call with flexible argments def _log(self,level,msg,*args,**kwargs): # override me at runtime :) # I think Java people call this Dependency Runtime Injection if level&gt;1: print msg,args,kwargs logger = Logger() # boilerplate code def logged(level): # what pattern do you call this? def logged_decorator(function): # and this? def func(*args,**kwars): name = func.__name__ # look ma, reflective metaprogramming! logger.log(level,name,*args,**kwargs) return func(*args,**kwargs) return func # boilerplate code return logged_decorator # boilerplate code </code></pre> <p>Example use:</p> <pre><code>@logged def my_func(arg1,arg2): # your code here pass </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload