Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "python rules"
-
This code review gave me eye cancer.
So, first of all, let me apologize to anyone impacted by eye cancer, if that really is a thing... because that sounds absolutely horrible. But, believe me, this code was absolutely horrible, too.
I was asked to code review another team's script. I don't like reviewing code from other teams, as I'm pretty "intense" and a nit-picker -- my own team knows and expects this, but I tend to really piss off other people who don't expect my level of input on "what I really think" about their code...
So, I get this script to review. It's over 200 lines of bash (so right away, it's fair game for a boilerplate "this should be re-written in python" or similar reply)... but I dive in to see what they sent.
My eyes.
My eyes.
MY EYES.
So, I certainly cannot violate IP rules and post any of the actual code here (be thankful - be very thankful), but let me just say, I think it may be the worst code I've ever seen. And I've been coding and code-reviewing for upwards of 30 years now. And I've seen a LOT of bad code...
I imagine the author of this script was a rebellious teenager who found the google shell scripting style guide and screamed "YOU'RE NOT MY REAL DAD!" at it and then set out to flagrantly violate every single rule and suggestion in the most dramatic ways possible.
Then they found every other style guide they could, and violated all THOSE rules, too. Just because they were there.
Within the same script... within the SAME CODE BLOCK... 2-space indentation... 4-space indentation... 8-space indentation... TAB indentation... and (just to be complete) NO indentation (entire blocks of code within another function of conditional block, all left-justified, no indentation at all).
lowercase variable/function names, UPPERCASE names, underscore_separated_names, CamelCase names, and every permutation of those as well.
Comments? Not a single one to be found, aside from a 4-line stanza at the top, containing a brief description of that the script did and (to their shame), the name of the author. There were, however, ENTIRE BLOCKS of code commented out.
[ In the examples below, I've replaced indentation spacing with '-', as I couldn't get devrant to format the indentation in a way to suitably share my pain otherwise... ]
Within just a few lines of one another, functions defined as...
function somefunction {
----stuff
}
Another_Function() {
------------stuff
}
There were conditionals blocks in various forms, indentation be damned...
if [ ... ]; then
--stuff
fi
if [ ... ]
--then
----some_stuff
fi
if [ ... ]
then
----something
something_else
--another_thing
fi
And brilliantly un-reachable code blocks, like:
if [ -z "$SOME_VAR" ]; then
--SOME_VAR="blah"
fi
if [ -z "$SOME_VAR" ]
----then
----SOME_VAR="foo"
fi
if [ -z "$SOME_VAR" ]
--then
--echo "SOME_VAR must be set"
fi
Do you remember the classic "demo" programs people used to distribute (like back in the 90s) -- where the program had no real purpose other than to demonstrate various graphics, just for the sake of demonstrating graphics techniques? Or some of those really bad photo slideshows, were the person making the slideshow used EVERY transition possible (slide, wipe, cross-fade, shapes, spins, on and on)? All just for the sake of "showing off" what they could do with the software? I honestly felt like I was looking at some kind of perverse shell-script demo, where the author was trying to use every possible style or obscure syntax possible, just to do it.
But this was PRODUCTION CODE.
There was absolutely no consistency, even within 1-2 adjacent lines. There is no way to maintain this. It's nearly impossible even understand what it's trying to do. It was just pure insanity. Lines and lines of insanity.
I picture the author of this code as some sort of hybrid hipster-artist-goth-mental-patient, chain-smoking clove cigarettes in their office, flinging their own poo at their monitor, frothing at the mouth and screaming "I CODE MY TRUTH! THIS CODE IS MY ART! IT WILL NOT CONFORM TO YOUR WORLDLY STANDARDS!"
I gave up after the first 100 lines.
Gave up.
I washed my eyes out with bleach.
Then I contacted my HR hotline to see if our medical insurance covers eye cancer.32 -
"Python is such a hard language. It has so many rules" - Undergraduate Student who sent out mass email to the class
*Professor makes the next assignment in ARM Assembly*10 -
So, I sign up for devrant and read all about the school devops fuckery everyone seems to have.
The only problem is, computers at my school's lab has no internet access and only a pirated copy of.... Visual Studio *6*. Hell, that's 5 years older than I am.
No python, no git, nothing. The best part, you ask? They use VS6 just for teaching 9th graders Visual Basic, and for C and C++, they use TurboC++ in DOSBox. 25-year old software. They teach us Pre-ANSI C++.
No fucking wonder people from here re-learn everything on the job. I jumped the gun and started messing with basic C++ in 7th grade, and then had to go back and remember that 25 years ago, they used <iostream.h> instead of just <iostream>.
Everyone just saves their code in the TC/BIN folder in DOS too, making it more of a chaotic mess than anything ever imaginable.
Bringing your own device? Too bad that's against the school rules.
The fact that they went out of their damn way to make me use TurboC in DOSBox on Windows 7 instead of giving me a sane Linux install with an editor and GCC is just... ugh.
My classmates all think I work magic, while all I really do is simple logic. Schools here in India are almost universally terrible.
Well, it's a good thing I started learning it on my own, because if I thought programming was in any way similar to how they try to teach it to us, I would've given up a long time ago.18 -
I wonder why stack overflow gets so much hate on here. To me, it is a tremendously helpful community. People are usually pleasant and forthcoming.
I sometimes see questions closed as "not constructive", even though it has thousands of upvotes, but generally, if you follow the rules, you'll have a good time.
Maybe people want SO to be something it is not, or maybe people behave differently around different technologies. I mostly find Python, Djang and general web answers, and they are fine5 -
In my office they forced us to use Darwin Box. We need to login and click on clock in once we come to office. Fucking irritated. Who the hell remembers to clock in.
I wrote a simple Python code to clock in and made it as launched jobs.
Automatic clock in. *No Worries* 😅
#ProudToBeDev
Here is github:: https://github.com/Gowtham95india/...5 -
Frustrated, tired and a bit lost.
I'm a "Senior PHP Backend Dev", which includes not the greatest tech stack nor the best job title, but it pays fine, and the company is awesome to work for.
I suck at writing features, but I'm great at bitching, and I easily put complex abstract concepts into usable models. So I'm also QA, tester, tech lead, database architect, whatever.
That makes writing PHP less annoying, because I create the rules, and whip devs around when they forget a return type definition or forget to handle an edge case. But I don't write a lot of code anymore, I mostly read (bad) code.
Lately I REALLY feel like doing something else... problem is that I know JS/ES6, but really dislike React/Vue and the whole crappy modern frontend toolchainchootrain of babelifyingwebpackingyarnballs. I know Python/Tensorflow/etc, but don't feel like I want to go into data science or AI. And then I'm awesome at the shit no one uses, like Haskell, Go and Rust (and worse).
I got a job offer which combines a very interesting PHP codebase with a Java infrastructure, where I could learn a lot... and I'm kind of tempted.
Problem is, everyone always shits on Java. I always made a bit of fun of Java myself. Don't even know exactly why, probably some really cruel instinct which causes kids to bully the least popular kid.
I know the basics, I've written the hello world, and a small backend app for a personal project. I know how strict and verbose it can be. I love the strictness in Haskell and Rust.... but those are both also quite terse.
Should I become a Java dev? I'm not talking about Android SDK, but an insane enterprise codebase at a life sciences corporation.
To the pro Java devs: What are the best and worst things about your job, about the weekly processes, about the toolchains? Have you ever considered other languages? Do you unconditionally love and believe in Java, or do you believe Swift, Kotlin, Scala or whatever will eventually make it completely obsolete?
Will Java hasten my decline into the cynical neckbeard I was always destined to be?
There are a lot more fun langauges, but looking at realistic demand and career value...20 -
Branch Manager without actual credentials (just a manager no real business decisions are made by him).
- Constantly is sick
- at home a lot doing „home office“ and not being responsive in company chat or emails
- is in home office 3-4 days a week while company policy clearly states one day a week
- watches YouTube a lot at work and calls out other people when they check their emails or quickly order something on amazon or maybe just listen to a podcast at work
- is a scrum master but rarely acts like it as in softens up rules as he sees fit
- backstabs employees in front of ceo when he actually entrusts them beforehand and says he is definitely in the employees side
- actually tried to physically intimidate me and another employee
- has no real technological background but chimes in on technical discussions and thinks it’s a new round of bullshit bingo
- does personal errands during work and books the time for it as work time
- claims people cheat on their time management entries and gets them warned and fired for it, while doing the exact thing himself
- knows he is trusted by the ceo but actually takes 0 interest in the future of the company
- tirades and gossips about other employees that just aren’t around at that moment
- is sexist at times
- very untrustworthy
- is responsible for a very toxic environment around the office
So that are his attributes - he got me warned and sacked because I supposedly committed fraud with my time management and caused the company financial harm - I had no projects or todos and was keeping myself busy with learning JS and python stuff instead of sitting around waiting for a ticket to come around.
Needless to say I’m glad I don’t see that guy any more. I’d break his jaw if I’d have to see him again.3 -
One of the most infuriating ideas in software development culture is that you can build maintainable applications without a strictly enforced type system and structured data.
Sure, it's more fun to wack around a dynamically typed system until it works or to write a major application with mutable datastructures... It's a least fun until a few years in and you have to debug an unexpected overwrite or a inconsistent use of an object property or whatever.
Anyone who writes maintainable code eventually figures out that you need rules and procedures, the issue with JavaScript, python, ruby, lisp, etc developers is that they think it's us developers that needs to enforce these rules instead of the compiler (which is infinitely better at it).60 -
Something that really annoys me is when people abuse the lax semicolon rules in JavaScript. Personally I believe semicolons should be a standard and always used in a language like JavaScript, and while the loose rule on semicolons may be considered convenient when one is forgotten every now and then, it is /not/ meant to be abused and semicolons completely unused. It's particularly annoying when I have to work on a group repo at work and the standard is to not use semicolons. JavaScript to me is much more similar to a C style language than something like Python, so even though the language is built to be loose and easy conventions such as bracket scoping and semicolons should be kept and practiced.4
-
My two cent: Java is fucking terrible for computer science. Why the fuck would you teach somebody such a verbose language with so many unwritten rules?
If you really want your students to learn about computer, why not C? Java has no pointer, no passed by reference, no memory management, a lots of obscure classes structure and design pattern, this shit is garbage. The student will almost never has contact with the compiler, many don't even know of existence of a compiler.
Java is so enterprise focused and just fucked up for educating purpose. And I say it as somebody who (still) uses it as main language.
If you want your students to be productive and learn about software engineering, why not Python? Things are simple in Python can can be done way easier without students becoming code monkeys (assuming they don't use for each task a whole library). I mean java takes who god damn class and an explicitly declared entry point which is btw. fucking verbose to print something into the console.
Fuck Java.17 -
Why do I program everything myself in C, even a rest service? By writing everything yourself in C you make simple things complex to make complex things simple.
Writing a rest service for example learns you a part of http protocol, how sockets work, how to create a parser (in this case json). Three thing's you would miss if I used python.
On top, your rest service uses WAY lesser resource than written in python for example. Especially for CPU usage.
Allocating and free-ing still often have issues there, but I consider it a skill problem / discipline issue. Not blaming C for that. The rules are clear.12 -
I've been sort of lost after New Year's...
Last few years, my main goal was just to learn stuff to pass technical interviews. I also did a lot of personal dev in C#... and played with the js, python, and when a bit of c++.
But this year I kinda feel sorta of "ah screw it". Interviews never work out, haven't for years, what's the point in even trying... I get paid enough though the work is sort boring and team sort of feels like the Wild West, no rules, code reviews, processes...
But ¯\_(ツ)_/¯
Feels like coding has lost its place at the top now. The future is all cloud, machine learning, big data/real time analytics but feels like these are out of reach for just 1 guy...
And well doesn't seem like anyone is going to give me a job because I'm not a good fit or have enough experience in these areas...
Sorta lost now but guess this is what a sudden thought leads to...
Oh and maybe just with tech in general. It feels this year I'm just not as interested as I was before... Spent a lot of time binge watching movies and stuff instead....4 -
!rant
Part of my job involves researching a shitload of documentation and tutorials in order to have an established and well tested point of refference for the rest of the team. As a Django guy, I have always been happy with the plethora of tutorials and what not made available for this amazing framework. Until recently I had absolutely no clue that MDN had their own Django tutorial and I must say....I am impressed! I seldom recommend something over the already great tutorial made available by the Django page itself, but this one by MDN really is worth considerind for people starting into the framework. One can even see the love that they have for the framework just by reading the tutorials.
Kudos to MDN for creating such a great resource!4 -
Fave languages and frameworks, go!
As of now for me, loving these:
PHP8 and Laravel with Livewire*, Django5.1, MariaDB. PHP must stand for PrettyHeckinPCoolasFFFFFFFFFUUUUUUU
*after using React and Vue for quite a while, I've concluded that the best front end is back end. And I like Postgres, I just find that MySQL is fine for most things.25 -
Lets play a little python game together and win some devRant points :
We have an array of integers named L
We need to sort this array so that the biggest number be in the beginning and lowest at the end..descending order
Rules:
-You are not allowed to write more than one line of code in the comment...only one
-if you comment once...you cannot comment directly after that...you have to wait for two other comments after you so you can comment again
-you have to build your code upon the previous comments ... you cannot start from scratch
-the lucky one who puts the final comment is the winner..and we should all ++ his comment to give him the biggest amount of points
Lets start and see who will win :)15 -
Calling any Python programmer here (especially package maintainers)
I run Gentoo, so am responsible for maintaining the dependency tree (to a degree). When it comes to Python I have 2.7, 3.4, 3.5, 3.6 available. I'm always running into some package needing one version or another, and I can't just set a single version and forget it (which is fine. I'm running Gentoo).
I know that this is because python changes rapidly and so different libraries need different versions. Fine.
Why does this happen with Python and not C++, JavaScript, php, ruby, or any other languages on my system? I don't have 3 different versions installed to cover any other languages, and I don't spend time adding installation rules to cover them.
Why does Python need to be a pain in the ass about it?3 -
I'm at my Community College as a member of the engineering club requesting funds for a software and hardware-related physical project.
The code was mostly pre-written in Python from a university already, but we needed to build essentially a gaming-level PC to run it, do some welding and metalwork for the hardware, cables, et citera. I don't want to get too detailed in case anyone involved is reading this story.
To get funding, we needed to go before the student senate. I didn't go the first time, but later when we needed more funding for the project to do expansions, we attended.
I came in with a few pages of documentation explaining how the project operated, it's scope, and why we needed the additional $500 on top of the previous $1000 or so spent. I went in woefully behind the times on what a student senate meeting was like.
For starters, I thought this would be somewhat formal, being "Student Senate" in Week 8, and prepared to defend my project fully. Instead, we spent the first 15 minutes going around the table explaining what animal we would be and why, if we had to turn into an animal. It just kept going hilariously, painfully downhill from there.
They did ask some questions about what my project was and how it operated (as not many had seen it), and they wanted explanations even though it was clear absolutely nobody else in the room understood anything. My partner virtually shut down and let me do all the talking for my project and his because he couldn't take the ignorance of some of the questions and the assorted nonsense spread throughout the meeting.
Amazingly, we got funding. We had to sit for the rest of the meeting though, which (among other things) included a segment about whether we should create a new committee called the "Fundamental Insecurities committee" to help out with, well, "Fundamental Insecurities." There was only one member on this proposed committee.
When I brought up the question on why we were making a one-person committee alongside the, like, three one-person committees already in existence, they congratulated me for asking good questions and said I should come more often. They then said the exact same thing again when I pointed out there were better names than "Fundamental Insecurities." It's such a reality check that you are trying to impress people to get funding, when you can't help but feel that everyone is an utter idiot in the back of your head.
Almost a year later, I had to go back with a list of parts we needed. I wrote a whole complex list of things we needed for the project. Even though they tried to ask questions about what certain parts were (to appear like they weren't totally incompetent), and despite asking questions about a bunch of the items, nobody cared about what the $10 for "C418" was (google it if you don't get this joke). I spent about 30 minutes talking with them and succeeded in getting $600 more in funding. We then, to my surprise, spent less than 5 minutes debating whether to send 2 students on a field trip for $700. 30 minutes for $600, for a permanently installed project. <5 minutes for a $700 one-time thing.
And, because this is already a long rant, here's one more thing: The Student Senate's voting rules initially gave everyone who showed up 1 vote. We're all students, we all get a say, right?
Well, I soon put together that Student Senate had fairly low attendance. Engineering Club had high attendance. Student Senate and Engineering Club took place at the same date and time. I then, of course, asked why we couldn't bring the whole Engineering Club into Senate one day, and then proceed to pass an order by simple majority saying that all Student Life funding goes to us.
They then said that the administrators (the heads of Student Senate) could override that, but I pointed out that kind of defeats the purpose of voting in the first place. They then switched script and said they wouldn't do that and would honor such a vote. Shortly after, they changed the rules saying that you only get a vote on your 2nd consecutive visit; and again said I should visit more often because I was brilliant.
You can't make this stuff up.3 -
My TL has his custom rules to format code, we use python and black as formatter, still, We have to remember his rules. He forced us to mention type rather than compiler do it for us. Our pr will not be approved until we do this.
My point is if you want to follow this then forced it programmatic way, event better use a language which gives this all by default. why we should remember all of these rules. Other team members are also doing the same and I hate those pr comments like there should be two empty lines or the type is missing. He never listens to any of us and takes it on his ego.1 -
so some controversial opinions
Our company is moving most of our code style to snake_case, even the JavaScript. Here's our resoning:
Take the CustomerAccountMembership model. In our Python server, we would access it as obj.customer_account_membership, in JavaScript as obj.customerAccountMembership and our API endpoint as api/path/customer-account-membership. Thus we had several String utility functions such as `camelize`, `kebabChop` (which is ironically camelCased) and `snakeify`, and we would use them in translating from URL path to JS to Python, which was troublesome.
Now HTTP allows _underscores_ unescaped and do not pose any significant meaning. JavaScript also accepts it as a valid character in variable names. On the other hand, HTTP is strictly lower-cased, and all computer languages use the -dash- to signify subtraction. Sooo the _underscore_ is the only style that is compliant everywhere.
Unless, of course, we go with customeraccountmembership, which I refuse to do.
I'm not that deep into code character rules.
Opinions?7 -
Good times: Migrating a Jenkins build pipeline patched together out of groovy, python, bash, awk, perl scripts and God knows what else since I have only scratched the surface so far, from Maven to Gradle while not breaking day-to-day builds, integrations and deployments of features, hotfixes and releases. I'm actually enjoying the challenge but it's taking forever due to several issues:
- Jenkins breaks/hangs randomly because it's Jenkins
- Gradle can't handle sets of version ranges but Maven can
- Maven can't handle Gradle style version ranges
- Gradle doesn't have a concept of parent poms, you need to write a plugin and apply stuff programmatically. But plug-ins being part of the buildscript{} don't fall under depency management rules :clap:
- Meme incompatibility issues of BSD vs GNU versions of CLI tools like sed, grep etc1 -
So I've just about finished a simple application practice project, it's just a program that will show you today's horoscope for different signs from an RSS feed, but I'm wondering if or how I should include disclaimers/credits for things like fonts (The two fonts I use are both open source.), and/or things like the tools used for building it (Written with Python and Tkinter in Atom.)? Do I add it under a "Help" menu or something?
What are the rules and etiquette? And is there anything specific I should include in a separate file? This is also kind of my first proper project.4 -
"if compiler can infer this, there is no need to add "x ->" , simply use it" ..AAAGHH FUCK YOUUUUU KOTLIN!! what else should i fucking not write? why do't you take a number of my employee and ask his requirements, maybe add a ShoppingKartApp.kt in your compiler next time? it will be completely inferred when i write "Fuck you" in the gradle.
And fucking companies are promoting this! I wonder how those devs are living there
Person A knows only that lambda is
{name:Type,name:Type->code}, and thus writes a clean code.
Person B comes says "This shit suck", writes "{ acc, i -> acc + " " + i }" ,goes away
Person A : "wtf is this shit? why it works?"
Please for the love of god, follow some rules! My first language was python, i love its zen:
- Beautiful is better than ugly.
- Simple is better than complex.
- Readability counts.
- Special cases aren't special enough to break the rules.
- There should be one-- and preferably only one --obvious way to do it.
- If the implementation is hard to explain, it's a bad idea.
-...
I just wish it follows at least one thing from python's zen : "There should be one-- and preferably only one --obvious way to do it."3 -
Recently I completed a whole year in programming. Holy jebus, I have no idea I could make it through.
I started thinking I was "decent" at this because I had taken a half dozen courses in python plus some algorithm logic in school lol @ innocent me
I'm an applied math student and I hereby declare I was the most incompetent dude you'll ever see.
I've been through so much shit I didn't realize I had a shitty boss, because one would think it's normal for a beginner to approach everything in programming because I was told to do so. Full blown restful apis, stateful redux react apps with responsive CSS using Google's material design. Don't forget to dockerize everything and deploy the swarm on Amazon cloud all the while having to run integration unit tests, make sure all the rules on your nginx are correct we don't want exposure do you know how to write a visualization tool on JavaScript so we can 3d-fy some x-ray prints and good luck balancing tight schedules with your school and girlfriend ye right lul
My manager would ask me to deliver new shit to an app I was developing mostly by my self in react (I barely even knew what RFC or ES6 was by the time I started).
I got fired from this project because I couldn't deliver by myself what 5 experienced dudes could (debatable, but still... Cuz they couldn't when they took over. Boss wanted to rewrite the whole app in a week and a half)
Turns out I got called back by the same company but to contribute in another project. This time to automate some shizzle with python.
Feelsgoodman but I want out ASAP can't stay sane for longer -
Yo, DevRat! Python is basically the rockstar of programming languages. Here's why it's so dope:
1. **Readability Rules**: Python's code is like super neat handwriting; you don't need a decoder ring. Forget those curly braces and semicolons – Python uses indents to keep things tidy.
2. **Zen Vibes**: Python has its own philosophy called "The Zen of Python." It's like Python's personal horoscope, telling you to keep it simple and readable. Can't argue with cosmic coding wisdom, right?
3. **Tools Galore**: Python's got this massive toolbox with tools for everything – web scraping, AI, web development, you name it. It's like a programming Swiss Army knife.
4. **Party with the Community**: Python peeps are like the coolest party crew. Stuck on a problem? Hit up Stack Overflow. Wanna hang out? GitHub's where it's at. PyCon? It's like the Woodstock of coding, man!
5. **All-in-One Language**: Python isn't a one-trick pony. You can code websites, automate stuff, do data science, make games, and even boss around robots. Talk about versatility!
6. **Learn It in Your Sleep**: Python's like that subject in school that's just a breeze. It's beginner-friendly, but it also scales up for the big stuff.
So, DevRat, Python's the way to go – it's like the coolest buddy in the coding world. Time to rock and code! 🚀🐍💻rant pythonbugs pythonwoes pythonlife python pythonprogramming codinginpython pythonfrustration pythoncode pythonrant pythoncommunity pythondev4 -
Hello, I am doing master in Pharmacy, but I like programming and consider to switch or connect somehow industries. I could write simple scripts and small programmes in Python, but I want to write code with good practice from beginning.
So my question what should I know and put in use, maybe some resources if someone has them or just terms for further search. At this moment I use gitlab for VCS (my commits sucks and my whole usage of Git sucks, but at least I use branches), I am trying to separate control from model (MVC but I guess I do it poorly), also I use keepchangelog rules for changeling, and semantic versioning for versions, PEP8 and Pokemon names for my variables and functions as it helps read code later.7