workspace stringclasses 1
value | channel stringclasses 1
value | sentences stringlengths 1 3.93k | ts stringlengths 26 26 | user stringlengths 2 11 | sentence_id stringlengths 44 53 | timestamp float64 1.5B 1.56B | __index_level_0__ int64 0 106k |
|---|---|---|---|---|---|---|---|
pythondev | help | anyone know of any good resources for learning algorithms in python? | 2017-10-18T10:54:49.000620 | Bruno | pythondev_help_Bruno_2017-10-18T10:54:49.000620 | 1,508,324,089.00062 | 97,303 |
pythondev | help | there is some in our repo | 2017-10-18T10:55:24.000254 | Ciera | pythondev_help_Ciera_2017-10-18T10:55:24.000254 | 1,508,324,124.000254 | 97,304 |
pythondev | help | for the bot? | 2017-10-18T10:55:47.000051 | Bruno | pythondev_help_Bruno_2017-10-18T10:55:47.000051 | 1,508,324,147.000051 | 97,305 |
pythondev | help | well, going for an in person interview for a place in SF and I know algorithms will be a topic. so I need to brush up and try and learn some I am not familiar with. | 2017-10-18T10:57:00.000802 | Bruno | pythondev_help_Bruno_2017-10-18T10:57:00.000802 | 1,508,324,220.000802 | 97,306 |
pythondev | help | some times being self taught has its drawbacks. lol | 2017-10-18T10:57:12.000837 | Bruno | pythondev_help_Bruno_2017-10-18T10:57:12.000837 | 1,508,324,232.000837 | 97,307 |
pythondev | help | the learning ressource one | 2017-10-18T10:59:07.000360 | Ciera | pythondev_help_Ciera_2017-10-18T10:59:07.000360 | 1,508,324,347.00036 | 97,308 |
pythondev | help | <https://github.com/pyslackers/learning-resources/blob/master/topics/algorithms.md> | 2017-10-18T10:59:33.000260 | Ciera | pythondev_help_Ciera_2017-10-18T10:59:33.000260 | 1,508,324,373.00026 | 97,309 |
pythondev | help | ooh nice. thanks | 2017-10-18T11:03:40.000657 | Bruno | pythondev_help_Bruno_2017-10-18T11:03:40.000657 | 1,508,324,620.000657 | 97,310 |
pythondev | help | <@Ciera> :taco: | 2017-10-18T11:03:45.000347 | Bruno | pythondev_help_Bruno_2017-10-18T11:03:45.000347 | 1,508,324,625.000347 | 97,311 |
pythondev | help | i found this too <https://github.com/TheAlgorithms/Python> | 2017-10-18T11:04:24.000278 | Bruno | pythondev_help_Bruno_2017-10-18T11:04:24.000278 | 1,508,324,664.000278 | 97,312 |
pythondev | help | add it to the doc <@Bruno> | 2017-10-18T11:08:34.000266 | Johana | pythondev_help_Johana_2017-10-18T11:08:34.000266 | 1,508,324,914.000266 | 97,313 |
pythondev | help | What place? Just curious, I work in sf :) | 2017-10-18T11:10:56.000260 | Martha | pythondev_help_Martha_2017-10-18T11:10:56.000260 | 1,508,325,056.00026 | 97,314 |
pythondev | help | yea ill submit a PR | 2017-10-18T11:11:36.000088 | Bruno | pythondev_help_Bruno_2017-10-18T11:11:36.000088 | 1,508,325,096.000088 | 97,315 |
pythondev | help | done | 2017-10-18T11:16:13.000395 | Bruno | pythondev_help_Bruno_2017-10-18T11:16:13.000395 | 1,508,325,373.000395 | 97,316 |
pythondev | help | dropbox | 2017-10-18T11:21:26.000432 | Bruno | pythondev_help_Bruno_2017-10-18T11:21:26.000432 | 1,508,325,686.000432 | 97,317 |
pythondev | help | Sorry have a quick php question, anyone know why `$_FILES` would be empty when uploading a file? I am submitting the file via postman so the issue isn't malformed HTML and I have confirmed that the issue isn't coming from the settings mentioned in the link below (temp dir is set, file upload size isn't too small, etc). Also, this issue just started happening within the past week (we recently moved servers, which may have had some affect, but a similar upload worked yesterday in another spot so I'm not sure). Any help would be greatly appreciated:
<https://stackoverflow.com/questions/3586919/why-would-files-be-empty-when-uploading-files-to-php> | 2017-10-18T11:28:38.000807 | Vita | pythondev_help_Vita_2017-10-18T11:28:38.000807 | 1,508,326,118.000807 | 97,318 |
pythondev | help | Cool! Good luck :) | 2017-10-18T11:29:47.000422 | Martha | pythondev_help_Martha_2017-10-18T11:29:47.000422 | 1,508,326,187.000422 | 97,319 |
pythondev | help | thanks! | 2017-10-18T11:33:06.000742 | Bruno | pythondev_help_Bruno_2017-10-18T11:33:06.000742 | 1,508,326,386.000742 | 97,320 |
pythondev | help | <@Vita> for one this isnt php chat. 2, all of my suggestions are pretty much in the first answer in that SO post. did you confirm all of those and make sure those things were enabled or fixed? | 2017-10-18T11:37:12.000362 | Bruno | pythondev_help_Bruno_2017-10-18T11:37:12.000362 | 1,508,326,632.000362 | 97,321 |
pythondev | help | <@Bruno> yea i did, and sorry I know it wasnt php but i thought someone here might have knowledge on it, I can delete it if need be | 2017-10-18T11:38:05.000780 | Vita | pythondev_help_Vita_2017-10-18T11:38:05.000780 | 1,508,326,685.00078 | 97,322 |
pythondev | help | its fine. | 2017-10-18T11:38:22.000802 | Bruno | pythondev_help_Bruno_2017-10-18T11:38:22.000802 | 1,508,326,702.000802 | 97,323 |
pythondev | help | the first time i went into the #pocoo channel on irc i saw armin ronacher helping a guy. The guy was trying to run python scripts like php where the url is like `<http://mywebsite.com/file.py>` and trying to work with flask. I couldn’t believe how amazingly patient armin was. Armin kept repeating over and over for them to do the tutorial and they didn’t seem to want to try to understand. i eventually ended up with a headache b/c the guy was being so difficult and didn’t want to try any suggestions. I was impressed with how patient he was and it left an impression on me since i was just getting into Flask and saw the author himself helping someone who was being difficult and never losing their cool. | 2017-10-18T11:42:19.000137 | Johana | pythondev_help_Johana_2017-10-18T11:42:19.000137 | 1,508,326,939.000137 | 97,324 |
pythondev | help | and after that day i saw armin like one other time, lol. | 2017-10-18T11:45:11.000548 | Johana | pythondev_help_Johana_2017-10-18T11:45:11.000548 | 1,508,327,111.000548 | 97,325 |
pythondev | help | 0_o really cool of the author to do that, suprising the guy wouldnt listen to the AUTHOR of the framework | 2017-10-18T11:45:23.000145 | Vita | pythondev_help_Vita_2017-10-18T11:45:23.000145 | 1,508,327,123.000145 | 97,326 |
pythondev | help | yea, it was … difficult. i wanted to go nuts and yell, “PYTHON IS NOT PHP!!!!” | 2017-10-18T11:46:00.000453 | Johana | pythondev_help_Johana_2017-10-18T11:46:00.000453 | 1,508,327,160.000453 | 97,327 |
pythondev | help | Lol considering watching your patience with all of us in the <#C0LN2AD7T|flask> channel that makes me kinda cringe at the thought of hwo bad it was | 2017-10-18T11:46:56.000153 | Vita | pythondev_help_Vita_2017-10-18T11:46:56.000153 | 1,508,327,216.000153 | 97,328 |
pythondev | help | haha, like i said. he left an impression on me and now i try to take the patient approach. | 2017-10-18T11:47:34.000085 | Johana | pythondev_help_Johana_2017-10-18T11:47:34.000085 | 1,508,327,254.000085 | 97,329 |
pythondev | help | Nice! | 2017-10-18T11:48:06.000210 | Vita | pythondev_help_Vita_2017-10-18T11:48:06.000210 | 1,508,327,286.00021 | 97,330 |
pythondev | help | i guess i was really amazed that he would even take the time to help. | 2017-10-18T11:48:09.000311 | Johana | pythondev_help_Johana_2017-10-18T11:48:09.000311 | 1,508,327,289.000311 | 97,331 |
pythondev | help | It does say a lot about the guy willing to help a total beginner on it | 2017-10-18T11:49:33.000430 | Vita | pythondev_help_Vita_2017-10-18T11:49:33.000430 | 1,508,327,373.00043 | 97,332 |
pythondev | help | he’s a pretty interesting guy. i tried to ask him a lot of questions about his decisions in flask whenever i did get a chance to see him. He always gave these very simple yet cryptic replies. One time I asked kinda a silly question b/c i was a newb but impressed with the flexibility of Flask. I asked him what I could read, learn, or do to write applications that were extensible and flexible. He wrote back, “Don’t write software that isn’t flexible.” At the time I was confused and like “oh … ok”… but now I know what he meant and in the end it was a pretty good answer. | 2017-10-18T11:54:18.000568 | Johana | pythondev_help_Johana_2017-10-18T11:54:18.000568 | 1,508,327,658.000568 | 97,333 |
pythondev | help | Lol nice :joy: | 2017-10-18T11:54:58.000538 | Vita | pythondev_help_Vita_2017-10-18T11:54:58.000538 | 1,508,327,698.000538 | 97,334 |
pythondev | help | I feel like that should be followed with a "But don't write software that is too flexible" | 2017-10-18T11:55:01.000553 | Vada | pythondev_help_Vada_2017-10-18T11:55:01.000553 | 1,508,327,701.000553 | 97,335 |
pythondev | help | lol | 2017-10-18T11:55:06.000480 | Johana | pythondev_help_Johana_2017-10-18T11:55:06.000480 | 1,508,327,706.00048 | 97,336 |
pythondev | help | which can be a shortcoming for flask sometimes | 2017-10-18T11:55:17.000882 | Johana | pythondev_help_Johana_2017-10-18T11:55:17.000882 | 1,508,327,717.000882 | 97,337 |
pythondev | help | he later wrote me back saying he sometimes has trouble articulating his thoughts (i was very surprised by that b/c his writing is good) and that I should ensure that my stuff has a lot of “hooks”. | 2017-10-18T11:55:49.000491 | Johana | pythondev_help_Johana_2017-10-18T11:55:49.000491 | 1,508,327,749.000491 | 97,338 |
pythondev | help | i spent a lot of time looking up what hooks were lol. | 2017-10-18T11:55:56.000607 | Johana | pythondev_help_Johana_2017-10-18T11:55:56.000607 | 1,508,327,756.000607 | 97,339 |
pythondev | help | "Don't write software that isn't flexible" is itself a pretty flexible answer. | 2017-10-18T11:58:13.000034 | Sirena | pythondev_help_Sirena_2017-10-18T11:58:13.000034 | 1,508,327,893.000034 | 97,340 |
pythondev | help | I like the hooks line though | 2017-10-18T11:58:32.000015 | Vada | pythondev_help_Vada_2017-10-18T11:58:32.000015 | 1,508,327,912.000015 | 97,341 |
pythondev | help | i may have used the word extensible and not flexible but whatevs | 2017-10-18T11:58:34.000267 | Johana | pythondev_help_Johana_2017-10-18T11:58:34.000267 | 1,508,327,914.000267 | 97,342 |
pythondev | help | it was a number of years ago. | 2017-10-18T11:58:57.000145 | Johana | pythondev_help_Johana_2017-10-18T11:58:57.000145 | 1,508,327,937.000145 | 97,343 |
pythondev | help | I don't often think of my code in terms of events but it's probably worth putting myself in that mindset more | 2017-10-18T11:59:14.000033 | Vada | pythondev_help_Vada_2017-10-18T11:59:14.000033 | 1,508,327,954.000033 | 97,344 |
pythondev | help | they're interchangeable when you're not being terribly specific about your meaning | 2017-10-18T11:59:23.000841 | Sirena | pythondev_help_Sirena_2017-10-18T11:59:23.000841 | 1,508,327,963.000841 | 97,345 |
pythondev | help | Oh boy this is funky, I need to coerce csv values to match the type in the database (to abstract away some ETL stuff), is there a better way than:
```
def same_data(self, csv_row: Dict[str, str],
db_record: namedtuple) -> bool:
for csv_name, col_name in self.csv_to_col.items():
col_val = db_record._asdict()[col_name]
csv_val = type(col_val)(csv_row[csv_name]) # coerce
if col_val != csv_val:
return False
return True
```
where `col_name` is the database column name, `csv_name` is the csv column name, `db_record` is a named tuple from psycopg2, and `csv_row` is a dict from a csv.DictReader row | 2017-10-18T12:09:42.000079 | Beula | pythondev_help_Beula_2017-10-18T12:09:42.000079 | 1,508,328,582.000079 | 97,346 |
pythondev | help | TIL: `type( )( )` pattern | 2017-10-18T12:16:08.000069 | Winnifred | pythondev_help_Winnifred_2017-10-18T12:16:08.000069 | 1,508,328,968.000069 | 97,347 |
pythondev | help | I am not sure I recommend it yet, it's really the only reliable way I could think of doing the coercion to do the comparisons | 2017-10-18T12:16:32.000557 | Beula | pythondev_help_Beula_2017-10-18T12:16:32.000557 | 1,508,328,992.000557 | 97,348 |
pythondev | help | had a need to coerce values from an Excel import, into Django models, and I used a mapping of the columns to the type, not as concise as your example but explicit | 2017-10-18T12:19:37.000779 | Ronni | pythondev_help_Ronni_2017-10-18T12:19:37.000779 | 1,508,329,177.000779 | 97,349 |
pythondev | help | I thought about that as an option too - but I like the idea of the database being the "source of truth" for this project since it's just a data pipeline (I want it to be low maintenance). But that is a good option too | 2017-10-18T12:20:55.000284 | Beula | pythondev_help_Beula_2017-10-18T12:20:55.000284 | 1,508,329,255.000284 | 97,350 |
pythondev | help | do table columns and csv headers have same name or are they similar? | 2017-10-18T12:22:01.000219 | Winnifred | pythondev_help_Winnifred_2017-10-18T12:22:01.000219 | 1,508,329,321.000219 | 97,351 |
pythondev | help | Not always, but I just expanded it to default to the same if no `csv_to_col` is set on the class | 2017-10-18T12:22:25.000222 | Beula | pythondev_help_Beula_2017-10-18T12:22:25.000222 | 1,508,329,345.000222 | 97,352 |
pythondev | help | Because that is serving as a mapping of csv row to the db row | 2017-10-18T12:22:41.000193 | Beula | pythondev_help_Beula_2017-10-18T12:22:41.000193 | 1,508,329,361.000193 | 97,353 |
pythondev | help | yeah, I actually like this. I just noticed you’re using a namedtuple. | 2017-10-18T12:27:01.000747 | Winnifred | pythondev_help_Winnifred_2017-10-18T12:27:01.000747 | 1,508,329,621.000747 | 97,354 |
pythondev | help | Yep! Psycopg2 has a NamedTupleCursor | 2017-10-18T12:27:17.000237 | Beula | pythondev_help_Beula_2017-10-18T12:27:17.000237 | 1,508,329,637.000237 | 97,355 |
pythondev | help | also a dictcursor | 2017-10-18T12:27:41.000198 | Beula | pythondev_help_Beula_2017-10-18T12:27:41.000198 | 1,508,329,661.000198 | 97,356 |
pythondev | help | it made a lot more sense in my case b/c with Django as the intermediary the model class can still be the source of truth - I later created a module that uses the ModelForm so it can validate and coerce as necessary as well | 2017-10-18T12:28:24.000349 | Ronni | pythondev_help_Ronni_2017-10-18T12:28:24.000349 | 1,508,329,704.000349 | 97,357 |
pythondev | help | Yeah, that totally makes sense! | 2017-10-18T12:28:43.000040 | Beula | pythondev_help_Beula_2017-10-18T12:28:43.000040 | 1,508,329,723.00004 | 97,358 |
pythondev | help | yeah, the mapping aspect is covered here and I think that’s the important part — ~I wonder what the internals of the coercion are~ | 2017-10-18T12:29:08.000453 | Winnifred | pythondev_help_Winnifred_2017-10-18T12:29:08.000453 | 1,508,329,748.000453 | 97,359 |
pythondev | help | If it's a complex class it probably wont work, but it's all database primitives (Decimal, float, int, string) pretty much | 2017-10-18T12:29:50.000003 | Beula | pythondev_help_Beula_2017-10-18T12:29:50.000003 | 1,508,329,790.000003 | 97,360 |
pythondev | help | I don't see anything wrong with using `type` like you have here - you need to read that line a bit carefully to see what's going on, but it strikes me as a reasonable strategy | 2017-10-18T12:30:03.000713 | Ronni | pythondev_help_Ronni_2017-10-18T12:30:03.000713 | 1,508,329,803.000713 | 97,361 |
pythondev | help | And they all have constructors like `int('1')` or `str('foobar')` | 2017-10-18T12:30:15.000007 | Beula | pythondev_help_Beula_2017-10-18T12:30:15.000007 | 1,508,329,815.000007 | 97,362 |
pythondev | help | Thanks for the feedback on it, I will add a little comment to make sure it's clear when I come back in two weeks and :facepalm: about some bad assumption I made :joy: | 2017-10-18T12:30:42.000240 | Beula | pythondev_help_Beula_2017-10-18T12:30:42.000240 | 1,508,329,842.00024 | 97,363 |
pythondev | help | So I was reading <https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python> and I was wondering, what IS the standard? I wrote my own str_to_bool function and just reuse that, but it feels like there should be an easy built-in that I'm missing | 2017-10-18T13:37:27.000494 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:37:27.000494 | 1,508,333,847.000494 | 97,364 |
pythondev | help | <@Marcelina> I'm not sure that I get the question, so to clarify, you're trying to evaluate string `"False"` to `False` and `"True"` to `True` or what? | 2017-10-18T13:44:13.000691 | Mirian | pythondev_help_Mirian_2017-10-18T13:44:13.000691 | 1,508,334,253.000691 | 97,365 |
pythondev | help | Correct | 2017-10-18T13:44:22.000228 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:44:22.000228 | 1,508,334,262.000228 | 97,366 |
pythondev | help | `bool("False") = True` | 2017-10-18T13:44:29.000285 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:44:29.000285 | 1,508,334,269.000285 | 97,367 |
pythondev | help | write your own map, and a function to parse it correctly | 2017-10-18T13:44:45.000738 | Patty | pythondev_help_Patty_2017-10-18T13:44:45.000738 | 1,508,334,285.000738 | 97,368 |
pythondev | help | Which is what I did - I'm asking what's convention | 2017-10-18T13:44:56.000134 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:44:56.000134 | 1,508,334,296.000134 | 97,369 |
pythondev | help | Depends on what you're doing, IMO. In cases where you are accepting user input directly from a shell or something, then I would do the approach `input_value.lower() in ['yes', 'y', 'true', '1', ...]` | 2017-10-18T13:44:56.000370 | Beula | pythondev_help_Beula_2017-10-18T13:44:56.000370 | 1,508,334,296.00037 | 97,370 |
pythondev | help | Otherwise I'd just make sure the thing gives you the right `type` | 2017-10-18T13:45:07.000452 | Beula | pythondev_help_Beula_2017-10-18T13:45:07.000452 | 1,508,334,307.000452 | 97,371 |
pythondev | help | I don't believe there is a different convention than that | 2017-10-18T13:45:23.000610 | Beula | pythondev_help_Beula_2017-10-18T13:45:23.000610 | 1,508,334,323.00061 | 97,372 |
pythondev | help | Parsing a payload from a JSON object with users who go back and forth between using a bool correctly in a JSON payload vs sending it as a string | 2017-10-18T13:45:42.000537 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:45:42.000537 | 1,508,334,342.000537 | 97,373 |
pythondev | help | But cool | 2017-10-18T13:45:49.000602 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:45:49.000602 | 1,508,334,349.000602 | 97,374 |
pythondev | help | Sounds good | 2017-10-18T13:45:51.000470 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:45:51.000470 | 1,508,334,351.00047 | 97,375 |
pythondev | help | I just wasn't sure if there was a built-in I was missing | 2017-10-18T13:46:02.000160 | Marcelina | pythondev_help_Marcelina_2017-10-18T13:46:02.000160 | 1,508,334,362.00016 | 97,376 |
pythondev | help | If you are defining the contract for the API, only accept bools | 2017-10-18T13:46:13.000061 | Beula | pythondev_help_Beula_2017-10-18T13:46:13.000061 | 1,508,334,373.000061 | 97,377 |
pythondev | help | Or give a 400 | 2017-10-18T13:46:19.000352 | Beula | pythondev_help_Beula_2017-10-18T13:46:19.000352 | 1,508,334,379.000352 | 97,378 |
pythondev | help | No reason they can't do the work on the front end since a bool is valid in the JSON spec | 2017-10-18T13:46:31.000233 | Beula | pythondev_help_Beula_2017-10-18T13:46:31.000233 | 1,508,334,391.000233 | 97,379 |
pythondev | help | hello, people!
i am starting to use `pytest` for a project and trying to get my head around the best and correct design patterns of using fixtures.
specifically, i have a couple of questions:
1. if i want to have a fixture that can serve both a single test at function scope and a bunch of tests in a class/module scope (determined by command line option at runtime) - shall i create 2 fixtures that provide basically the same dependency (a Class instance, that prepares and exposes a resource I'm testing) but each decorated with different scope? what is the best way to tackle this?
2. is it common practice to use the request.config as a place to store shared data that can be accessed by different fixtures? what is the better way?
thanks for any help in advance! :slightly_smiling_face:
p.s.
are you familiar with any open source projects that leverage pytest extensively - for more than just unit tests, with complex fixtures that uses other fixtures, etc... so one could learn from? | 2017-10-19T05:07:14.000359 | Arlean | pythondev_help_Arlean_2017-10-19T05:07:14.000359 | 1,508,389,634.000359 | 97,380 |
pythondev | help | <@Arlean> 1. Why? Do you have an example?
2. I'd use a shared session-scoped fixture instead | 2017-10-19T05:15:03.000176 | Collette | pythondev_help_Collette_2017-10-19T05:15:03.000176 | 1,508,390,103.000176 | 97,381 |
pythondev | help | I am using the open() function to append a file however, this function creates a new file if it does not exist. How do I disable this part. I only want to append existing files and not create new ones if they aren't available. Any help would be much appreciated | 2017-10-19T06:22:47.000181 | Ronald | pythondev_help_Ronald_2017-10-19T06:22:47.000181 | 1,508,394,167.000181 | 97,382 |
pythondev | help | check if a file exists first | 2017-10-19T06:25:17.000350 | Meg | pythondev_help_Meg_2017-10-19T06:25:17.000350 | 1,508,394,317.00035 | 97,383 |
pythondev | help | then open it | 2017-10-19T06:25:20.000140 | Meg | pythondev_help_Meg_2017-10-19T06:25:20.000140 | 1,508,394,320.00014 | 97,384 |
pythondev | help | use `os.path.isfile()` | 2017-10-19T06:25:41.000148 | Scot | pythondev_help_Scot_2017-10-19T06:25:41.000148 | 1,508,394,341.000148 | 97,385 |
pythondev | help | for checking existence | 2017-10-19T06:26:01.000250 | Scot | pythondev_help_Scot_2017-10-19T06:26:01.000250 | 1,508,394,361.00025 | 97,386 |
pythondev | help | or `os.path.exists()`
they basically do the same thing here | 2017-10-19T06:26:33.000167 | Meg | pythondev_help_Meg_2017-10-19T06:26:33.000167 | 1,508,394,393.000167 | 97,387 |
pythondev | help | When would i use `exist` over `isfile` ? | 2017-10-19T06:27:37.000147 | Scot | pythondev_help_Scot_2017-10-19T06:27:37.000147 | 1,508,394,457.000147 | 97,388 |
pythondev | help | Works for directories as well I see | 2017-10-19T06:29:04.000155 | Scot | pythondev_help_Scot_2017-10-19T06:29:04.000155 | 1,508,394,544.000155 | 97,389 |
pythondev | help | correct | 2017-10-19T06:30:04.000071 | Meg | pythondev_help_Meg_2017-10-19T06:30:04.000071 | 1,508,394,604.000071 | 97,390 |
pythondev | help | so, its a bit of duplicate functionality | 2017-10-19T06:30:12.000217 | Meg | pythondev_help_Meg_2017-10-19T06:30:12.000217 | 1,508,394,612.000217 | 97,391 |
pythondev | help | `isfile` would work for a path to a file, `isdir` is for a path to a directory | 2017-10-19T06:30:49.000300 | Meg | pythondev_help_Meg_2017-10-19T06:30:49.000300 | 1,508,394,649.0003 | 97,392 |
pythondev | help | `exists` covers both, with some potential issues of permissions | 2017-10-19T06:31:31.000367 | Meg | pythondev_help_Meg_2017-10-19T06:31:31.000367 | 1,508,394,691.000367 | 97,393 |
pythondev | help | I'd rather go with ```
try:
with open(filename, 'r+') as f:
f.seek(0, 2) # Seek to the end of the file
# proceed with reading/writing
except FileNotFoundError:
pass
``` | 2017-10-19T06:31:35.000386 | Collette | pythondev_help_Collette_2017-10-19T06:31:35.000386 | 1,508,394,695.000386 | 97,394 |
pythondev | help | `os.path.exists` and `os.path.isfile` are both error-prone to race conditions | 2017-10-19T06:31:53.000374 | Collette | pythondev_help_Collette_2017-10-19T06:31:53.000374 | 1,508,394,713.000374 | 97,395 |
pythondev | help | Seems a bit of an overkill for most of my purposes, but good to know... | 2017-10-19T06:32:57.000001 | Scot | pythondev_help_Scot_2017-10-19T06:32:57.000001 | 1,508,394,777.000001 | 97,396 |
pythondev | help | ```
import os
if os.path.exists(filename):
with open(filename, 'a+') as f:
# proceed with reading/writing
```
is only 2 lines shorter. The correct version doesn't seem to be a huge overkill to me :slightly_smiling_face: | 2017-10-19T06:34:43.000210 | Collette | pythondev_help_Collette_2017-10-19T06:34:43.000210 | 1,508,394,883.00021 | 97,397 |
pythondev | help | Enlighten a dummy: Any penalty to speed using `seek`? My files are in the 10-100Gb sizes from time to time | 2017-10-19T06:36:47.000216 | Scot | pythondev_help_Scot_2017-10-19T06:36:47.000216 | 1,508,395,007.000216 | 97,398 |
pythondev | help | You need to be at the end of the file if you want to append, so it's doing nothing that wouldn't already be done | 2017-10-19T06:40:51.000314 | Gabriele | pythondev_help_Gabriele_2017-10-19T06:40:51.000314 | 1,508,395,251.000314 | 97,399 |
pythondev | help | <@Scot> CPython calls `lseek` with `whence=SEEK_END`
<https://github.com/python/cpython/blob/master/Modules/_io/fileio.c#L908> | 2017-10-19T06:42:24.000251 | Collette | pythondev_help_Collette_2017-10-19T06:42:24.000251 | 1,508,395,344.000251 | 97,400 |
pythondev | help | I suspect I may have misunderstood the intent of the `seek` way of doing it from the get-go. Understood it as a general better replacement to using `os.path.isfile` | 2017-10-19T06:42:35.000162 | Scot | pythondev_help_Scot_2017-10-19T06:42:35.000162 | 1,508,395,355.000162 | 97,401 |
pythondev | help | No, `seek` is a way to move the current file pointer over the file as you wish | 2017-10-19T06:45:30.000284 | Collette | pythondev_help_Collette_2017-10-19T06:45:30.000284 | 1,508,395,530.000284 | 97,402 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.