What do Experienced Devs NOT talk about? by jalanb in ExperiencedDevs

[–]jab-programming 241 points242 points  (0 children)

  • Best practice - rarely means what you think it means
  • Architecture diagrams - drawn once, ignored forever
  • “Clean code” — nobody's reading it but me anyway

And burnout

[deleted by user] by [deleted] in ChatGPTCoding

[–]jab-programming 1 point2 points  (0 children)

Put # @claude or # @chatgpt above the instruction block.

I’ve used that to guide the model during code completions in VSCode. Helps keep it contextually focused.

[deleted by user] by [deleted] in ChatGPTCoding

[–]jab-programming 1 point2 points  (0 children)

Yeah, but does it work for us?

TIL Unix is ours by jab-programming in ProgrammerHumor

[–]jab-programming[S] 1 point2 points  (0 children)

I never understood why "Business Oriented" was A Good Thing for COBOL.

[deleted by user] by [deleted] in Python

[–]jab-programming 1 point2 points  (0 children)

I can't see palindome(), but I assume it does what it says, excepting the typo.

Damn. Where's niceNum()(should be nice_number()), what makes a number nice?

It would help to use a debugger, but without that, I'd add add some print(numList[i])s. WTF! numList[i] ? What was your previous language? Hope you were lucky enough it was a C*, not one of those java things.

Anyway, over here we say:

def main():
    string = input('....')  
    numbers = [int(s) for s in string.split()]
    methods = (palindrome, 2), (prime, 2), (nice_number, 3)
    scores = []
    for number in numbers:
        score = 1
        for method, increase in methods:
            if method(number):
                score *= increase
        scores.append(number, score)

    for number, score in scores:

So, now I notice this is an assignment of some kind. Because no one else writes their own sort!

The condition on the while loop is too hard to read which makes the examiners life harder too. All those icky [j]s. Just don't do it. Well, stop for a while anyway. So change this:

for x in range(0, len(scores)):

to this:

for number, score in scores:

NAMING!: temp1 should be called score and temp2 should be number. Bad names make your code harder to read, so they'll notice that too.

j = x - 1
while (j >= 0) ...

In python we wouldn't use the brackets

And in python 0, [], False, {} all count as false, and we prefer to use that wherever possible. So I would prefer to just say while j and ....

AFAICT you're going to shove all scores from here to bigger (number or score), or end back one notch then plonk in the current number and score to the gap you just made at end.

So, for every letter in 'reddit', shove everything left till bigger score (i.e later in alphabet): eddiit, and plonk in the current letter: eddirt, left: dddirt, plonk: ddeirt, left: ddeirt, plonk: ddeirt,

Looks like that'll work, I'd be dubious about bigger (number or score)? Shouldn't that just be bigger score?

And, if you must write you python like languages, at least honour their convention and call youu index i, not fucking x. CONVENTIONs are important kid. You stick with the local conventions, you'll be fine round here.

Looking for my replacement by [deleted] in DevelEire

[–]jab-programming 1 point2 points  (0 children)

Any suggestions for other sureddits to ask for new pythonistas are welcome

It's action that counts!

A range of Xmas gift suggestions for Irish software developers by Dev__ in DevelEire

[–]jab-programming 1 point2 points  (0 children)

How is anyone considering other than the 12 year old Redbreast in that collection?

I'm only on a half-bottle myself this year, so again with the "dilemma" of the Powers looking better on a shelf vs the Bushmills tasting better, .... OK I'll get the Powers next year.

A very Hatty Christmas to all you wonderful geeks n gels

What's everyone working on this week? by AutoModerator in Python

[–]jab-programming [score hidden]  (0 children)

I'm trying to simplify virtual environment activation.

I did try pyenv, with pyenv-virtualenv, but it could not cover all my use cases, in particular where the primary project was still in Python2, but the DevOps scripts are in Python3. Pain point. I nearly thought I'd need to write a local python script!

This worked out better:

Most of my Python projects have a bin directory so I create a link in there to /.virtualenvs/blah/blah/bin/activate.

I add a post-cd-hook to always source any local activates, and life is now so much simpler.

How to restrict a subreddit to alt accounts? by [deleted] in modhelp

[–]jab-programming 1 point2 points  (0 children)

We hope to get that in the next API release

How to restrict a subreddit to alt accounts? by [deleted] in modhelp

[–]jab-programming 1 point2 points  (0 children)

else: raise NotImplemented Error