UKC

Learning Python

New Topic
This topic has been archived, and won't accept reply postings.
 LastBoyScout 21 May 2021

Hi,

Talking about the progrmming language, not the snake!

Can anyone recommend an online training resource/crash course for this, ideally free, but would consider paid for courses.

Ideally with a leaning towards manipulating databases (Oracle/SQL server), as that's what it's mainly going to be used for, at least initially - I'm going to be picking up supporting a utility at work that's mainly written in Python.

For background, I'm an experienced developer in several other languages, but looking to branch out a bit.

Please don't reply with "don't bother with Python, you should be learning/re-writing it in <x> instead"

 elsewhere 21 May 2021
In reply to LastBoyScout:

https://docs.python.org/3/tutorial/

I've not used python RDBMS connection for a while but I think the python bit is DB agnostic apart from the initial connection.

On windows I use the ActiveState version but check the licenscing.

PS don't bother with Python, you should be learning/re-writing it in binary instead, even hex code is for wimps 

Post edited at 16:15
 wintertree 21 May 2021
In reply to LastBoyScout:

If you're experienced then just working through the online tutorial [1] in a couple of hours should do it for fluency and being up and running.

When I've fielded questions from experienced colleagues moving to Python, most of their queries and WTFs/confusion have been over two things:

  • The object model.  It's a perfectly sensible object model, but if you're steeped in C++ it's going to take some getting used to.  I'd recommend reading the detailed documentation on Python.org for that
  • The intersection of mutable vs immutable native types, object identities and equality testing, and in-place operations.   Sometimes things in these areas come together to really surprise you if you don't understand how it all works. It's worth reading through the object model and type model and so on, and as a matter of principle never doing in place operations on stuff passed in as an argument to a function.

I can't recommend JupyerLab enough as an interface for developing and learning.  I basically live in it developing the leading edge of my data pipeline, with stuff getting moved in to modules (files) as it matures.

> Please don't reply with "don't bother with Python, you should be learning/re-writing it in instead" 

On that note...  I've been using Python since 2004, and pushed hard to move an introductory programming course in the sciences from FORTRAN 90 in to Python 15 years ago against, fighting against people who - sincerely - thought it could meaningfully be taught it in C++.  No idea.  Now, Python is in use across the course to phenomenal success, with a range of scientific modules and plotting libraries a few key presses away.  As you may or may not have spotted, I'm a great fan of Python for plotting data.  Check it's place in Tiobe.... -  on its way to #1 after all this time. [3]

These days I have something like 2 Pb of data a week passing through code that's 99.9% Python.

[1] https://docs.python.org/3/tutorial/

[2] https://jupyter.org

[3] https://www.tiobe.com/tiobe-index/

Edit: Took so long to write that Elsewhere beet me to it with the tutorial.

Post edited at 16:29
 kathrync 21 May 2021
In reply to LastBoyScout:

Assuming you are already somewhat familiar with the basics of Python (the official Python tutorial linked by others above is good for this), this might be of use to you: https://www.freecodecamp.org/news/connect-python-with-sql/ 

I don't know how good it is mind you, I haven't worked through it myself. Skimming it, it looks like it should be enough to get you up and running if you are an experienced developer already as long as you are reasonably confident shifting between languages.

Depending on exactly what you are doing, it might also be worth looking at the tutorials for some of the web framework packages available in Python. Django is probably the trendiest full featured model-template-view style package with support for the most common relational database backends at the moment.

Post edited at 16:30
 kathrync 21 May 2021
In reply to wintertree:

> When I've fielded questions from experienced colleagues moving to Python, most of their queries and WTFs/confusion have been over two things:

....

> The intersection of mutable vs immutable native types, object identities and equality testing, and in-place operations.   Sometimes things in these areas come together to really surprise you if you don't understand how it all works. It's worth reading through the object model and type model and so on, and as a matter of principle never doing in place operations on stuff passed in as an argument to a function.

Ha yes - sometimes these areas intersect in a way that suprises you even if you have been working in Python for a long time!

 Alkis 21 May 2021
In reply to LastBoyScout:

Only thing I wanna add on top of what wintertree has already said, ensure that whatever documentation/tutorial/whatsit you use is not for Python 2.x. You'd be surprised how often you come across Python 2.7 even now.

Post edited at 16:52
 wercat 21 May 2021
In reply to elsewhere:

right, I'll get my array of switches in line then ready to pulse the strobe inputs ...

 wercat 21 May 2021
In reply to LastBoyScout:

before you start you are supposed to know a lot of Monty Python sketches so you fit in with the ethos

you should alternate a python sketch with a practical session

Post edited at 16:45
 jdh90 21 May 2021
In reply to LastBoyScout:

There is occasionally a bundle of python textbooks available on humblebundle. "Pay what you want to charity" to access, but in reality, the more you pay the more you get.

You've timed your question with there being a package available.

Can't vouch for the quality as I haven't read them yet, but at just over a tenner for the full set I thought I'd punt on them yesterday.

When I told the girlfriend who uses python regularly I'd bought them with the intention to learn she recommended code academy website.  She said the titles of the books sound good for structuring the learning with ideas for projects though.

 Luke90 21 May 2021
In reply to elsewhere:

> PS don't bother with Python, you should be learning/re-writing it in binary instead, even hex code is for wimps 

Pah, real programmers use a magnetised needle and a steady hand

https://xkcd.com/378/

 Ramblin dave 21 May 2021
In reply to wintertree:

Yeah, agree with this - there are a lot of great "learn Python" resources out there, but a lot of them start with "what is a for loop" sort of stuff, which you probably won't need if you're already an experienced programmer. If that's where you're starting it should be fairly quick to jump into.

One thing I would recommend is Brett Slatkin's book, Effective Python, for a bunch of concrete suggestions on idiomatic Python and how and when to use some of the more advanced language features.

OP LastBoyScout 21 May 2021
In reply to wercat:

> before you start you are supposed to know a lot of Monty Python sketches so you fit in with the ethos

> you should alternate a python sketch with a practical session

I didn't expect the Spanish Inquisition...

 JMarkW 21 May 2021
In reply to LastBoyScout:

Another vote for Jupiter notebooks. If you are doing database stuff, u say slant  SQL in guessing Azure?

Maybe have a look at databricks community edition?

Pyspark ( or pandas) is very interesting. Python pyspark requires a fundamental mindset change mind.

Andy Gamisou 22 May 2021
In reply to wintertree:

> On that note...  I've been <snip> fighting against people who - sincerely - thought it could meaningfully be taught it in C++.  No idea. 

Well, it wouldn't be my first choice today, but many of us came into programming through the C/C++ route, what with it being the most prevalent technical programming environment at the time.  Not sure we'd say we had no idea or that we failed to be meaningfully taught.

 wintertree 22 May 2021
In reply to Andy Gamisou:

Sorry, that wasn’t a general comment or a dig at C++.  

It was a 10 hour course for students who’d never been taught programming before and most of whom had never used a command line before.   Using Python we could get them to the point they were analysing and plotting data in accordance with their wider course.  So, “meaningful” in the context of their studies, with many of them then choosing to do this instead of using Excel for plotting in future lab courses.  I mean that the people pushing to teach this course in C++ had "no idea" about how it was going to play out in C++ vs Python.  Hint - it wasn't going to easier than FORTRAN, nor was it going to catch many student's interests through clear and rewarding achievements.  For all its limitations, FORTRAN was a more beginners friendly language for the students than C++ and the feedback on the FORTRAN course was clear...

In reply to LastBoyScout:

> For background, I'm an experienced developer in several other languages, but looking to branch out a bit.

Then just have at it. You'll be fine.

You'll spend more time reading the docs for the modules you import than you will learning the python.

 wercat 22 May 2021
In reply to Longsufferingropeholder:

reminds me of IBM JCL, very simple syntax but appalling parameters needed for the invoked programs

I literally had a nightmare about it while learning it where the instructor told me my job was being rejected not because of any sintax errors but simply because I hadn't made it rhyme (in the dream this was an undocumented but essential requirement).

Post edited at 13:21
 kathrync 24 May 2021
In reply to wintertree:

> It was a 10 hour course for students who’d never been taught programming before and most of whom had never used a command line before.   Using Python we could get them to the point they were analysing and plotting data in accordance with their wider course.  So, “meaningful” in the context of their studies, with many of them then choosing to do this instead of using Excel for plotting in future lab courses.  

Yes, this is a common theme here too, with many biology courses choosing to outsource teaching  of programming to the School of Computing Science, who inevitably deliver in C++ or Java. Nothing wrong with either language (hmmm, well, Java...) but in this context it has two disadvantages - firstly less rewarding for students in the context of the rest of their studies. Wintertree described this very well. Secondly, when these students come to do honours projects later on, they are inevitably placed in labs who primarily work in Python or R. Most of them won't have spent enough time writing code to switch languages easily at that point, and most won't get any support for writing in the language they have been taught from the lab hosting them.

 mondite 24 May 2021
In reply to jdh90:

> Can't vouch for the quality as I haven't read them yet, but at just over a tenner for the full set I thought I'd punt on them yesterday.

No Starch generally produce pretty good books unlike some publishers so worth the punt.

 wintertree 24 May 2021
In reply to kathrync:

When it comes to programming in a degree that isn't CS or engineering, it strongly comes down to "minimum viable product" as far as I'm concerned.  

It's perfectly possible to jump the shark even with a language like Python by bogging the teaching down in front loaded theory, introducing OO when it's in no way needed, too much focus on peripheral CS concepts.  Programming courses when not outsourced tend to fall to those who make extensive use of programming in their professional lives. I'm not convinced that's necessarily the way forwards, as those are the people who may find it hardest to bridge the gap to an undergraduate who has never programmed and isn't even sure why they need to. 

> who inevitably deliver in C++ or Java. Nothing wrong with either language

Er...

> (hmmm, well, Java...) 

You had me going there for a moment.  

Quite separate to any academic discussion over the language, the recent legal bruhaha of Google LLC v. Oracle America, Inc. must have put the wind up a fair few people over the long term safety and sustainability of using Java in a professional context.  The Supreme Court saw sense, but getting there - what drama and direct and indirecet cost.  Oracle are not  showing themselves to be the kind of custodian I'd like behind my environment.  On that note, I'd half expected the recent Free Software Foundation / RMS controversy to pop up on these pages.  What a disappointing set of developments.

Post edited at 11:02
 kathrync 24 May 2021
In reply to wintertree:

> When it comes to programming in a degree that isn't CS or engineering, it strongly comes down to "minimum viable product" as far as I'm concerned.  

Absolutely

> It's perfectly possible to jump the shark even with a language like Python by bogging the teaching down in front loaded theory, introducing OO when it's in no way needed, too much focus on peripheral CS concepts.  Programming courses when not outsourced tend to fall to those who make extensive use of programming in their professional lives. I'm not convinced that's necessarily the way forwards, as those are the people who may find it hardest to bridge the gap to an undergraduate who has never programmed and isn't even sure why they need to. 

Absolutely agree that's it's definitely possible to make Python far too heavy. However, my experience of Python or R teaching that is not outsourced tends to be that students end up learning how to do very specific things by rote without really understanding what is happening, with the result that they struggle to apply what they have learnt to more abstract problems. I agree that focusing too much on CS concepts is unecessary, but there is definitely a balance to be struck there.

> Quite separate to any academic discussion over the language, the recent legal bruhaha of Google LLC v. Oracle America, Inc. must have put the wind up a fair few people over the long term safety and sustainability of using Java in a professional context.  

Ha, yes. Our funders have actually requested that we move away from both the Java midlayer and Oracle RDBMS backend that our software currently uses in the wake of this. We were in the process of moving to PostgreS anyway, so that part isn't a big problem. Finding developer time to port all of our Java code at short notice, however, is a bit more of a headache. 

 wintertree 24 May 2021
In reply to kathrync:

> However, my experience of Python or R teaching that is not outsourced tends to be that students end up learning how to do very specific things by rote without really understanding what is happening, with the result that they struggle to apply what they have learnt to more abstract problems

Agreed.  Once they've done some stuff in the language and it's tangible to them, it's much easier (or much less difficult) to explain the more abstract concepts than if you try and front load them in the course.   The problem then is finding the time and justification in the curriculum to follow up the practical side of the course with a closing abstract/theoretical session.

> Our funders have actually requested that we move away from both the Java midlayer and Oracle RDBMS backend that our software currently uses in the wake of this. We were in the process of moving to PostgreS anyway, so that part isn't a big problem. Finding developer time to port all of our Java code at short notice, however, is a bit more of a headache. 

Wise funders.  What a sorry state of affairs all around.

Post edited at 14:57
OP LastBoyScout 24 May 2021
In reply to kathrync:

> Ha, yes. Our funders have actually requested that we move away from both the Java midlayer and Oracle RDBMS backend that our software currently uses in the wake of this. We were in the process of moving to PostgreS anyway, so that part isn't a big problem. Finding developer time to port all of our Java code at short notice, however, is a bit more of a headache.

