Piotr Sikora - Logo - Automatyzacja procesów | AI | JavaScript | Front End | Team Leader
  • Home
  • Services
    • Process Automation
    • AI for Lawyers
  • Blog
  • Quotes
  • Contact
PL/EN

Overwritting print function in Python

  • Home
  • Blog
  • Overwritting print function in Python
Overwritting print function in Python

By Piotr Sikora

  • 6 September 2025

  • 1 min read

Did you knew that you can easily overwrite print function using FunctType? Use code below to see how it works.

import random
def random_str():
    return random.choice([
        'first', 'second', 'third'
    ])

def alt_print(s):
    output = []
    for ch in s:
        c = ord(ch)
        if c in range(ord('a'), ord('z')+1):
            c += 119945
        elif ord('A') <= c <= ord('Z'):
            c += 119951
        output.append(chr(c))
        output.append(' ')
    print(''.join(output))


def firstFunction(s="test"):
    print(s)

import types
myFirstFunction = types.FunctionType(
    firstFunction.__code__,
    {
        "print": alt_print
    },
    name="myFirstFunction",
    argdefs=("Function",) # <= there is "," in the end - IT HAS TO BE THERE
)

myFirstFunction()

Share this article

TwitterLinkedInFacebook

Tags:

  • #python

  • #pip

  • #print

  • #hacker

Categories

after-hours(1)AI(7)ai-en(1)angular(4)automatic-tests(1)Automation(2)cryptography(1)css(8)CyberSecurity(2)Development(6)DevOps(1)events(3)javascript(11)n8n(10)ollama(1)security(2)seo(1)

Recent Posts

Testing Kimi Code: First Impressions from Web and CLI

Development

Testing Kimi Code: First Impressions from Web and CLI

Why You Shouldn't Cram Multiple Webhooks Into One n8n Workflow

Automation

Why You Shouldn't Cram Multiple Webhooks Into One n8n Workflow

DRY, WET, AHA: Finding the Right Balance in Code Reuse

Development

DRY, WET, AHA: Finding the Right Balance in Code Reuse

API vs Webhook: Understanding the Difference

Development

API vs Webhook: Understanding the Difference

RTCROS Framework: Structure Your Prompts for Better AI Results

AI

RTCROS Framework: Structure Your Prompts for Better AI Results

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates
View Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO

Tags

activepiecesafter-hoursahrefsaiAI cost reductionai-agentsai-automationangularantigravityapiAqua Securityarcade-gamesarchitectureautomationbackendbest-practicescadillacs-and-dinosaurschatbotchatgptCI/CD
“An intellectual says a simple thing in a hard way, an artist says a hard thing in a simple way.”
Charles Bukowski
View more quotes

Similar Articles

Discover more related content

XOR Cipher Implementation: Encryption in Python

XOR Cipher Implementation: Encryption in Python

Explore XOR cipher implementation in Python. Learn how this encryption algorithm works with practical code examples and analysis.

Piotr Sikora | ai | n8n | javascript | python

Let's get to know each other!

Get in touch with me
Piotr Sikora | Process Automation  | AI Implementation 🤖 | Technology Consulting
Quick links
  • Home
  • Blog
  • Contact
Contact
  • piotr.sikora.ck@gmail.com
  • +48 505 684 661

© Piotr Sikora 2026 | All Rights Reserved