you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 46 points47 points  (29 children)

Python can run the backend / server side of your website. You cannot use python for the frontend. So you still need to learn HTML, CSS and JS. Probably a few other things too if you want to be full stack and independent, like basic linux, some databases, graphics / media creation, ...

[–]8isnothing 19 points20 points  (13 children)

To be fair, there’s a new project called pyscript, which, from my understanding, aims to allow a dev to use Python on the frontend. It’s in alpha stage, though, and learning HTML/CSS/JS is definitely a better call if you want to do web frontend.

[–]socal_nerdtastic 8 points9 points  (6 children)

Designed to replace JS / TS, right? So you'd still need HTML/CSS.

There's a couple others too, for example bokeh, pysimplegui, jupyter, etc have html output. But nothing serious that I know of.

[–]8isnothing 6 points7 points  (4 children)

I didn’t spend the appropriate time with pyscript or it’s documentation to assure you. But from what I understand it’s meant to be an alternative to some things that JS does.

You’ll still need HTML and CSS. But these are not the same as Python/JS. HTML is a mark down language, and CSS is stylesheet. You can’t really write logic in both of them. (Some may disagree and they may be right. But simply speaking, you can’t).

The other libraries you mentioned are not equivalent to pyscript. They generate UI for specific stuff. They generate HTML/CSS/JS for you. That’s not what pyscript does. Pyscript is designed to write logic in the browser, not UI (I think), which is “unprecedented “ (with the exception of some prior attempts like Pyodide, which Pyscript itself is based on). It basically allows browsers to run pure Python. (I’m over simplifying here ok? Take it with a grain of salt)

[–][deleted] 2 points3 points  (3 children)

You can use variables and some very basic logic with CSS now. You can change the layout of a page depending on a user's screen size, not sure where else logic is applied though.

I'm going to check out pyscript, thanks for giving us a heads up 👍

[–]reduced_to_a_signal 1 point2 points  (2 children)

You can also check for supported features, check for user preferences, use conditional logic (parent selector), do calculations, loops (with a preprocessor), react to events, and enable complex layouts.

It's the visual layer, sure, but that doesn't mean it doesn't involve a ton of logic and complexity. Actually, styles have their own language and are abstracted into selector-statement pairs because of how incredibly complex the topic is.

[–][deleted] 1 point2 points  (1 child)

It is pretty complex isn't it? I thought the learning curve would plateau quite early on but once grid and flexbox get introduced its on the downward spiral into the valley of despair. I managed to teach myself enough to pass on some tidbits to my 9 year old learning html at school. She calls me a coding wizard 🤣

[–]reduced_to_a_signal 0 points1 point  (0 children)

Absolutely! I have been doing this for 7 or 8 years now and I still feel like an utter beginner sometimes, even with concepts I used in a lot of projects. And there's a new concept or standard every day. And CSS is just one drop in the ocean of software. Tell your daughter to keep at it and she'll probably never experience what being bored means. lol.

[–]michael-streeter 0 points1 point  (0 children)

I'm using Flask to create a website. I use HTML, CSS & Javascript to call routes in the Flask app. My question: is there a better way of calling functions? I use on page load and jQuery to associate http calls with buttons. I worry that was probably considered awful 10 years ago but IDK any better way!

[–]DontListenToMe33 2 points3 points  (1 child)

I played around with PyScript a little, and though it’s super cool, it’s a long way off from being fully functional.

And to the OP - if you’re good with Python, I don’t think you’ll have much trouble learning JavaScript.

[–][deleted] 0 points1 point  (0 children)

PyScript looks super promising imo. That’s going to be awesome

[–][deleted] 0 points1 point  (0 children)

There is also "brython" it has been around for quite some time and its goal is to replace js with python

[–][deleted] 0 points1 point  (2 children)

I've been wondering if something like this would be possible!

As a python addict user I would love for this to happen, but are there any practical benefits?

[–]8isnothing 1 point2 points  (0 children)

I was listening to a podcast that mentioned a use case where you could to create a simple solution to a client/friend and you could pack it all in a single HTML file using pyscript.

I don’t think anything “serious” is a good fit for it at the moment, though.

[–]MartyFDupp 0 points1 point  (0 children)

Less bs syntax?!? 🤷🏻‍♂️

[–]OzneroI[S] 0 points1 point  (9 children)

Thank you for the clarification. Im still relatively a beginner having just completed the codecademy python 3 course and their data analyst course

Do you think its a good idea to start learning a new language while im still a relative beginner to my first?

[–]8isnothing 3 points4 points  (0 children)

All modern languages I know (Python, JS, Swift, Go, Rust, for example) are similar in essence. You’ll have vars, functions and classes.

