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
json, secrets, asyncio etc
2018-02-21T13:49:49.000063
Porsha
pythondev_help_Porsha_2018-02-21T13:49:49.000063
1,519,220,989.000063
35,224
pythondev
help
when you say missing, do you mean not in the virtualenv location or not importable?
2018-02-21T13:49:55.000084
Floy
pythondev_help_Floy_2018-02-21T13:49:55.000084
1,519,220,995.000084
35,225
pythondev
help
Literally not included in the Lib folder of the virtualenv
2018-02-21T13:50:16.000499
Porsha
pythondev_help_Porsha_2018-02-21T13:50:16.000499
1,519,221,016.000499
35,226
pythondev
help
and yet you have no problem actually importing the libs?
2018-02-21T13:50:38.000064
Floy
pythondev_help_Floy_2018-02-21T13:50:38.000064
1,519,221,038.000064
35,227
pythondev
help
I have pycharm set to use the virtualenv path for a particular project. I can import 3rd party packages installed via pip (in the virtualenv) and some of the standard library, however when I try and import json or secrets it imports it from my base python
2018-02-21T13:52:12.000403
Porsha
pythondev_help_Porsha_2018-02-21T13:52:12.000403
1,519,221,132.000403
35,228
pythondev
help
what are you expecting to happen?
2018-02-21T13:52:36.000028
Floy
pythondev_help_Floy_2018-02-21T13:52:36.000028
1,519,221,156.000028
35,229
pythondev
help
should it not import json from the virtualenv lib?
2018-02-21T13:52:59.000164
Porsha
pythondev_help_Porsha_2018-02-21T13:52:59.000164
1,519,221,179.000164
35,230
pythondev
help
```import flask import json print(flask.__path__) print(json.__path__)```
2018-02-21T13:53:27.000573
Porsha
pythondev_help_Porsha_2018-02-21T13:53:27.000573
1,519,221,207.000573
35,231
pythondev
help
output
2018-02-21T13:53:38.000122
Porsha
pythondev_help_Porsha_2018-02-21T13:53:38.000122
1,519,221,218.000122
35,232
pythondev
help
```['S:\\webdev\\projects\\kold_brew_desktop_app\\backend\\env\\lib\\site-packages\\flask'] ['c:\\users\\julian nash\\python36\\Lib\\json']```
2018-02-21T13:53:41.000148
Porsha
pythondev_help_Porsha_2018-02-21T13:53:41.000148
1,519,221,221.000148
35,233
pythondev
help
I think that's expected
2018-02-21T13:54:27.000782
Micki
pythondev_help_Micki_2018-02-21T13:54:27.000782
1,519,221,267.000782
35,234
pythondev
help
yeah, symlink is by default
2018-02-21T13:54:55.000828
Floy
pythondev_help_Floy_2018-02-21T13:54:55.000828
1,519,221,295.000828
35,235
pythondev
help
a virtualenv isn't a full install of python but a bunch of symlink
2018-02-21T13:54:59.000220
Micki
pythondev_help_Micki_2018-02-21T13:54:59.000220
1,519,221,299.00022
35,236
pythondev
help
you don’t copy all the packages from the base install, just link to them
2018-02-21T13:55:08.000437
Floy
pythondev_help_Floy_2018-02-21T13:55:08.000437
1,519,221,308.000437
35,237
pythondev
help
unless you explictly tell it to
2018-02-21T13:55:17.000678
Floy
pythondev_help_Floy_2018-02-21T13:55:17.000678
1,519,221,317.000678
35,238
pythondev
help
Ok cool
2018-02-21T13:55:19.000641
Porsha
pythondev_help_Porsha_2018-02-21T13:55:19.000641
1,519,221,319.000641
35,239
pythondev
help
I thought I had an issue
2018-02-21T13:55:25.000120
Porsha
pythondev_help_Porsha_2018-02-21T13:55:25.000120
1,519,221,325.00012
35,240
pythondev
help
i’m having, what i think, is an odd issue
2018-02-21T13:55:39.000326
Tobias
pythondev_help_Tobias_2018-02-21T13:55:39.000326
1,519,221,339.000326
35,241
pythondev
help
i have a nested list comp
2018-02-21T13:55:52.000100
Tobias
pythondev_help_Tobias_2018-02-21T13:55:52.000100
1,519,221,352.0001
35,242
pythondev
help
:taco: <@Floy> <@Micki> :heart:
2018-02-21T13:56:08.000370
Porsha
pythondev_help_Porsha_2018-02-21T13:56:08.000370
1,519,221,368.00037
35,243
pythondev
help
and it doesn’t behave the same way as nested for statements and i can’t figure out _why_
2018-02-21T13:56:12.000063
Tobias
pythondev_help_Tobias_2018-02-21T13:56:12.000063
1,519,221,372.000063
35,244
pythondev
help
``` extensions = ('.yaml', 'yml') pattern = re.compile("values") values_files = [] for folder in folders: for filename in os.listdir(folder): if filename.endswith(extensions) and pattern.match(filename): values_files.append(os.path.abspath(filename)```
2018-02-21T13:56:47.000240
Tobias
pythondev_help_Tobias_2018-02-21T13:56:47.000240
1,519,221,407.00024
35,245
pythondev
help
^ this works.
2018-02-21T13:56:53.000587
Tobias
pythondev_help_Tobias_2018-02-21T13:56:53.000587
1,519,221,413.000587
35,246
pythondev
help
``` values_files = [ os.path.abspath(filename) for folder in folders for filename in os.listdir(folder) if filename.endswith(extensions) and pattern.match(filename) ] ```
2018-02-21T13:57:01.000519
Tobias
pythondev_help_Tobias_2018-02-21T13:57:01.000519
1,519,221,421.000519
35,247
pythondev
help
^ this does not
2018-02-21T13:57:13.000106
Tobias
pythondev_help_Tobias_2018-02-21T13:57:13.000106
1,519,221,433.000106
35,248
pythondev
help
wrong way around in the list comp
2018-02-21T13:57:40.000167
Micki
pythondev_help_Micki_2018-02-21T13:57:40.000167
1,519,221,460.000167
35,249
pythondev
help
most outer list must be the one the most on the right
2018-02-21T13:57:55.000159
Micki
pythondev_help_Micki_2018-02-21T13:57:55.000159
1,519,221,475.000159
35,250
pythondev
help
the output of the first one is `["values.yaml"]` the second is `["values,yaml", "values.yml"]`
2018-02-21T13:57:58.000128
Tobias
pythondev_help_Tobias_2018-02-21T13:57:58.000128
1,519,221,478.000128
35,251
pythondev
help
hrm. that gives me “local variable filename referenced before assignment”
2018-02-21T13:58:35.000369
Tobias
pythondev_help_Tobias_2018-02-21T13:58:35.000369
1,519,221,515.000369
35,252
pythondev
help
``` Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; a = [1, 2] &gt;&gt;&gt; b = [3, 4] &gt;&gt;&gt; for x in b: ... KeyboardInterrupt &gt;&gt;&gt; [x for x in a for _ in b] [1, 1, 2, 2] &gt;&gt;&gt; [x for x in a if x == 2 for _ in b] [2, 2] &gt;&gt;&gt; ```
2018-02-21T14:00:04.000807
Micki
pythondev_help_Micki_2018-02-21T14:00:04.000807
1,519,221,604.000807
35,253
pythondev
help
you need to also move the if
2018-02-21T14:00:27.000077
Micki
pythondev_help_Micki_2018-02-21T14:00:27.000077
1,519,221,627.000077
35,254
pythondev
help
I'm cooking if you need more details ask :slightly_smiling_face:
2018-02-21T14:01:04.000189
Micki
pythondev_help_Micki_2018-02-21T14:01:04.000189
1,519,221,664.000189
35,255
pythondev
help
thanks, i think this arms me with enough info. i’m still having a hard time wrapping my head around it. i can read the first one and it makes sense
2018-02-21T14:01:38.000455
Tobias
pythondev_help_Tobias_2018-02-21T14:01:38.000455
1,519,221,698.000455
35,256
pythondev
help
the list comp seems backwards
2018-02-21T14:01:44.000060
Tobias
pythondev_help_Tobias_2018-02-21T14:01:44.000060
1,519,221,704.00006
35,257
pythondev
help
it kind of is
2018-02-21T14:02:09.000365
Monroe
pythondev_help_Monroe_2018-02-21T14:02:09.000365
1,519,221,729.000365
35,258
pythondev
help
simple ones i can rattle off `foo = [f for of in some_iterable if f.is_true() ]`
2018-02-21T14:02:39.000034
Tobias
pythondev_help_Tobias_2018-02-21T14:02:39.000034
1,519,221,759.000034
35,259
pythondev
help
but anything beyond that i get myself in the mess i’m in now
2018-02-21T14:02:49.000714
Tobias
pythondev_help_Tobias_2018-02-21T14:02:49.000714
1,519,221,769.000714
35,260
pythondev
help
it reads just like english
2018-02-21T14:03:09.000418
Micki
pythondev_help_Micki_2018-02-21T14:03:09.000418
1,519,221,789.000418
35,261
pythondev
help
In the first example, `extensions`, `patterns`, and `values_list` are all global, when the for loop is started it looks in the namespace Local, enclosed, global, then built-in. It finds folders (presumably because you created it in global before) and then creates `folder`, and then as it drills down, it creates the `fi...
2018-02-21T14:05:57.000569
Monroe
pythondev_help_Monroe_2018-02-21T14:05:57.000569
1,519,221,957.000569
35,262
pythondev
help
It reads like English except the very first part is the last part, return `f` rest of iteration, I prefer not to inline mine because it doesn't (yet?) feel comfortable to me.
2018-02-21T14:08:29.000719
Monroe
pythondev_help_Monroe_2018-02-21T14:08:29.000719
1,519,222,109.000719
35,263
pythondev
help
doesn’t look like what i want to do is possible
2018-02-21T14:11:24.000518
Tobias
pythondev_help_Tobias_2018-02-21T14:11:24.000518
1,519,222,284.000518
35,264
pythondev
help
because?
2018-02-21T14:11:59.000733
Monroe
pythondev_help_Monroe_2018-02-21T14:11:59.000733
1,519,222,319.000733
35,265
pythondev
help
when i move the `for folder in folders` to what i believe is the right spot i get the undefined var message
2018-02-21T14:12:27.000154
Tobias
pythondev_help_Tobias_2018-02-21T14:12:27.000154
1,519,222,347.000154
35,266
pythondev
help
any reason this isn't a function?
2018-02-21T14:13:20.000247
Monroe
pythondev_help_Monroe_2018-02-21T14:13:20.000247
1,519,222,400.000247
35,267
pythondev
help
_shrug_
2018-02-21T14:13:29.000572
Tobias
pythondev_help_Tobias_2018-02-21T14:13:29.000572
1,519,222,409.000572
35,268
pythondev
help
because i’m not that clever?
2018-02-21T14:13:37.000573
Tobias
pythondev_help_Tobias_2018-02-21T14:13:37.000573
1,519,222,417.000573
35,269
pythondev
help
``` values_files = [ os.path.abspath(filename) for filename in os.listdir(folder) if filename.endswith(extensions) and pattern.match(filename) for folder in folders ] ```
2018-02-21T14:14:34.000328
Micki
pythondev_help_Micki_2018-02-21T14:14:34.000328
1,519,222,474.000328
35,270
pythondev
help
does that work ?
2018-02-21T14:14:43.000698
Micki
pythondev_help_Micki_2018-02-21T14:14:43.000698
1,519,222,483.000698
35,271
pythondev
help
I believe that's where he was getting `local variable filename referenced before assignment`
2018-02-21T14:15:37.000131
Monroe
pythondev_help_Monroe_2018-02-21T14:15:37.000131
1,519,222,537.000131
35,272
pythondev
help
yeah, what <@Monroe> said
2018-02-21T14:15:45.000399
Tobias
pythondev_help_Tobias_2018-02-21T14:15:45.000399
1,519,222,545.000399
35,273
pythondev
help
i think is what led me to put it the way it is above
2018-02-21T14:16:06.000536
Tobias
pythondev_help_Tobias_2018-02-21T14:16:06.000536
1,519,222,566.000536
35,274
pythondev
help
it seems you can't use a part from the second loop in the `in` of the first loop
2018-02-21T14:21:12.000551
Micki
pythondev_help_Micki_2018-02-21T14:21:12.000551
1,519,222,872.000551
35,275
pythondev
help
i tried something like this but it’s returning a list of lists, and that dreaded “values.yml” that doesn’t exist
2018-02-21T14:21:56.000246
Tobias
pythondev_help_Tobias_2018-02-21T14:21:56.000246
1,519,222,916.000246
35,276
pythondev
help
``` def find_values_files(folder): return [file for file in os.listdir(folder) if file.endswith(extensions) and pattern.match(file)] values_files = [ find_values_files(folder) for folder in folders```
2018-02-21T14:22:02.000350
Tobias
pythondev_help_Tobias_2018-02-21T14:22:02.000350
1,519,222,922.00035
35,277
pythondev
help
``` &gt;&gt;&gt; [x for x in [2,4] for a in [1,2]] [2, 2, 4, 4] &gt;&gt;&gt; [x for x in [a*2, a*2] for a in [1,2]] Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; NameError: name 'a' is not defined &gt;&gt;&gt; ```
2018-02-21T14:22:16.000293
Micki
pythondev_help_Micki_2018-02-21T14:22:16.000293
1,519,222,936.000293
35,278
pythondev
help
not sure if this is an improvement or not
2018-02-21T14:33:52.000624
Tobias
pythondev_help_Tobias_2018-02-21T14:33:52.000624
1,519,223,632.000624
35,279
pythondev
help
``` values_files = [] def find_values_files(folder): [values_files.append(os.path.join(folder, file)) for file in os.listdir(folder) if file.endswith(extensions) and pattern.match(file)] [find_values_files(folder) for folder in folders]```
2018-02-21T14:33:56.000609
Tobias
pythondev_help_Tobias_2018-02-21T14:33:56.000609
1,519,223,636.000609
35,280
pythondev
help
does it work?
2018-02-21T14:34:09.000790
Monroe
pythondev_help_Monroe_2018-02-21T14:34:09.000790
1,519,223,649.00079
35,281
pythondev
help
the first abomination i wrote _works_ at least this method is more reusable
2018-02-21T14:34:32.000120
Tobias
pythondev_help_Tobias_2018-02-21T14:34:32.000120
1,519,223,672.00012
35,282
pythondev
help
it’s nested functions now so that `values_files` is mutatable within the context
2018-02-21T14:35:06.000747
Tobias
pythondev_help_Tobias_2018-02-21T14:35:06.000747
1,519,223,706.000747
35,283
pythondev
help
I would probably declare `values_files` in the function and return it
2018-02-21T14:35:15.000615
Micki
pythondev_help_Micki_2018-02-21T14:35:15.000615
1,519,223,715.000615
35,284
pythondev
help
hehe, this may be one of those times that you come back in 6 months and say, "omg what is that?! who wrote that?!" I've been cruising the net trying to figure the most pythonic way to do this because I'd just make a global of the os...(filename) but that's a code smell
2018-02-21T14:35:41.000053
Monroe
pythondev_help_Monroe_2018-02-21T14:35:41.000053
1,519,223,741.000053
35,285
pythondev
help
and then do `[*find_values_files(folder) for folder in folders]`
2018-02-21T14:35:51.000265
Micki
pythondev_help_Micki_2018-02-21T14:35:51.000265
1,519,223,751.000265
35,286
pythondev
help
but that's a bit nitpicking
2018-02-21T14:36:07.000695
Micki
pythondev_help_Micki_2018-02-21T14:36:07.000695
1,519,223,767.000695
35,287
pythondev
help
it would make the func more reusable ¯\_(ツ)_/¯
2018-02-21T14:36:18.000246
Micki
pythondev_help_Micki_2018-02-21T14:36:18.000246
1,519,223,778.000246
35,288
pythondev
help
i tried something like that at first and it was a list of lists
2018-02-21T14:36:52.000257
Tobias
pythondev_help_Tobias_2018-02-21T14:36:52.000257
1,519,223,812.000257
35,289
pythondev
help
and make `extensions` and `pattern` arguments
2018-02-21T14:37:05.000330
Micki
pythondev_help_Micki_2018-02-21T14:37:05.000330
1,519,223,825.00033
35,290
pythondev
help
did you do the star argument `[*find_values...`
2018-02-21T14:37:17.000206
Monroe
pythondev_help_Monroe_2018-02-21T14:37:17.000206
1,519,223,837.000206
35,291
pythondev
help
`SyntaxError: iterable unpacking cannot be used in comprehension`
2018-02-21T14:37:45.000233
Micki
pythondev_help_Micki_2018-02-21T14:37:45.000233
1,519,223,865.000233
35,292
pythondev
help
i haven’t seen that before
2018-02-21T14:37:46.000153
Tobias
pythondev_help_Tobias_2018-02-21T14:37:46.000153
1,519,223,866.000153
35,293
pythondev
help
yeah, i’m getting that too, on python3.6
2018-02-21T14:37:55.000368
Tobias
pythondev_help_Tobias_2018-02-21T14:37:55.000368
1,519,223,875.000368
35,294
pythondev
help
can't use unpacking in comprehension it seems
2018-02-21T14:37:58.000673
Micki
pythondev_help_Micki_2018-02-21T14:37:58.000673
1,519,223,878.000673
35,295
pythondev
help
(this is a great learning experience :disappointed: )
2018-02-21T14:38:11.000448
Monroe
pythondev_help_Monroe_2018-02-21T14:38:11.000448
1,519,223,891.000448
35,296
pythondev
help
yeah, i had a thing that worked 2 hours ago! but i feel like i know more?
2018-02-21T14:38:26.000310
Tobias
pythondev_help_Tobias_2018-02-21T14:38:26.000310
1,519,223,906.00031
35,297
pythondev
help
hah
2018-02-21T14:38:26.000722
Tobias
pythondev_help_Tobias_2018-02-21T14:38:26.000722
1,519,223,906.000722
35,298
pythondev
help
was the `?` at the end of the more intentional :wink:
2018-02-21T14:38:56.000439
Monroe
pythondev_help_Monroe_2018-02-21T14:38:56.000439
1,519,223,936.000439
35,299
pythondev
help
unpacking dict works in dict comprehension, weird that it's not for list
2018-02-21T14:39:07.000524
Micki
pythondev_help_Micki_2018-02-21T14:39:07.000524
1,519,223,947.000524
35,300
pythondev
help
and you can do it with a tuple
2018-02-21T14:39:37.000147
Monroe
pythondev_help_Monroe_2018-02-21T14:39:37.000147
1,519,223,977.000147
35,301
pythondev
help
i ran into another like that today
2018-02-21T14:39:50.000087
Tobias
pythondev_help_Tobias_2018-02-21T14:39:50.000087
1,519,223,990.000087
35,302
pythondev
help
but I don't know about in a comprehension
2018-02-21T14:39:52.000574
Monroe
pythondev_help_Monroe_2018-02-21T14:39:52.000574
1,519,223,992.000574
35,303
pythondev
help
ah no it doesn't. Hmm weird I'm almost certain I have used that
2018-02-21T14:39:58.000138
Micki
pythondev_help_Micki_2018-02-21T14:39:58.000138
1,519,223,998.000138
35,304
pythondev
help
extensions is a tuple because the endswith module doesn’t take a list
2018-02-21T14:40:03.000318
Tobias
pythondev_help_Tobias_2018-02-21T14:40:03.000318
1,519,224,003.000318
35,305
pythondev
help
raymond hettinger rant a bit about that in one of his talks
2018-02-21T14:41:33.000685
Micki
pythondev_help_Micki_2018-02-21T14:41:33.000685
1,519,224,093.000685
35,306
pythondev
help
that it's a bad API and they were forced to it that way
2018-02-21T14:41:54.000594
Micki
pythondev_help_Micki_2018-02-21T14:41:54.000594
1,519,224,114.000594
35,307
pythondev
help
Hi everyone - anyone have any suggestions on mocking a file with pytest? Use case is we use a lot of APIs where we are submitting files, and trying to write tests for it that simulate a file getting passed in.
2018-02-21T14:42:15.000787
Hayden
pythondev_help_Hayden_2018-02-21T14:42:15.000787
1,519,224,135.000787
35,308
pythondev
help
pytest has a `tmpdir` fixture you could use that to create your own that put a small file in it ?
2018-02-21T14:43:47.000412
Micki
pythondev_help_Micki_2018-02-21T14:43:47.000412
1,519,224,227.000412
35,309
pythondev
help
<https://docs.pytest.org/en/latest/tmpdir.html>
2018-02-21T14:44:25.000656
Micki
pythondev_help_Micki_2018-02-21T14:44:25.000656
1,519,224,265.000656
35,310
pythondev
help
it seems there is already something to create a file
2018-02-21T14:44:34.000020
Micki
pythondev_help_Micki_2018-02-21T14:44:34.000020
1,519,224,274.00002
35,311
pythondev
help
<@Tobias> I'd love to hear how you ended up doing this. Also, if you start to type a question in Stack Overflow, sometimes either it becomes clear or a really good answer shows up in recommended. It's outside my skillset, though I think you've explained it well.
2018-02-21T14:45:18.000763
Monroe
pythondev_help_Monroe_2018-02-21T14:45:18.000763
1,519,224,318.000763
35,312
pythondev
help
<@Micki> yea I saw that - am I missing something about generating a random file?
2018-02-21T14:46:33.000462
Hayden
pythondev_help_Hayden_2018-02-21T14:46:33.000462
1,519,224,393.000462
35,313
pythondev
help
lol, this works. not sure if it’s any better (again)
2018-02-21T14:47:06.000015
Tobias
pythondev_help_Tobias_2018-02-21T14:47:06.000015
1,519,224,426.000015
35,314
pythondev
help
``` def find_values_files(folder): return [os.path.join(folder, file) for file in os.listdir(folder) if file.endswith(extensions) and pattern.match(file)] values_files = list(filter(None, ([ ','.join(find_values_files(folder)) for folder in folders ]))```
2018-02-21T14:47:12.000371
Tobias
pythondev_help_Tobias_2018-02-21T14:47:12.000371
1,519,224,432.000371
35,315
pythondev
help
``` def test_create_file(tmpdir): p = tmpdir.mkdir("sub").join("hello.txt") p.write("content") assert p.read() == "content" assert len(tmpdir.listdir()) == 1 assert 0 ```
2018-02-21T14:47:52.000178
Micki
pythondev_help_Micki_2018-02-21T14:47:52.000178
1,519,224,472.000178
35,316
pythondev
help
in this example it seems like they are creating a `hello.txt` file with `content` in it
2018-02-21T14:48:07.000638
Micki
pythondev_help_Micki_2018-02-21T14:48:07.000638
1,519,224,487.000638
35,317
pythondev
help
<@Micki> man your handle is hard in this slack - I just realized I overlooked that
2018-02-21T14:48:19.000261
Hayden
pythondev_help_Hayden_2018-02-21T14:48:19.000261
1,519,224,499.000261
35,318
pythondev
help
why would it be so easy :slightly_smiling_face:
2018-02-21T14:48:28.000189
Hayden
pythondev_help_Hayden_2018-02-21T14:48:28.000189
1,519,224,508.000189
35,319
pythondev
help
andP
2018-02-21T14:48:29.000286
Hayden
pythondev_help_Hayden_2018-02-21T14:48:29.000286
1,519,224,509.000286
35,320
pythondev
help
<@Micki> what's up with this:
2018-02-21T14:48:59.000673
Hayden
pythondev_help_Hayden_2018-02-21T14:48:59.000673
1,519,224,539.000673
35,321
pythondev
help
all the other `ovv something` are accounts of mine I made to test <@Hyo> join message :smile:
2018-02-21T14:49:06.000636
Micki
pythondev_help_Micki_2018-02-21T14:49:06.000636
1,519,224,546.000636
35,322
pythondev
help
haha
2018-02-21T14:49:20.000528
Hayden
pythondev_help_Hayden_2018-02-21T14:49:20.000528
1,519,224,560.000528
35,323