Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
QuarkJets
Sep 8, 2008

Basically "hey it seems dumb that I need to specify the type of every variable" is correct, there are upsides to both approaches and even older vanguard languages have acknowledged that.

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

D34THROW posted:

Ever have those moments when you look back at your old code, or how you used to do things, and have a :smugbert: look on your face?

Last time I did this dance, I input a shitton of data manually into the DB from flask shell.

Now, I'm putting everything in an Excel file, sheet names matching the class names and column names matching the field names for the ORM interfaces, and I'm just gonna use dataframes to read it all into the DB. That way, when I inevitably gently caress something up and have to DROP TABLE *, I don't have to spend an hour retyping poo poo.

"The worst coder ever is me, 6 months ago."

Deffon
Mar 28, 2010

punk rebel ecks posted:

I’ve just started learning Java and was wondering why I have to do things like put “int” in front of a number to state it’s a number rather than simply not putting quotes around it. Or why I need curly brackets everywhere.

I thought it was just obtuse but I realize after reading that Quora post it’s likely to increase speed as the language has to do “less checks”.

Languages like Haskell go one step further - functions usually don't even need type signatures because they can be inferred. You can write one though, and the compiler will make sure that it was able to deduce the same thing. So a lot of Java verbosity isn't strictly neccessary for a statically typed language.

The below quicksort function takes a list of some type, and returns a list of the same type. If you tried to call it with anything else or treated the return value as something else you would get a compile-time error.

Edit: The item type would have to be comparable since the function uses < and >= to compare items. If it wasn't doing that, then the item type could've been anything.

code:
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
    where
        lesser = filter (< p) xs
        greater = filter (>= p) xs

Deffon fucked around with this message at 21:35 on Mar 17, 2022

punk rebel ecks
Dec 11, 2010

A shitty post? This calls for a dance of deduction.
I want to learn C++ once I have fully learned Python and Java. Would it be best to learn C first, before I learn C++?

12 rats tied together
Sep 7, 2006

I would go for Python -> Java -> cython -> C++ if you still feel like it.

If you aren't already using it, pick up mypy or one of the other static type checkers for python and start getting used to it before learning Java.

For your actual question, C is different enough from C++ as to be actively harmful to your experience learning either after the other. The ++ is more of a generational leap thing than a simple increment.

necrotic
Aug 2, 2005
I owe my brother big time for this!

CarForumPoster posted:

"The worst coder ever is me, 6 months ago."

1000x this. Past me is future me’s worst enemy. Learning to support future you is a huge step to enlightenment.

QuarkJets
Sep 8, 2008

punk rebel ecks posted:

I want to learn C++ once I have fully learned Python and Java. Would it be best to learn C first, before I learn C++?

No, you should just go straight to C++.The situations where you should use C are somewhat specific

Under no circumstances should you go learn Java, not without a specific reason

QuarkJets fucked around with this message at 03:58 on Mar 18, 2022

punk rebel ecks
Dec 11, 2010

A shitty post? This calls for a dance of deduction.

QuarkJets posted:

No, you should just go straight to C++.The situations where you should use C are somewhat specific

Under no circumstances should you go learn Java, not without a specific reason

I'm learning Java because I'm going to look for jobs with Python and like half the jobs I see says either knowledge of Java is a plus or even required.

The Iron Rose
May 12, 2012

:minnie: Cat Army :minnie:
I found learning C pretty useful purely from an educational perspective. I’d never program anything outside of a classroom in it, but it makes you appreciate the abstractions a little bit more.

ExcessBLarg!
Sep 1, 2001
C is a relatively small language and most of what you'd learn from it would transfer to C++ anyways, given that C is a subset of C++.

Now, C++ proponents will rightly tell you that modern, best-practices C++ code is quite different from C, which is true, but if you're working in C++ in a professional capacity there's a drat good chance you're going to come across code bases that go back 30 years and include all flavors of C++ past and present, including straight C code that got shoved into a .cpp file at one point. You at least want to know what that stuff is doing.

One of Java or C# is worth knowing because the vast majority of the world's software over the past 30 years is written in one of those languages and so it's good for employment purposes. They're easier language than C++ and some of the knowledge transfers too.

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.

punk rebel ecks posted:

I want to learn C++ once I have fully learned Python and Java. Would it be best to learn C first, before I learn C++?

Trying to take all language fanboy-ism out of it, the corporate world runs on Java (and Java-likes like C# and Go). Java and similar languages are a very powerful, flexible tool and you see them everywhere because they're an appropriate tool for a wide variety of solutions. Java itself feels old, lame, boring, occasionally frustrating, and verbose, but is also battle-proven for a whole host of situations that Python, PHP, NodeJS and others are not as good a fit for, or even not capable of reaching.

Old companies, companies with enormous scale, or companies with high performance needs (games) will have a ton of C++ too. It will take more effort to do the same thing to the same level of safety and robust-ness in C++ than it will in Java/C#. That said, if you need memory efficiency and low latency, sometimes C++ is the tool for the job. It has so many sharp edges and hidden traps that some environments with low-latency needs will choose to write a really bizarre style of zero-allocation Java instead of doing C++. High-frequency trading famously does this, running Java with the GC off.

There are a lot of languages competing to replace C++ with something safer, the biggest being Rust and the buzziest at this instant being Zig. Rust is seeing real adoption in places that have needed C++ in the past, like browsers. I'm not very experienced with Rust personally, but my understanding is that knowing C++ well is not necessarily useful for being effective in Rust. However, for all of the languages competing to be the next Java, I think that knowing Java well does help. I'm talking about Kotlin, and Scala, or even C#.

I think that learning C is worth the effort. C itself is very small, and a separate language than modern C++. Also, when you do interop between languages, it will pretty much always be via C FFI, so if you're gluing together Rust and C++ code, you're probably doing it via C! Extending Python will always be via C FFI, same for Java JNI.

So yes, that's a very long-winded way to say "I think that you should learn C first". Not because it helps you learn C++, but because C is the lingua franca that all of these tools can use to talk to each other at the point that you're gluing stuff together. And if you aren't heading somewhere that needs C++, there is a reason that Rust has a cult of people saying "use Rust all the time everywhere", Rust has less downsides than C++ in most situations.

Wallet
Jun 19, 2006

CarForumPoster posted:

"The worst coder ever is me, 6 months ago."

If you truly believe this you have not yet fully experienced the true hell that is other people's code. I'm never going to write an entire codebase full of chained cascading callbacks no matter how drunk/unmotivated I become. I'm also unlikely to ever write a function that will iterate through an entire db table deleting records if it's passed a null instead of a record ID*.


* Deployed to production, no less. The issue was discovered after everyone woke up one morning wondering where all da data done gone. Their backup script had been silently failing for over a month because their storage was full and we ended up having to reconstruct their database by replaying changes against the last known good backup using the incredibly verbose log entries they were inexplicably emitting on every request.

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
And another one of those :smugbert:-at-my-past-self moments. Instead of taking input from a Flask form and putting it into an object, then passing the new object's attributes individually to a calculation function...why not just pass the object itself? That way I'm not passing n parameters, I'm just passing one.

Python code:
def get_form_data(form):
	line = Foo(bar=form.bar, baz=form.baz, qux=form.qux, quux=form.quux)
	do_the_math(line.bar, line.baz, line.qux, line.quux)

def do_the_math(bar, baz, qux, quux):
	...
Python code:
def get_form_data(form):
	line = Foo(bar=form.bar, baz=form.baz, qux=form.qux, quux=form.quux)
	do_the_math(line)

def do_the_math(line: Foo):
	...
Like...what the gently caress was I doing? :stare:

Metasyntactic variables are fun :allears:

Data Graham
Dec 28, 2009

📈📊🍪😋



Actually that reminds me of a problem I'm trying to figure out an elegant way around in Django. I'll go post in the Django thread though

punk rebel ecks
Dec 11, 2010

A shitty post? This calls for a dance of deduction.

Twerk from Home posted:

Trying to take all language fanboy-ism out of it, the corporate world runs on Java (and Java-likes like C# and Go). Java and similar languages are a very powerful, flexible tool and you see them everywhere because they're an appropriate tool for a wide variety of solutions. Java itself feels old, lame, boring, occasionally frustrating, and verbose, but is also battle-proven for a whole host of situations that Python, PHP, NodeJS and others are not as good a fit for, or even not capable of reaching.

Old companies, companies with enormous scale, or companies with high performance needs (games) will have a ton of C++ too. It will take more effort to do the same thing to the same level of safety and robust-ness in C++ than it will in Java/C#. That said, if you need memory efficiency and low latency, sometimes C++ is the tool for the job. It has so many sharp edges and hidden traps that some environments with low-latency needs will choose to write a really bizarre style of zero-allocation Java instead of doing C++. High-frequency trading famously does this, running Java with the GC off.

There are a lot of languages competing to replace C++ with something safer, the biggest being Rust and the buzziest at this instant being Zig. Rust is seeing real adoption in places that have needed C++ in the past, like browsers. I'm not very experienced with Rust personally, but my understanding is that knowing C++ well is not necessarily useful for being effective in Rust. However, for all of the languages competing to be the next Java, I think that knowing Java well does help. I'm talking about Kotlin, and Scala, or even C#.

I think that learning C is worth the effort. C itself is very small, and a separate language than modern C++. Also, when you do interop between languages, it will pretty much always be via C FFI, so if you're gluing together Rust and C++ code, you're probably doing it via C! Extending Python will always be via C FFI, same for Java JNI.

So yes, that's a very long-winded way to say "I think that you should learn C first". Not because it helps you learn C++, but because C is the lingua franca that all of these tools can use to talk to each other at the point that you're gluing stuff together. And if you aren't heading somewhere that needs C++, there is a reason that Rust has a cult of people saying "use Rust all the time everywhere", Rust has less downsides than C++ in most situations.

Great post.

Maybe I’ll learn Rust instead of C++.

Are there any games made in Rust?

ExcessBLarg!
Sep 1, 2001

punk rebel ecks posted:

Are there any games made in Rust?
No, just web browsers.

Jose Cuervo
Aug 25, 2004
In JupyterLab how would I change the terminal from Windows Powershell to the anaconda prompt? Been searching for a while and I thought

conda init

might be what does it, but that does not seem to work.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Jose Cuervo posted:

In JupyterLab how would I change the terminal from Windows Powershell to the anaconda prompt? Been searching for a while and I thought

conda init

might be what does it, but that does not seem to work.

I use Jupyter Notebook but the general way you get to the "Anaconda" terminal from command prompt is by running activate (activate.bat on windows). This isn't a Jupyter Lab specific answer though. I have a batch file that runs a jupyter notebook on a schedule this way.

Explained a bit more: https://stackoverflow.com/questions/46305569/how-to-make-batch-files-run-in-anaconda-prompt

Jose Cuervo
Aug 25, 2004

CarForumPoster posted:

I use Jupyter Notebook but the general way you get to the "Anaconda" terminal from command prompt is by running activate (activate.bat on windows). This isn't a Jupyter Lab specific answer though. I have a batch file that runs a jupyter notebook on a schedule this way.

Explained a bit more: https://stackoverflow.com/questions/46305569/how-to-make-batch-files-run-in-anaconda-prompt

Got it, thanks.

ExcessBLarg!
Sep 1, 2001
I've said before that I think Python is a bad language, or at least one where its designers have consistently made poor design decisions, to the point where there's a FAQ about them. But here is a specific, and interesting example:

Today I learned about the walrus operator. Or rather, I finally updated a machine to a recent enough version of Python to be able to make use of it.

Read the PEP, it's well motivated, and a good change for the language. But assignment expressions is something that's existed in other languages (Ruby, C, etc.) for decades--why did it take so long for Python folks to come around on it? Well, look at an older version of the aforementioned FAQ:

The aforementioned FAQ posted:

Why can’t I use an assignment in an expression?

Many people used to C or Perl complain that they want to use this C idiom:
C code:
while (line = readline(f)) {
    // do something with line
}
where in Python you’re forced to write this:
Python code:
while True:
    line = f.readline()
    if not line:
        break
    ...  # do something with line
...
An interesting phenomenon is that most experienced Python programmers recognize the while True idiom and don’t seem to be missing the assignment in expression construct much; it’s only newcomers who express a strong desire to add this to the language.
Yeah look, that's crap. People rightfully complained about the lack of a basic language feature and Stockholmed Pythonists defend this stuff saying "it's not Pythonic!" until suddenly it is a language feature. Hooray! Now fix all the other broken design poo poo that's also listed in your FAQ so that I can finally safely use them sometime before I retire.

By the way, the walrus operator version of the above code is:
Python code:
while line := f.readline():
    ...  # do something with line
And yes, iterators are preferred when reading lines from a file but they're not applicable to all situations.

ExcessBLarg! fucked around with this message at 03:15 on Mar 20, 2022

QuarkJets
Sep 8, 2008

ExcessBLarg! posted:

I've said before that I think Python is a bad language, or at least one where its designers have consistently made poor design decisions, to the point where there's a FAQ about them. But here is a specific, and interesting example:

Today I learned about the walrus operator. Or rather, I finally updated a machine to a recent enough version of Python to be able to make use of it.

Read the PEP, it's well motivated, and a good change for the language. But assignment expressions is something that's existed in other languages (Ruby, C, etc.) for decades--why did it take so long for Python folks to come around on it? Well, look at an older version of the aforementioned FAQ:

Yeah look, that's crap. People rightfully complained about the lack of a basic language feature and Stockholmed Pythonists defend this stuff saying "it's not Pythonic!" until suddenly it is a language feature. Hooray! Now fix all the other broken design poo poo that's also listed in your FAQ so that I can finally safely use them sometime before I retire.

By the way, the walrus operator version of the above code is:
Python code:
while line := f.readline():
    ...  # do something with line
And yes, iterators are preferred when reading lines from a file but they're not applicable to all situations.

Okay

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

ExcessBLarg! posted:

I've said before that I think Python is a bad language, or at least one where its designers have consistently made poor design decisions, to the point where there's a FAQ about them. But here is a specific, and interesting example:

Today I learned about the walrus operator. Or rather, I finally updated a machine to a recent enough version of Python to be able to make use of it.

Read the PEP, it's well motivated, and a good change for the language. But assignment expressions is something that's existed in other languages (Ruby, C, etc.) for decades--why did it take so long for Python folks to come around on it? Well, look at an older version of the aforementioned FAQ:

Yeah look, that's crap. People rightfully complained about the lack of a basic language feature and Stockholmed Pythonists defend this stuff saying "it's not Pythonic!" until suddenly it is a language feature. Hooray! Now fix all the other broken design poo poo that's also listed in your FAQ so that I can finally safely use them sometime before I retire.

By the way, the walrus operator version of the above code is:
Python code:
while line := f.readline():
    ...  # do something with line
And yes, iterators are preferred when reading lines from a file but they're not applicable to all situations.

Sounds like you're ready for Go.

ploots
Mar 19, 2010
All languages are bad, if you don’t hate the design of your favorite, you haven’t used it enough.

My most recent :psyduck: about python is that docstrings are statements.

ExcessBLarg!
Sep 1, 2001
Mmm that sounds like something a Stockholmed Pythonist would say.

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:

Electoral Surgery posted:

All languages are bad, if you don’t hate the design of your favorite, you haven’t used it enough.

My most recent :psyduck: about python is that docstrings are statements.

What, that you can get to the docstring with foo.__doc__?

EDIT: Mods plz change title to Stockholmed Pythonists tia

QuarkJets
Sep 8, 2008

Electoral Surgery posted:

My most recent :psyduck: about python is that docstrings are statements.

Could you clarify what you mean?

SurgicalOntologist
Jun 17, 2004

To speak for Electoral Surgery, I think the idea is that it's a little weird that docstrings are string literals rather than a type of comment. In my experience it gives people the idea they can use triple-quoted string literals throughout their code as multiline comments. I've had to explain that distinction to more than a few less experienced Python developers.

(edit: wrong poster named)

SurgicalOntologist fucked around with this message at 22:20 on Mar 20, 2022

ploots
Mar 19, 2010

QuarkJets posted:

Could you clarify what you mean?

Until a few days ago, my mental model for docstrings was "a special kind of comment, there are some tools to generate documentation from them, whatever". But they're not comments (ignored by the interpreter), they're statements with no effect or side effect.

This in syntactically valid code:
code:
class YouShallNot:
    """an example"""

def do_not_collect_two_hundred_dollars() -> None:
    """and stay away from go, too"""
Those look very wrong to my mental parser, but python3 thinks they're fine, because they have at least one statement in the class definition/function body.

I found out about this when we turned on an analysis tool that happened to complain about unnecessary pass statements.

12 rats tied together
Sep 7, 2006

you can use triple quoted strings as multi line comments, just don't have them also be docstrings. iirc the parser ignores them unless they are the first line in a class or module

QuarkJets
Sep 8, 2008

Electoral Surgery posted:

Until a few days ago, my mental model for docstrings was "a special kind of comment, there are some tools to generate documentation from them, whatever". But they're not comments (ignored by the interpreter), they're statements with no effect or side effect.

This in syntactically valid code:
code:
class YouShallNot:
    """an example"""

def do_not_collect_two_hundred_dollars() -> None:
    """and stay away from go, too"""
Those look very wrong to my mental parser, but python3 thinks they're fine, because they have at least one statement in the class definition/function body.

I found out about this when we turned on an analysis tool that happened to complain about unnecessary pass statements.

So the problem is that people think that triple-quoted strings are comments? People should probably be disabused of that notion

So for instance this should also work, because a valid statement exists inside the class:

code:
class Foo:
    3+4

SurgicalOntologist
Jun 17, 2004

12 rats tied together posted:

you can use triple quoted strings as multi line comments, just don't have them also be docstrings. iirc the parser ignores them unless they are the first line in a class or module

Maybe it ignroes all string literals that aren't assigned to a variable, but it doesn't ignore all triple-quoted strings. I use them all the time for multiline strings.

ExcessBLarg!
Sep 1, 2001
code:
<<<EOF
Python needs more Here Documents.
EOF

Wallet
Jun 19, 2006

12 rats tied together posted:

you can use triple quoted strings as multi line comments, just don't have them also be docstrings. iirc the parser ignores them unless they are the first line in a class or module

Or, you know, don't. I just indent lines after the first :shrug:. Pycharm even recognizes it as a continuation if you do it for tagged comments (TODO and poo poo).

Python code:
# TODO: Set line length to fifty characters to
#  torment other developers

Tuxedo Gin
May 21, 2003

Classy.

Asking this in the Python thread because it's the language I'm most familiar with, but open to other suggestions:

Is anyone aware of a tool or library that will scrape all of the replies to an individual tweet? I've been using snscrape to scrape tweets containing keywords, but I also have an instance where I need to scrape all of the replies to a specific tweet, which snscrape can't do.

punk rebel ecks
Dec 11, 2010

A shitty post? This calls for a dance of deduction.
So I'm trying to have `self.button_lights` change it's Pixmap image while this codes runs so it can simulate a "loading light that blinks". But no matter what I do, the it doesn't change until the function is finished.

code:
#The "Mother Code" Run        
    def extract(self):
        self.loading = True
        load_flash =  self.button_lights.setPixmap(QPixmap(f"{start}/assets/passets/button_loading_loading.png"))
        self.pokemon = self.line.text().lower()
        Data.run_api(self,"pokemon", self.pokemon)
        x = 0
        while self.loading:
            x+=500
            QTimer.singleShot(x, lambda: load_flash)
            x+=500
            QTimer.singleShot(x, lambda: Data.error_light_off(self))
            MainWindow.button_activation(self)
            self.name = self.data["name"].title()
            Data.ability_effect(self)
            Data.height_weight(self)
            Data.type(self)
            Data.misc_info(self)
            Data.attacks(self)
            Data.create_attack_summary_list(self)
            Data.find_sprites(self)
            Data.show_sprites(self)
            self.borders_screen.setPixmap(QPixmap(f"{start}/assets/passets/foreground.png"))
            Data.stat_updates(self)
            Data.type_image_updates(self)
            self.loading = False
        self.button_lights.setPixmap(QPixmap(f"{start}/assets/passets/button_loading_complete.png"))
And while the code runs, what's in the QTimer doesn't run until the very end.

Messing around with it, even if I take the code out of QTimer and just have the image only change once it still doesn't run until the end of the code when everything else is finished.

fisting by many
Dec 25, 2009



Tuxedo Gin posted:

Asking this in the Python thread because it's the language I'm most familiar with, but open to other suggestions:

Is anyone aware of a tool or library that will scrape all of the replies to an individual tweet? I've been using snscrape to scrape tweets containing keywords, but I also have an instance where I need to scrape all of the replies to a specific tweet, which snscrape can't do.

I don't think the twitter API itself has an endpoint for replies to a specific tweet. I think the only way around it is to scrape all tweets that mention @user and throw away the ones that aren't replies to a given tweet.

QuarkJets
Sep 8, 2008

punk rebel ecks posted:

So I'm trying to have `self.button_lights` change it's Pixmap image while this codes runs so it can simulate a "loading light that blinks". But no matter what I do, the it doesn't change until the function is finished.

code:
#The "Mother Code" Run        
    def extract(self):
        self.loading = True
        load_flash =  self.button_lights.setPixmap(QPixmap(f"{start}/assets/passets/button_loading_loading.png"))
        self.pokemon = self.line.text().lower()
        Data.run_api(self,"pokemon", self.pokemon)
        x = 0
        while self.loading:
            x+=500
            QTimer.singleShot(x, lambda: load_flash)
            x+=500
            QTimer.singleShot(x, lambda: Data.error_light_off(self))
            MainWindow.button_activation(self)
            self.name = self.data["name"].title()
            Data.ability_effect(self)
            Data.height_weight(self)
            Data.type(self)
            Data.misc_info(self)
            Data.attacks(self)
            Data.create_attack_summary_list(self)
            Data.find_sprites(self)
            Data.show_sprites(self)
            self.borders_screen.setPixmap(QPixmap(f"{start}/assets/passets/foreground.png"))
            Data.stat_updates(self)
            Data.type_image_updates(self)
            self.loading = False
        self.button_lights.setPixmap(QPixmap(f"{start}/assets/passets/button_loading_complete.png"))
And while the code runs, what's in the QTimer doesn't run until the very end.

Messing around with it, even if I take the code out of QTimer and just have the image only change once it still doesn't run until the end of the code when everything else is finished.

There's a lot of extraneous stuff going on here and I don't really understand what you want to do, sorry. Here's a simple example that flips a QLabel between two images, is that kind of what you're looking for?

Python code:
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QGridLayout, QLabel, QWidget

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.images = (QPixmap(r"C:\Users\USERNAME\Pictures\FLCwx9eXIAE6bpX.png"),
                       QPixmap(r"C:\Users\USERNAME\Pictures\FLCwx9eXIAE6bpX_upsidedown.png"))
        self.image_index = 0
        self.label = QLabel()
        self.grid = QGridLayout()
        self.grid.addWidget(self.label,1,1)
        self.setLayout(self.grid)
        self.setGeometry(50,50,320,200)
        self.setWindowTitle("The most deserving bug")
        self.changeImage()
        self.timer = QTimer()
        self.timer.timeout.connect(self.changeImage)
        self.timer.start(1000)  # ms
        self.show()

    def changeImage(self):
        self.label.setPixmap(self.images[self.image_index])
        self.image_index = 1 - self.image_index

app = QApplication([])
ex = Example()
Result:


QTimer will emit a signal every 1000 ms in this implementation, and that signal is connected to the changeImage method, which just flips the label between 1 of 2 preloaded pixmaps. So every 1000 ms the label contents change to the other preloaded image, which I just hard-coded as a tuple that the class owns. This was just something that I mocked up real quick in Notepad++, I probably could have used a fancier collection and iterators and the formatting is probably horrible but :effort:

I hope this helps

QuarkJets fucked around with this message at 06:40 on Mar 22, 2022

KICK BAMA KICK
Mar 2, 2009

fisting by many posted:

I don't think the twitter API itself has an endpoint for replies to a specific tweet. I think the only way around it is to scrape all tweets that mention @user and throw away the ones that aren't replies to a given tweet.
Just seconding, same conclusion I reached when I was looking for that for a project a few years ago.

I assume maybe the paid products can query on that, cause why wouldn't they?

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug
So I have a bit of a best practices question. In the event that you have a function that mutates a data structure like a list/etc, is it best practice to return the mutated version, or to just make it clear in the docstring that the function mutates the object? For the sake of argument, let's assume that this isn't a library or other externally facing function and is pretty tightly bound business logic specific to a situation, where you're separating code out into functions to improve readability/etc.

code:
big_dict = retrieve_data()
remove_butts(big_dict)
vs
code:
big_dict = retrieve_data()
big_dict = remove_butts(big_dict)

Adbot
ADBOT LOVES YOU

Macichne Leainig
Jul 26, 2012

by VG
I think that's kind of up to your preference. Though if you are not returning anything then you should be very clear that the function does not return anything and thus mutates an argument as a side effect. It shouldn't do both; either return a new object or mutate the existing one.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply