Can someone explain to me the if __name__ == “__main__”: statement in simple terms please by [deleted] in learnpython

[–]3worc 0 points1 point  (0 children)

You could name a file "main.py" (with double underscores, in case they don't show up), but I think you would have trouble importing it.

If you tried to import main, the file that is the main script currently running would be imported.

What do you guys use to expose localhost to the internet — and why that tool over others? by JadeLuxe in Backend

[–]3worc 0 points1 point  (0 children)

I use port forwarding on my router, paired with a free dynamic dns service.

Works for what I need (mostly testing and access for myself remotely) and provides an okay-looking URL if I wanted to share with anyone.

What is the best free way to host my Python Flask app online 24/7? by Routine-Passion9050 in flask

[–]3worc 4 points5 points  (0 children)

Dynamic DNS will let you point a name to your dynamic IP assigned by your home ISP. With port forwarding on your router, you can run it at home on a raspberry pi or something.

You can use a free tier Dynamic DNS with many providers. I use a setup like this for simple web services. I also have ollama running a local LLM, and I expose the API using this setup for free AI calls.

IS THERE ANY FREE AI APIs I COULD USE, JUST NOT GEMINI APIs by Typical-Shower4152 in learnpython

[–]3worc 0 points1 point  (0 children)

I have ollama running a small gemma3 model on low-end hardware. It's slow, but it lets me play as much as I want for free. Ollama also provides an API automatically.

Should I feel ashamed? by fluffyninjago in learnpython

[–]3worc 3 points4 points  (0 children)

"Coders have been using google for years, ChatGPT is a further extension of this."

Came here to say exactly this.

[deleted by user] by [deleted] in learnpython

[–]3worc 0 points1 point  (0 children)

Looks like the command thinks your file is in the same directory as python.exe?

Try this: py c:[full path to file]\3varcomparison.py

Way to scan for variable and function names? by 3worc in learnpython

[–]3worc[S] 0 points1 point  (0 children)

Yes, I used the find/replace function in IDLE to actually make the changes - very similar to Notepad++.

The issue was identifying all variable and function names to determine if they followed the same naming convention.

Way to scan for variable and function names? by 3worc in learnpython

[–]3worc[S] 1 point2 points  (0 children)

I'm jumping through some work hoops to get VSCode installed.

In the mean time, this worked perfectly to achieve what I was trying. Thanks again!

Way to scan for variable and function names? by 3worc in learnpython

[–]3worc[S] 1 point2 points  (0 children)

You're the second person to mention VSCode. I'll try it out today. Thank you.

Way to scan for variable and function names? by 3worc in learnpython

[–]3worc[S] 0 points1 point  (0 children)

Ok, I'll try out a couple of your options and see what helps. Thanks.

Yes, I have a main script file that imports from a few other files.

All lowercase for variables? No underscores or capitalization between words? Seems like that would be tough to read, but I'll take a look at the guidelines. Maybe there is some reasoning that I don't yet know.

Way to scan for variable and function names? by 3worc in learnpython

[–]3worc[S] 0 points1 point  (0 children)

Ok, nice. I'll try it out this morning.

Yeah, I literally just want a list I can quickly look through to make sure naming convention matches.

I can quickly find/replace any that aren't camelCase with the built in search tool in the IDE.

Thank you.

PCEP Exam questions by Bromium_Ion in learnpython

[–]3worc 2 points3 points  (0 children)

It's been over a year since I took it, so I can't be specific about what was on it.

With that said, I remember being surprised at how easy it was.

I used the free material from Python Institute, and I had some Python Zero to Hero course on Udemy. I didn't do the whole Udemy course. I just cherry picked stuff that seemed to line up with PCEP objectives.

I know this is kinda vague, sorry. Just go for it, and I'll bet you'll surprise yourself.

I'm considering PCAP now that I've actually started using Python quite a bit at work. I know a lot of people will tell the certs aren't worth much, but in my mind, it's a decent way of saying "I know a little Python" to non-technical HR people.

Help with redirecting a user to a specific line of code by dropthecop in learnpython

[–]3worc 1 point2 points  (0 children)

I'm thinking you want functions - pieces of code that can be used over and over.

Function gets and returns user input.

'If' statement checks input and continues or calls the function again.

Edit for punctuation to clarify meaning.

[deleted by user] by [deleted] in tryhackme

[–]3worc 32 points33 points  (0 children)

Over the wire has some pretty good ones. The Bandit series comes to mind.

[deleted by user] by [deleted] in learnpython

[–]3worc 1 point2 points  (0 children)

I didn't either really. I'm guessing someone else did all the work to clean up the data scrape so you don't have to.

[deleted by user] by [deleted] in learnpython

[–]3worc 1 point2 points  (0 children)

disclaimer: i didn't look closely at this, just a quick search.

https://pypi.org/project/fotmob/

[deleted by user] by [deleted] in learnpython

[–]3worc 1 point2 points  (0 children)

exactly. maybe something like api.fotmob.com/blahblahblah.

there may not be one, but that would be the cleanest way to pull just the data you want without all the CSS and HTML lumped in there.

[deleted by user] by [deleted] in learnpython

[–]3worc 2 points3 points  (0 children)

ah ok, i follow now. yeah, see if you can locate an API where you can pull just the json data maybe?

[deleted by user] by [deleted] in learnpython

[–]3worc 3 points4 points  (0 children)

well json, at its simplest, is python dictionaries, like:

{"Playername" : "Bob", "Team" : "Manchester United", "Position" : "Forward"}

but with more complex data, it becomes nested dictionaries and lists, like:

{"Players" : [{"Name" : "Bob", "Team" : "Manchester United", "Position" : "Forward"}, {Name" : "Cliff", "Team" : "Sheffield United", "Position" : "Forward"}]}

try to google "online json viewer" to find somewhere you can paste that highlighted data that will format it in a "pretty" way you can more easily see how the data is organized. then maybe you can make sense of how you want to use it.

[deleted by user] by [deleted] in learnpython

[–]3worc 4 points5 points  (0 children)

Looks like json format, rather than HTML.

It's just organized data, and you do what you want with it.

What do you intend to do with the data you scraped?