My name is Brian. With 20+ years in software development, from startups to Fortune 500s, I now focus on application security in finance. My background in computer science drives the essence of this channel.
Our Focus
Begin Secure emphasizes security in software development. We delve into Java, Spring, Python, and DevOps, but our core is a security-first coding approach.
Why Us?
Security isn't an afterthought-it's vital. We bridge software development and application security, equipping developers for secure coding.
For Whom?
From seasoned developers to newcomers, our content is universally relevant.
Join discussions in comments, our community tab, or on Discord.
I've never understood what's the point of writing this kind of esoteric syntax to avoid a very basic, fast to read and easy to understand control structure, unless it's for performance gains.
I dunno, it seems like a super niche feature to me. I have literally never needed that. I have, however, needed a for loop where I have direct control over the iterator, rather than being forced to rely on a pre-defined series. I know I can just use a while loop but this feels like a way more mainstream case than a while loop else clause.
You're right, it’s not something you'll see every day. Direct iterator control in for loops would definitely be more mainstream. Thanks for the thoughtful comment!
Thanks for your comment! 😊 I get that the else keyword can seem confusing in this context. In Python, it's used here to execute code only if the loop wasn't broken out of. While the naming might not feel intuitive, it's part of how Python handles loops. Appreciate your feedback!
You must be new to programming, I'm glad you're finding out new little neat features of the python language, keep it up! I don't enjoy python personally, there are just so many dumb little things that I run into whenever I have to use it- like for example in your code python makes you append one to a variable the verbose way instead of the common ++ syntax you see in most c based languages
Thanks for your comment! 😊 Python does handle some things differently compared to C-based languages, like using i += 1 instead of i++. Each language has its quirks and strengths. I'm glad you found the feature interesting, and I appreciate you sharing your perspective!
Thanks for your comment! 😊 I understand that the else keyword in loops can seem a bit unintuitive. In Python, it's used to run code only if the loop completes without a break. While the naming might feel unexpected, that's just how Python handles it. Appreciate you sharing your thoughts!
Never heard of an else block before lol? This behaves the exact same with a "for" or "while" as long as there is no "break". Definitely not a secret. This is basic python
Thanks for pointing that out! 😊 You're right-the else block works the same with for and while loops without a break. Just sharing for those who might not know!
It's not the prettiest, but i usually use this when i iterate over something and set up values and use the else block for default when nothing was found Works with for loops too
Absolutely! 😊 Using the else block in loops is great for handling the "nothing found" scenario after iterating. It's a neat way to set up default values when an item isn't found, and it works with both for and while loops. Thanks for sharing how you use it!
won't lie i thought that was pretty obv. I don't really use python a lot i script more in lua but im suprised at how many devs overlook that since it feels pretty obv in my opinion atleast
Whats the use case for this? If it breaks nornally wouldn't it always go to the next line If it errors in the while loop it will throw and not go tonthe next line?
Appreciate your comment! The else in a while loop runs only if the loop wasn't exited by a break. If the loop ends naturally, it goes to the else. If an exception is thrown, it won't execute the else block. Hope this helps!
I understand it might seem unnecessary. The else block in loops can be a bit confusing, but it has its unique uses. Thanks for watching and sharing your perspective!
Be careful though, because the .exe is recognized afterwards by viruses with 7 virus declarations, these are false positives, but it is to be taken into account :) unless you add a certificate, but it is chargeable
Great point! False positives can happen when creating .exe files from Python scripts. I'll look into adding a section about code signing in a future video. Thanks for the suggestion!
Weird feature. It acts as a "someone DIDN'T break out of the loop" detector? What if there's stuff I want to do IF I break out? Is there an "else-else" block?
Great question! 😊 You're right-the else block runs only if the loop completes without a break, acting like a "no break occurred" detector. If you want to execute code specifically when the loop does break, you can place that code right after the loop or use a flag variable to check if a break happened. There's no built-in "else-else" block, but you can structure your code to handle both scenarios effectively!
set a "fail" variable to 0 before entering the loop and in the else block. Set it to I inside the loop. That way you know that it broke and where. i = 0 fail = 0 while i < 2: fail = i print(i) i +=1 else: fail = 0 if fail>0: print("failure detected")
Good point! Dark mode isn’t for everyone. It’s all about what feels comfortable for your eyes. Have you tried customizing the theme in your IDE to see if that helps?
Exactly! xargs lets you run commands in parallel, so instead of downloading files one by one, it speeds things up by handling multiple downloads at once.