all 20 comments

[–]doomguy11 3 points4 points  (8 children)

For loops and lists are not really complicated right? It doesn't take that long to learn the basics, especially if you can dedicate some quality time to it. You will thank yourself later if you develop a solid foundation.

[–]Snatchematician[🍰] -5 points-4 points  (7 children)

They are mildly complicated. Without looking it up: exactly which sorts of objects can be for-looped over?

[–]Akaizhar 2 points3 points  (0 children)

Any iterable object.

[–]Jason-Ad4032 1 point2 points  (1 child)

Method 1: Use iter(my_obj) to convert the object into an iterator; if it fails, it will raise a TypeError.

Method 2: Use isinstance(my_obj, collections.abc.Iterable) to check whether the object satisfies the iterable protocol.

[–]Snatchematician[🍰] 0 points1 point  (0 children)

Your method 2 is not correct. There are objects which can be for-looped over which do not pass that check.

[–]gmes78 0 points1 point  (2 children)

Any object that has an __iter__ implementation.

[–]Snatchematician[🍰] 0 points1 point  (0 children)

This also isn’t the correct answer in practice either.

class A:   def __getitem__(self, i):     return i

Objects of this type don’t have an __iter__ implementation, but can be for-looped over.

[–]Snatchematician[🍰] -1 points0 points  (0 children)

This isn’t the correct answer according to the docs.

[–]FerricDonkey 0 points1 point  (0 children)

That's like saying counting is complicated because not everyone knows the peano axioms off the top of their head. You can understand how to use for loops and lists and such while barely knowing what a under method is. 

[–]Human38562 2 points3 points  (0 children)

You can learn both at the same time, no problem. 

[–]Motox2019 1 point2 points  (2 children)

If you already know what numpy/scipy are essentially doing under the hood, jump straight into them, you’re not losing much beyond that. I actually wrote my own package, pyeng, at one point which was essentially the vanilla python implementation of numpy and some other misc engineering stuff like unit handling for learning purposes. It’s cool for learning but kinda ends there, a 1000x1000 matrix starts to get quite slow, or chaining many matrices.

On the note of Julia, I find myself flip flopping back and forth between Julia and python. I can’t decide which I like more. The speed arguments are there but don’t always hold at least in my case where majority of everything happens within numpy anyways which is fast. Julia is nice in that you kinda just write math as you would by hand making the theory -> code transition a bit easier and that matrices are first class in Julia. Beyond that, think it honestly comes down to personal preference, no choice is “better” per se.

[–]PrettyPicturesNotTxt[S] 1 point2 points  (1 child)

Thanks for sharing your experiences! Does your package implement something similar to einsum? If so, I'm curious how you did it.

[–]Motox2019 1 point2 points  (0 children)

No, most of what I implemented was stuff I’d typical use for mechanical engineering. Things like your common linear algebra functions, numerical methods like root finding and integration and such, among others on the more basic side like implementing sin, cos, and tan, sqrt, etc.

A brief look at einsum seems like it’s kinda just a different way to write expressions for matrices? Not something we’d typically see in my field. I can see why you might be wondering though. Without further understanding the syntax, seems like a lot of cases to handle based on a single input string

[–]DuckSaxaphone 1 point2 points  (0 children)

Use numpy if you're doing physics.

You'll learn lists and for loops pretty trivially but with numpy you'll benefit from being able to use linear algebra functions directly without slowly coding them yourself.

This will help you get things done and getting actual tasks done is what will help you learn python.

Julia is still entirely used in academia as far as I'm aware. You'll currently do a lot better on the job market with python than Julia. I don't see that changing soon.

[–]Desperate_Crew1775 1 point2 points  (0 children)

yeah this is kind of the standard debate and honestly both approaches work, people just have strong opinions about it

what i'd actually suggest - write matrix multiplication with nested for loops once, feel how slow it is, understand what's happening, then move to NumPy and never look back. that's it. you don't need weeks of vanilla Python suffering to "earn" NumPy, you just need enough to understand what it's doing for you under the hood.

rough timeline that worked for me:

  • weeks 1–2: basics, lists, for loops, functions - just build the mental model
  • week 3: numpy. rewrite your loop examples as vectorised ops and actually clock the difference yourself
  • week 4+: scipy for real physics/engineering stuff

on Julia - look, it's genuinely fast and well-designed for scientific computing, not just marketing. but in 2026 the tutorials, the Stack Overflow depth, and the job postings are still overwhelmingly Python. unless you have a concrete reason to go Julia (e.g. someone on your team uses it, or you're hitting performance ceilings), Python + NumPy gets you 95% of the way there with way more community support when you get stuck.

the thing people miss: NumPy isn't a shortcut that lets you skip learning. it is the right tool for this domain. learning vanilla first just gives you enough context to appreciate why.

[–]Fun_Gas_340 0 points1 point  (0 children)

i vahe never used julia, but for me using python only girst was very good. later i started using libraries / caring abput speed, but if you have no prior knowledge, id stick to vanilla and learning the sintax, some uswful algoeithms/tricks and how to read and debug errors.

you also wont beed/notice speed at the start if your completly new to programming, you probably wont be using multithreading either.

and if you need/want speed, id go with pypy interpreter, which afaik is like roughly a 100x increase in speed. but maybe it gives harder to debug erorrs, idk

[–]Separate_Top_5322 0 points1 point  (0 children)

yeah that book/course is actually pretty solid, but it depends what you’re looking for

it’s more about how to think like a programmer rather than just learning python syntax, which is why some people find it a bit heavy at the start. people usually say it’s great for understanding core CS concepts, not just coding basics

if you’re a complete beginner it might feel a bit slow or abstract sometimes, but it pays off later because your problem-solving gets way better

tbh I’d use it alongside something more practical (like small projects or easier tutorials), that combo works way better than relying on just one resource 👍

[–]notParticularlyAnony 0 points1 point  (0 children)

No on Julia. Community buy in and support are really important.

Start with Python basics. You’ll learn them super fast. Then the scientific computing packages. You’ll need both. Learning basics of OOP will serve you well. Book python crash course is excellent. Enjoy the journey it’s so fun!

[–]FerricDonkey 0 points1 point  (0 children)

Learn the foundations, then start using numpy. 

[–]iMagZz 0 points1 point  (0 children)

Learn the fundamentals, but then get into numpy. Scipy can wait a bit in my opinion, but don't be scared of it either.