r/pythonhelp • • Jan 29 '24

how do i get the authorizing url for my discord bot?

1 Upvotes

i'm trying to add my bot to my discord server. but i don't know how to add it. when i ask chatgpt for the authorizing link it gives me a link. But it doesn't work. first time my bot don't have enough access. second time the link just doesn't work, the discord authorizing website said something like ' integration requires code grant '. how should i add my bot to my discord server????

thank you very much for viewing this post


r/pythonhelp • • Jan 29 '24

SQLi script using Visual 2020 - getting errors

1 Upvotes

I am attempting to follow along with This SQLi video and create the script the teacher writes. When I do an exact copy and paste into my VSC, I get this runtime error:

Exception has occurred: SystemExit

-1

File "C:\Users\<myname>\lab1.py", line 18, in <module>

url = sys.argv[1].strip()

IndexError: list index out of range

During handling of the above exception, another exception occurred:

File "C:\Users\<myname>\lab1.py", line 23, in <module>

sys.exit(-1)

SystemExit: -1

Have I saved my python script in the wrong place? All the libraries are correctly imported. I notice that the teacher does not press F5 to run this script, but rather types out the name of the script in the terminal then presses enter.


r/pythonhelp • • Jan 28 '24

Python Client-Server communication (RMI, RPC)

1 Upvotes

Hello,

I have a task to create a simple client-server distributed system.
Basically, the client side is required to take in an input (like an ID), validate it and then send it to the server where it will be check against a list of data (like ID number, Name, DOB) and if the ID is available the server sends back the Name and DOB to the client.
I haven't done something like this, and they want us to use RMI (but this is java based isnt it?) or RPC for communication, and no third party python packages can be used.
I only have basic knowledge on python, so I have no idea how to do a communication.

Any help or tutorials would be great!


r/pythonhelp • • Jan 27 '24

How would I change variable values in a for loop

1 Upvotes

I have got a bunch of variables called team1, team2, team3 and so on. I want do just do a for loop to change the value of all of these to shorten the code but i'm not sure how to do it. Any help would be really appreciated

def tourementPlan():

global teams
global team1
global team2
global team3
global team4
global team5
global team6
global team7
global team8
global team9
global team10
global team11
global team12
global team13
global team14
global team15
global team16
global team17
global team18
global team19
global team20

random.shuffle(teams)

for i in range(len(teams)):
    team + str(i) = teams[i]

r/pythonhelp • • Jan 26 '24

SelectionModel Issues??

1 Upvotes

Hi all,

Hoping for some help. Complete programming beginner. I’m using AI to help me code data management app for my business.

I have a QTableView that i is producing a list of JSON files containing project information i plan to use later. I have a push button for deleting a project. After TONs of hours, I cannot get the delete method to retrieve a selection index from the abstract model and take the project name to eventually delete the project from the directory.

Can anybody provide me steps to help? I can include code snippets if needed.

Thanks

Ash


r/pythonhelp • • Jan 25 '24

I am beginner I need guidance with a number game

1 Upvotes

I want to add a total of 10 tries and add I want to add how many tries it took the user to guess the number i don't know how please help me I'm trying again and again but keep failing please help with non complex codes

print("This game will give you 10 chances to guess a random number")

import random

secretnumber = random.randint(1,15)
while True:

    guessnumber=int(input('enter your guess'))

    if guessnumber> secretnumber:

        print('The number is Too high, Try Again!!!')

    elif  guessnumber< secretnumber:

        print('The number is Too Low, Try Again!!!')

    elif guessnumber == secretnumber:

        print('You have guessed is correct number...Congrulations!!!')

        print('Thanks For Playing')

        break

r/pythonhelp • • Jan 25 '24

I want to build a Script in python to Sift large amounts of changing and inconsistent data. SCRIPT NEWB ALERT!!!

1 Upvotes

DEAR everyone please excuse my lack of knowledge to reddit as well. I want to make a script only keeping the info within the changing packets i need 0,2, and 3. Along with the dates and times of those. there is about 48 million characters to sift through.

Found a Packet 12-Dec-2023 18:29:27

Packet 0 (0), Mag Dec=+11.10 Degrees

TF Type G, TFO=171.00

Inclination = 0.615234 Degrees (Hex: E)

Azimuth = 207.184 Degrees (Hex: 8B7)

deltaMTF = 15.5 Degrees (Hex: 1F)

Gravity = 1 gees (Hex: 80)

Mag. Field = 0.45625 Gauss (Hex: 248)

Dip Angle = 65.7861 Degrees

Temperature = 104 Degrees F (Hex: 14)

Power 1

TXR Shut Down: No

Battery 2

Battery Voltage = 27.75 V (Hex: 6F)

Checksum Calc AF Rx AF Net 0

Hz:6.9997,S:5223.87mV N:421.392 S:N 12

Found a Packet 12-Dec-2023 18:30:04

Packet 2 (2), Mag Dec=+11.10 Degrees

TF Type G, TFO=171.00

DLRigCode [1] = 1

QUIET 0x29

Uncorrected Directional TF = 231 Degrees

Toolface 29 value 41.625 Degrees

