Bob IS BACK
posted to Share by CSharpIsGud

Confusion

Discord.py How to ping users?
posted to Ask by slavstic

Discord uses special formatting for pings: <@user_id>. With discord.py, there are two easy ways to ping a user:

#  If you have the ctx object (inside a command)
await ctx.send(ctx.message.author.mention)

# If you have a message object (such as the on_message event)
await message.channel.send(message.author.mention)

# If you know their ID
await ctx.send("<@" + str(user_id) + ">")
Tkinter in python
posted to Ask by UmerkkkKhan

All you have to do is when you select your language, select Tkinter instead of python.

Browser Crasher
posted to Share by xxpertHacker

Doesn't appear to work on safari, but it works on Chrome, Chromium, and Brave

How to restart a python program ?
posted to Ask by TejasvMaheshwar

I see that people have answered your second question, but not the first. I don't think that there is a way to restart a python program from within the file, unless you put it in a function and just told it to re-run the function, then break the original, like this:

def main():
    #main code here
    #to "restart" program:
    main() #this just re-runs the program that is currently running
    exit() #this tells the python program to stop completely

main()

If you need a better example just let me know

Edit #1:
I just noticed that when you except an error, you also re-run the function. This is not necessary because it is in a while loop and will re-run by itself.

    except:
      print("Invalid input, Try Again")

not

    except:
      print("Invalid input, Try Again")
      calc()
Project I've been working on.
posted to Share by ArtemPionov

How come you're using sys to print to the screen, instead of print()?
An easier way would probably be doing this:

def slow_print(text):
    for char in text:
        print(char, end='') #Print each individual character but don't go to a newline
    print() #Go to the next line (because 'end' defaults to '\n'
list is not updated_hangman
posted to Ask by OfirLiron

Here's what you can do. Define your variables at the top of your code, like
old_letter_guessed = []
and any other variables you have.
Then, when you use them inside of a function, do this instead:

def my_function():
    global old_letter_guessed #Put this line at the top of your function.

This tells Python that you want the variable to update outside fo the function. Otherwise, the variable will stay inside the function, so to speak.

Hope this helps

I cannot fix this syntax error
posted to Ask by ArtemPionov

SixBeeps has it. You have main_character = input(str(">>>"("Are you sure?"))
you need main_character = input(str(">>>"("Are you sure?"))) (Note the extra ))

i need help on my assingment from python of 7.4 practice code.
posted to Ask by MiltonAmaya

KeyError means that the key 'workspace' does not exist in the list. In this case, the list os.environ[] has not key 'workspace'

This simply means that there is no variable in os.environ called workspace. Maybe you meant HOME?

Repl Talk Rules and Guidelines [README]
posted to Announcements by mat1

You missed a comma after the word "repls"

A super simple chatroom that is fast and secure
posted to Share by Vandesm14

@Vandesm14 Did you mean to send that comment to pyelias?

A super simple chatroom that is fast and secure
posted to Share by Vandesm14

Amazing. Maybe add a password feature, so you can create a room, and set a password, so only those with the password can access

Weekly Repls #39
posted to Announcements by 21natzil

@21natzil
My repl was deleted(the text based dodge ball game.)
Here is the link
https://repl.it/talk/share/No-GUI-dodge-ball/16441

Can anyone help me with this please?
posted to Ask by FamousRW

@codingjlu Making everything easier to read

How do you make a working purge command
posted to Ask by CUSULe

@epicseg No need to apologize, I was just wondering.

How do you make a working purge command
posted to Ask by CUSULe

Why not just use channel.purge()? It's litteraly an API endpoint that discord has ended for this purpose. @epicseg

Database isnt working
posted to Ask by BananaJellyfish

@BananaJellyfish Yeah I find it odd, I always thought the point of repl.it was other people could run your code without forking it. I guess it doesn't apply to programs that use the db.

How do you make a working purge command
posted to Ask by CUSULe

You would use channel.purge() to do this. Here is an example command:

@bot.command(name="purge")
@commands.has_guild_permissions(manage_messages=True)
async def purge(ctx, limit: int):
    if limit > 1000:
        await ctx.send("You can only purge up to 1000 messages")
        return
    elif limit < 1:
        await ctx.send("You must purge at least 1 message")
        return

    await ctx.channel.purge(limit=limit)

Two things to note. First off, you are using discord.Client instead of discord.ext.commands.Bot. You should always use Bot, never use Client (unless you're making a self bot ig).

All you have to do is replace

client = discord.Client()

with

bot = discord.ext.commands.Bot(command_prefix="!")

Also, you should add this to your imports:

from discord.ext import commands
How do you make a working purge command
posted to Ask by CUSULe

@epicseg This isn't really a good way. It's slow and likely to hit the API ratelimit.

Can anyone help me with this please?
posted to Ask by FamousRW

@codingjlu Because python is the best

Database isnt working
posted to Ask by BananaJellyfish

Maybe this is why?

Discord.py How to ping users?
posted to Ask by slavstic

@Coder100 Oh sorry I missed that.

Discord.py How to ping users?
posted to Ask by slavstic

@Coder100 It's always <object>.mention, .name and .id will send just their name or their id.

[Python] Convert None to int
posted to Ask by Bookie0

You can use typhinting to declare the type of a variable without giving it a value. However, python will not recognize it as a valid variable until you assign it a value.

my_int: int
my_float: float

print(my_int)  # Results in error

I can think of two reason why python wouldn't let you set an int as None:
1. None is it's own type (NoneType) -- Just like an integer can't be a string, and integer cannot by None
2. Say I did set an int as None: my_int = int(None). What would happen if I tried using that variable? my_int > other_int wouldn't work, my_int += 1 wouldn't work.

I hope this helps.

Make your own console
posted to Templates by ChezCoder

help clear gives Error: 'clear' is not a valid command. even though clear clears the console.

@coder100
posted to Ask by SamCox2

@Coder100 This is outrageous. I now submit the rest of my life to make sure Coder100 is no longer the go-to (jk)

Pygame Template
posted to Share by LD1

@katyadee oof sorry for the late (really late) response

I probably don't have the time to do that, but I've updated it to be a simple pygame example with cleaner code.

Pygame Template
posted to Share by LD1

@Zachary007 Hope you like it! Also I just made a new simple pygame game and updated it here. I hope you find it useful

Pygame Template
posted to Share by LD1

@Zachary007 Sorry, I forgot I had posted this and I deleted the original. If you give me a few minutes I can write another though.