Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Dominoes
Sep 20, 2007

onionradish posted:

It is; I'd avoid him on principle based on how he lashed out against critics, aside from suspecting anything he says as being out of date since he's been so anti-Python3. Suddenly, he'd be worth listening to?

Automate the Boring Stuff is probably the most-recommended starter since it emphasizes doing something practical with the language.

Other sources I found useful when learning:
  • PyCharm as an IDE to kick me in the pants on style and provide easy access to method calls
  • Reddit's /learnpython wiki
  • Reddit's /learnpython and /Python groups; /learnpython has a mix of beginner questions and lazy student questions, which means anyone can ask beginner questions without standing out, or see how many of the existing questions you already know the answer to - it's something a beginner outgrows, which is a decent milestone
  • PyVideo.org, which has hundreds of video sessions from Python conferences, ranging from brief overviews of modules, to 3+ hour tutorials on topics from basic Python, to good Pythonic code (Hettinger, et al), to heavily-specific scientific topics (using modules for DNA analysis, real-time bidding for online ads, etc.)
  • DevDocs.io to copy a local, offline, browser-accessible version of Python docs (as well as bunch of other languages)
Thx! Sent him the ATBS link; seems perfect. I'm recommending Anaconda since it has all the packages.

Eela6 posted:

BTW, should we make a new Python thread? This one is pretty crusty. It might be nice to have an updated OP with some of this material.
Congrats, you just nominated yourself. I bet you can't have it up by this time tmw.

Adbot
ADBOT LOVES YOU

Eela6
May 25, 2007
Shredded Hen

Dominoes posted:

Thx! Sent him the ATBS link; seems perfect. I'm recommending Anaconda since it has all the packages.

I can only type with one hand because of health issues, so it will take a little longer than that. But I'm happy to do it.

Dominoes
Sep 20, 2007

Some highlights you could put in:

