Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

realstarexx

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realstarexx

Coding and programming isn't same

pipPyPI
Version
1.0.2
Maintainers
1

Starexx

It provides a structured way to build Python programs through object composition rather than writing code directly.

Installation

Step 1: pip install starexx
Step 2: Implement in your code

from starexx import *

Basic Usage

Simple Calculator Example

from starexx import *

program = src(
    var("a", 10),
    var("b", 5),
    
    p("a =", get("a")),
    p("b =", get("b")),
    p("a + b =", add(get("a"), get("b"))),
    p("a - b =", subtract(get("a"), get("b"))),
    p("a * b =", multiply(get("a"), get("b"))),
    p("a / b =", divide(get("a"), get("b")))
)

program.run()

Output:

a = 10
b = 5
a + b = 15
a - b = 5
a * b = 50
a / b = 2.0

Variables and Conditions

from starexx import *

program = src(
    var("name", "Alice"),
    var("age", 25),
    
    p("Name:", get("name")),
    p("Age:", get("age")),
    
    if_(
        gt(get("age"), 18),
        p(get("name"), "is an adult"),
        else_=p(get("name"), "is a minor")
    )
)

program.run()

Output:

Name: Alice
Age: 25
Alice is an adult

Core Components

Basic Structure:
· src(*nodes) - Main program container
· var(name, value) - Variable declaration
· p(*values) - Print statement
· get(name) - Variable reference

Control Flow:
· if_(condition, then_branch, else_branch) - If statement
· for_(item, iterable, body) - For loop
· while_(condition, body) - While loop

Functions:
· function(name, params, *body) - Function definition
· call(name, args) - Function call
· return_(value) - Return statement

Data Structures:
· list_(*items) - List literal
· dict_(**items) - Dictionary literal

Operations:
· add(a, b), subtract(a, b), multiply(a, b), divide(a, b)
· eq(a, b), neq(a, b), gt(a, b), lt(a, b)
· and_(a, b), or_(a, b), not_(a)

Advanced Examples

Function with Loop

from starexx import *

program = src(
    function(
        "calculate_sum",
        ["numbers"],
        var("total", 0),
        for_("num", get("numbers"), src(
            set_("total", add(get("total"), get("num")))
        )),
        return_(get("total"))
    ),
    
    var("scores", list_(85, 92, 78, 96)),
    var("total_score", call("calculate_sum", [get("scores")])),
    p("Scores:", get("scores")),
    p("Total:", get("total_score"))
)

program.run()

List Operations

from starexx import *

program = src(
    var("fruits", list_("apple", "banana", "orange")),
    p("Fruits:", get("fruits")),
    p("First fruit:", call("fruits.__getitem__", [0])),
    
    # Add a new fruit
    call("fruits.append", ["grape"]),
    p("Updated fruits:", get("fruits")),
    
    # List length
    p("Number of fruits:", len_(get("fruits")))
)

program.run()

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts