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.
 
  • Post
  • Reply
Dominoes
Sep 20, 2007

CAO Apr 2020
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 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, and not. Generally, it runs slowly compared to other languages like C, Go, 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 making 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: 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. 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.
-Extensive standard library.

Python has a split userbase between (incompatible) versions 2 and 3. Many old code bases use v2. Highlights: The versions handle character encoding differently, v3 uses lazy evaluation in the standard library when possible, and v3 includes many new features.


General links


Learn


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.

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. Using virtual environments is especially important on Linux; altering the system python may break your OS. See the Virtual environments section below.

Third-party packages can be installed with the built-in package manager pip. Run pip install packagename. Or create a text file of package names, and install with pip install -r requirements.txt. Anaconda users can install most packages with conda install packagename.

Consider using Poetry or pipenv to install packages, rather than using pip and virtual environments separately. Use commands like this: pipenv install requests, or pipenv install, if you already have a pipfile established. (pipenv creates and manages this file automatically).


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 Matplotlib, 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
Using virtual environments lets you isolate a project's dependencies from your system's Python installation. This is important on Linux, where altering the system Python can break your OS, and useful on any OS to keep packages separate and easy-to-manage.

Official python virtual environment reference. Consider using pipenv instead of this directly; it combines workflows for package management and virtual environments. You can access the environment from a terminal using commands such as pipenv shell, or pipenv run, followed by a command.

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.

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.


Code editors
  • 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.


Web 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. Check out Tango with Django for a Django tutorial. huhu posted a Flask intro in this thread.

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

Microcontrollers
Micropython allows you to run Python on embedded systems.

Additionally, Python has good library support on single-board-computers like the Rasperry Pi.
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
Prototyping, and other fast-to-develop programs that compile to native binaries: Go.

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. Rust provides a modern alternative.
  • HTML, CSS, and Javascript 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, it can make python functions run much faster, but limits which parts of the language you can use in these functions. It usually requires writing loops manually, where otherwise you might used vectorized code.
  • Micropython allows you to code custom microcontrollers with Python.


Neat specialized tutorials



(By Randall Munroe)

This OP’s a community effort; PM me for updates and edits.

Dominoes fucked around with this message at 16:22 on Apr 23, 2020

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

You're catching the TypeError before it occurs; ie once you've gotten thing.foo, you have no more error checking, and 10 doesn't have any keys.

@property makes methods look like properties; I think they're for writing Java-style code. I wouldn't use them, since they mask that calculations are being run.

Boris Galerkin posted:

Basically I want a dict/container object that has a default return value when I don't give it an index or key or whatever. If I do then I want it to return the value of that key, which internally in my class is saved as a dictionary.
I'm not sure this is a good idea - you're trying to treat it as two different types of objects based on context. Here's a snippet that does what you ask, although as a function rather than a class.
Python code:
def try_this(my_dict: dict, key) -> Union[dict, int]:
    DEFAULT = 10
    try:
        return my_dict[key]
    except KeyError:
        return DEFAULT
    

my_dict = {'a_key': 20, 'b_key': 30}

print(try_this(my_dict, 'a_key'))  # 20
print(try_this(my_dict, 'not_a_key'))  # 10
Or if you use it a lot:

Python code:
try_my_dict = functools.partial(try_this, my_dict)


try_my_dict('a_key')  # 20
try_my_dict('not_a_key')  # 10
Not sure if this helps, but are you familiar with dict's get method? It'll return a default of your choice if it can't find the key.

Dominoes fucked around with this message at 21:24 on Mar 8, 2017

Dominoes
Sep 20, 2007

And I'd like to clarify: That type annotation's not accurate for the function I posted; I got confused part way through about what Boris wanted. Union[dict, int] means it could return either a dict or int. As posted, my example was really just int, or Union[Any, int] if you expect to pass it arbitrary dicts.

Dominoes
Sep 20, 2007

I like being able to get an idea of what the function does by looking at its signature.

Dominoes
Sep 20, 2007

Objects are nice if you're defining something that can be thought of as a datatype, or if you're using a collection of similar items.

Dominoes
Sep 20, 2007

namedtuple unless it's mutable, or would benefit from methods.

