Saturday, June 15, 2019

Convert a python dictionary to comma separated key list and comma separated value list

I have a dictionary as follows:-
dict={'a':'1','b':'2', 'c':'3'}
To convert it into into a comma separated keys string key_string and a comma separated values string val_string I do the following:-
key_list=[]
val_list=[]

 for key,value in dict.iteritems():
     key_list.append(key)
     val_list.append(value)

 key_string = ','.join(key_list)
 val_string = ','.join(val_list)
The result is
 key_string = "a,b,c"
 val_string = "1,2,3" 

Tuesday, June 4, 2019

Java Compiler

Javac is Java Compiler -- Compiles your Java code into Bytecode
JVM is Java Virtual Machine -- Runs/ Interprets/ translates Bytecode into Native Machine Code
JIT is Just In Time Compiler -- Compiles the given bytecode instruction sequence to machine code at runtime before executing it natively. It's main purpose is to do heavy optimizations in performance.
So now, Let's find answers to your questions..
1)JVM: is it a compiler or an interpreter? -- Ans: Interpreter
2)what about JIT compiler that exist inside the JVM? -- Ans: If you read this reply completly, you probably know it now
3)what exactly is the JVM? -- Ans:
  • JVM is a virtual platform that resides on your RAM
  • Its component, Class loader loads the .class file into the RAM
  • The Byte code Verifier component in JVM checks if there are any access restriction violations in your code. (This is one of the principle reasons why java is secure)
  • Next, the Execution Engine component converts the Bytecode into executable machine code
Hope this helped you..

Sunday, June 2, 2019

Switcing python versions in Anaconda


You can easily maintain separate environments for Python 2 programs and Python 3 programs on the same computer, without worrying about the programs interacting with each other. Switching to an environment is called activating it.
Please follow below link
https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/