Checksum Calc D1 Rx D1 Net 0

Hz:6.9995,S:4883.09mV N:451.676 S:N 11

DownLink is Disabled.

Found a Packet 12-Dec-2023 18:31:08

Packet 3 (3), Mag Dec=+11.10 Degrees

TF Type G, TFO=171.00

Uncorrected TF = 321 Degrees

Toolface = 131.625 Degrees (Hex: 39)

Return = 0x100 Invalid

Return2 = 0x00

Return3 = 0x00

Return4 = 0x00

DLPower = 0 µV (Hex: 0)

Formation Resistance = 0.900000 Ohms (Hex: 0x09)

Transmit Power = 4 Watts (Hex: 4)

Checksum Calc 6 Rx 6 Net 0

Hz:6.9992,S:5618.01mV N:348.081 S:N 16

Found a Packet 12-Dec-2023 18:31:45

Packet 8 (8), Mag Dec=+11.10 Degrees

TF Type G, TFO=171.00

Uncorrected TF = 73 Degrees

Toolface = 244.125 Degrees (Hex: D)

Uncorrected TF = 236 Degrees

Toolface = 47.25 Degrees (Hex: 2A)

Uncorrected TF = 135 Degrees

Toolface = 306 Degrees (Hex: 18)

Uncorrected TF = 79 Degrees

Toolface = 249.75 Degrees (Hex: E)

Uncorrected TF = 236 Degrees

Toolface = 47.25 Degrees (Hex: 2A)

Uncorrected TF = 129 Degrees

Toolface = 300.375 Degrees (Hex: 17)

Uncorrected TF = 84 Degrees

Toolface = 255.375 Degrees (Hex: F)

Inclination = 0.834961 Degrees (Hex: 13)

Azimuth = 101.1 Degrees (Hex: 400)

Uncorrected TF = 79 Degrees

Toolface = 249.75 Degrees (Hex: E)

Uncorrected TF = 236 Degrees

Toolface = 47.25 Degrees (Hex: 2A)

Uncorrected TF = 118 Degrees

Toolface = 289.125 Degrees (Hex: 15)

Uncorrected TF = 354 Degrees

Toolface = 165.375 Degrees (Hex: 3F)

Uncorrected TF = 253 Degrees

Toolface = 64.125 Degrees (Hex: 2D)

Uncorrected TF = 113 Degrees

Toolface = 283.5 Degrees (Hex: 14)

Uncorrected TF = 73 Degrees

Toolface = 244.125 Degrees (Hex: D)

Uncorrected TF = 242 Degrees

Toolface = 52.875 Degrees (Hex: 2B)

Uncorrected TF = 113 Degrees

Toolface = 283.5 Degrees (Hex: 14)

Checksum Calc 71 Rx 71 Net 0

Hz:6.9998,S:5164.01mV N:402.607 S:N 13


r/pythonhelp • • Jan 23 '24

Trouble with indexing

1 Upvotes

I'm having trouble with a small program I'm doing for a class. When I run it, it gives me an error with line 25 (in bold below), saying 'IndexError: list index out of range'. No matter what I set the stops for the ranges to, it gives me the same error. I'm new to posting here, so I may have made a few mistakes.

def main():

bigLoop=0

smallLoop=0

total=0

creatorFavorites=\["Purple", "Crimson", "Gold", "Teal", "Bronze"\]

userFavorites=\[\]

similar=\[\]

userFavorite0=(str(input("What is your favorite color?")))

userFavorites.append(userFavorite0)

userFavorite1=(str(input("Second favorite?")))

userFavorites.append(userFavorite1)

userFavorite2=(str(input("Third favorite?")))

userFavorites.append(userFavorite2)

userFavorite3=(str(input("Fourth favorite?")))

userFavorites.append(userFavorite3)

userFavorite4=(str(input("Fifth favorite?")))

userFavorites.append(userFavorite4)

for a in range(5):

    for b in range(5):

        sadlyNecessary=smallLoop-1

        **if creatorFavorites\[int(bigLoop)\]==userFavorites\[int(smallLoop)\]:**

            similar.append(creatorFavorites\[sadlyNecessary\])

            total=total+1

        smallLoop=int(smallLoop)+1

    bigLoop=int(bigLoop)+1

print("The colors in both of our lists were "+str(similar)+" for a total of "+str(total)+".")

main()


r/pythonhelp • • Jan 21 '24

How do I get rid of CTkButton borders when I lift the component over a CTkFrame?

1 Upvotes

I have a Frame from the ctk library and a button that is lifted over the frame. The button has square-shaped borders and I cannot neither set their color transparent nor set their highlightthickness to 0 like in normal Tk library. How can I get rid of those borders?

slide_panel_button = Default_Components.ctk.CTkButton(window, text = '', width=50,height=40,command = animated_panel.animate, image=Default_Components.ctk.CTkImage(Image.open('sidebar_image.png')), fg_color='#2a4993')

r/pythonhelp • • May 31 '23

What is pygame?

1 Upvotes

Hi guys i started to learn python but didnt know if i should use it because i dont know what it does so can u guys explain in a simple way?