Author Topic: Trying to Understand Python  (Read 2971 times)

0 Members and 1 Guest are viewing this topic.

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Trying to Understand Python
« Reply #25 on: June 15, 2022, 11:44:27 am »
Thanks for the warning, but as far as I understand it Python 2 was never the same as Python 3. 3 was not just an updated version like C++98 vs C++17. Therefore I never expected code written in one to work flawlessly with the other, anymore than I would expect the same from code written in any two different languages, regardless of the similarities.

Well, if you expect C++17 code to compile with C++98 compiler, good luck. That's not what I would consider as "just an updated version". Also C++17 has removed and deprecated quite a few things that worked in C++98 - auto_ptr, functional, random_shuffle() among others. So even the backwards compatibility isn't 100%.

That's the same sort of difference we are talking about with Python 2 vs Python 3.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Trying to Understand Python
« Reply #26 on: June 15, 2022, 11:47:30 am »
Well, I am not planning on writing very much new Python code. I will be using C/C++ when I start writing for myself. I just need to understand the Python so I can understand, and work thought, the examples I find. Which reminds me, I need to look up tuples as I do not think they are what I am thinking they are.

Then for your own sake, do not learn Python 2!

 ;D

Given that Python is used for a lot of infrastructure and tooling as a scripting language (code build systems, sysadmin stuff, etc.) and it is the most popular programming language at the moment (no doubt driven by the machine learning and scientific computing where it has practically completely eliminated Matlab),  ignoring it is at your own peril even if you don't write applications in it.  :-//
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Trying to Understand Python
« Reply #27 on: June 15, 2022, 11:10:57 pm »
Well, if you expect C++17 code to compile with C++98 compiler, good luck. That's not what I would consider as "just an updated version". Also C++17 has removed and deprecated quite a few things that worked in C++98 - auto_ptr, functional, random_shuffle() among others. So even the backwards compatibility isn't 100%.

That's the same sort of difference we are talking about with Python 2 vs Python 3.

Exactly.

There might come a time when I need some updated functionality, but until then, there is no benefit to updating for the sake of having the latest and greatest...anything.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Trying to Understand Python
« Reply #28 on: June 16, 2022, 10:44:26 am »
There might come a time when I need some updated functionality, but until then, there is no benefit to updating for the sake of having the latest and greatest...anything.

Sorry but that's complete BS. This is not about some fad or 'latest and greatest' but that you are literally setting up yourself for a failure because you are using obsolete and long unsupported tooling. GCC will still compile C++98 code with the right switches. Python 2 code will not run in Python 3 and Python 3 code (i.e. all current libraries and tools) will not work in Python 2.

Given that you literally don't know much about the language, are asking for advice - and then promptly decide to ignore it, good luck  :-//

 
The following users thanked this post: gmb42

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Trying to Understand Python
« Reply #29 on: June 16, 2022, 10:35:23 pm »
Given that you literally don't know much about the language, are asking for advice - and then promptly decide to ignore it, good luck  :-//

No, I was asking about a specific problem, where it turned out I was confused by the format and did not notice the function was outside the class. Since what I am working on uses Python 2, trying to use Python 3 would only cause troubles, as you repeatedly state. In fact, I would probably be having even more trouble. So, actually I am following your advice, just not the way you keep insisting on. Oh wait, I should find newer examples, right? Well, this is what I started with and what I intend to finish, before starting another one. If it makes you feel better, the next one I have planned will use Python 3, If what ever I do after that goes back to Python 2, then I will do the same. Once I get a good enough understanding of all this, I might never use Python again.

The right tool for the job is not necessarily the shiniest one.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6172
  • Country: fi
    • My home page and email address
Re: Trying to Understand Python
« Reply #30 on: June 17, 2022, 04:15:19 pm »
The right tool for the job is not necessarily the shiniest one.
It's not that, using the latest and newest, at all.  It's that Python 2 is no longer officially supported; it is EOL'd.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Trying to Understand Python
« Reply #31 on: June 17, 2022, 06:04:06 pm »
Given that you literally don't know much about the language, are asking for advice - and then promptly decide to ignore it, good luck  :-//

No, I was asking about a specific problem, where it turned out I was confused by the format and did not notice the function was outside the class. Since what I am working on uses Python 2, trying to use Python 3 would only cause troubles, as you repeatedly state. In fact, I would probably be having even more trouble. So, actually I am following your advice, just not the way you keep insisting on. Oh wait, I should find newer examples, right? Well, this is what I started with and what I intend to finish, before starting another one. If it makes you feel better, the next one I have planned will use Python 3, If what ever I do after that goes back to Python 2, then I will do the same. Once I get a good enough understanding of all this, I might never use Python again.

The right tool for the job is not necessarily the shiniest one.

Sure, but while I may agree with you if you had to deal with a large code base written in Python 2 and porting it to Python 3 would be a major risk, if you're just starting with Python and are dealing with some code example, that's a completely wrong approach IMHO. That would be a bit like trying to learn C in 2022 using the original C and the first edition of the K&R book and complaining this is all confusing and that all compilers you've tried so far keep giving you warnings and errors.

 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Trying to Understand Python
« Reply #32 on: June 18, 2022, 01:33:13 am »
Sure, but while I may agree with you if you had to deal with a large code base written in Python 2 and porting it to Python 3 would be a major risk, if you're just starting with Python and are dealing with some code example, that's a completely wrong approach IMHO. That would be a bit like trying to learn C in 2022 using the original C and the first edition of the K&R book and complaining this is all confusing and that all compilers you've tried so far keep giving you warnings and errors.

