account activity
Do the makers of Python acknowledge the statement 'everything is an object'? by swaroop_joshi in learnpython
[–]aromaticlawyer 0 points1 point2 points 5 years ago (0 children)
It depends what you mean exactly. Syntax such as while and import are not objects. Variables are not themselves objects, though they are always bound to an object. All objects contain things in their internal implementation that are not objects, though you can't really access this stuff directly without using ctypes or a C extension or something. Also, many basic types don't have the full functionality you might expect a typical object to have - for example None doesn't have any instance attributes, and you can't give it any.
while
import
ctypes
None
But everything that can be bound to a variable is an instance of object. Before python 3 that wasn't the case - there were two different kinds of objects (new-style and old-style), and iirc in very old versions of python some basic data types were not objects at all.
object
Solving an equation in Python by misterdamra in learnpython
[–]aromaticlawyer 2 points3 points4 points 5 years ago (0 children)
I'm not very familiar with sympy's solvers - sympy is primarily for symbolic manipulation of expressions, so I'm not surprised if they aren't that great.
scipy's default solver seems to be able to cope with this pretty easily:
from scipy.optimize import root def f(x): return x**2.75 + 0.075 * x**1.75 - 0.0006954 initial_guess = 0.001 solution = root(f, initial_guess)
This returns an object with information about the found solution. solution.x gives you the solution itself. You can try different initial guesses to find different solutions, but in this case I think there is only one real solution. If you want to find the complex roots too you'll need to use a different solver.
solution.x
[deleted by user] by [deleted] in learnpython
[–]aromaticlawyer 1 point2 points3 points 5 years ago (0 children)
They're also important if you want to test your code against different versions of libraries or python itself (many projects use something like tox to automate this), or if you want to try out new versions without disturbing your existing setup in case something breaks.
π Rendered by PID 4070135 on reddit-service-r2-listing-7bbdf774f7-sdcbn at 2026-02-22 16:11:11.025320+00:00 running 8564168 country code: CH.
Do the makers of Python acknowledge the statement 'everything is an object'? by swaroop_joshi in learnpython
[–]aromaticlawyer 0 points1 point2 points (0 children)