|
Thermopyle posted:I swear I've posted warnings about this multiple times in this thread! THANKS FOR NOT READING MY WORDS! You may well have. I've only dropped into this thread recently. Not new to programming but new to python.
|
# ? Jun 17, 2019 21:57 |
|
|
# ? May 15, 2024 04:10 |
|
I learned python in community college a few years back and I'm going to be going back to school soon and would like to get a refresher course. Anyone have any online video series they could recommend? Something from Coursersa or Edx or Codeacademy, etc..?
|
# ? Jun 18, 2019 16:56 |
|
FCKGW posted:I learned python in community college a few years back and I'm going to be going back to school soon and would like to get a refresher course. I really liked the mit one on edx.
|
# ? Jun 18, 2019 16:58 |
|
FCKGW posted:I learned python in community college a few years back and I'm going to be going back to school soon and would like to get a refresher course. I like codecademy but even more than that I like picking something you want to make and making it. You'll pick it up quickly.
|
# ? Jun 18, 2019 22:38 |
|
Can you run a Flask app as a Celery worker ? I'm working on a project with a base app file that goes like this (way oversimplified) rest.py Python code:
Python code:
In that situation I can request a task to be run by sending a request to the correct url, and get the result. I'm asking because according to the author launching the flask app as a celery worker should be enough. It looks like code:
If I Ctrl+C in the console, Flask stops and a celery worker starts, a second Ctrl+C stops the worker. An alternate question would be, can you programmatically create a Task and spin it as a celery worker ? unpacked robinhood fucked around with this message at 16:43 on Jun 20, 2019 |
# ? Jun 20, 2019 16:39 |
|
I am building a scraper for a music thread on here. bs4 is parsing the output and populating a dict with the posts, and each post contains dictionaries of the various youtube links, each with a 'scraped' key that contains a boolean to indicate whether or not its been downloaded. I would like to use youtube-dl's python api but I can't get it to work.Python code:
I'm halfway through a workaround that checks if the output file for each scrape process has been created (if it fails, these are not created and it is essentially a status code) but I would like to figure out how to do it with subprocess alone. larper fucked around with this message at 00:06 on Jun 21, 2019 |
# ? Jun 21, 2019 00:01 |
|
Is there a good practical guide on the logging module anywhere? I'm working on an internal library/module, with a setup that I think is typical (I'm not a professional dev by any means( code:
Anyway, my question is how do I get the logging module imported everywhere consistently? Regardless of which subpackage I need in a particular script, I want to have the same logging options and be able to control them with command line flags, that way I can litter the code with proper log levels to help with later debugging. But I see even with the logging info in the top level __init__.py , it doesn't take affect down to the subpackages.
|
# ? Jun 24, 2019 02:09 |
|
The doc pages for the logging module are very good and should basically be able to explain everything that you need. You should be able to Google for them, they'll be a lot more helpful than the module's docstrings The module uses named instances, so if your submodules create logging instances with the same string name it should all simply work
|
# ? Jun 24, 2019 03:31 |
|
logging.basicConfig definitely takes effect on subpackages but it has to be called before any other logging calls happen in your code or basicConfig does nothing. Once you’ve set up basicConfig the way you want all loggers created via logging.getLogger will inherit those settings.
|
# ? Jun 24, 2019 04:49 |
|
i'm doing some homework and could use some help. i've got an array of strings and i need to display the first letter of each string. i think the best way to do this would be a for..in loop, but i'm not sure how. also, my cvode to find the number of user input letters in an array isn't working code:
Mycroft Holmes fucked around with this message at 19:24 on Jun 25, 2019 |
# ? Jun 25, 2019 19:18 |
|
Mycroft Holmes posted:i'm doing some homework and could use some help. strings are arrays of characters
|
# ? Jun 25, 2019 19:23 |
|
The Fool posted:strings are arrays of characters I am aware of that. I need a section of code that works regardless of how many strings are in the array
|
# ? Jun 25, 2019 19:24 |
|
i also have another array that is a list of vowels. I need to count how many times the vowels in array 2 appear in the array 1. How can I do this?
|
# ? Jun 25, 2019 19:30 |
|
Mycroft Holmes posted:I am aware of that. I need a section of code that works regardless of how many strings are in the array are you just looking for code:
code:
If that's not what you need, you might want to re-state? Mycroft Holmes posted:i also have another array that is a list of vowels. I need to count how many times the vowels in array 2 appear in the array 1. How can I do this? The easiest and probably conceptually simplest way is to take each vowel in 2 and make a for loop that says "for each character in 1, check if it's the same as the vowel I've got, if so, increment a counter. Once you're done with everything in array 1, print the counter, and reset it to zero."
|
# ? Jun 25, 2019 19:36 |
|
Mycroft Holmes posted:I am aware of that. I need a section of code that works regardless of how many strings are in the array Then maybe I didn't understand which part you needed help with. In broad strokes: You use your for loop to loop through your array of strings. For each string in your array, you display the first character of the string. Mycroft Holmes posted:i also have another array that is a list of vowels. I need to count how many times the vowels in array 2 appear in the array 1. How can I do this? there are better ways to do this, but the naive way would be to use two loops: use a for loop each vowel, then loop through your string comparing the current letter to current vowel if you get a match, increment a counter
|
# ? Jun 25, 2019 19:36 |
|
The Fool posted:Then maybe I didn't understand which part you needed help with. ok, how do i select each entry? just a[0] and increment by one each time?\ the actual questions are: 4. Display a string that consists of the first letter from each of 11 names in the list a Output should be the string “EANDFTEEBFN” See 9 in the output and consider using the + operator Must use a loop 5. Display a string that consists of the last letter from each of 11 names in the list a Output should be the string “dsnstgrneih”
|
# ? Jun 25, 2019 19:52 |
|
ok, so i've gotcode:
Mycroft Holmes fucked around with this message at 20:01 on Jun 25, 2019 |
# ? Jun 25, 2019 19:58 |
|
On top of an annoying day, I've banged my head against this a fair bit today: How do I go about mocking calls to functions from the requests library (post, get) etc in my unit tests? More specifically, I know how to make it return values (using unittest.mock.patch and its side_effect argument), but requests still tries to connect to the underlying TCP socket etc., which I very much want to avoid. I tried overriding bits and pieces of urllib3, socket, and requests itself, to no avail. I would prefer to this with just pytest/mock, avoiding an external library like requests-mock. Any ideas?
|
# ? Jun 25, 2019 20:04 |
|
I've never programmed in an enterprise environment but probably want to do that now. Are ETL and Airflow something I can learn shallowly and easily enough to slap on my resume or would someones bullshit meter immediately be flipped
|
# ? Jun 25, 2019 20:04 |
|
Mycroft Holmes posted:ok, so i've got Python code:
Then x will be a number that automatically increments for the length of a. Then you can access the first element of your second dimension by a[x][0] The Fool fucked around with this message at 20:11 on Jun 25, 2019 |
# ? Jun 25, 2019 20:09 |
|
Mycroft Holmes posted:ok, how do i select each entry? just a[0] and increment by one each time?\ The right way to do this is to basically do the same as question 4, but instead of zero, you use -1, because that will make it take the last letter. so that it looks like this: code:
e: The Fool I think they're trying to go about it in a backwards kinda way.
|
# ? Jun 25, 2019 20:10 |
|
A for loop basically iterates over a bunch of items, handing you each item in turn. So in the body of the loop, you do something with the current item, and when you run the loop it will basically do that thing with all the items. so you want something like Python code:
e- lookit all them replies
|
# ? Jun 25, 2019 20:11 |
|
Meyers-Briggs Testicle posted:I've never programmed in an enterprise environment but probably want to do that now. Are ETL and Airflow something I can learn shallowly and easily enough to slap on my resume or would someones bullshit meter immediately be flipped ETL can be many things, depending on source systems, target systems, architectures, etc., so this strongly depends on the place, what they do, and what they understand as such. ETL can be anything from downloading a CSV file and directly copying it into a database to building multi-tiered, highly complicated systems with myriads of transformations, rules, systems, orchestration layers etc. Airflow is just a tool (and one I'm not too fond of), though at its core, it's basically just an abstraction to write sequences of tasks, express dependencies, and schedule those tasks. If I see somebody with "ETL" on their resume without accompanying mentions of SQL, dealing with databases, and general programming, I'm going to be very inquisitive, indeed. Ditto if you only list graphical ETL tools (Alteryx, Talend, etc.). edit: Questions that come to mind rather immediately for me concern database structures, schemas, normalisation, when to prefer ELT, how to orchestrate ETL/ELT jobs etc. Hollow Talk fucked around with this message at 20:14 on Jun 25, 2019 |
# ? Jun 25, 2019 20:11 |
|
The Fool posted:
cool, that works. Now, the strings are of variable length. how do i print only the last letter of the string? is there a function for that?
|
# ? Jun 25, 2019 20:12 |
|
Mycroft Holmes posted:cool, that works. Now, the strings are of variable length. how do i print only the last letter of the string? is there a function for that? Someone else answered that already further up.
|
# ? Jun 25, 2019 20:15 |
|
alright, those two questions are working. Now, the next question is : 6. Ask the user for a letter. Display the number of times the letter appears in the list See the count function from the prior labs. my code is : code:
|
# ? Jun 25, 2019 20:16 |
|
You're just counting how many strings are literally just the letter entered.
|
# ? Jun 25, 2019 20:19 |
|
necrotic posted:You're just counting how many strings are literally just the letter entered. oh. how do id o this correctly, then? do i do a[x][x] and just increment? except the strings are of variable length, so that won;t work....
|
# ? Jun 25, 2019 20:21 |
|
Use a for loop, look at each name, build up a total
|
# ? Jun 25, 2019 20:22 |
|
Assuming a is a list of words Make a counter that starts at 0 Loop through a for each word Check the letter count of each word Increment your counter by the number of letters When the loop is over, print the final count
|
# ? Jun 25, 2019 20:24 |
|
okay it might help to post the arrays a = [ "Euclid", "Archimedes", "Newton", "Descartes", "Fermat", "Turing", "Euler", "Einstein", "Boole", "Fibonacci", "Nash"] vowels = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U','u'] so i need to find each instance of the values in list vowels in list a and then increment a counter. so if i go code:
|
# ? Jun 25, 2019 20:27 |
|
wait poo poo thats the next question, i'm stuck on the find a number of letters instance
|
# ? Jun 25, 2019 20:29 |
|
i hate online courses
|
# ? Jun 25, 2019 20:29 |
|
Mycroft Holmes posted:wait poo poo thats the next question, i'm stuck on the find a number of letters instance nobody just wants to give you the answer but Python code:
|
# ? Jun 25, 2019 20:40 |
|
Hollow Talk posted:On top of an annoying day, I've banged my head against this a fair bit today: I'm on my phone so not a lot of details here, but there's nothing special about the requests library. You just have make sure you're patching it in the right place. If you're importing requests in foo.bar, you do mock.patch("foo.bar.requests"). If that's not where you're having trouble then it's likely with doing the side effects thing. Have you used side effects on anything before? I can't remember the exact syntax right now so I'll have to give you more help on it later.
|
# ? Jun 25, 2019 20:43 |
|
baka kaba posted:nobody just wants to give you the answer but except that answer fails n/m i'll wait until my teacher gets back to me
|
# ? Jun 25, 2019 20:47 |
|
Mycroft Holmes posted:except that answer fails You probably need to convert each name and your input letter to lowercase (or whatever, just so there's no mismatch) because 'e' won't match 'E'
|
# ? Jun 25, 2019 21:04 |
|
Thermopyle posted:I'm on my phone so not a lot of details here, but there's nothing special about the requests library. You just have make sure you're patching it in the right place. I managed to figure it out. The "where to patch"-thing was a good hint to go and look at it again, thanks for that. Side effects were working, but I didn't quite patch the right thing, or rather, I didn't patch enough. This was the solution (this is obviously simplified): module/submodule.py Python code:
Python code:
edit: syntax highlighting Hollow Talk fucked around with this message at 23:25 on Jun 25, 2019 |
# ? Jun 25, 2019 23:18 |
|
baka kaba posted:You probably need to convert each name and your input letter to lowercase (or whatever, just so there's no mismatch) because 'e' won't match 'E' The list of vowels posted has both capital and lowercase (for whatever reason) so I assume that's not the issue. I'm also not sure I really follow what the question is, exactly, since Mycroft Holmes seems to be talking about two different questions at the same time. Mycroft Holmes posted:so i need to find each instance of the values in list vowels in list a and then increment a counter. There's no reason to use a range here, because you want to iterate through all items in a list and for x in list will do that right out of the box. Based on the questions you posted before it, this seems to be a lesson about loops, and so I assume they want you to use nested loops to do something like this: Python code:
Python code:
Python code:
Wallet fucked around with this message at 23:22 on Jun 25, 2019 |
# ? Jun 25, 2019 23:20 |
|
|
# ? May 15, 2024 04:10 |
|
Wallet posted:The list of vowels posted has both capital and lowercase (for whatever reason) so I assume that's not the issue. I believe he was counting just 'E' or just 'e', and I assume he needed the count of both.
|
# ? Jun 25, 2019 23:28 |