Python For Change Format is a flexible marked language which allows to implement Python For Change solutions to several problems.
PFCF Language allows to easily integrate different Python For Change Ecosystem functionalities.
- PFCF Language is written 100% in python and allows to write in python.
- Then, PFCF can improve it itselft. That allows PFCF to get new special commands everyday.
- PFCF have special eigen commands (NQS scripts) that simplify the development of code with IBM Qiskit. This scripts are currently deprecated. [Learn more about NQS here.](https://nqs.rtfd.io)
Get the last version of this software here <https://github.com/PythonForChange/FilesFormat>`__
Install pyforchange
pip install pyforchange
Import pfcf in your python file
import pyforchange.pfcf
Enjoy!
Writting PFCF code with Pyfoch Editor
Open Pyfoch.
Write the following lines:
hello,world",|
~this text can not be printed~
Hi!,- Run main.py,
- Edit this file and see the magic,
- This is the first real-time editor of .pfcf files,|
Welcome to pfcf,
~
multiline
commentary
~
a new lang...,
a new experience...,
Welcome to the future,:),|May 10 2021\, 13:45,
by Eanorambuena,|Add code like this:,|
\<qiskit\>,
q0 q1,X,
H,
.---X,
c1,
$host qasm_simulator,
$hist true,
$draw true,
\</qiskit\>\,,
|
\<python\>,
print("hello world"),
\</python\>\,,
|
\<wolfram\>,
Range[5],
\</wolfram\>\,,- Run main.py,
In "File" menu, click on "Export".
Give a name to your exported file and save.
Open the exported file.
The exported file will have the following text:
hello
worldHi!
1. Run main.py
2. Edit this file and see the magic
3. This is the first real-time editor of .pfcf filesWelcome to pfcf
a new lang...
a new experience...
Welcome to the future
:)May 10 2021, 13:45
by EanorambuenaAdd code like this:
<qiskit>
q0 q1X
H
.---X
c1
$host qasm_simulator
$hist true
$draw true
</qiskit>,<python>
print("hello world")
</python>,<wolfram>
Range[5]
</wolfram>,Enjoy!
Import executepfcf from pyforchange.pfcf.read.
from pyforchange.pfcf.read import executepfcf
Execute yourfilename.pfcf
executepfcf(yourfilename)
Import pfcf and give the instructions.
from pyforchange.pfcf.files import *
l=LogFile("log1")
l.row("hello[") #this [ can not be printed
l.row("world\"") #this " can not be printed
l.section() #break
l.row("hello"+l.vip("[")) #this [ can be printed
l.row("world"+l.vip("\"")) #this " can be printed
l.section() #break
l.row("by Eanorambuena"+l.den("this text can not be printed"))
l.read()
First, log1_0.pfcf file is made.
v2.0.2 or upper:
hello[,world",|hello\[,world\",|by Eanorambuena~this text can not be printed~,
Then, log1_0.pfcf is read and printed.
hello
worldhello[
world"by Eanorambuena
Finally, 0 is append to log1_hist.pfcf file.
0
l.reset()
l.p.den=":"
l.row(l.den("this text can not be printed"))
l.read()
First, log1_1.pfcf file is made.
v2.0.2 or upper:
:this text can not be printed:,
Then, log1_1.pfcf is read and printed.
Finally, 1 is append to log1_hist.pfcf file.
0
1
data = {}
data['clients'] = []
data['clients'].append({'first_name': 'Sigrid',
'last_name': 'Mannock',
'age': 27,
'amount': 7.17})
- data['clients'].append({
- 'first_name': 'Joe',
'last_name': 'Hinners',
'age': 31,
'amount': [1.90, 5.50]})- data['clients'].append({
- 'first_name': 'Theodoric',
'last_name': 'Rivers',
'age': 36,
'amount': 1.11})l2=LogFile("log2")
l2.fromDict(data)
First, log2.json file is made.
{
"clients": [
{
"first_name": "Sigrid",
"last_name": "Mannock",
"age": 27,
"amount": 7.17},
{"first_name": "Joe",
"last_name": "Hinners",
"age": 31,
"amount": [1.9,
5.5]
},
{"first_name": "Theodoric",
"last_name": "Rivers",
"age": 36,
"amount": 1.11}
]
}
Then, log2.json is read as a .pfcf file.
Finally, it is printed.
clients:
first_name: Sigrid
last_name: Mannock
age: 27
amount: 7.17
first_name: Joe
last_name: Hinners
age: 31
- amount:
1.9
5.5
first_name: Theodoric
last_name: Rivers
age: 36
Add the comma symbol to create a new line.
This is a line,This is other line
Our exported file will be something like this:
This is a line
This is other line
Add the vertical line symbol to create a new paragraph.
Always we must write a comma before the vertical line symbol.
This is a paragraph,|This is other paragraph
Our exported file will be something like this:
This is a paragraph
This is other paragraph
We can also write the comma symbol twice, but Pyfoch will not recognize it like a new paragraph.
This is a paragraph,,This is a a line in the same paragraph\, which looks like another paragraph
The aesthetic result will be the same:
This is a paragraph
This is a a line in the same paragraph, which looks like another paragraph
Note we use the "\" symbol in order to Pyfoch do not recognize the comma like a new line command.
In general, we say that the "\" symbol scapes the next character.
Write the text between the labels "$block begin" and "$block end".
Pyfoch will recognize it like Python code.
This is a common line.,|
$block begin
This is a line in a block of text.,|
$block end
This is another common line
Our exported file will be something like this:
This is a common line.
This is a line in a block of text.This is another common line
$block begin" and "$block end" are both changeability commands.
Changeability commands are further explored below.
Write the text between the labels "<python>" and "</python>".
Pyfoch will recognize it like Python code.
<python>
print("Hello World")
</python>:
Our exported file will be something like this:
print("Hello World")
This will be useful when you domain changeability commands.
Changeability commands are further explored below.
Write the text between the labels "<wolfram>" and "</wolfram>".
Pyfoch will recognize it like Wolfram Language code.
<wolfram>
Range[5]
</wolfram>
Our exported file will be something like this:
Range[5]
In general, if "alanguage" is a supported programming language, write the text between the labels "<alanguage>" and "</alanguage>" in order to Pyfoch recognize it like "alanguage" code.
The heart of PFCF language is the changeability. Changeable code has a marked tendency to change.
PFCF use the changeability in order to improve the efficience in the coding development experience.
Add the "$" symbol to write a new changeability command. For example, let's say Pyfoch we want to start a new text block.
$block begin
The general sintaxis is simple:
$command parameter
Always we must write in a new line after writting a changeability command.
PFCF suports Natural Quantum Script code, language that simplifies the quantum code development.
This scripts are currently deprecated. [Learn more about NQS here](https://nqs.rtfd.io)
NQS is first-based in IBM qiskit. Write the text between the labels "<qiskit>" and "</qiskit>".
Pyfoch will recognize it like NQS commands.
<qiskit>
"Your code"
</qiskit>: