ekb.py - python vs

Download ekb.py - Python VS

If you can't read please download the document

Upload: it-people

Post on 25-May-2015

738 views

Category:

Technology


3 download

DESCRIPTION

Автор - Илья Шабалин

TRANSCRIPT

  • 1. Python vs. ? , Exadel,

2. BufferedReader myFile =newBufferedReader( newFileReader(filename)); while( true ) { String line = myFile.readLine(); if(line ==null ) { break ; } System.out.println(line); } : Java 3. forlinein open (filename): printline : Python 4. $ handle =@ fopen ( $ filename ) ; if ( $ handle ) { while (( $ buffer = fgets ( $ handle ,4096 )) !== false ) { echo $ buffer ; } if ( ! feof ( $ handle )) { echo" Error: unexpected fgets() fail n "; } fclose ( $ handle ) ; } : PHP 5. public classEtmDecoratorimplementsInvocationHandler { private finalObject obj; public staticObject newInstance(Object obj) { returnProxy.newProxyInstance( obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), newEtmDecorator(obj)); } publicEtmDecorator(Object obj) { this .obj = obj; } @ Override publicObject invoke(Object proxy, Method m, Object[] args)throwsThrowable { EtmPoint point = EtmManager.getEtmMonitor().createPoint(m.getName()); try{ returnm.invoke(obj, args); }catch(InvocationTargetException e) { throwe.getCause(); }finally{ point.collect(); } } } : Java 6. def measure (func): @ functools.wraps (func) def wrapper (*args, **kwargs): point = create_measurement_point(func.__name__) try : returnfunc(*args, **kwargs) finally : point.collect() returnwrapper : Python 7. classDecorator{ private $ obj ; function __construct ( $ obj ) { $ this -> obj= $ obj ; } function __call ( $ method ,$ args ) { $ point =createMeasurementPoint ( $ method ) ; try { $ rv = call_user_func_array ( array ( $ this -> obj,$ method ) ,$ args ) ; $ point -> collect () ; return $ rv ; } catch ( Exception $ e ) { $ point -> collect () ; throw $ e ; } } } : PHP 8. CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery campaigns = cb.createQuery(Campaign. class ); Root from = campaigns.from(Campaign. class ); campaigns.select(from); campaigns.where(cb.equal(from.get( "name" ), name)); TypedQuery query = entityManager.createQuery(campaigns); returnquery.getSingleResult(); ORM: Java 9. returnSession.query(Campaign). filter (Campaign.name==name).first() ORM: Python 10. ?