while learning velocity …

I was looking at velocity for templating.  This is the first program that i wrote

package com.i2.template;

import org.apache.velocity.app.Velocity;
import  org.apache.velocity.VelocityContext;
import java.io.StringWriter;

public class Test{
     public static void main(String[] args){
          VeloctyContext ctx = new VelocityContext( );
          String template= " Hello World in $lang ";

          StringWriter writer = new StringWriter( );
           Velocity.init( );
           Velocity.evaluate(ctx, writer,"",template );
           System.out.println(writer.getBuffer( ) ); // Hello World in Java

I have been trying to learn python as well and suddenly it occured to me that I would do the following in Python.

st = " Hello World in %(lang)s"
result = st % {‘lang’:’Python’}
print  result  #  Hello World in Python

I realize that Velocity is more than just  variable substitution.  But statement /expression evaluation in python should’nt be too difficult either.

I wish I had a chance to execute a python project and figure what this Static Vs Dynamic typing  is all about .

Content Team

The IndicThreads Content Team posts news about the latest and greatest in software development as well as content from IndicThreads' conferences and events. Track us social media @IndicThreads. Stay tuned!

Leave a Reply