|
Nippashish posted:Its a convention that more or less everyone follows, like using snake_case instead of camelCase for variables or naming classes with PascalCase instead of something else. I've never encountered anyone with strong opinions about it though.
|
# ¿ Dec 1, 2016 05:43 |
|
|
# ¿ May 8, 2024 21:38 |
|
Hey dudes, running into issues scraping this image: http://www.feynmanlectures.caltech.edu/img/FLP_I/f16-01/f16-01_tc_big.svgz Getting 403s, despite having a user agent header. Ie: Python code:
|
# ¿ Dec 6, 2016 21:11 |
|
If you click the link above, it'll work. These guys have complained about people scraping the site before, so I suspect they're doing something deliberate; can't figure it out!
|
# ¿ Dec 6, 2016 23:44 |
|
taqueso posted:Clicking that link 403s for me. Maybe it would work if you set the referrer header to their site? Dominoes fucked around with this message at 00:28 on Dec 7, 2016 |
# ¿ Dec 7, 2016 00:09 |
|
mystes posted:Can you even do this in MyPy? If OrderedDict is just a normal class, isn't there no way for MyPy to understand that it should actually take type parameters? Surely this is why you need the separate "typing" namespace? I'm don't know if there's a clean solution to this. You could probably call it a Dict and things would mostly work out. (although you're losing some of the self-documentation value; add a comment?). Or leave it as OrderedDict, but skip defining the key/val types. Here's a SA post with another thought: post
|
# ¿ Dec 19, 2016 04:15 |
|
Hey dudes; trying to run a java file from Python, using subprocess. It's not doing anything. The most basic example:Python code:
Python code:
|
# ¿ Jan 12, 2017 20:36 |
|
Thansk for the subprocess words. Got it sorting using that advice!
|
# ¿ Jan 14, 2017 15:26 |
|
Anecdote of the current state of installing Python packages that include C/Fortran code in windows with pip instead of conda: The following packages work without a problem (Ie I loaded them in a requirements.txt, then 'ran pip install -r requirements.txt'.) numpy pandas matplotlib jupyter sympy PyQt5 keras requests requests_oauthlib pytest toolz cytoolz beautifulsoup4 django-toolbelt The following required Chris Gohlke's site: scipy scikit-learn h5py tables Numba installs from pip only after installing llvmlite from CG's site. Dominoes fucked around with this message at 12:05 on Jan 21, 2017 |
# ¿ Jan 21, 2017 00:25 |
|
pdfminer works well enough, but is slow.
|
# ¿ Jan 21, 2017 17:07 |
|
No Safe Word posted:
This is the way to handle it: code:
|
# ¿ Feb 2, 2017 00:56 |
|
Hey dudes. How do I make pip work with Ubuntu on Python 3.6? Ie pretend I'm an idiot and need basic instructions. I've been using Anaconda for a while on Windows and Ubuntu. Thought I'd try 3.6 on Windows, so uninstalled Anaconda, and got 3.6 up and running smooth by installing packages with pip from a requirements.txt, and a few from Chris Gohlke's site. Trying on Ubuntu, now, and it's a mess. There's a beta in the official packages you can run with 'python3.6', and a source dist on python's site that I can get sort of working (make works, but make install crashes, and it sort of works, but the files are in th wrong place?), and there are some unofficial repos. In all cases, I can't get pip to work with the 3.6 install. Any ideas, other than going back to Anaconda? The main issue seems to be having 3 version of Python floating around. The command 'python3.6 -m pip...' results in an error: 'ModuleNotFoundError: No module named 'pip._vendor' edit: After experimenting with the default 3.5 setup, the amount of packages that won't install with pip's about the same as on Windows! Rather than CG's site, these can be installed with 'sudo apt install'. Packages that install with pip in Win and Ubuntu: code:
code:
code:
Dominoes fucked around with this message at 15:42 on Feb 3, 2017 |
# ¿ Feb 3, 2017 13:56 |
|
Eela6 posted:Scipy is notoriously finicky. My honest advice is to start with anaconda and expand on it with pip from there. I know that's not what you want to hear, but it's probably the easiest solution. The good news is Anaconda is finally up and running with Python 3.6! Dominoes fucked around with this message at 12:53 on Feb 4, 2017 |
# ¿ Feb 4, 2017 12:47 |
|
Thx. It installs fine from CG's site on Win, and sudo apt install on Ubuntu; I was hoping it'd work with pip, now that pip supports binary wheels.
|
# ¿ Feb 4, 2017 15:46 |
|
A few highlights: -Built-in functions tend to return iterators rather than lists. Ie range(), .items(), map() etc. -Division doesn't auto-round. -string encoding is handled differently -print is a function -Python 3 supports a number of new features. I'd just dive in, and fix things as they break. You can try the new features once you're comfortable with the changes. Dominoes fucked around with this message at 22:02 on Feb 7, 2017 |
# ¿ Feb 7, 2017 21:59 |
|
Hey dudes. Looking to see if there are pre-built solutions that would help for a project I'm going to undertake for work. I'm trying to build a scheduler app for a flying club. In early planning stages. Currently, we have a white board, and magnetic name tags we shift around. The schedule changes frequently, and there are different qualifications, training requirements etc each person maintains that place constraints on the scheduling. Subject to chaos, people getting sick, last-minute changes etc. Thought 1: Scheduling? Aren't there a bunch of already made solutions, since it's such a common task? Thought 2: This seems like a unique use case, with many non-standard variables; roll your own rather than fit a square peg in a round hole. Thoughts?
|
# ¿ Feb 9, 2017 22:52 |
|
Munkeymon posted:Sounds like you want a rules engine.
|
# ¿ Feb 11, 2017 02:44 |
|
Rosalind - Python's a general-purpose language, so the tools you need for things like statistics will be included in third-party packages. Finding the right package, and info on how to use it can be confusing, as you've found out. Like Quarkjets said, start with Anaconda, since the packages you need will already be included. The packages you need in this case are pandas (to read the CSV, and do some stats), and scipy.stats, and statsmodels for the anaysis. Post what you're specifically looking for, or post equivalent R code, and we'll give you example code. Translating between Python and R is usually easy. Dominoes fucked around with this message at 11:29 on Feb 11, 2017 |
# ¿ Feb 11, 2017 11:12 |
|
Munkeymon posted:There aren't some already kicking around out there?
|
# ¿ Feb 13, 2017 20:05 |
|
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.
Dominoes fucked around with this message at 17:16 on Feb 27, 2017 |
# ¿ Feb 27, 2017 17:05 |
|
Isn't that by the guy who ranted about Python 3 in the old V, then justified it recently with odd reasoning?
Dominoes fucked around with this message at 19:13 on Feb 27, 2017 |
# ¿ Feb 27, 2017 19:09 |
|
Thanks for the Udacity rec. The guy looking for the rec is new to programming, other than a C++ course in college a decade ago.
|
# ¿ Feb 27, 2017 19:28 |
|
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? 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.
|
# ¿ Feb 27, 2017 19:43 |
|
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 |
# ¿ Feb 27, 2017 20:45 |
|
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.
|
# ¿ Mar 5, 2017 17:51 |
|
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 |
# ¿ Mar 5, 2017 23:23 |
|
Draft. CAO March 2017 Python code:
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
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:
Python code:
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 |
# ¿ Mar 5, 2017 23:37 |
|
Done. Sorry Therm - I'm really butchering your material!
Dominoes fucked around with this message at 00:38 on Mar 6, 2017 |
# ¿ Mar 6, 2017 00:26 |
|
I agree Nip; going to cut them entirely.
|
# ¿ Mar 6, 2017 01:58 |
|
VC Code feels like a faster Atom.
Dominoes fucked around with this message at 14:16 on Mar 6, 2017 |
# ¿ Mar 6, 2017 14:11 |
|
Thread's up. Still looking for additions and edits.
|
# ¿ Mar 6, 2017 15:36 |
|
VikingofRock posted:Maybe add some stuff about Python 2 vs. Python 3? Someone new to the language is bound to have questions about it, since it comes up fairly often in Python discussions, and there is still a lot of Python 2 code floating around out there (particularly in scientific circles). Even if the section is just "Python 3 is better and you should definitely use it and here is why", it's probably worth having that section IMO. Dominoes fucked around with this message at 10:43 on Mar 7, 2017 |
# ¿ Mar 7, 2017 10:39 |
|
OK
|
# ¿ Mar 7, 2017 19:05 |
|
|
# ¿ May 8, 2024 21:38 |
|
QuarkJets posted:For some reason Enthought (their product Canopy is basically like Anaconda) only supports Python2. Edited to reflect that!
|
# ¿ Mar 7, 2017 20:17 |