Dominoes
Sep 20, 2007

I'm mostly repeating what Eela and Epsilon said:

It doesn't matter what tools you use at this point. Atom and Visual Studio Code are simple, good text editors.

Spyder's an IDE that's easy to use; you could try that as well: 'pip install spyder' in a terminal. You might like it because it has a console built in, and buttons to run your code. Don't mess with PyCharm yet; it can be overwhelming while you're learning.

Installing Anaconda will make installing third-party packages easier.

Dominoes
Sep 20, 2007

Linked to huhu's post in OP.

Dominoes
Sep 20, 2007

I've been using wrappers like this if I'm working with dataframes and the speed is a limitation. Lets you use Pandas' descriptive row and column indicies instead of integers, while maintaining the speed of working with arrays. Pandas DFs can be orders-of-magnitude slower than arrays.

Python code:
class FastDf:
    def __init__(self, df: pd.DataFrame, convert_to_date: bool=False):
        """Used to improve DataFrame index speed by converting to an array. """
        if convert_to_date:
            # Convert from PD timestamps to datetime.date.
            self.row_indexes = {row.date(): i for i, row in enumerate(df.index)}
        else:
            self.row_indexes = {row: i for i, row in enumerate(df.index)}
        self.column_indexes = {col: i for i, col in enumerate(df.columns)}
        self.array = df.values

    def loc(self, row, col):
        return self.array[self.row_indexes[row], self.column_indexes[col]]

    def loc_range(self, row_start, row_end):
        return self.array[self.row_indexes[row_start]: self.row_indexes[row_end]]

Dominoes fucked around with this message at 12:09 on Mar 31, 2017

Dominoes
Sep 20, 2007

funny Star Wars parody posted:

I got promoted to developer recently and my first project has been building a file directory browser in php and Ajax and HTML and it's a fuckton to take in in two weeks so ya idk what it is with web stuff that is so hard to learn (probably all the acronyms and different languages/frameworks interfacing) but ya appreciate it! Flask looks like the way to go 😊 thanks!
Yo dawg. Web dev is hard because there are a lot of independent skills you need to learn. You need databases, backend-frameworks, HTML, CSS, JS. AKAX, migrations and whatever extra frameworks you're adding. You'll probably have to find independent tutorials for each. It's a pain at first, but keep at it!

Re Flask vs Django: Django for websites, Flask for other things you need a webserver for. Flask becomes a pain once you start adding plugins for things like admin, auth, migrations, databases etc.

Dominoes fucked around with this message at 02:35 on Apr 1, 2017

Dominoes
Sep 20, 2007

Explicit is better than implicit... ;)

Dominoes
Sep 20, 2007

QuarkJets posted:

Wouldn't that necessitate also specifying that the step size is 1, then?
Oh poo poo.

Dominoes
Sep 20, 2007

Whatever, nerd.

Dominoes
Sep 20, 2007

Broad topic. Many python modules use C code to improve speed. When installing them from source, (Including pip without a wheel) you'll need a compiler; Visual C++ is used in Win. Which package are you referring to? You can usually avoid this by using Conda, or a Chris Gohlke binary.

To speed up Python, you can use Cython, Numba, vectorized code, PyPy etc, on the bottlenecks. What specifically do you want to know?

Dominoes
Sep 20, 2007

Whoah - I always assumed they leaked, and set my vars up so it wouldn't be an issue. FYI, javascript uses a 'let' command that explicitly makes a variable nonleaky.

Dominoes
Sep 20, 2007

PyCharm doesn't like to work with files unless they're in a folder that includes PyCharm meta files (.idea directory). Maybe that's it?

Dominoes
Sep 20, 2007

Cingulate posted:

Different question: does Continuum make money? What are the chances "conda install all_the_software_i_need" won't work in 2018 because Travis Oliphant has to choose between making it slightly easier for me to set up numpy or feeding his kids?
Switching to Pip and binaries is not a big deal.

onionradish posted:

As a Python user on Windows, I'd put Christoph Gohlke in the same "I hope nothing ever happens to him" category. His "Unofficial Windows Binaries for Python" site has been a project lifesaver on more than one occasion.
Yes def. I've found non-Conda python on Windows easier than Ubuntu, since for packages that don't install well via pip, his binaries always work, while apt-get is a crapshoot, and probably out-of-date. And I still can't figure out how to deconflict the multiple versions of OS python, ie 2.7, 3.5 and 3.6 all at once

Dominoes fucked around with this message at 18:46 on Apr 18, 2017

Dominoes
Sep 20, 2007

Azuth0667 posted:

I'm not sure what this would be called but, is there anything for python gui making that is similar to what VB.net has where you can place all the widgets on a template?

I've been slamming my face into tkinter with little to no progress for long enough that I'm ready to try something new.
Qt Creator (Designer?). It's a WSIWYG editor, but learning how to use Qt is difficult.

Dominoes
Sep 20, 2007

XLSXwriter can do pretty-much everything, but it's missing some useful abstractions. Ie the code will be kind of brute force, iterating over row indexes etc. The API and docs's nice. I don't know how it compares to OpenPyxl; they're both popular, full-featured libraries; after researching which to go with, I ended up neutral, and picked writer arbitrarily. Those are the only two full-featured, modern libraries.

Dominoes fucked around with this message at 11:58 on Jun 1, 2017

Dominoes
Sep 20, 2007

__init__ is boilerplate used in classes. Its most typical use is to convert arguments that are supplied when creating instances of the class into class-scope 'self' variables. Ie:


Python code:
class Snake
    def __init__(self, age, personality,  adult):
        self.age = age
        self.personality = personality
        self.adult = adult
You could also add other things to pre-calculate. This example also includes how you'd access these 'self' variables you're creating.
Python code:
class Snake
    def __init__(self, age, personality,  adult):
        self.age = age
        self.personality = personality
        self.adult = adult

        self.length = age * 5 if adult else age * 10

    # Another double-underscore function demonstrating how the arguments you give the new class 
    # instance are now available by self. - prefixed methods; see what it's for below.
    def __string__(self): 
        return f'{A {self.personality} snake {self.age} years old'
When you create an instance like this, it runs the code in your __init__ method.
Python code:
martha = Snake(5, 'friendly', True)

print(martha)  # A friendly snake 5 years old
__main__ is boilerplate used when executing your file directly. ie:

Python code:
if __name__ == "__main__":
    run_all()
Code structure is a complex, nuanced subject that depends on your project and personal preference. Dive into a project and experiment, then ask specific questions about it when it comes up. Same for when to use classes. Some people use them everywhere as abstract chunks of code. I prefer them for relatively concrete things that have many instances, things like the snake example above, or for creating new data types.

Dominoes fucked around with this message at 12:18 on Jun 1, 2017

Dominoes
Sep 20, 2007

Good point I missed: If you run_all() at the end without __main__, your code will run whenever it's imported. __main__ will only run if you load your script standalone.

Dominoes
Sep 20, 2007

PyCharm and Anaconda aren't mutually exclusive.

I apologize if I'm saying things you know already, but would you please describe exactly what steps you did to install the packages, then use them? To install packages, do this:

code:
conda install numpy

# or, 

pip install numpy
You can check which packages are installed by using this:

code:
pip freeze 

# or

pip list

# or

conda list  # Which you said you tried.
Note that conda includes many packages by default

Import and use packages like this:

Python code:
import numpy as np

np.linspace(0, 1, 100)
I think one of Anaconda's downsides is the confusion over having two separate package managers. I'm hoping this is easy to troubleshoot; you're on windows, so you don't need to worry about having 3 separate versions of Python installed.

Dominoes fucked around with this message at 13:38 on Jun 4, 2017

Dominoes
Sep 20, 2007

LochNess - I don't know what the Anaconda prompt is, but by default, the Anaconda installer should add Python and related tools (pip, jupyter qtconsole etc) to your system path, exposing them to a normal terminal. Anaconda does include Python. If these aren't set up, do this: press winkey, type 'environment', press enter, click 'Environment Variables', edit Path, and add your Python scrips path... Someone who's using Ananconda can tell you what it is; for stock python, it's something like 'C:\Users\UserName\AppData\Local\Programs\Python\Python36\Scripts'.

Open powershell or command prompt. Type 'pip list' or 'conda list'. What do you see?

Dominoes
Sep 20, 2007

LochNessMonster posted:

None of the commands (search / list / install ) give any output at all. Just a blank line and then a new prompt.
Did you do what I suggested? This should not happen; if there's an install or path problem, your output should be this:

code:
pip : The term 'pip' is not recognized as the name of a cmdlet, function...
Since you're trying to use spyder... What happens if you type 'spyder3' (or 'spyder'; not sure how Anaconda configures it) in powershell?


Do this exactly:
-Press the win key
-type 'powers'; press enter
-type 'pip list'; press enter
-Post the output here.

Dominoes fucked around with this message at 16:50 on Jun 4, 2017

Dominoes
Sep 20, 2007

Like baka said, don't worry about the Anaconda shell.

Conda makes installing binary packages easy, and uniform across WIndows, Mac and Linux. Your alternative is to use installers from this site for packages pip gives you errors with.

It's up to you whether you want to use conda or pip; try them out and make your own choice, or better yet, pick one and don't worry about it yet. I chose to stick with pip only, and ditched Anaconda, because dealing with two separate package managers was confusing; you still have to use pip for packages that aren't on conda.

Dominoes
Sep 20, 2007

I recommend stop trying to run the anaconda shell (I assume that's what typing 'anaconda' in powershell does) until you sort the basics out. It seems like a big stumbling block, and is unnecessary. Viking - if you're right about pip being tied to a prev install, he can test by running 'python' in powershell, and checking if 'Anaconda' appears in the Python console's header.

I think the best option is a clean install. Use the 'Add or Remove Programs' tool in Windows to remove everything with the name Python or Anaconda in it. Run either the Anaconda, or Python installer again, and we'll go from there if you have any issues. Fixing the path is easy (I posted instructions earlier for the non-Anaconda version), but I think it's best you start fresh.

Dominoes fucked around with this message at 13:24 on Jun 5, 2017

Dominoes
Sep 20, 2007

LochNessMonster posted:

That last post was after a complete uninstall and reinstall of Anaconda. I checked if there were any Python related programs in the Programs/Features list but there weren't.

After this reinstall I selected the option to add the executables to the PATH. When the installer was done the pip command gives results back in powershell but conda commands don't do anything. Id it was a PATH issue I'd expect an error message saying the executable can't be found.

Should I try to uninstall and see if miniconda works?

Edit: The anaconda command was just to see if that did work. Everything I did was in powershell.

edit2: system variable path includes the following directories

code:
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\Library\mingew-w64\bin
C:\ProgramData\Anaconda3\Library\usr\bin
C:\ProgramData\Anaconda3\Library\bin
C:\ProgramData\Anaconda3\Scripts

Type 'python' in powershell. What do you see? I'm out of ideas.

Dominoes
Sep 20, 2007

Loch - I've no idea why the Anaconda-specific commands aren't working.

shrike82 posted:

Do most of you run Python in Windows?

Package issues like this and the difficulty getting tensorflow running on Windows drove me to a dual boot Ubuntu setup.

It's a pain in the rear end to setup but I've found switching to a Linux build helpful in mitigating stuff like this.
Have you tried getting Python 3.6 running in Linux without Anaconda? That was really frustrating for me, and I never got it working!

Dominoes fucked around with this message at 12:16 on Jun 6, 2017

Dominoes
Sep 20, 2007

Dex posted:

were you trying to replace the system python version, because you really don't ever want to do that. building from source with configure, make and make altinstall then using python3.6/pip3.6 works fine for me on centos7. literally did this today as part of an automated setup for a vm i need to do stuff on
I tried everything! At one point I had all 3 versions installed at once, but couldn't get pip to work with 3.6. Somehow broke my system beyond repair (ie fixing would be more difficult than starting fresh) troubleshooting it.

Dominoes fucked around with this message at 14:32 on Jun 6, 2017

Dominoes
Sep 20, 2007

I think the break involved trying to uninstall 3.5 or 3.6. Multiple versions on the system is awkward at best. In the future, I'd use Anaconda, which sets up things up nicely automatically, or virtual environs. There's probably a clean way to get 3.6 working in Ubuntu, but googling and troubleshooting for hours didn't do it; I'm classifying this one as difficult. It's comparatively straightforward in Windows, due to the lack of system python, and a nice official installer.

Dominoes fucked around with this message at 05:07 on Jun 7, 2017

Dominoes
Sep 20, 2007

Your avatar is ridiculous.

Dominoes
Sep 20, 2007

Eela6 posted:

I agree. Differential equations are prone to all sorts of numerical analysis problems. Don't roll your own solutions - use a known stable algorithm.
Not related to this, but the state of ODE solvers is not very good: If you need anything other than a basic solver (like those offered by scipy.integrate), you will have to roll your own, or use poorly-documented libs(like scikit odes, and another that escapes me). I had to roll my own rk4 due to having to interrupt the solver when certain conditions are met, and had multiple objects. (I think you can do either, but not both with scipy). There are alternatives that claim to do both, that I couldn't get working, and have awful APIs.

Dominoes fucked around with this message at 19:41 on Jun 17, 2017

Dominoes
Sep 20, 2007

Update on the status of pip on windows: It works pretty good! Here's my requirements.txt; you need to install numpy+mkl, scipy, and llvmlite via Chris Gohlke installers (numpy on its own works fine in pip, btw); the rest will pip install, assuming you have C++ build tools 2015; the link to DL that shows up in the error you get for not having it installed.

Python code:
# Install the following packages from Chris Gohlke's site:
# numpy-mkl
# scipy
# llvmlite (Numba prereq)

# Some of the packages below require MS VSC++ build tools; link will show
# in the terminal when attempting to install.

# Scipy stack
pandas
matplotlib
jupyter
sympy


# Science extras
pandas-datareader
scikit-learn
numba  
scikit-image
pillow
seaborn


# Misc
PyQt5
django-toolbelt
twine
wheel
requests
requests_oauthlib
pytest
h5py
toolz
cytoolz
beautifulsoup4
lxml
sqlalchemy
saturn
fplot

Dominoes fucked around with this message at 05:17 on Jul 1, 2017

Dominoes
Sep 20, 2007

Additionally, the builtin math.isnan and np.isnan work on several nan-like-types.

Dominoes
Sep 20, 2007

Hadlock posted:

For those who have used VS Code in the last ~6 months (the vscode product has changed/improved a lot since early last year) What's the delta between vscode and pycharm these days once you plugin the top two or three vscode python plugins? I've been using vscode now for a little over a year writing Go, Powershell, Bash etc and trying to see if the jump to pycharm CE is worth it for Python.
Pycharm for large, multi-file projects. VSCode for editing individual files.

Dominoes
Sep 20, 2007

Like, Intel Inside and Gateway2000 stickers?

Dominoes
Sep 20, 2007

Is there a package out there that simply requires the scipy stack? (numpy, scipy, pandas, jupyter, sympy, matplotlib) Like django-toolbelt. I didn't find anything.

edit: There is now.

Dominoes fucked around with this message at 21:22 on Sep 12, 2017

Dominoes
Sep 20, 2007

Thirding Anaconda; a stock installation should do.

Dominoes
Sep 20, 2007

Thermo and public each gave you a valid answer; this is a pain point in Anaconda: You have two separate package managers, and packages may need to be installed in a mix of the two.

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

Hey dudes, I set up some Powershell scripts to automate installing a calculator-like virtual env.

Running the setup script does the following:
-Creates a virtual environment in the directory you downloaded the scripts
-Installs the scipy stack, PyQt, and Spyder. (Downloads Scipy and its numpy+MKL prereq from Chris Gohlke's site, then the rest from PyPi. See this for why this is currently necessary; something to do with a Fortran compiler license)
-Setups up shortcuts that run Qtconsole or Spyder in that env.

I made bash scripts to do the same, but can't test it since my Ubuntu version has broken venvs. Might try setting up a special ipython config to automatically import numpy as np etc, but haven't figured out how to do that on a per-env or per-instance basis. Stack Overflow post I made describing my troubles here.


Related: Spyder feels appropriate for this type of use; I didn't give it a chance before, but it's great for writing and running one-off scripts for solving math and science problems.

Dominoes fucked around with this message at 16:21 on Sep 22, 2017

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply