This article has not yet passed wikiHow's quality review process. Learn more
Edit Article

Many Python programmers start out trying to use the JSON python library or just writing text to a file to transfer data between files. In this article I will cover the basics of creating a sub-language(not a full programming language), with little-to-no syntax, just perfect for writing small data bases or save files.

Ok,
Close
This article has not yet passed wikiHow's quality review process. Learn more

Steps

  1. 1
    Download Python if you haven't already. Get some basic knowledge on Python first. Open up IDLE and create a new file named whatever you want.
  2. 2
    Create a 'Load' function, which will be used to load the file so the user can write and get data from the loaded file
    • Add a parameter, the file name(fname) to the function, then create two globals: file and ln. Then set file to open the file (open(fname, "r+"), r+ stands for Read and write. Set ln to be file.readlines() so we can access to all the lines in the file. Lastly return file
  3. 3
    Create a 'var' function, which will be used to get variables from the file and into python itself
    • Add a parameter, the line to scan(line) to the function, then get our previous globals. Set the variable 'text' to be ln[line](Gets the value of line line and saves it as text. Now return text
  4. 4
    Create a 'write' function, which will be used to add data to our file(since we've already can retrieve data from a loaded file)
    • Add a parameter, the value to write in the file, get the global file and seek (file.seek(0, 2) to the end of the file then add file.write("\n%s"%value)(Which writes a newline, then the value to the file).Return file
  5. 5
    Create a 'end' function, which will be used to save the file and close it so we can access a different file.
    • Get the global file and file.close() it, then return file

We could really use your help!

Can you tell us about
Instagram?
Can you help us
rate articles?
Yes
No
Instagram
how to increase Instagram followers
Can you tell us about
Adobe Photoshop?
Yes
No
Adobe Photoshop
how to use the warp tool in Photoshop
Can you tell us about
lock-picking?
Yes
No
lock-picking
different ways to open a lock
Can you tell us about
astrology relationships?
Yes
No
astrology relationships
how to attract Scorpio guys
Thanks for helping! Please tell us everything you know about
...
Tell us everything you know here. Remember, more detail is better.
Tips
Provide Details.
Please be as detailed as possible in your explanation. Don't worry about formatting! We'll take care of it. For example:
Don't say: Eat more fats.
Do say: Add fats with some nutritional value to the foods you already eat. Try olive oil, butter, avocado, and mayonnaise.

Article Info

Categories: Programming

Thanks to all authors for creating a page that has been read 1,350 times.

Did this article help you?
Yes No