Libraries in EasyBite
What Are Libraries?
In programming, libraries are reusable sets of code written by developers to make tasks easier. They often contain functions, classes, and methods that solve specific problems — such as performing calculations, manipulating strings, handling files, connecting to databases, or creating user interfaces — without needing to write that code yourself every time.
In EasyBite, libraries are pre-built collections of helpful tools that you can include in your program whenever you need them. These libraries are built-in, which means you don’t have to install anything or download them separately — you just need to import them into your code and start using them right away.
Using libraries makes your programs:
- Simpler: You write less code to achieve more.
- Cleaner: Code is better organized and easier to read.
- Faster to build: You don’t need to reinvent the wheel.
- More powerful: You can achieve things you couldn’t easily do on your own.
How to Use Libraries in EasyBite
To make use of a library in EasyBite, you use the import
keyword. This tells the interpreter to load a specific library or specific parts of it into your program.
There are three main ways to import libraries in EasyBite, giving you flexibility based on your needs.
1. Importing the Entire Library
This is the most basic form. It loads the whole library, and you access its contents using dot notation (libraryname.functionname
).
Example:
import math
show math.sqrt(36)
Output:
6
In this example, we imported the math
library and used the sqrt
(square root) function to find the square root of 36.
2. Importing Specific Functions or Classes
Sometimes you don’t need everything in a library — only a few functions or a specific class. You can use the from
keyword to import only what you need. This allows you to use the function directly, without writing the library name every time.
Example:
from math import sqrt
show sqrt(49)
Output:
7
Here, we directly imported sqrt
from the math
library, and we can now call it without prefixing it with math.
3. Importing Multiple Functions or Classes
EasyBite supports importing multiple items at once by separating them with commas. This works with both the import
keyword and the from
keyword.
Example 1 – Importing Multiple Libraries:
import math, string, datetime
show math.sqrt(100)
show string.toupper("easybite")
show datetime.today()
This way, you bring in several libraries in one line and can use each of their tools with dot notation.
Example 2 – Importing Multiple Items from a Single Library:
from math import sqrt, pow, pi
show sqrt(25)
show pow(3, 2)
show pi
This is useful when you want to reduce the amount of typing and keep your code clean, especially when using the same functions repeatedly.
Summary of Importing Methods
Syntax | Description | Example |
---|---|---|
import library | Imports the whole library. You must use dot notation to access contents. | import math show math.sqrt(16) |
from library import item | Imports specific functions or classes so you can use them directly. | from string import tolower show tolower("HELLO") |
import lib1, lib2 | Imports multiple libraries at once. | import math, string |
from library import a, b | Imports multiple items from one library. | from math import sqrt, pow |
This flexibility in importing helps keep your programs both powerful and easy to manage.
Why Use Libraries?
Using libraries is considered best practice in programming for several reasons:
- ✅ Save time – Built-in functions are already optimized and tested.
- ✅ Increase productivity – Focus on the unique parts of your program rather than the repetitive ones.
- ✅ Improve reliability – Built-in tools are more likely to behave predictably.
- ✅ Enhance readability – Code becomes clearer and easier to maintain.
- ✅ Avoid errors – You’re less likely to make mistakes by using proven code.
Available Built-in Libraries in EasyBite
Here are all the built-in libraries currently available in EasyBite. Each one is designed to handle specific tasks, from mathematics to file systems to graphics.
Library | Description | Documentation |
---|---|---|
math | Functions for calculations: square root, powers, trigonometry, constants like pi. | View |
string | Tools for working with text: upper, lower, replace, trim, and more. | View |
array | Array manipulation: sort, reverse, search, filter, map, reduce. | View |
dict | Dictionary handling: insert, update, delete, get keys and values. | View |
datetime | Date and time handling: current time, date formatting, intervals. | View |
convert | Data type conversions: string to int, int to float, boolean conversions. | View |
fs | File system access: reading, writing, appending, deleting files. | View |
sqlite | Local database support using SQLite: queries, inserts, schema creation. | View |
mysql | Connect and interact with MySQL databases. | View |
socket | TCP/IP socket communication tools. | View |
requester | Send HTTP requests: GET, POST, PUT, DELETE. | View |
listener | Listen for custom events or network messages. | View |
system | System-level operations: run commands, get environment variables. | View |
thread | Threading support: run code in parallel or background. | View |
gui | Build simple graphical interfaces with buttons, labels, etc. | View |
plotter | Create charts and graphs: bar, pie, line, scatter, and more. | View |
To learn more about any specific library, click its name in the table above to visit its full reference guide.
Conclusion
Libraries are one of the most important tools in any programming language, and EasyBite makes using them simple, flexible, and powerful. Whether you're building a calculator, a database-driven website, or a data visualizer, you can rely on EasyBite's built-in libraries to provide the support you need.
Learn how each library works, try the examples, and begin using them in your projects to save time and write better code.
For a full walkthrough of getting started with libraries in EasyBite, visit:
📚 Libraries Overview