# Which concepts known from Python programming are useful in understanding Julia and which are not?

**URL:** <https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [June 11, 2024, 9:09am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460 "2024-06-11T09:09:52Z")\
**Posts on this page:** 15\
**Page:** 3

<div class="post-metadata">

**Author:** ![Chriz\_Zend](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chriz_zend/32/209871_2.png) [@Chriz\_Zend](https://discourse.julialang.org/u/Chriz_Zend)\
**Post date:** [June 14, 2024, 4:58am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/49 "2024-06-14T04:58:19Z")

</div>

Thank you… 🙂

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 14, 2024, 5:18am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/50 "2024-06-14T05:18:19Z")

</div>

> [@oOosys](#):
>
> `size(A, 1) > size(A, 2) ? size(A, 1) : size(A, 2)`

Or

```julia
max(size(A)...) 

```

I think, btw, you should tone down the talk about “insanity”. You are basically implying that almost everyone here is insane. I, too, have left my senses according to your posts. It’s a bit much.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [June 14, 2024, 5:23am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/51 "2024-06-14T05:23:10Z")

</div>

Wish I could downvote a comment 😆  
I took a peek at your profile and writings on “oOo” and I think you’re right, maybe I _am_ insane!  
I’m sorry you don’t like the current scheme though, but oh well 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [June 14, 2024, 5:31am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/52 "2024-06-14T05:31:06Z")

</div>

The original code was correct, actually. @oOosys misled you there 😅  
See below where it works for both narrow and wide matrices:

```julia
julia> collect_diagonals_orig(A) = [diag(A, i) for i in -(size(A, 1)-1):size(A, 2)-1];

julia> let A = collect(LinearIndices((3, 2)))
           display(A)
           collect_diagonals_orig(A)
       end
3×2 Matrix{Int64}:
 1 4
 2 5
 3 6
4-element Vector{Vector{Int64}}:
 [3]
 [2, 6]
 [1, 5]
 [4]

julia> let A = collect(LinearIndices((2, 3)))
           display(A)
           collect_diagonals_orig(A)
       end
2×3 Matrix{Int64}:
 1 3 5
 2 4 6
4-element Vector{Vector{Int64}}:
 [2]
 [1, 4]
 [3, 6]
 [5]

```

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [June 14, 2024, 1:44pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/54 "2024-06-14T13:44:17Z")

</div>

> [@tomerarnon](#):
>
> The original code was correct, actually. @oOosys misled you there 😅  
> See below where it works for both narrow and wide matrices:

have checked it out … **you are right** … somehow I haven’t questioned my point of view … I have spent several days on getting code about diagonals right and arrived at code which needed handling of the cases to make the code work properly assuming it must be that way.

Running this simple code example I was first not believing my eyes … it worked correctly and I needed to revise what I have been considering to be true (using Python) without checking it after so much effort put into the wrong conclusion in first place,

_Thank you much for the clarification_ … and excuse me for the trouble caused out of the confusion I was trapped myself for a week or two busy with approaching indexing of 2D-arrays using the “diagonal coordinate system”.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [June 14, 2024, 7:36pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/55 "2024-06-14T19:36:26Z")

</div>

> [@oOosys](#):
>
> I have spent several days on getting code about diagonals right and arrived at code which needed handling of the cases to make the code work properly assuming it must be that way.

It’s much easier when you have the right mental model, isn’t it 😉  
I guess centering on the main diagonal leads to a more harmonious view of the solar system after all!

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [June 14, 2024, 8:57pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/56 "2024-06-14T20:57:42Z")

</div>

> [@tomerarnon](#):
>
> It’s much easier when you have the right mental model, isn’t it 😉  
> I guess centering on the main diagonal leads to a more harmonious view of the solar system after all!

Yes, it is … it was a terrible confusion at the beginning … and asking questions on stackoverflow has shown to me that the respondents are all also highly confused. The OOP way of programming made people no more able to grasp most basic things … so I had to answer my questions all myself … animating on that way others to follow my path of thought … which resulted in code 1000 times faster than the first proposed in the initial answer. The patterns of Python programming ingrained by decades of “experience” are showing a quite devastating effect on my ability of deep understanding … taking days and weeks in order to arrive at at least a bit clearer mind allowing then to see how confused the minds of others are …

I have a general issue with NEGATIVITY … and negative numbers are NEGATIV … focusing on what is missing, pointing out how much less there is of something which is nothing … it’s craziness at a highest level possible … established by mathematicians and other smart people … having many negative thoughts … leading to negative numbers. Maybe renaming them to “the other side of N” or similar would help to avoid the negativity spreading this way, on evil purpose or not - hard to see it clearly. The language words decide about your awareness and your focus ,… decide about your personality … So True and False … or True and NOT True … are just things that CAN be avoided … but no language in the world seems to have only the YES in the vocabulary … without the negativity of NO …

If you are not aware how much the vocabulary you use decide about who you are and how you filter what is, you will have hard time to understand how it comes that the convenience of zero and negative numbers is something preventing spreading of happiness around the world ,…

This is why I am not giving-in … even if it seems to be more convenient from some point of view … I would be probably more happy with the main diagonal being the number ONE and then others 1,2,3 above or below instead of +2 and (minus) -2 (a NEGATIVE number).

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [June 17, 2024, 7:38am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/57 "2024-06-17T07:38:26Z")

</div>

> [@oOosys](#):
>
> I have a general issue with NEGATIVITY

So do I. But I’ll double down on it, hoping that it will turn into something positive again.

I do appreciate the irony hidden in your posts though: Pointing out how you prefer a language/world without negativity, yet insulting others who reply to you with (presumably) good intentions by calling them “confused” and their ideas “craziness” – even after someone already kindly pointed out to you that this is rude.

Just use unsigned integers … and let me spread happiness by defining some `Bool`s. I might even subtract them if I feel frisky today.

PS: My post clearly doesn’t relate to the original question, sorry for that. My impression was that this ship has long sailed.

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [June 17, 2024, 7:44am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/58 "2024-06-17T07:44:52Z")

</div>

> [@Allowing the object.method(args...) syntax as an alias for method(object, args ...)](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051/218):
>
> I’ m working on an implementation like something in Goland [gocompletefunctionsfortype.animated.gif（GIF 图像，920x428 像素）] in vscode extension. If anyone want to try out, please see [Release A quick dot methods completion demo · xgdgsc/julia-vscode · GitHub](https://github.com/xgdgsc/julia-vscode/releases/tag/v1.41.1_methodswith) . Welcome opinion/bug reports.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [June 17, 2024, 8:49am UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/59 "2024-06-17T08:49:56Z")

</div>

Some useful concepts from Python. Version 3.7 (2018) onwards: `@dataclass` creates a class for holding data only, without bundling user-defined methods. It creates default constructor and printing methods for you. This is a nice break from heavy OOP and is similar to structs in Julia. Dataclass documentation encourages the use of type hints, and this becomes essential for Julia where concrete types in struct fields are important for performance.

Python 3.4 (2014) introduces abstract base classes, which have similarities with abstract types in Julia.

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [June 17, 2024, 4:40pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/60 "2024-06-17T16:40:29Z")

</div>

> [@Sevi](#):
>
> others who reply to you with (presumably) good intentions

Sometimes being rude is the only way to “wake others up” … you know: _“the road to hell is paved with good intentions …”_

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 17, 2024, 4:46pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/61 "2024-06-17T16:46:16Z")

</div>

No, rudeness is neither required nor accepted here. This forum is built on mutual respect, and we [expect everyone](https://discourse.julialang.org/faq) here to be respectful and welcoming to all.

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [June 17, 2024, 4:49pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/62 "2024-06-17T16:49:19Z")

</div>

> [@mbauman](#):
>
> No, rudeness is neither required nor accepted here. This forum is built on mutual respect, and we [expect everyone](https://discourse.julialang.org/faq) here to be respectful and welcoming to all.

OK … got the message. Will try as good as possible to me to stick to this rule, or … if not possible or making sense … just to keep what would need to be said to myself 🙂 .

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 17, 2024, 4:53pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/63 "2024-06-17T16:53:20Z")

</div>

Thank you! And thanks to everyone who participated here for the interesting discussion.

Let’s bring this particular topic to a close. As always, any specific points of particular interest can be continued in new — more focused — topics.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 17, 2024, 4:53pm UTC](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460/64 "2024-06-17T16:53:27Z")

</div>

Closed on June 17, 2024, 4:53pm UTC



[Previous page](https://discourse.julialang.org/t/which-concepts-known-from-python-programming-are-useful-in-understanding-julia-and-which-are-not/115460.md?page=2)