lol, pip might be worse than you guys. It is also nice that someone actually understands where I am coming from. I did start with Python 3, the latest Anaconda version. It did not work on my ancient machine. Went back a few versions, and still it did not work. I figured it must be an incompatibility problem between 2 and 3. Went farther back to 2.7 and still had problems, which is when I finally decided to ask here.

 
 

Offline retiredfeline

  • Frequent Contributor
  • **
  • Posts: 526
  • Country: au
Re: Trying to Understand Python
« Reply #33 on: June 18, 2022, 09:02:42 am »
Are you one of those people clinging on to an ancient OS like XP?  :P
 
The following users thanked this post: Bassman59

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6172
  • Country: fi
    • My home page and email address
Re: Trying to Understand Python
« Reply #34 on: June 18, 2022, 04:36:20 pm »
I did start with Python 3, the latest Anaconda version. It did not work on my ancient machine.
Well, Python 3 works on any version of Linux you have a compiler for, including for machines over two decades old, so it's not that.

It sounds more like "I did not find Python 3 binaries for my ancient OS version" instead.  Just because upstream does not provide suitable binaries as a download, does not mean Python 3 is not compatible; it only means there are not enough users/demand for upstream to bother building such binaries.

Indeed, I would suggest you check the WinPython binaries, especially WinPython64-3.10.4 (and the downloads that include PyQt5, if you are interested in Qt 5 user interfaces in Python).
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Trying to Understand Python
« Reply #35 on: June 18, 2022, 06:22:04 pm »
Or use a language that is more widely supported on more OSs without having to go through hoops. ;D
Python 3 is not supported on Windows 7 and older anymore, for instance, starting with version 3.9 IIRC (somewhere from 3.8 to 3.10, not quite sure), and I'm sure it's not supported on many other "older" OSs anymore either.

The problem with Python is that you only have ONE implementation AFAIK. That's interestingly (but understandably) the case for most languages that are not standardized. So it's the same for Rust, Go (AFAIK), etc. That means that you are stuck with what ONE team decides, and that's it. I don't like that at all.

Sure, you can always try building Python yourself if binaries are not available for your particular environment, but there's absolutely no guarantee that it will work or that it will even build.
MSYS2 has managed to provide Python 3 binaries, compatible with Windows 7, but that did require a fricking lot of patching. Not something for the faint of heart. (Oh and unfortunately, the MSYS2 team decided to stop supporting Win 7 sometime in 2022. Didn't happen yet, but I'm expecting sometime near the end of the year.) So beyond that point, you'll be on your own.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11790
  • Country: us
Re: Trying to Understand Python
« Reply #36 on: June 18, 2022, 08:41:18 pm »
The problem with Python is that you only have ONE implementation AFAIK. That's interestingly (but understandably) the case for most languages that are not standardized.

If there is only one implementation, does that not mean, by definition, that the one implementation is the standard?
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Trying to Understand Python
« Reply #37 on: June 19, 2022, 12:22:44 am »
Are you one of those people clinging on to an ancient OS like XP?  :P

No, but mostly because when I went to 64 bit, Windows 7 was the only option. Since this post started out in an AI area, I will entertain this question. Can you tell me what Windows 10, or 11, offers that XP did not? Support for applications is a moot point since Microsoft basically killed that, not the software developers. It is not hardware support. My 20 year old machine specs out similar to any modern one, and is better than many. Security? Well now we get into the bit where the OS thinks it knows better. Granted Microsoft turns off many of its new features on final release, It does not necessarily remove them. They may just sit dormant until the next release.

IF you think current Widows OSs do not implement AI, you should probably look a little closer. Personally , I do not want an OS telling me what I should or should not do.

@ SiliconWizard you make valid points. 3.7 still works and is the minimum for Tensorflow, so no problems there. I do not expect a conflict when switching between versions. I have not tried yet, so maybe I am not right?

Quote
without having to go through hoops. ;D
Is that even possible? I am constantly stuck in some kind of loop. At the moment I cannot get my phone to connect to the computer. It will start charging, but I cannot upload my app for testing. I have quite  a few steps between that and when I get to anything discussed in this thread.
 

Online ve7xen

  • Super Contributor
  • ***
  • Posts: 1192
  • Country: ca
    • VE7XEN Blog
Re: Trying to Understand Python
« Reply #38 on: June 20, 2022, 07:19:04 pm »
Quote
If there is only one implementation, does that not mean, by definition, that the one implementation is the standard?

There are at least a couple implementations. PyPy (self-hosted JIT) and IronPython (.NET CLR) come to mind, but there are / have been a few others like Jython (which I think is defunct).

The language standard is here: https://docs.python.org/3/reference/ . I am not sure it is complete enough to implement the language without also consulting CPython, but I believe it is close.

Quote
3.7 still works
Python 3.8 is the last version to run on Windows 7, or 3.7 on XP. So get that, at least. You might be missing a few minor language features and some library improvements but it will be substantially similar.

Quote
Can you tell me what Windows 10, or 11, offers that XP did not?
You've got to be kidding. The APIs constantly move forward on all axes. Whether you deem these improvements 'worthy' or not, software developers need to track them. At some point supporting the old way either hobbles functionality unnecessarily, or is just a waste of maintenance effort. How do you propose they even set up an automated test environment for Windows 7 when it's no longer available? Microsoft no longer supports XP or 7, so neither does Python. It shouldn't be a big surprise. I really don't quite grok why people expect a 13 / 21 year old operating system to run modern code, and act all indignant about it when developers stop supporting their vintage OS. That's the consequence of wanting to run ancient software. Do you also expect a DOS 6.22 Python interpreter to be released by the Python team?

Quote
My 20 year old machine specs out similar to any modern one
lolwut
73 de VE7XEN
He/Him
 
The following users thanked this post: gmb42, newbrain


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf