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 | What are some best practices when it comes to storing secrets (api keys, passwords, ...) for usage in Python?
Obviously I won't store them in git,but I need to access them without prompting the user for a password | 2019-03-04T07:36:07.381900 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:36:07.381900 | 1,551,684,967.3819 | 11,821 |
pythondev | help | <@Jonas> :taco: | 2019-03-04T07:36:34.382500 | Jung | pythondev_help_Jung_2019-03-04T07:36:34.382500 | 1,551,684,994.3825 | 11,822 |
pythondev | help | Just a file placed outside of version control? | 2019-03-04T07:36:36.382800 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:36:36.382800 | 1,551,684,996.3828 | 11,823 |
pythondev | help | what is the environment? an end user's machine or a server? | 2019-03-04T07:38:41.383400 | Karoline | pythondev_help_Karoline_2019-03-04T07:38:41.383400 | 1,551,685,121.3834 | 11,824 |
pythondev | help | Server, both cloud and physical machine at the customer. Must work without Internet access.
All keys/passwords/secrets are limited to that customer, so if they figure out how to read the data they only get access to their own stuff | 2019-03-04T07:40:25.385000 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:40:25.385000 | 1,551,685,225.385 | 11,825 |
pythondev | help | in this case I'd probably allow for configuration via environment variable or config file. potentially via CLI argument as well | 2019-03-04T07:42:06.385900 | Karoline | pythondev_help_Karoline_2019-03-04T07:42:06.385900 | 1,551,685,326.3859 | 11,826 |
pythondev | help | this lets them figure out how to store these things securely (or not, it's up to them), and keeps your application agnostic to those details | 2019-03-04T07:43:11.386500 | Karoline | pythondev_help_Karoline_2019-03-04T07:43:11.386500 | 1,551,685,391.3865 | 11,827 |
pythondev | help | We are responsible for the servers as well as the applications, they just get a box from us and plug in, so we are responsible for everything.
Env. variables or config file is probably good enough, then we can use some proper password handling on our side to store everyones keys/secrets | 2019-03-04T07:44:48.388100 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:44:48.388100 | 1,551,685,488.3881 | 11,828 |
pythondev | help | ah, I didn't realize you would be handling the full environment. | 2019-03-04T07:45:48.388500 | Karoline | pythondev_help_Karoline_2019-03-04T07:45:48.388500 | 1,551,685,548.3885 | 11,829 |
pythondev | help | well without an internet connection how will the handling of keys/secrets work? | 2019-03-04T07:46:12.389000 | Karoline | pythondev_help_Karoline_2019-03-04T07:46:12.389000 | 1,551,685,572.389 | 11,830 |
pythondev | help | and what are these keys/secrets for? | 2019-03-04T07:46:24.389200 | Karoline | pythondev_help_Karoline_2019-03-04T07:46:24.389200 | 1,551,685,584.3892 | 11,831 |
pythondev | help | We assume that we have Internet access most of the times, but it might drop and our system should work regardless.
It's both S3 keys as well as password to the local Raspberry Pis and databases et c. | 2019-03-04T07:48:56.391900 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:48:56.391900 | 1,551,685,736.3919 | 11,832 |
pythondev | help | Obviously the S3 integration will not work without an Internet access, but the local RPis should be accessable regardless. | 2019-03-04T07:49:22.392500 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:49:22.392500 | 1,551,685,762.3925 | 11,833 |
pythondev | help | are local raspberry pis the machine it itself is on or some other machine on the same network? | 2019-03-04T07:49:59.393000 | Karoline | pythondev_help_Karoline_2019-03-04T07:49:59.393000 | 1,551,685,799.393 | 11,834 |
pythondev | help | are the databases local or remote? | 2019-03-04T07:50:16.393400 | Karoline | pythondev_help_Karoline_2019-03-04T07:50:16.393400 | 1,551,685,816.3934 | 11,835 |
pythondev | help | There is one central local server and then any amount of other local machines such as RPi. | 2019-03-04T07:52:06.394800 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:52:06.394800 | 1,551,685,926.3948 | 11,836 |
pythondev | help | I'd probably centralize any remote services you need under a single set of user credentials and use IAM to delegate access, and then yeah, have your application pull down any other credentials needed at start - presuming that part can require an internet connection, you only need one set of credentials | 2019-03-04T07:56:49.397300 | Karoline | pythondev_help_Karoline_2019-03-04T07:56:49.397300 | 1,551,686,209.3973 | 11,837 |
pythondev | help | and you can provide that to the applications via the mechanisms discussed above | 2019-03-04T07:57:08.397700 | Karoline | pythondev_help_Karoline_2019-03-04T07:57:08.397700 | 1,551,686,228.3977 | 11,838 |
pythondev | help | good idea <@Karoline> :taco:. will investigate that track | 2019-03-04T07:58:51.398200 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:58:51.398200 | 1,551,686,331.3982 | 11,839 |
pythondev | help | <@Karoline> :taco: (doesn't work when editing messages?) | 2019-03-04T07:59:54.398900 | Yaeko | pythondev_help_Yaeko_2019-03-04T07:59:54.398900 | 1,551,686,394.3989 | 11,840 |
pythondev | help | yeah it doesn't pick it up unless it's part of the first message | 2019-03-04T08:00:10.399200 | Karoline | pythondev_help_Karoline_2019-03-04T08:00:10.399200 | 1,551,686,410.3992 | 11,841 |
pythondev | help | :pacman: | 2019-03-04T08:00:16.399400 | Karoline | pythondev_help_Karoline_2019-03-04T08:00:16.399400 | 1,551,686,416.3994 | 11,842 |
pythondev | help | `>>> {frozenset([1, 2]), frozenset([2, 1])} == {frozenset([1, 2])}`
`True` | 2019-03-04T08:30:25.401900 | Johana | pythondev_help_Johana_2019-03-04T08:30:25.401900 | 1,551,688,225.4019 | 11,843 |
pythondev | help | Hello everyone.
What the best library for convert string with a date to python DateTime format?
I have many different strings and many strings look different.
For example:
```
1/2/2019 6:32:00 PM
```
Or
```
1.2.2019 16:32:00
```
etc
Thank you very much. | 2019-03-04T08:45:58.402300 | Jung | pythondev_help_Jung_2019-03-04T08:45:58.402300 | 1,551,689,158.4023 | 11,844 |
pythondev | help | `arrow` is a great datetime lib. I’ve linked to the section on datetime creation from a string. It can handle parsing ISO-8601 compliant date strings without a format argument, but for any other format you will need to provide the formatting yourself (and that will be true all datetime libs as far as I am aware) <https://arrow.readthedocs.io/en/latest/#creation> | 2019-03-04T08:53:17.404600 | Clemmie | pythondev_help_Clemmie_2019-03-04T08:53:17.404600 | 1,551,689,597.4046 | 11,845 |
pythondev | help | thanks for pointing me to that library <@Clemmie>, I can definitely use it for one of my projects! | 2019-03-04T08:54:48.405700 | Genaro | pythondev_help_Genaro_2019-03-04T08:54:48.405700 | 1,551,689,688.4057 | 11,846 |
pythondev | help | <@Clemmie> :taco: | 2019-03-04T09:34:26.406100 | Jung | pythondev_help_Jung_2019-03-04T09:34:26.406100 | 1,551,692,066.4061 | 11,847 |
pythondev | help | I need to find dbg/debuginfo (both deb and rpm) packages in an application repository depending on the app version and OS (centos, ubuntu, debian, etc).
Does anyone have an example of a good python crawler that I can use for this purpose? | 2019-03-04T10:05:00.408100 | Jennifer | pythondev_help_Jennifer_2019-03-04T10:05:00.408100 | 1,551,693,900.4081 | 11,848 |
pythondev | help | Just installed a fresh copy of Python on a new laptop and it seems it didn't set any environment variables. Is that normal? I thought there would be a variable that refers to Python.exe? | 2019-03-04T10:07:21.409500 | Bobbi | pythondev_help_Bobbi_2019-03-04T10:07:21.409500 | 1,551,694,041.4095 | 11,849 |
pythondev | help | What kind of environment variable? Why would you think that? | 2019-03-04T10:20:15.409800 | Jonas | pythondev_help_Jonas_2019-03-04T10:20:15.409800 | 1,551,694,815.4098 | 11,850 |
pythondev | help | <@Jimmy> :taco: for your help. | 2019-03-04T10:23:14.410500 | Jamey | pythondev_help_Jamey_2019-03-04T10:23:14.410500 | 1,551,694,994.4105 | 11,851 |
pythondev | help | Not sure for what that is but thanks | 2019-03-04T10:35:54.410800 | Jimmy | pythondev_help_Jimmy_2019-03-04T10:35:54.410800 | 1,551,695,754.4108 | 11,852 |
pythondev | help | i currently have the following for an Elasticsearch query class and two files worth of queries. I want to be able to have the queries being part of the instantiated class if possible without moving all of the query functions into the class itself? Is there a way to do this with some kind of inheritance? Let me know if anything is unclear thanks! | 2019-03-04T11:20:51.411000 | Mica | pythondev_help_Mica_2019-03-04T11:20:51.411000 | 1,551,698,451.411 | 11,853 |
pythondev | help | the two files are queries specific to independent ES indexes | 2019-03-04T11:21:13.411600 | Mica | pythondev_help_Mica_2019-03-04T11:21:13.411600 | 1,551,698,473.4116 | 11,854 |
pythondev | help | I'm confused by ```I want to be able to have the queries being part of the instantiated class if possible without moving all of the query functions into the class itself?``` do these query functions already exist? | 2019-03-04T11:23:47.412000 | Lillia | pythondev_help_Lillia_2019-03-04T11:23:47.412000 | 1,551,698,627.412 | 11,855 |
pythondev | help | Or is `first_query()` an example of one? | 2019-03-04T11:24:04.412300 | Lillia | pythondev_help_Lillia_2019-03-04T11:24:04.412300 | 1,551,698,644.4123 | 11,856 |
pythondev | help | just an example and they do exist. I have one file that has the class defined with all the key components such as IP and port, and I've recently added the ability to parse indexes and doc_type to the class. I have to files containing queries for the ES using this Model, originally each query instantiated a new class instance and used that for the query. I was wondering if it would be possible to get around that by making the queries a part of the class without copy pasting them into the actual class code and making it some several hundred line file | 2019-03-04T11:26:28.414900 | Mica | pythondev_help_Mica_2019-03-04T11:26:28.414900 | 1,551,698,788.4149 | 11,857 |
pythondev | help | so:
```
class Foo:
...
def query():
Foo().query()
```
is what i had | 2019-03-04T11:27:12.415700 | Mica | pythondev_help_Mica_2019-03-04T11:27:12.415700 | 1,551,698,832.4157 | 11,858 |
pythondev | help | but I don't think it's right, though I could be wrong | 2019-03-04T11:27:24.416000 | Mica | pythondev_help_Mica_2019-03-04T11:27:24.416000 | 1,551,698,844.416 | 11,859 |
pythondev | help | I would say don’t compromise clarity and readability for some amorphous idea that the file is “too long” if the queries are cognitively tied to the class, then make them part of it | 2019-03-04T11:29:01.417500 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:29:01.417500 | 1,551,698,941.4175 | 11,860 |
pythondev | help | If all these queries rely on the same data (in this case, IP/port, indices, doc_types) then moving them into the class is probably the best option | 2019-03-04T11:29:03.417600 | Lillia | pythondev_help_Lillia_2019-03-04T11:29:03.417600 | 1,551,698,943.4176 | 11,861 |
pythondev | help | :thumbsup: cheers guys, at least i think I'm moving it in the right direction (i think) haha | 2019-03-04T11:29:54.419100 | Mica | pythondev_help_Mica_2019-03-04T11:29:54.419100 | 1,551,698,994.4191 | 11,862 |
pythondev | help | too much second guessing | 2019-03-04T11:30:00.419500 | Mica | pythondev_help_Mica_2019-03-04T11:30:00.419500 | 1,551,699,000.4195 | 11,863 |
pythondev | help | If they are not, then you probably want something where the class sets up the connections and workflow, and then fires a query. You could have a method
```
class Foo:
def run(query_function):
query_function()
``` | 2019-03-04T11:30:24.420200 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:30:24.420200 | 1,551,699,024.4202 | 11,864 |
pythondev | help | ^ was going to be my second suggestion | 2019-03-04T11:30:41.420800 | Lillia | pythondev_help_Lillia_2019-03-04T11:30:41.420800 | 1,551,699,041.4208 | 11,865 |
pythondev | help | and call it with
```
def a():
do_a_query_here....
foo.run(a)
``` | 2019-03-04T11:30:55.421400 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:30:55.421400 | 1,551,699,055.4214 | 11,866 |
pythondev | help | FWIW you can also go the other way around, where you pass the `Foo` object into the query function. Think of how you pass a database engine/connection to some frameworks. | 2019-03-04T11:32:08.423200 | Lillia | pythondev_help_Lillia_2019-03-04T11:32:08.423200 | 1,551,699,128.4232 | 11,867 |
pythondev | help | ye, I've migrated to having a single instance shared across the application with the index/doc_type loaded by the Flask app instance config info. However i want to be able to change the index in a query function. This meant i needed a separate ES connection instance for each endpoint request which can accept a custom data. currently just banging my head and second guessing :sweat_smile: | 2019-03-04T11:33:15.424400 | Mica | pythondev_help_Mica_2019-03-04T11:33:15.424400 | 1,551,699,195.4244 | 11,868 |
pythondev | help | ye, so like a decorator? | 2019-03-04T11:33:21.424700 | Mica | pythondev_help_Mica_2019-03-04T11:33:21.424700 | 1,551,699,201.4247 | 11,869 |
pythondev | help | ^great suggestion if you have queries that can be run by different backends | 2019-03-04T11:33:31.425100 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:33:31.425100 | 1,551,699,211.4251 | 11,870 |
pythondev | help | Not a decorator, because you want it to be dynamic | 2019-03-04T11:34:02.425500 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:34:02.425500 | 1,551,699,242.4255 | 11,871 |
pythondev | help | you have an abstract class SearchClass | 2019-03-04T11:34:17.425900 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:34:17.425900 | 1,551,699,257.4259 | 11,872 |
pythondev | help | that defines an abstract method `run` | 2019-03-04T11:34:27.426200 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:34:27.426200 | 1,551,699,267.4262 | 11,873 |
pythondev | help | you implement `run` for however individual backends run their query type | 2019-03-04T11:34:58.426900 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:34:58.426900 | 1,551,699,298.4269 | 11,874 |
pythondev | help | then your queries take a `klass` parameter and do this
```
def query1(klass):
klass.run(query1_specifics....)
```
You can even type hint that the `klass` needs to implement `SearchClass`, or just handle the attribute and notimplemented errors | 2019-03-04T11:36:48.429000 | Clemmie | pythondev_help_Clemmie_2019-03-04T11:36:48.429000 | 1,551,699,408.429 | 11,875 |
pythondev | help | :taco: <@Clemmie> for elaboration | 2019-03-04T11:39:21.429600 | Lillia | pythondev_help_Lillia_2019-03-04T11:39:21.429600 | 1,551,699,561.4296 | 11,876 |
pythondev | help | <@Clemmie> <@Lillia> :taco: :taco: thanks guys appreciate it! | 2019-03-04T11:41:26.430100 | Mica | pythondev_help_Mica_2019-03-04T11:41:26.430100 | 1,551,699,686.4301 | 11,877 |
pythondev | help | I think migrating the functions to the class makes the most sense for me, appreciate the extra info tho | 2019-03-04T11:43:42.430900 | Mica | pythondev_help_Mica_2019-03-04T11:43:42.430900 | 1,551,699,822.4309 | 11,878 |
pythondev | help | I have imported a module into another one that I want to run. But it doesn't run, so for example;
```
import module_b
#######some other code
mobule_b
```
Is this correct way of doing it as at the moment the module is not being run | 2019-03-04T11:52:11.433500 | Arturo | pythondev_help_Arturo_2019-03-04T11:52:11.433500 | 1,551,700,331.4335 | 11,879 |
pythondev | help | you need to run the specific function | 2019-03-04T11:52:47.434000 | Mica | pythondev_help_Mica_2019-03-04T11:52:47.434000 | 1,551,700,367.434 | 11,880 |
pythondev | help | so importing the module only loads the file containing the functions, you need to actually run the specific function you want to | 2019-03-04T11:53:21.434600 | Mica | pythondev_help_Mica_2019-03-04T11:53:21.434600 | 1,551,700,401.4346 | 11,881 |
pythondev | help | Isn't there a way just to run the whole module. Could I use `subrocess` or something like that? | 2019-03-04T11:54:47.435400 | Arturo | pythondev_help_Arturo_2019-03-04T11:54:47.435400 | 1,551,700,487.4354 | 11,882 |
pythondev | help | sorry `subprocess` | 2019-03-04T11:55:11.436200 | Arturo | pythondev_help_Arturo_2019-03-04T11:55:11.436200 | 1,551,700,511.4362 | 11,883 |
pythondev | help | you can do the if '__main__' == ... and that works, but only if you call that module using python | 2019-03-04T11:55:18.436700 | Mica | pythondev_help_Mica_2019-03-04T11:55:18.436700 | 1,551,700,518.4367 | 11,884 |
pythondev | help | What do you mean "the whole module"? Is there an `if __name__ == '__main__'`? | 2019-03-04T11:55:18.436800 | Lillia | pythondev_help_Lillia_2019-03-04T11:55:18.436800 | 1,551,700,518.4368 | 11,885 |
pythondev | help | The whole module will be "run" when you import it. | 2019-03-04T11:55:20.436900 | Melynda | pythondev_help_Melynda_2019-03-04T11:55:20.436900 | 1,551,700,520.4369 | 11,886 |
pythondev | help | ah ok | 2019-03-04T11:55:52.437200 | Arturo | pythondev_help_Arturo_2019-03-04T11:55:52.437200 | 1,551,700,552.4372 | 11,887 |
pythondev | help | I want to run it after a certain function | 2019-03-04T11:56:02.437500 | Arturo | pythondev_help_Arturo_2019-03-04T11:56:02.437500 | 1,551,700,562.4375 | 11,888 |
pythondev | help | why not bundle the code into a function and run that? | 2019-03-04T11:56:24.438400 | Mica | pythondev_help_Mica_2019-03-04T11:56:24.438400 | 1,551,700,584.4384 | 11,889 |
pythondev | help | guess I will rearrange some code to call a specific function | 2019-03-04T11:56:24.438500 | Arturo | pythondev_help_Arturo_2019-03-04T11:56:24.438500 | 1,551,700,584.4385 | 11,890 |
pythondev | help | it was a module I built a while back that was stand-alone, but now need to invoke it from another module | 2019-03-04T11:56:59.439500 | Arturo | pythondev_help_Arturo_2019-03-04T11:56:59.439500 | 1,551,700,619.4395 | 11,891 |
pythondev | help | you can bundle it into a separate function, but also have the `if __name__ == '__main__'` | 2019-03-04T11:57:29.440000 | Mica | pythondev_help_Mica_2019-03-04T11:57:29.440000 | 1,551,700,649.44 | 11,892 |
pythondev | help | that way you can run it stand alone or import and run it | 2019-03-04T11:57:38.440300 | Mica | pythondev_help_Mica_2019-03-04T11:57:38.440300 | 1,551,700,658.4403 | 11,893 |
pythondev | help | cool thanks everyone <@Mica> <@Melynda> <@Lillia> :taco: | 2019-03-04T11:58:40.441200 | Arturo | pythondev_help_Arturo_2019-03-04T11:58:40.441200 | 1,551,700,720.4412 | 11,894 |
pythondev | help | sorry one more thing <@Mica> should I have `if __name__ == '__main__'` in every module? | 2019-03-04T12:06:28.442100 | Arturo | pythondev_help_Arturo_2019-03-04T12:06:28.442100 | 1,551,701,188.4421 | 11,895 |
pythondev | help | nah, just the ones you might want to run independently | 2019-03-04T12:06:48.442400 | Mica | pythondev_help_Mica_2019-03-04T12:06:48.442400 | 1,551,701,208.4424 | 11,896 |
pythondev | help | ok that makes sense | 2019-03-04T12:07:03.442900 | Arturo | pythondev_help_Arturo_2019-03-04T12:07:03.442900 | 1,551,701,223.4429 | 11,897 |
pythondev | help | so you only put it in files where you might want to `python file.py` the specific file | 2019-03-04T12:07:04.443000 | Mica | pythondev_help_Mica_2019-03-04T12:07:04.443000 | 1,551,701,224.443 | 11,898 |
pythondev | help | <https://github.com/python/cpython/blob/master/Lib/json/tool.py> is a really cool example of having a specific file in a module acting as a "main" | 2019-03-04T12:08:27.443500 | Lillia | pythondev_help_Lillia_2019-03-04T12:08:27.443500 | 1,551,701,307.4435 | 11,899 |
pythondev | help | Hi, anyone used RotatingFileHandler for logging before? I wonder whether it deletes the old logs after specified number of backups file will be filled with logs. I mean, assume you have 5 backups with 20 MB each, and after you reached total of 100 MB of log, old logs will be deleted to reserve a space for upcoming logs. | 2019-03-04T13:40:33.446400 | Doretta | pythondev_help_Doretta_2019-03-04T13:40:33.446400 | 1,551,706,833.4464 | 11,900 |
pythondev | help | I don't think so | 2019-03-04T13:50:13.446600 | Jonas | pythondev_help_Jonas_2019-03-04T13:50:13.446600 | 1,551,707,413.4466 | 11,901 |
pythondev | help | IMO use logrotate for this | 2019-03-04T13:50:21.447000 | Jonas | pythondev_help_Jonas_2019-03-04T13:50:21.447000 | 1,551,707,421.447 | 11,902 |
pythondev | help | Actually, I am now experimenting this, and it looks like it is behaving in a way that i describe above. But still observing, will update here in case I find something else. | 2019-03-04T13:58:19.448000 | Doretta | pythondev_help_Doretta_2019-03-04T13:58:19.448000 | 1,551,707,899.448 | 11,903 |
pythondev | help | Seems like there is a problem, raising during logging and says that file being used by another process which I don't think so | 2019-03-04T14:02:24.448800 | Doretta | pythondev_help_Doretta_2019-03-04T14:02:24.448800 | 1,551,708,144.4488 | 11,904 |
pythondev | help | Permission Error | 2019-03-04T14:03:18.449000 | Doretta | pythondev_help_Doretta_2019-03-04T14:03:18.449000 | 1,551,708,198.449 | 11,905 |
pythondev | help | I am opening a large csv file (4.6 GB) with a context manager | 2019-03-04T14:16:30.450300 | Alvina | pythondev_help_Alvina_2019-03-04T14:16:30.450300 | 1,551,708,990.4503 | 11,906 |
pythondev | help | but I want to add an if statement (if filename.endswith('.gz') as file: | 2019-03-04T14:16:47.450700 | Alvina | pythondev_help_Alvina_2019-03-04T14:16:47.450700 | 1,551,709,007.4507 | 11,907 |
pythondev | help | is there a way to do this without duplicating all of the code beneath the context manager? | 2019-03-04T14:17:10.451100 | Alvina | pythondev_help_Alvina_2019-03-04T14:17:10.451100 | 1,551,709,030.4511 | 11,908 |
pythondev | help | None | 2019-03-04T14:17:41.451700 | Alvina | pythondev_help_Alvina_2019-03-04T14:17:41.451700 | 1,551,709,061.4517 | 11,909 |
pythondev | help | One way to do it would be to create a helper function containing the `if` logic, which returns the file handle. | 2019-03-04T14:18:09.453000 | Sasha | pythondev_help_Sasha_2019-03-04T14:18:09.453000 | 1,551,709,089.453 | 11,910 |
pythondev | help | functions are first class objects, so you can "choose" which function you're going to use based on any conditions, and then use it one time | 2019-03-04T14:18:35.454400 | Jettie | pythondev_help_Jettie_2019-03-04T14:18:35.454400 | 1,551,709,115.4544 | 11,911 |
pythondev | help | Go for clarity not cleverness here, do what <@Sasha> said | 2019-03-04T14:19:01.456100 | Lillia | pythondev_help_Lillia_2019-03-04T14:19:01.456100 | 1,551,709,141.4561 | 11,912 |
pythondev | help | i.e., `opener = gzip.open if filename.endswith('.gz') else open` | 2019-03-04T14:19:05.456500 | Jettie | pythondev_help_Jettie_2019-03-04T14:19:05.456500 | 1,551,709,145.4565 | 11,913 |
pythondev | help | but less ugly than this | 2019-03-04T14:19:23.457300 | Jettie | pythondev_help_Jettie_2019-03-04T14:19:23.457300 | 1,551,709,163.4573 | 11,914 |
pythondev | help | ```opener = open
if filename.endswith('.gz'):
opener = gzip.open
with opener(file=filename, mode='r') as file:
...``` | 2019-03-04T14:20:04.459100 | Lillia | pythondev_help_Lillia_2019-03-04T14:20:04.459100 | 1,551,709,204.4591 | 11,915 |
pythondev | help | IMO | 2019-03-04T14:20:09.459400 | Lillia | pythondev_help_Lillia_2019-03-04T14:20:09.459400 | 1,551,709,209.4594 | 11,916 |
pythondev | help | In python that shouldn’t be considered cleverness - it is one of the reasons to use python | 2019-03-04T14:20:09.459500 | Clemmie | pythondev_help_Clemmie_2019-03-04T14:20:09.459500 | 1,551,709,209.4595 | 11,917 |
pythondev | help | I more meant "don't put a ternary in the `with` statement" :smile: | 2019-03-04T14:20:28.459800 | Lillia | pythondev_help_Lillia_2019-03-04T14:20:28.459800 | 1,551,709,228.4598 | 11,918 |
pythondev | help | oh, yeah,ok - don’t do that | 2019-03-04T14:20:46.460200 | Clemmie | pythondev_help_Clemmie_2019-03-04T14:20:46.460200 | 1,551,709,246.4602 | 11,919 |
pythondev | help | <@Lillia> testing now! | 2019-03-04T14:24:00.464100 | Alvina | pythondev_help_Alvina_2019-03-04T14:24:00.464100 | 1,551,709,440.4641 | 11,920 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.