Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:05:58+00:00 2026-06-10T18:05:58+00:00

In bash you can give a command an alias like so: alias e=echoset alias

  • 0

In bash you can give a command an alias like so:

alias e=echoset 
alias e="echo blah"

I want to know how to do the same thing in Python. I know you can give classes aliases, but when I try to give a command (the print statement for example) an alias, I get an error:

>>> p = print
  File "<stdin>", line 1
    p = print
            ^
SyntaxError: invalid syntax

I can do this:

p = "print"
exec(p)

But that isn’t really the same thing as aliasing, and I can’t give any input to the command.

Update:
@atzz You guessed right, it is not specific to print. What I am trying to get to work is this:

This is supposed to set the command, but instead, it just beeps when I enter this:
>>> beep = Popen(['play', '-q', '/home/Username/Mich/Sound Effects/Beeps/beep-17-short.ogg'])

Then when I enter beep into the prompt, it shows this:
>>> beep
<subprocess.Popen object at 0x9967b8c>

But other then this problem I have, at least now I know that you can’t give statements aliases.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:06:00+00:00Added an answer on June 10, 2026 at 6:06 pm

    To answer your new question, if you want to do this and have beep execute later:

    beep = Popen(['play', '-q', '/home/Username/Mich/Sound Effects/Beeps/beep-17-short.ogg'])
    

    Change it to:

    beep = lambda: Popen(['play', '-q', '/home/Username/Mich/Sound Effects/Beeps/beep-17-short.ogg'])
    

    Or just a function 🙂

    def beep(): Popen(['play', '-q', '/home/Username/Mich/Sound Effects/Beeps/beep-17-short.ogg'])
    

    Otherwise ‘beep’ will just hold the return value of Popen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Bash I can easily do something like command1 && command2 || command3 which
In bash how can I make a construction like this to work: if (cp
Is there a Linux utility or a Bash command I can use to sort
Can someone please give me a recursive command that will go through a directory
I need to know how what command or commands I can use in a
I want to know if i can somehow or someway run a remote linux
I want to have the same output as ls creates in a bash or
In Bash I can create a map (hashtable) with this common construction hput() {
I have terminal.app set to accept utf-8 and in bash I can type unicode
I've got a bash script that can take arguments in a variety of different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.