-Tutorials and instructional books
-Strengths and weaknesses (ie easy, versatile, sucks at distributable standalone progs and inappropriate for sys programming)
-Installation guides (eg Anaconda vs pip wheels / linux packages / Chris Gohlke's installers)
-IDEs
-Scipy-stack info
-Popular packages (requests, pytz, sqlalchemy, beautifulsoup, toolz etc)
-GUI (Qt5, Kivy, TKinter etc)
-Web dev section, with a link to the Django thread
-Resources (like onion's reddit recommendations)
-Alternatives (ie R for stats, Julia for numerical things, Ruby for web dev)
-Neat projects (micropython, numba, pypy etc)
-Good articles and notebooks (Kalman filters, Data Science Handbook)

Dominoes fucked around with this message at 20:55 on Feb 27, 2017

Eela6
May 25, 2007
Shredded Hen

Dominoes posted:

Some highlights you could put in:

-Tutorials and instructional books
-Strengths and weaknesses (ie easy, versatile, sucks at distributable standalone progs and inappropriate for sys programming)
-Installation guides (eg Anaconda vs pip wheels / linux packages / Chris Gohlke's installers)
-IDEs
-Scipy-stack info
-Popular packages (requests, pytz, sqlalchemy, beautifulsoup, toolz etc)
-GUI (Qt5, Kivy, TKinter etc)
-Web dev section, with a link to the Django thread
-Resources (like onion's reddit recommendations)
-Alternatives (ie R for stats, Julia for numerical things, Ruby for web dev)
-Neat projects (micropython, numba, pypy etc)
-Good articles and notebooks (Kalman filters, Data Science Handbook)

I agree w/ the inclusions of all of these segments. However, I have zero front-end or webdev experience. I don't feel qualified to talk about :

-Popular packages (requests, pytz, sqlalchemy, beautifulsoup, toolz etc)
-GUI (Qt5, Kivy, TKinter etc)
-Web dev section, with a link to the Django thread

Also, I use Anaconda through windows powershell. I can't talk about the linux toolchain.

If someone else in the thread could produce these sections that would be cool

LochNessMonster
Feb 3, 2005

I need about three fitty


Probably late to the party but another rec for ATBS. I recently picked up Python without any programming experience besides a Java course over a decade ago. It was good to follow and felt good doing something practical.

I did a coursera course afterwards and it felt like a walk in the park due to already have done ATBS.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I've got a new thread for Python pretty much ready to go from a couple years ago, I just never got around to posting it.

I'll clean it up and post it by the end of the week.

edit: Well, I just read it over and its kind of dated and actually from the end of 2013. If someone wants to start with it as a base here it is. There's good suggestions in the comments on that page for improvements.

Thermopyle fucked around with this message at 22:16 on Feb 27, 2017

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Dominoes posted:

Hey dudes. What are the best ways to learn Python, for someone with no experience? I learned from Codeacademy, which was OK. The OP looks out of date.

If you have access to O'Reilly books, I would start with 'Learning Python' and then 'Python Cookbook'. You learn 'this is Python' and then they show you 'this is how to do stuff with it'

huhu
Feb 24, 2006

onionradish posted:


Automate the Boring Stuff is probably the most-recommended starter since it emphasizes doing something practical with the language.

[/list]

This has been an amazing book to learn from and I still go back to it every other project or so.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



https://pymotw.com/3/ deserves a mention. I know the standard modules are a functionality mausoleum but there's still good stuff in there i you know where to look.

huhu
Feb 24, 2006
I've got a Python function that I've added throughout a script I want to run autonomously. Its purpose is to print various log information to a txt file. What would the bests way to log any errors that might occur to the same file?

code:
def print_log(text_to_log):
    """
    Print text to log.txt file and command line
    """
    print(text_to_log)
    f = open("log.txt", "a")
    f.write(text_to_log + "\n")
    f.close()

a witch
Jan 12, 2017

Look into the logging module, it has a decent tutorial.

If you want to write messages to the console and a file at the same time, you'll want a logger with a FileHandler and a StreamHandler attached.

E: I'm on a phone so can't type code, here's the basic tutorial https://docs.python.org/3/howto/logging.html

a witch fucked around with this message at 17:43 on Mar 1, 2017

huhu
Feb 24, 2006

a witch posted:

Look into the logging module, it has a decent tutorial.

If you want to write messages to the console and a file at the same time, you'll want a logger with a FileHandler and a StreamHandler attached.

E: I'm on a phone so can't type code, here's the basic tutorial https://docs.python.org/3/howto/logging.html

Awesome thanks.

Another question - I have a script running that uploads files to dropbox. If the internet goes down mid upload, I get a MaxRetryError. Trying the following doesn't work though
code:
try:
    # upload file
    return True
except MaxRetryError:
    return False
what should I be putting instead?

Eela6
May 25, 2007
Shredded Hen
What do you want to happen?

huhu
Feb 24, 2006

Eela6 posted:

What do you want to happen?

I want the function to return false. However, with that code I'm getting "NameError: global name 'MaxRetryError' is not defined".

a witch
Jan 12, 2017

huhu posted:

I want the function to return false. However, with that code I'm getting "NameError: global name 'MaxRetryError' is not defined".

Is MaxRetryError the type of the exception being thrown? You will have to import it to make the name visible.

Eela6
May 25, 2007
Shredded Hen
This is what you have:
Python code:
"""awfulerrors.py is a stand-in 
for the function that contains 
your troublesome error"""

class AwfulError(Exception):
    pass

def fake_upload():
    raise AwfulError
Python code:
"""main.py"""
import awfulerrors
from awfulerrors import AwfulError
def main():
    try:
        awfulerrors.fake_upload()
    except AwfulError:
        print('caught correctly')
        return False
    except Exception:
        print('this line should never be reached')
        raise
    else: # No Error at All
        return True
    
if __name__ == '__main__':
    result = main()
    assert result is False
    print('we did it!')
OUT:
Python code:
this line should never be reached
Traceback (most recent call last):
<<< some ommitted>>
    line 11, in fake_upload
    raise AwfulError
Your code doesn't know what namespace (function, class, package, or module) the error lives in. It only knows about the stuff in it's local namespace, built-ins (like IOErrors), or globals.

You need to make one of these two changes to let it know where the error lives so you can catch it.
Python code:
# during your imports:
from awfulerrors import AwfulError 
#(this pushes it into the local namespace where it is
#defined; normally at the #module level)

#replacing your except block
except awfulerrors.AwfulError:
# this tells the interpreter that the error lives in 
# the awfulerrors package, which you have imported before
OUT (AFTER FIXING):
Python code:
caught correctly
we did it!
I personally prefer the second way, because it lets new readers of your code know where it comes from, and you're unlikely to keep using an error so often that you want to shorten it's name for readability purposes.

Eela6 fucked around with this message at 21:16 on Mar 1, 2017

Eela6
May 25, 2007
Shredded Hen
As a brief note, huhu, you might want to look in to how to phrase technical questions better. This section on stackoverflow might help you. You've asked questions a couple of times that were phrased in ways that made it difficult for us to help you, because we've had to guess at what your 'real question' is.

Eela6 fucked around with this message at 21:09 on Mar 1, 2017

Feral Integral
Jun 6, 2006

YOSPOS

poo poo wrong thread n/m

tef
May 30, 2004

-> some l-system crap ->
As much as i'd like to retire this thread, well, it's almost a decade now, but it's been a long decade.

king_kilr posted:

I got started with Python a few months a go, I've been using it for exclusively web stuff so far, using Django. I really like it so far, I would say the best part is code is so readable.

Eela6
May 25, 2007
Shredded Hen
Well, why don't we make a new thread now, and we'll continue to support the old one while people migrate over?

I'm sure almost everyone will switch over by the end of the year!

We can call it PyThread 3. :can:

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Do I use 3 or 4 spaces in my docstrings if I'm using sphinx?

e: logging chat:

If I use a third party package to build an app, and that third party package has a logger already set up, should I just hook into their logger or should I need to create my own and keep them separated? The info that their logger outputs is useful to me; my extra log messages are just additional things I've added for my app.

Boris Galerkin fucked around with this message at 16:01 on Mar 4, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

Do I use 3 or 4 spaces in my docstrings if I'm using sphinx?

e: logging chat:

If I use a third party package to build an app, and that third party package has a logger already set up, should I just hook into their logger or should I need to create my own and keep them separated? The info that their logger outputs is useful to me; my extra log messages are just additional things I've added for my app.

Create your own logger and logging config.

Cingulate
Oct 23, 2012

by Fluffdaddy

huhu posted:

code:
def print_log(text_to_log):
    """
    Print text to log.txt file and command line
    """
    print(text_to_log)
    f = open("log.txt", "a")
    f.write(text_to_log + "\n")
    f.close()
Somewhat generally, if you want to print to a file, the recommended way is using a context manager:

code:
with open('filename.txt', 'a') as f:
    f.write('Appending a line to a file ...\n')
The print function also has a param to print to a file, if you only need to print strings, that can be a very terse way.

(Is it in general preferred to use print to print to files in those contexts where it works?)

Eela6
May 25, 2007
Shredded Hen
I personally use the print function for almost all text output, even if I'm writing to standard error. However, using file.write is totally fine - they're both clear to the reader.

Context managers are awesome.

Plasmafountain
Jun 17, 2008

Anyone got any recommendations for a method of creating animations (avi/mpeg/mp4) from a bunch of .png files? I've inherited a collection of code that does this with cv2 (I think) but its awfully put together and throws lots of errors with the l/w/h parameters.

Nippashish
Nov 2, 2005

Let me see you dance!
Any reason you can't use ffmpeg or avconv?

huhu
Feb 24, 2006

Zero Gravitas posted:

Anyone got any recommendations for a method of creating animations (avi/mpeg/mp4) from a bunch of .png files? I've inherited a collection of code that does this with cv2 (I think) but its awfully put together and throws lots of errors with the l/w/h parameters.

Virtualdub is pretty awesome. Just select fps, compression method, and any other settings and you get a nice video.

QuarkJets
Sep 8, 2008

Nippashish posted:

Any reason you can't use ffmpeg or avconv?

Yeah ffmpeg should do a flawless job and is made for doing this sort of thing. Invoke it with Popen if you want.

I don't know what your inherited cv2 implementation looks like, Zero Gravitas, but opencv uses ffmpeg libraries for creating movies and the cv2 movie-writing API is pretty straightforward. It shouldn't be more than 20ish lines. Maybe just rewrite it the correct way? Is there something funky about your inputs, like they sometimes come in with different sizes or something?

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!

Thermopyle posted:

Create your own logger and logging config.

Okay thanks, will do.



Another question:

I've been trying out pytest and it's really neat. My test codes look much cleaner than with unittest, but what I like the most is the colored red/green output. I do something like TDD so I'm constantly alt-tabbing or tmux pane switching etc to another terminal to re-run tests. Is there already an established way to tell pytest something like "monitor test folder x and re-run your tests every single time source code in folder y changes"?

And going further (but maybe too Vim specific) is there a way to have pytest color my vim status bar red/green depending on status so I don't even have to look over to the other terminal unless I need to read the status messages?

e: what would be even better is if it would add information to my vim status line, just something short like: "b3,r66; b8,r23", telling me that one test failed in buffer 3 on line 66 so I could just switch my vim buffer directly to "3" and then see which test failed.

Boris Galerkin fucked around with this message at 15:34 on Mar 5, 2017

Dex
May 26, 2006

Quintuple x!!!

Would not escrow again.

VERY MISLEADING!

Boris Galerkin posted:

I've been trying out pytest and it's really neat. My test codes look much cleaner than with unittest, but what I like the most is the colored red/green output. I do something like TDD so I'm constantly alt-tabbing or tmux pane switching etc to another terminal to re-run tests. Is there already an established way to tell pytest something like "monitor test folder x and re-run your tests every single time source code in folder y changes"?

pytest-xdist gives you a watch option(-f).

quote:

And going further (but maybe too Vim specific) is there a way to have pytest color my vim status bar red/green depending on status so I don't even have to look over to the other terminal unless I need to read the status messages?

e: what would be even better is if it would add information to my vim status line, just something short like: "b3,r66; b8,r23", telling me that one test failed in buffer 3 on line 66 so I could just switch my vim buffer directly to "3" and then see which test failed.

i haven't used vim for actual dev in a while, but are you using some plugin like python-mode or just rolling your own config? maybe do something like run pytest on save and check for v:shell_error instead of watching?

personally i just use pycharm and toggle auto-test on though

Dominoes
Sep 20, 2007

Eela6 posted:

I can only type with one hand because of health issues, so it will take a little longer than that. But I'm happy to do it.

Thermopyle posted:

I've got a new thread for Python pretty much ready to go from a couple years ago, I just never got around to posting it.

I'm going to do it if y'all don't.

Eela6
May 25, 2007
Shredded Hen

Dominoes posted:

I'm going to do it if y'all don't.

Please do! It is painful for me to type more than a little at a time, so I am happy to pass the buck.

Eela6 fucked around with this message at 21:03 on Mar 5, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

I'm going to do it if y'all don't.

Don't forget that google doc i posted. If you want to use it, it should mostly be copy/paste with some updates for modern python.

Dominoes
Sep 20, 2007

Ha! Just clicked this as I'm drafting one; we have the same idea about the opener! Merging them now.

Dominoes fucked around with this message at 23:27 on Mar 5, 2017

Dominoes
Sep 20, 2007

Draft.
CAO March 2017
Python code:
import this

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
About
Python’s a high-level language featuring code that’s easy to learn, read, and write. It’s popular, has a robust collection of third-party modules, and a large community willing to help. It’s friendly to multiple programming styles; procedural and functional; object-oriented, or not. Generally, it runs slowly compared to other languages; eg C, Java, Julia, Rust, and Haskell.

Python is versatile, and is especially popular for scientific computing and web development. It’s not suitable for systems programming, and is weak when dealing with distributable stand-alone programs.

What makes Python different from other languages?
-Significant whitespace. In other words, you don’t use braces to indicate blocks of code, you use indentation.
-Duck typing.  If it walks like a duck…. What this means is that Python doesn’t care about the actual type of the objects you’re working with as long as the object implements the correct attributes and methods. Note that Python is also strongly typed, meaning that you can’t can add a string, a number, and a file object together to get some guessed-at result.
-Batteries included. Python comes with an extensive standard library.


General links
Official docs
Style guide
Official third-party package repository
Pyhon subreddit, Subreddit for beginners


Learn
Automate the Boring Stuff Dive into small projects
Codeacademy provides interactive exercises.
MIT OpenCourseware
Think Python


Installing Python and third-party packages
There are two main paths for installing Python. If you’re new, download Anaconda; it has many common third-party packages built-in. You can install additional packages later, with its conda package manager, or using the official one, pip. Enthought Canopy is similar to Anaconda.

You can also install Python directly from the Official downloads page.The default links on this page are for x86-versions; browse to the OS-specific pages to find the 64-bit downloads.

If you’re on Linux, you probably have Python installed already – perhaps multiple versions… be careful!

Third-party packages can be installed with the built-in package manager pip. Just run pip install packagename. Or create a text file of package names, and install with pip install -r requirements.txt. Packages that include code from other languages like C may work this way, or you may have to install using your system package manager (ie in Linux), or installers from This page on Windows. Anaconda users can install most packages with conda install packagename.


Selected third-party packages
  • Requests - for making web requests with easy syntax
  • Pytest - unit tests; cleaner than the built-in module.
  • SQLalchemy - for working with databases.
  • BeautifulSoup - for parsing HTML and XML. Recommended over a built-in alternative
  • Websockets – Live communication betweeen browser and server.
  • PyQt5 Lets you use the C++ GUI library Qt with Python
    . Steep learning curve, but QT is a powerful, well-documented way to make desktop and mobile GUIs. Used by Ipython Qtconsole, and Spyder.
  • Toolz - functional programming tools like currying, accumulate, take, compose, and pipe. Some of this functionality's included in the built-in itertools and functools libraries, or is easily created from them. You should check those libraries out too!


Virtual environments
Check out virtualenv and related tools. Virtualenv is a tool to create isolated Python environments.

The introduction explains what it is and why you want want it. Many people use virtualenvwrapper to make working with virtualenvs easier.Virtualenv-burrito makes setting up the two easy. Anaconda has its own virtual-environment tools.


Scientific computing
The Scipy Stack is a collection of modules that expand python’s numerical-computing capability. They work well together, but learning when to use each package can be tricky. The Python Data Science Handbook, linked below, can help. All of these packages can be installed with conda; most with Pip.

Numpy: Provides a multi-dimensional array data type that allows fast vectorized options. Great for linear algebra, and nearly all numerical computing in Python relies on it.

Scipy – A collection of unrelated tools, divided into submodules. Includes modules for statistics, Fourier transforms, scientific constants, linear algebra, signal processing, image manipulation, root-finding, ODE-solvers, and specialized functions (Bessel etc) etc If you're considering implementing a common scientific operation by hand, check Scipy first.Documentation here

Matplotlib– Plotting. Robust and flexible. Has two APIs, both of which are awkward.

Sympy – symbolic computation. Manipulate equations abstractly, take derivatives and integrals analytically, manipulate variables.

Pandas – Used in statistics and data analysis; wraps Numpy arrays with labels and useful methods.

Ipython / Jupyter. Exists as three related components: Ipython terminal: A powerful improvement over the default. Ipython QtConsole: Similar to the terminal app, but has advantages provided by a GUI. Notebook: Work on pages of mixed code, LaTeX, and text on redistributable web pages. Set to be replaced by a new project called Jupyter Lab

Related: Scikit-learn is a machine-learning package with a simple API. Solves classification, regression, and clustering problems with a range of techniques. Tensorflow and Theano provide neural net frameworks.


IDEs
PyCharm Robust and full-featured. Its community edition is free, and works well for Python. Its Profession edition costs ~$60/year, and includes addition features like web-development tools. Free for students and contributors to open-source projects.

Spyder is targeted at scientific computing, and is simpler than PyCharm. Can be installed with pip, and is included with Anaconda.

If you'd prefer a text-editor with language-specific features, try Visual Studio Code or Atom


We development
Python is great for server-side web development, when paired with one of these packages:
Django – Batteries-included and popular. Intimidating to start with, and involves many files working together, but includes most of what you need to build a website. Extensive docs, and many people who can help on StackOverflow.

Flask Minimalist, and easy to start with. Customizable. As your projects grow, you’ll likely want to add other modules for things like database management, migrations, admin, and authentication.

Pyramid and Pylons are other popular frameworks.This page shows an overview of what's available.

Warning: Diving into these packages directly can be challenging if you’re new to web development, since it requires proficiency in several skills. I recommend learning Python, database basics, HTML, CSS, and Javascript independently first.

Heroku is a service that makes hosting Python websites easy; it has free plans for development, and can quickly scale up for production use.


Alternatives
For scientific computing: Julia is fast, and has more natural syntax for math and equations. Similar syntax to Python; it’s easy to pick up one if you know the other.
code:
f(x) = 2x^2
Python code:
f = lambda x: 2 * x**2
Pure functional programming: Haskell has a steep learning curve, and is a robust functional language. Is a high-level langauge like Python.

Statistics and data analysis: R. Specialized, popular language with a large collection of stats packages.

Web development: Ruby on Rails is another high-level framework with nice syntax.


Complementary languages
C: Python runs on C, so it's a natural language to write high-speed extensions in.
HTML, CSS, Javascript, and JQuery for web development.
SQL, if you use Python to manage databases.


Expanding Python into new realms
PyPy is a Just-in-time (JIT) compiler for Python that allows a subset of the language to run very fast.

Numba is another way to speed up Python to near-C-speeds with a JIT. By applying a decorator, can make python functions run much faster; but limits which parts of the language you can use in these functions. Usually requires writing out loops manually, where otherwise you might used vectorized code.

Micropython allows you to code custom microcontrollers with Python.


Neat specialized tutorials
Python Data Science Handbook – Introduction to scientific programming in Python.
Kalman and Bayesian Filters in Python – A detailed introduction to Kalman filters, making heavy use of Python.


This OP’s a community effort; post in the OP or PM-me for updates and edits.

Dominoes fucked around with this message at 15:03 on Mar 6, 2017

Cingulate
Oct 23, 2012

by Fluffdaddy
Put Neural Networks under Scientific Computing.

You're using print in command mode in the 2nd example with print.

Your quotes are not ASCII, so I can't copy-paste your code examples :v:

List comprehensions are the best thing ever so why not feature them in one of the examples?

I also use Anaconda and I think most of us do, but shouldn't Canopy Enthought at least get a mention?

Dominoes
Sep 20, 2007

Done. Sorry Therm - I'm really butchering your material!

Dominoes fucked around with this message at 00:38 on Mar 6, 2017

Eela6
May 25, 2007
Shredded Hen
It might be fun to have

Python code:
new_features = [r'await/async',
 'better dictionaries', 
'formatted string literals'
'@ operator for matrix multiplication'
'type hints']
print(f"new in python: {new_features}")


Also a "why use Python"
interpreted -> fast write, run, tweak loop
readability
ease of use
scientific and numeric tools
power of multiple programming paradigms,
metaprogramming, operator overloading, and other dynamic Lang tricks
__double_underscore_methods__


Why not:
Interpreted, dynamic - whole class of errors that could he avoided with typechecking compilers
Interpreter overhead / slow
Portability issues / resolving dependencies, toolchain
GIL/Concurrency/Parallelism issues
Metaprogramming, operator overloading and other dynamic lang tricks dangerous

Eela6 fucked around with this message at 00:59 on Mar 6, 2017

Nippashish
Nov 2, 2005

Let me see you dance!
The code examples probably aren't useful. People don't read megathred OPs to learn the language. They're also a really big thing to put before the main content. They'd be better in a second post if you must have them.

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

I agree Nip; going to cut them entirely.

  • Locked thread