Not so much Java (we don't use much of that, if any), but it's been a long-running issue with some of our customers about moving away from Oracle, mainly due to cost - the problem is that all our install scripting is heavily reliant on PL/SQL and it would be a nightmare to migrate it all...

 kathrync 24 May 2021
In reply to LastBoyScout:

> Not so much Java (we don't use much of that, if any), but it's been a long-running issue with some of our customers about moving away from Oracle, mainly due to cost - the problem is that all our install scripting is heavily reliant on PL/SQL and it would be a nightmare to migrate it all...

Yeah, we're fighting a bit with the PL/SQL that we have lying around too. When I said "not a problem" I really meant in the sense that we were planning it anyway, so had already budgeted time and personnel for it, unlike the unplanned move of the Java layer.

 kathrync 25 May 2021
In reply to wercat:

> I literally had a nightmare about it while learning it where the instructor told me my job was being rejected not because of any sintax errors but simply because I hadn't made it rhyme (in the dream this was an undocumented but essential requirement).

Have you come across Perl poetry before? The idea is to write a poem that passes validation by the Perl interpreter - it doesn't actually have to do anything useful. I suspect there are similar examples in other languages but Perl lends itself particularly well to poetry because it was designed by a linguist. I guess it has to be good for something...!

This is the earliest example I know of: https://en.wikipedia.org/wiki/Black_Perl
This one is just a bit of fun: https://www.perlmonks.org/?node_id=174135

 yorkshire_lad2 25 May 2021
In reply to LastBoyScout:

This popped up on another forum that I lurk on.  It's beginner level question, so not the same level as this thread, but thought it might be useful if anyone pops in on either thread and wants further/different info.

https://www.lemonfool.co.uk/viewtopic.php?f=95&t=29570&p=414973#p41...

(Have posted links between threads)

 mondite 25 May 2021
In reply to kathrync:

>  unlike the unplanned move of the Java layer.

Why was the Java moce so sudden given this has been bubbling on for ages?

I was amused recently when pulled into discussion about a third party tool we use and are planning to move away from due to various fun and games around licencing and saw one of the proposed alternatives was an Oracle product.

 Wingnut 25 May 2021
In reply to wercat:

>>I hadn't made it rhyme

I once produced some code for work that, through creative use of variable names and comments, actually did rhyme. (I'm a bit more professional these days, honest!)

 wercat 25 May 2021
In reply to Wingnut:

I used a 4GL in the 80s/90s that only parsed the first 3 letters of keywords and allowed the rest either to be omitted or to be anything you wanted.  It was possible to make some sequences quite rude

ANAL NET was valid as was stuff like GROUP SEX PERIOD before you even tried making your own extensions.

 kathrync 25 May 2021
In reply to mondite:

> >  unlike the unplanned move of the Java layer.

> Why was the Java moce so sudden given this has been bubbling on for ages?

Because rather than deciding to do it ourselves, costing it out, assessing alternatives, assessing what other deliverables could be shelved while we do it and so on like we did for the Oracle->Postgres move, our funding body (it's an academic project) told us out of the blue "you need to do this within 3 months or we'll pull your funding". They are also not being very flexible on other deliverables.

We had indeed already discussed migrating internally, but as a future plan for after the Oracle->Postgres move was complete. We had a working group assessing alternatives. So, it is something we would have done probably in the early part of next year. We're just being forced now to do it before the end of June instead.

 wintertree 25 May 2021
In reply to kathrync:

> told us out of the blue "you need to do this within 3 months or we'll pull your funding". They are also not being very flexible on other deliverables.

I retract my previous comment about them being wise.  It's good to steer away from something like this mess, but not to do it like that.

 kathrync 26 May 2021
In reply to wintertree:

> I retract my previous comment about them being wise.  It's good to steer away from something like this mess, but not to do it like that.

Yes - I don't object to what they have asked us to do, but I do object to how they have asked us to do it. 

 wintertree 26 May 2021
In reply to Alkis:

> You'd be surprised how often you come across Python 2.7 even now.

Good point.

Spending over a decade in an end-of-life, maintenance only state seemed to move Python 2.7 to an absolutely bomb proof level of robustness.  It's not often a highly used piece of code gets a total feature freeze but on going bug fixes for 11 years.  This might explain why there's some 2.7 die hards out there...  

1
 lowersharpnose 26 May 2021
In reply to LastBoyScout:

codewars is good ( https://www.codewars.com ).  Lots of graded mini exercises.  When you have completed one, you can view the code of other solutions which can be very instructive.

In reply to LastBoyScout:

I keep seeing this thread and every time I expect it to be about becoming familiar with the Parrot sketch

OP LastBoyScout 26 May 2021
In reply to DubyaJamesDubya:

I think you're just pining for the fjords...

Andy Gamisou 27 May 2021
In reply to wintertree:

> Sorry, that wasn’t a general comment or a dig at C++.  

> It was a 10 hour course for students who’d never been taught programming before and most of whom had never used a command line before.  

Ah, fair enough.  I recall having to work with someone on a c project who had only ever worked in visual basic and had never even come across the concept of command line. As the "IDE" used for the project was basically "vi" and "ksh" the whole process was rather frustrating for both of us, as he couldn't get his head around not pressing a button to make it all work.  Sometime later I had the opposite problem when I worked on a Visual-C++ project - I couldn't understand why I couldn't just hack around with some make files and shell scripts instead of fannying around with menus and other bullshit.  Still can't tbh

Currently playing around with python for a spot of machine learning.

Post edited at 04:47

New Topic
This topic has been archived, and won't accept reply postings.
Loading Notifications...