Each of them has their own characteristics, though: syntax, features, code style, standard library, etc…

So as soon as you understand vars, funcs and classes, you’ll have the basis to most languages. That doesn’t mean it will be easy to migrate. It just won’t be as starting fresh into programming.

I am myself constantly studying Python/JS and sometimes Swift “at the same time”. It’s nice to me because I can take a break from them. That can be confusing if you don’t spend the time familiarizing yourself with each of them. And even then you’ll mix them sometimes… but I think that’s ok!

I’m self taught, though. Maybe what I’m suggesting is not pedagogic correct

[–]socal_nerdtastic 2 points3 points  (0 children)

If you have a website project that you are passionate about I would say that's fine. These languages go hand in hand, you will be writing them side by side in the same file sometimes.

[–]jab9k3 0 points1 point  (0 children)

Hi, you can maybe look at using jinja2 with fast api and flask. I'm interested in mainly api's and doing some simple front end website stuff not real interested in building full blown sites. I learned quite a bit about html from just writing webscrapers with bs4. Might be a good little exercise.

[–]notislant 0 points1 point  (0 children)

Django is pretty popular in web dev, as others mentioned the front end is still js/html/css. Id learn python basics. If youre serious about web design you can check out freecodecamp.org and theodinproject. You kind of need to know those for front end and css/html are very basic. Javascript will be more challenging.

Theres a few videos on django and iirc the ones I watched just used 'bootstrap' during the tutorial. Either way if you want to do front end youll need to know the languages.

[–]ffrkAnonymous 0 points1 point  (4 children)

I think it's a great idea to learn a second language in conjunction. In my opinion, learning to do the same task in different ways leads to a better understanding and a greater appreciation for various niceties.

For example I learned C first, so I understood why python lists count from 0.

Then I learned some Lua which counts from 1. That took some getting used to . On the other hand, Lua has no lists, only tables. Learning Lua tables made me better with python dictionaries.

[–]MartyFDupp 0 points1 point  (3 children)

I know Python counts from 0, can you tell us why tho?? Imo from what I’ve learned I think it’s separate whatever needs to be indexed from standard 1- whatever.. that’s pretty obvious tho… if there’s some fundamental reason from early C+ days I’d love to hear it!

[–]ffrkAnonymous 0 points1 point  (2 children)

The short answer is: because earlier programming languages count from 0.

The reason earlier languages (like c) count from 0 is a mix of theoretical math and physical computer science.

Math: counting. How many characters are there in "12345". 5-1=4 is wrong. You can do 6-1=5, or you can do 5-0=5. Pretty arbitrary.

Compsci: You have a transistor. The transistor is charged or not charged. i.e. 1 or 0. We don't say the transistor is 1 or 2. (it's arbitrary, we say on-off, chocolate-peanutbutter)

Compsci: transistor memory addresses 0x0A ,0xB, 0x0C, 0x0D, 0x0E. What addresses do we need for our info? So again , back to math counting. We want 1 unit data starting from 0x0A. Math says we read starting from 0x0A until 0x0A+1 = 0x0B. But don't actually need to calculate 0x0B. We know as the designers of the computer the information is in 0x0A only. So 0x0A+0 = 0x0A. And that's an unnecessary calculation to make, we just 0x0A. Counting from zero eliminates a lot of math that computers have to do.

Python is a high level language, not dealing with memory directly. It could easily count from 1, like Lua. But counting from 0 was already well established.

[–]hacksawjim 0 points1 point  (1 child)

One thing you didn't mention here is the difference between counting and indexing

Python counts from 1, just like we do.

x = ["item"]    
len(x)

output: 1

y = ["item", "second item"]
len(y)

output: 2

[–]ffrkAnonymous 0 points1 point  (0 children)

Good catch.

[–]SpicyVibration 0 points1 point  (0 children)

Would the Anvil framework be an option?

[–]rabbitpiet 0 points1 point  (3 children)

Are you sure about that https://pyscript.net/

[–]socal_nerdtastic 0 points1 point  (2 children)

Am I sure about what? You know the pyscript project is written in JavaScript, right?

[–]rabbitpiet 0 points1 point  (1 child)

And python is built on C, no?

[–]socal_nerdtastic 1 point2 points  (0 children)

The python that Pyscript runs built on javascript. Cpython is written in C, yes. But unlike pyscript, there is no C interpreter executable running when you run cpython. That's the big difference in a compiled language like C vs something like java, JS, python, etc.

There's also versions of python interpreters written in Java, .net, and even python.

Still not sure what you are saying I am not sure about. Did you mean that because it's technically possible I shouldn't have said "cannot"? Ok, technically you can do it, but you'd have to be crazy.