From where to start my python journey and i am soo confused !
Because i had never try to learn code but now i am ready but how to start learning it , i didn't know..!
Because i had never try to learn code but now i am ready but how to start learning it , i didn't know..!
Program :
import sys
for arg in sys.argv[1:]:
print("Hello, I'm", arg)
Output:
PS C:\Users\Eshan Jain> python new.py Eshan Jain
C:\Users\Eshan Jain\AppData\Local\Python\pythoncore-3.14-64\python.exe: can't open file 'C:\\Users\\Eshan Jain\\new.py': [Errno 2] No such file or directory
PS C:\Users\Eshan Jain>
Can anyone please tell me what the problem is over here
Hi,
I have enjoyed writing a bit of python a long time ago but not got into the ecosystem.
A few years ago I have forbid myself to install python and pip on my laptop because of the security implications of full access to my /home.
Now I am missing out on a lot of good tools and often look for a solution but never found a solid answer:
-venv: I could never fully understand if it is a solid isolation mechanism
- distrobox: no, this is not a sandboxing/security solution https://github.com/89luca89/distrobox/issues/28
- docker: a bit the same problem, it make everything complicated, especially if you need to really secure it
- bubblewrap: maybe I couldn't find any good post on how to manage sandboxed python environment with it
- raw chroot: maybe
- there are a lot of repos on github / projects which pretend to do that, but with very few stars and I do / should not trust them.
To be clear I am not looking to develop anything in python, just installing an app.
Thank you for you help !
I know this sounds simple, but today I finished a basic calculator program in Python without copying full code from anywhere.
A few weeks ago even functions confused me, and now I finally understand how input → process → output flows together.
It’s not fancy:
But seeing it work gave me a huge motivation boost.
What was the first program that made programming finally feel real for you?
I am making a 2d cave generation script out of boredom and I've just added a method for showing the map visually. My current scripts works with a 2d array of numbers and it loops through it and draws a different colored square for each number with it's color and position based on the number and it's order in the arrays. The main problem is that the approach is currently drawing literal tens of thausants of squares when i turn it on (I'm testing with a 150x150 map rn and am scared to go higher). How could I optimize this?
Current code:
def draw_map(self, file_mame):
for y in range(self.map_height):
for x in range(self.map_width):
self.c.create_rectangle(x * self.sqr_size, y * self.sqr_size, (x + 1) * self.sqr_size, (y + 1) * self.sqr_size, width = 0, fill = self.gfx_dict[self.map[y][x]])
self.c.mainloop()
so i hit about 200 pages no problem. requests.get() just worked. felt like a genius
then i tried scaling to 8,000 pages across 12 sites and everything fell apart in maybe 3 hours. 403s everywhere. captchas on sites that didnt even have captchas last week?? half returning blank html because turns out they render everything in javascript now
spent way too long convinced it was my headers. rewrote my user-agent rotation 4 times. even bought rotating proxies for $35/mo thinking thatd fix it. it did not
i knew requests.get() was just raw http with no browser behind it but stubbornness is my only engineering skill so i kept hacking around it
now im looking at headless browser setups for web scraping and the whole landscape is.. confusing. does anyone actually run this at scale without losing their mind??
With setuptools and build, I can put __version__ constant in mymodule/__init__.py, and then refer to it in pyproject.toml with:
[project]
dynamic = ["version"]
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.dynamic]
version = { attr = "mymodule.__version__" }
Can I do something similar with uv_build? If I switch to build-backend = "uv_build" and then execute uv build, it tells me:
Error: Invalid pyproject.toml
Caused by:
TOML parse error at line 1, column 1
|
1 | [project]
| ^^^^^^^^^
missing field `version`
Some people advices me that its better to master one language rather than 3 different languages, but then again when i try to learn it deeply and gets exhausted when i try to read the documentations or asking why behind everything, then people says that just learn enough to able to code and don't try to master it as no one can every master any language perfectly. but then i am not sure what should i do and how exactly to study...
second thing i have say 15-16 hours in a day, do i need to spend all the day studying just one language if that's what other say to me? but i finds it so exhausting and i can't just keep studying one thing only all day...
thirdly i am a beginner in coding and i have just a basic foundation of python and web development and have done some basic projects back a year ago, and after that my college started and i just focused on my academics in the first year and now i m in the second year with computer science branch. even tho i have a computer science branch still we just studied general subjects during our first year and coding mainly starts from the second year. and i am not sure on the part that how many more months i still need to give to python and when can i start exploring more.
most importantly since i already have a basic foundation of coding i have started doing projects from a book called The Big Book of Small Python Project, but i can just make the code working and my code is still not optimised with the best coding practices like i lacks indentations or poor comments and other basic flaws or maybe not the best approach to solve the given problem.
where should i learn these things from?
should i just learn it by seeing the solution from the same book? or should i rather just focus on able to just solve the given question instead of best coding practices?
if you want reference, these are my codes and book's code arranged parelelly for your reference,
book's code : https://inventwithpython.com/bigbookpython/project1.html
my code: https://pastecode.io/s/zgwxaq3o
eg. 2 book : https://inventwithpython.com/bigbookpython/project2.html
my code : https://pastecode.io/s/r3caee8h
another project from book : https://inventwithpython.com/bigbookpython/project3.html
my code: https://pastecode.io/s/pkef2wj1
i am just not sure if i should refer to book to improve my code? or its a waste of time?
also i have a doubt whether i should ask for help regarding doubts in coding over platforms like discord since i have tried that earlier and it's not more than just a waste of time cuz i don't think its the best way to learn to rely on people to that level. you can see how it goes i have attached this link https://discord.com/channels/267624335836053506/1368551114907062352 on the python discord server of my help message on discord back ago which just ends up wasting of time. or should i just keep studying on my own? in that case how else should i improve my code then? and learn the best practices?
i am just not sure how to actually learn coding and i am willing to change anything that i am doing wrong.
My vacation just started. I wanted to learn coding before i get into a college. I have heard from a lot of seniors that python is the most important coding language. I want to learn python from the scratch but dont know where to start. I cant find any courses which are certified. Some advice pls
while True:
print('hello usser')
print('please enter your name ='),
name=input()
if name == 'hitendra':
print('hello hitendra')
print('please enter password')
password = 1324
while password != 1234:
password = int(input())
print('acces granted')
break
else:
print('you are not the usser')
continue
THE FOLLOWING IS QUITE SIMPLE CODE TO UNDERSTAD THE USAGE OF DIFFRET FUCNTIONS TOGETHER BUT I HAVE A QUESTION IN THE SECOND WHILE LOOP (PASSWROD ONE )I ENTER THE LOOP AND AFTR ENTERING THE PASSWORD IT SAYS BREAK SO IT SHOULD BE BREAKING THE LOOP OF PASSWROD ONE BUT WHAT ABOUT THE EXTERNAL LOOP (FIRST ONE IE WHILE TRUE ) AFTER ENTERING MY PASSWORD I EXIT THE COMMAND BUT SHOULD IT BE LOOPING AND YEA HERE THE ELSE IS NOT AFTER THE BREAK COMMAND IT IS CONNECTED TO THE IF COMMAND (NAME ONE)
I've spent 4 years as a Python developer working on direct client projects inside a company — ERPNext, AI agents, FastAPI, Django, RAG systems. Real production work
I recently started freelance as a full time, to give a try. LinkedIn is my main focus right now, but I want one more platform to run alongside it.
I'm looking at Contra, Arc.dev, Gun.io, Upwork and skipping Toptal (not ready for that process yet).
For those who've used any of these — which one actually gets traction for a Python developer with my stack? And is there anything you wish you knew before starting?
Any honest experience appreciated.
I have programming experience, I'm decent at c language like c++ and c# but I want to learn Python. Where can I learn it that doesn't reteach things I already know like what a variable is.
I see many tutorials regarding understanding python, any that show how to actually code something for absolute beginners? Thanks.
I've been trying to use openpyxl to create an automated report. Whenever Excel opens the file, it gives a uselessly vague error saying it removed "unreadable content", even though when saving the file it actually increases in size.
Turns out though that even the most basic code doesn't work. The following will produce the same error in Excel:
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws.title = "Sheet"
ws["A1"] = "Header"
ws["A2"] = "Some Data"
wb.save("simple_example.xlsx")
What else can I do here? Unfortunately, the actual report is run daily and is for customers to view, so I can't just say "oh just ignore it, the report is fine".
degree = int(input("Of what degree is your function?[0-51]: "))
degree_value = degree
function = ""
constant = 97
while degree >= 0:
if degree > 1:
function = function + "" + chr(constant) + "(x^" + str(degree) + ") + "
elif degree == 1:
function = function + "" + chr(constant) + "(x) + "
elif degree == 0:
function = function + "" + chr(constant)
degree = degree - 1
constant = constant + 1
if constant == 123:
constant = 65
print(function)
constant = 97
constants = []
degree = degree_value
while degree >= 0:
new_constant = (float(input(chr(constant) + " = ")))
constants.append(new_constant)
degree = degree - 1
constant = constant + 1
if constant == 123:
constant = 65
number_of_terms = len(constants)
function = ""
location = 0
degree = degree_value
while number_of_terms > 0:
if constants[location] == 0 and degree == 0:
function = function + "0"
elif constants[location] == 0:
function = function
elif constants[location] != 1:
if degree > 1:
function = (function + str(constants[location]) + "x^"
+ str(degree) + " + ")
elif degree == 1:
function = function + str(constants[location]) + "x + "
elif degree == 0:
function = function + str(constants[location])
elif constants[location] == 1:
if degree > 1:
function = function + "x^" + str(degree) + " + "
elif degree == 1:
function = function + "x + "
elif degree == 0:
function = function + str(constants[location])
number_of_terms = number_of_terms - 1
location = location + 1
degree = degree - 1
print("f(x) = " + function)
derivative = ""
location = 0
degree = degree_value
while degree >= 1:
if (constants[location] == 0 and degree == 1):
derivative = derivative + "0"
elif (constants[location] * degree) != 1 and (constants[location] * degree) != -1:
if degree > 2:
derivative = derivative + str(constants[location] * degree) + "x^" + str(degree - 1) + " + "
elif degree == 2:
derivative = derivative + str(constants[location] * degree) + "x + "
elif degree == 1:
derivative = derivative + str(constants[location])
elif (constants[location] * degree) == 1 or (constants[location] * degree) == -1:
if degree >= 3:
derivative = derivative + "x^" + str(degree - 1) + " + "
elif degree == 2:
if constants[location] > 0:
derivative = derivative + "x + "
else:
derivative = derivative + "-x + "
elif degree == 1:
if constants[location] > 0:
derivative = derivative + "1"
else:
derivative = derivative + "-1"
degree = degree - 1
location = location + 1
print("f'(x) = " + derivative + "\n")
if derivative == "0":
print("f'(x) cannot equal zero.")
quit()
print("Newton-Rhapson method:")
finished = False
while not finished:
x = float(input("Initial guess = "))
iterations = int(input("How many iterations?: "))
function = ""
derivative = ""
x_n = 1
number_of_constants = len(constants) - 1
location = 0
while number_of_constants >= 0:
if number_of_constants > 0:
function = function + str(constants[location]) + " * x ** " + str(number_of_constants) + " + "
if number_of_constants > 1:
derivative = derivative + str(constants[location] * number_of_constants) + " * x ** " + str(number_of_constants - 1) + " + "
if number_of_constants == 1:
derivative = derivative + str(constants[location])
if number_of_constants == 0:
function = function + str(constants[location])
number_of_constants = number_of_constants - 1
if number_of_constants >= 0:
location = location + 1
print("x0 = " + str(x))
while x_n <= iterations:
try:
x = x - (eval(function))/eval((derivative))
print("x" + str(x_n) + " = " + str(x))
x_n = x_n + 1
except:
print("f'(x0) cannot equal zero.")
quit()
answer = input("Do you want to do another approximation?[y/n]: ")
if answer == "n":
finished = True
I am in my first year studying engineering; I've had my decent amount of Python knowledge in my classes but still didn't use them in any big project, and I was wondering if getting a Python certificate will benefit me in finding internships or any job opportunities, or if I should ought to sharpen my skills and go for bigger projects.
I'm working on a project to teach myself python and am currently playing around with classes. I've made a class, 'event', and a subclass, 'num_event'. These each have 2 args: outcome and probability. The idea is that these are probabilistic events that I can use for discrete probability experiments like bernoulli trials. I've only defined __init__ in each, and the only difference between the two is that num_event has an extra layer of input data validation to ensure that the outcome is either a float or int. For this validation, I wrote the following function:
def numerical(x)->bool:
| num = (int or float)
| if(type(x) == num):
| | return True
| else:
| | return False
This is pretty simple and works well, which is why I'm so confused that my function 'is_event' is failing:
def is_event(x)->bool:
| events = ('event' or 'num_event')
| if(type(x).__name__ == events):
| | return True
| else:
| | return False
Now, I do understand that I'm going from comparing types to strings, but if I separate the logical test into 2 parts
if(type(x).__name__ == 'event') or (type(x).__name__ == 'num_event'):
It works fine.
Ideally, I'd like to have type(x) return event as a type object like int rather than a string, but that doesn't seem to be the way that user defined classes work.
Regardless, can someone explain why the logical test works for types but not strings? Thanks!
Hey everyone,
I'm working on a literature data project and I have hit a massive wall. I'm trying to crossreference two lists of top literature, but my methodology for filtering the data is a mess. I've been trying to use AI to do the heavy lifting (free AI), but it can't handle the context window and hallucinates a completely different outcome every time I run it.
I need some advice on how to actually build a workflow for this.
Here are the two datasets I am working with:
List 1: A master list of the Top 10,000 works from TheGreatestBooks.org. This is generated by combining dozens of different "best of" book lists.
List 2: a 1,514 works listed in the appendix of literary critic Harold Bloom’s book, The Western Canon. (actually I probably also need help with this, I found sources online that have the full appendix of Harold Bloom but each source is slightly different than the other, is there an actual way for me to extract or make sure that all the works in the appendix are actually mentioned?)
My goal is to filter Bloom's academic list against the Top 10,000 list to create a final, definitive list.
My initial methodology is to first purge any non-narrative forms of literature, and then filter the Harold Bloom list based on their rank in the Top 10,000 using this logic:
If an author has 5+ works in the Top 500, keep their top 5.
If 4+ works in the Top 1,000, keep their top 4.
If 3+ works in the Top 2,000, keep their top 3.
If 2+ works in the Top 5,000, keep their top 2.
If 1+ work in the Top 10,000, keep their top 1.
But because I'm relying on free AI, this isn't working at all. On top of the AI failing, the data itself is incredibly "dirty"
Harold Bloom doesn't always mention specific titles. For example, his list just says "William Shakespeare: Plays and Poems" or "Anton Chekhov: The Tales". Meanwhile, List 1 ranks individual books (Hamlet, Macbeth, etc.). How can I map these umbrella terms so they actually trigger a match against the individual books in List 1?
Bloom's list includes philosophy, lyric poetry, and essays. I only want to compare narrative literature (novels, epics, plays, short stories). Is there a way to automate purging nonnarrative works (maybe pinging an API like Goodreads or OpenLibrary to check the genre tags?) rather than deleting them manually?
does anyone have any advice on how I should approach this? what to use? because I've been working on this project for days and have already filtered it 3 times, each time having a different result and having to restart it all over again.
Hi, I am building a simple class that parses dictionary data where the data themselves are stored on a dictionary.json file.
with open ('dictionary.json' , 'r') as file:
self.game_lexicon = json.load(file)
Under which folder would you save this file on your python project?
Would you create a data folder ?
There seems to be a problem with changing a local variable within exec():
test = "test1"exec("test = 'test2'", {}, {"test": test})print(test) # <- erroneously returns test1
returns 'test1' - the change to 'test' during exec() has not persisted
However if passed inside a dict variable:
localDict = {"test": "test1"}exec("test = 'test2'", {}, localDict)test = localDict["test"]print(test) # <- correctly returns test2
It seems to work for some reason and returns 'test2'!
Is this a bug in exec() in Python 3.14?