October 20, 2021, 10:27:42

Author Topic: Learning Python  (Read 12284 times)

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3235
  • elgol
Re: Learning Python
« Reply #75 on: February 01, 2021, 09:33:19 »
The 3 problems I have with Python are:

1) It's just another generic language, so it relies on extra libraries to do anything but basic text programs.  Which means you have to 'bolt-on' libraries written by other people that might have a very different design philosophy to Python.  Plus it's something else not native and so must be learnt for each library added, is the documentation any good?

2) Blocks of code and scope are based on what column the text is in!  While looking neat when correct, this is a terrible idea imo!  Bugs will be harder to spot, and if your code file ever gets inputted to another text editor the code might get out of column alignment, so the program will not work immediately and easily.

3) It's interpreted and therefore slow compared to compiled code.  Computers these days are so fast that a lot of 2d games are possible and it runs immediately, but when you need extra speed it's not there.
« Last Edit: February 01, 2021, 09:37:32 by Steve Elliott »
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry pi 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline Aurel

  • Sr. Member
  • ****
  • Posts: 352
Re: Learning Python
« Reply #76 on: February 01, 2021, 10:50:39 »
Yes Steve i agree with you in all 3 points

let say this program should be web server on local machine in 3 lines of code

Code: [Select]
import os
from http.server import HTTPServer, CGIHTTPRequestHandler
# Make sure the server is created at current directory
os.chdir('.')
# Create server object listening the port 80
server_object = HTTPServer(server_address=('', 80), RequestHandlerClass=CGIHTTPRequestHandler)
# Start the web server
server_object.serve_forever()

ok i save code ,do exectly what is stated on that site and then i try to run
it looks that interpreter run code but then i figure that is not
then as thay say user need to run it from CMD...yeah
windows says ..it is not recognized...i am not surprized at all...and so on
ok maybe i do something wrong ...but what a heck...

Yes as you say ...user must learn all stuff if you using specific lib...so you dont learn python then
user must learn how to use this lib and how is designed ..all that is such a mess.
(Y)

Offline Aurel

  • Sr. Member
  • ****
  • Posts: 352
Re: Learning Python
« Reply #77 on: February 01, 2021, 10:58:32 »
Then i become pissed off and try another one ...

Code: [Select]
# Python 3 server example
from http.server import BaseHTTPRequestHandler, HTTPServer
import time

hostName = "localhost"
serverPort = 8080

class MyServer(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8"))
        self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
        self.wfile.write(bytes("<body>", "utf-8"))
        self.wfile.write(bytes("<p>This is an example web server.</p>", "utf-8"))
        self.wfile.write(bytes("</body></html>", "utf-8"))

if __name__ == "__main__":
    webServer = HTTPServer((hostName, serverPort), MyServer)
    print("Server started http://%s:%s" % (hostName, serverPort))

    try:
        webServer.serve_forever()
    except KeyboardInterrupt:
        pass

    webServer.server_close()
    print("Server stopped.")

..OK ...this one work because i see in console (IDE output message )

*** Remote Interpreter Reinitialized  ***
Server started http://localhost:8080


OK ...BUT this is not in just 3 LINES OF CODE !!!

..OMG ...i become a python programmer ... ::)
(Y)

Offline TomToad

  • Hero Member
  • *****
  • Posts: 556
Re: Learning Python
« Reply #78 on: February 01, 2021, 13:05:57 »
Just like any other language, Python has its positives and negatives. 

Python is very good at processing large amounts of data.  With things like list comprehensions, and statistical functions, all fine tuned and handled in the runtime, makes it good for things like machine learning and scientific research.  It's dynamic nature makes it highly scalable which makes it good for large web services.  There is a reason why sites like Facebook and Twitter use Python on their servers.

As for games and GUI applications, Python is not the best choice.  Python does have TKInter, but it is very basic and outdated, mainly used to make a quick interface for your program.  Python also has PyGame, but it is slow and jerky.  There are better 3rd party modules you can use such as WxPython or AGK for Python, but if you are developing a full featured GUI app or game, I think there are better languages.

Basically it comes down to using the right tool for the right job.  You should learn several languages, not just one.  To criticize Python as a language because you cannot make a good game with it, or criticize C++ because it takes 10x more lines to do the same code than Python, is like criticizing the pliers in your toolbox because it is poor at hammering in screws.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Aurel

  • Sr. Member
  • ****
  • Posts: 352
Re: Learning Python
« Reply #79 on: February 01, 2021, 16:59:25 »
Look
I do not critic python as it is then in general ...what many around promoted..
alsmost looks like we dont need any other programming language than python..
do you get it now..?
also i am not new in programming and i know very well what is what !
(Y)

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3235
  • elgol
Re: Learning Python
« Reply #80 on: February 01, 2021, 18:19:41 »
Quote
almost looks like we dont need any other programming language than python..

They said that about Java  :))
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry pi 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline Scaremonger

  • Full Member
  • ***
  • Posts: 233
    • ITSpeedway - Ramblings of a geek!
Re: Learning Python
« Reply #81 on: February 01, 2021, 18:34:33 »
You can do a lot without any external libraries apart from those shipped with Python. I mentioned a 5 line bit of code, but it can be even easier:

1. Put an index.html and style.css file into a folder (Samples below).
2. Open a command prompt and navigate to that folder.
3. Type the following
Code: [Select]
python -m SimpleHTTPServer
4. Point your browser at 127.0.0.1:8000 and check it is working.

index.html
Code: [Select]
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

style.css
Code: [Select]
body { background-color: powderblue; }
h1 { color: blue; }
p { color: red; }


Offline LineOf7s

  • Full Member
  • ***
  • Posts: 106
    • LineOf7s Entertainment
Re: Learning Python
« Reply #82 on: February 02, 2021, 02:05:06 »
Show us on the doll where the bad programming language hurt you.

It's okay.  Python can't hurt you anymore.

Offline Aurel

  • Sr. Member
  • ****
  • Posts: 352
Re: Learning Python
« Reply #83 on: February 16, 2021, 08:13:58 »
Quote
Show us on the doll where the bad programming language hurt you

wait a moment ..are you one of this which constantly spreading such
patronized and insulting ...babeling ..

I can only say to you ...PUT THE PIPE DOWN !
(Y)

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3235
  • elgol
Re: Learning Python
« Reply #84 on: February 16, 2021, 10:04:44 »
Quote
Show us on the doll where the bad programming language hurt you

Quote
wait a moment ..are you one of this which constantly spreading such
patronized and insulting ...babeling ..

I can only say to you ...PUT THE PIPE DOWN !

 :))
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry pi 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal