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
<@Garrett> the zip is much cleaner, i like it
2018-01-05T14:46:33.000204
Sheldon
pythondev_help_Sheldon_2018-01-05T14:46:33.000204
1,515,163,593.000204
27,824
pythondev
help
oh nice I dind't know that zip trick inside a list comp
2018-01-05T14:46:34.000253
Majorie
pythondev_help_Majorie_2018-01-05T14:46:34.000253
1,515,163,594.000253
27,825
pythondev
help
that said, that's a slightly awkward to read listcomp so i'd probably do it in a normal `for` loop
2018-01-05T14:47:12.000451
Garrett
pythondev_help_Garrett_2018-01-05T14:47:12.000451
1,515,163,632.000451
27,826
pythondev
help
Yea...you're probably right.
2018-01-05T14:47:45.000029
Majorie
pythondev_help_Majorie_2018-01-05T14:47:45.000029
1,515,163,665.000029
27,827
pythondev
help
``` test_var = zip(x,y) string_var = "" for z in test_var: if z[0] is 0: string_var += f"{z[1]}" elif z[0] &gt; 1: string_var += f"{z[1]}(+{z[0]})," ```
2018-01-05T14:47:46.000520
Pandora
pythondev_help_Pandora_2018-01-05T14:47:46.000520
1,515,163,666.00052
27,828
pythondev
help
Might need to add some more logic to get rid of that ending comma though
2018-01-05T14:48:32.000438
Pandora
pythondev_help_Pandora_2018-01-05T14:48:32.000438
1,515,163,712.000438
27,829
pythondev
help
naw, you can do it simpler than that
2018-01-05T14:50:29.000040
Garrett
pythondev_help_Garrett_2018-01-05T14:50:29.000040
1,515,163,829.00004
27,830
pythondev
help
unfortunately I'm stuck on 3.5 atm
2018-01-05T14:52:32.000360
Majorie
pythondev_help_Majorie_2018-01-05T14:52:32.000360
1,515,163,952.00036
27,831
pythondev
help
obv that `output` could be your `return` statement or whatever
2018-01-05T14:52:33.000342
Garrett
pythondev_help_Garrett_2018-01-05T14:52:33.000342
1,515,163,953.000342
27,832
pythondev
help
lol. fixed that for you, then
2018-01-05T14:52:58.000255
Garrett
pythondev_help_Garrett_2018-01-05T14:52:58.000255
1,515,163,978.000255
27,833
pythondev
help
zip() is doing something odd in my console when I save it to a var. I can output it once but when I do it again it outputs nothing
2018-01-05T14:53:49.000559
Pandora
pythondev_help_Pandora_2018-01-05T14:53:49.000559
1,515,164,029.000559
27,834
pythondev
help
yep. `zip()` is a generator
2018-01-05T14:53:59.000054
Garrett
pythondev_help_Garrett_2018-01-05T14:53:59.000054
1,515,164,039.000054
27,835
pythondev
help
LIke it loses itself after it gets used once
2018-01-05T14:53:59.000642
Pandora
pythondev_help_Pandora_2018-01-05T14:53:59.000642
1,515,164,039.000642
27,836
pythondev
help
you can only run through it once
2018-01-05T14:54:03.000308
Garrett
pythondev_help_Garrett_2018-01-05T14:54:03.000308
1,515,164,043.000308
27,837
pythondev
help
ahh
2018-01-05T14:54:05.000270
Pandora
pythondev_help_Pandora_2018-01-05T14:54:05.000270
1,515,164,045.00027
27,838
pythondev
help
ok
2018-01-05T14:54:06.000153
Pandora
pythondev_help_Pandora_2018-01-05T14:54:06.000153
1,515,164,046.000153
27,839
pythondev
help
in the shell, though, just recreate it by running `foo = zip(bar, baz)` again
2018-01-05T14:54:37.000252
Garrett
pythondev_help_Garrett_2018-01-05T14:54:37.000252
1,515,164,077.000252
27,840
pythondev
help
a vast chunk of python 3 is generators. :heart:
2018-01-05T14:54:48.000052
Garrett
pythondev_help_Garrett_2018-01-05T14:54:48.000052
1,515,164,088.000052
27,841
pythondev
help
That's what I was doing :slightly_smiling_face:
2018-01-05T14:54:48.000373
Pandora
pythondev_help_Pandora_2018-01-05T14:54:48.000373
1,515,164,088.000373
27,842
pythondev
help
generators are wonderful but that's definitely a bit of a gotcha
2018-01-05T14:56:21.000312
Garrett
pythondev_help_Garrett_2018-01-05T14:56:21.000312
1,515,164,181.000312
27,843
pythondev
help
That's the `yield` command in a function right?
2018-01-05T14:57:51.000006
Pandora
pythondev_help_Pandora_2018-01-05T14:57:51.000006
1,515,164,271.000006
27,844
pythondev
help
yep
2018-01-05T14:58:03.000052
Garrett
pythondev_help_Garrett_2018-01-05T14:58:03.000052
1,515,164,283.000052
27,845
pythondev
help
or `(x for x in y)` &lt;- generator expression
2018-01-05T14:58:17.000284
Garrett
pythondev_help_Garrett_2018-01-05T14:58:17.000284
1,515,164,297.000284
27,846
pythondev
help
like a list comp but doesn't produce a list in memory. you can't do a tuple comp since tuples are immutable
2018-01-05T14:58:43.000336
Garrett
pythondev_help_Garrett_2018-01-05T14:58:43.000336
1,515,164,323.000336
27,847
pythondev
help
best thing about generators in modern python is that you can yield from them
2018-01-05T15:00:45.000384
Garrett
pythondev_help_Garrett_2018-01-05T15:00:45.000384
1,515,164,445.000384
27,848
pythondev
help
Yeah, still trying to get my head around it and when to use it. Does it make processing time faster as well?
2018-01-05T15:03:56.000123
Pandora
pythondev_help_Pandora_2018-01-05T15:03:56.000123
1,515,164,636.000123
27,849
pythondev
help
possibly. mostly it's a memory-concern
2018-01-05T15:04:46.000343
Garrett
pythondev_help_Garrett_2018-01-05T15:04:46.000343
1,515,164,686.000343
27,850
pythondev
help
So, I have a program that uses MS Graph to pull unread emails out of an inbox and parses them. It parses them via a for loop right now. Would it make more sense to try using a generator so I don't have to interate through them like that?
2018-01-05T15:08:15.000361
Pandora
pythondev_help_Pandora_2018-01-05T15:08:15.000361
1,515,164,895.000361
27,851
pythondev
help
So each indv email isn't kept in memory?
2018-01-05T15:08:43.000352
Pandora
pythondev_help_Pandora_2018-01-05T15:08:43.000352
1,515,164,923.000352
27,852
pythondev
help
if you can make it so you yield each email as it comes out, yeah, i'd say that would be an improvement
2018-01-05T15:09:03.000568
Garrett
pythondev_help_Garrett_2018-01-05T15:09:03.000568
1,515,164,943.000568
27,853
pythondev
help
Perhaps in the API call function I made then?
2018-01-05T15:10:27.000010
Pandora
pythondev_help_Pandora_2018-01-05T15:10:27.000010
1,515,165,027.00001
27,854
pythondev
help
yeah, probably
2018-01-05T15:10:57.000333
Garrett
pythondev_help_Garrett_2018-01-05T15:10:57.000333
1,515,165,057.000333
27,855
pythondev
help
yeah, that line 20 could probably be `yield api_json_data`
2018-01-05T15:11:24.000543
Garrett
pythondev_help_Garrett_2018-01-05T15:11:24.000543
1,515,165,084.000543
27,856
pythondev
help
eh, no
2018-01-05T15:11:30.000272
Garrett
pythondev_help_Garrett_2018-01-05T15:11:30.000272
1,515,165,090.000272
27,857
pythondev
help
walk us through what that's doing? you don't have any comments and it's _really_ generic code
2018-01-05T15:11:59.000146
Garrett
pythondev_help_Garrett_2018-01-05T15:11:59.000146
1,515,165,119.000146
27,858
pythondev
help
like what is `api_response.json()`?
2018-01-05T15:12:37.000383
Garrett
pythondev_help_Garrett_2018-01-05T15:12:37.000383
1,515,165,157.000383
27,859
pythondev
help
Basically turns the api_response into a dictionary
2018-01-05T15:13:02.000185
Pandora
pythondev_help_Pandora_2018-01-05T15:13:02.000185
1,515,165,182.000185
27,860
pythondev
help
lol, yes, i know what the `.json()` _does_. but what's in there?
2018-01-05T15:13:18.000529
Garrett
pythondev_help_Garrett_2018-01-05T15:13:18.000529
1,515,165,198.000529
27,861
pythondev
help
is the api response the full inbox?
2018-01-05T15:13:25.000293
Garrett
pythondev_help_Garrett_2018-01-05T15:13:25.000293
1,515,165,205.000293
27,862
pythondev
help
also, don't do `if continue_code is True:`. just do `if continue_code:`
2018-01-05T15:13:50.000094
Garrett
pythondev_help_Garrett_2018-01-05T15:13:50.000094
1,515,165,230.000094
27,863
pythondev
help
`is` comparisons are 99.999% a code smell
2018-01-05T15:14:02.000250
Garrett
pythondev_help_Garrett_2018-01-05T15:14:02.000250
1,515,165,242.00025
27,864
pythondev
help
```email_json_data = api_caller( graph_api_endpoint, (f'/users/{username}/mailFolders/{inbox_mail_folder_id}/messages?$top=200'), "get", headers ) ```
2018-01-05T15:14:02.000584
Pandora
pythondev_help_Pandora_2018-01-05T15:14:02.000584
1,515,165,242.000584
27,865
pythondev
help
Here is an example of a call I make that gets the top 200 items from the inbox
2018-01-05T15:14:18.000305
Pandora
pythondev_help_Pandora_2018-01-05T15:14:18.000305
1,515,165,258.000305
27,866
pythondev
help
and that ends up with `email_json_data` being a list of dicts?
2018-01-05T15:15:49.000352
Garrett
pythondev_help_Garrett_2018-01-05T15:15:49.000352
1,515,165,349.000352
27,867
pythondev
help
Yep
2018-01-05T15:16:09.000620
Pandora
pythondev_help_Pandora_2018-01-05T15:16:09.000620
1,515,165,369.00062
27,868
pythondev
help
so, yeah, you could do `yield from api_json_data` (assuming `api_json_data` is an iterable)
2018-01-05T15:16:41.000620
Garrett
pythondev_help_Garrett_2018-01-05T15:16:41.000620
1,515,165,401.00062
27,869
pythondev
help
I'll give it a shot
2018-01-05T15:17:57.000032
Pandora
pythondev_help_Pandora_2018-01-05T15:17:57.000032
1,515,165,477.000032
27,870
pythondev
help
TypeError: 'generator' object is not subscriptable
2018-01-05T15:19:11.000168
Pandora
pythondev_help_Pandora_2018-01-05T15:19:11.000168
1,515,165,551.000168
27,871
pythondev
help
True
2018-01-05T15:19:26.000138
Garrett
pythondev_help_Garrett_2018-01-05T15:19:26.000138
1,515,165,566.000138
27,872
pythondev
help
you're trying to get an index from the generator. can't do that
2018-01-05T15:19:42.000463
Garrett
pythondev_help_Garrett_2018-01-05T15:19:42.000463
1,515,165,582.000463
27,873
pythondev
help
'cause you only ever have a single item at a time from the generator
2018-01-05T15:19:52.000161
Garrett
pythondev_help_Garrett_2018-01-05T15:19:52.000161
1,515,165,592.000161
27,874
pythondev
help
So how would I cycle through all the results?
2018-01-05T15:21:08.000322
Pandora
pythondev_help_Pandora_2018-01-05T15:21:08.000322
1,515,165,668.000322
27,875
pythondev
help
`for result in results:`
2018-01-05T15:21:31.000012
Garrett
pythondev_help_Garrett_2018-01-05T15:21:31.000012
1,515,165,691.000012
27,876
pythondev
help
how else would you do it?
2018-01-05T15:21:35.000354
Garrett
pythondev_help_Garrett_2018-01-05T15:21:35.000354
1,515,165,695.000354
27,877
pythondev
help
Oh, I see what I see what's going on.
2018-01-05T15:22:24.000178
Pandora
pythondev_help_Pandora_2018-01-05T15:22:24.000178
1,515,165,744.000178
27,878
pythondev
help
So the previous code was returning one single object that had a ['value'] property in the dictionary that had a list inside of it that I was interating through
2018-01-05T15:23:14.000209
Pandora
pythondev_help_Pandora_2018-01-05T15:23:14.000209
1,515,165,794.000209
27,879
pythondev
help
Now the results are showing @odata stuff and 'value' as a string
2018-01-05T15:24:15.000402
Pandora
pythondev_help_Pandora_2018-01-05T15:24:15.000402
1,515,165,855.000402
27,880
pythondev
help
None of the extra data underneath value.
2018-01-05T15:24:48.000580
Pandora
pythondev_help_Pandora_2018-01-05T15:24:48.000580
1,515,165,888.00058
27,881
pythondev
help
ah, yeah, if `api_json_data` was a dict, not a list of dicts, then you'd be yielding the keys
2018-01-05T15:25:30.000277
Garrett
pythondev_help_Garrett_2018-01-05T15:25:30.000277
1,515,165,930.000277
27,882
pythondev
help
bbiab, meeting
2018-01-05T15:26:47.000109
Garrett
pythondev_help_Garrett_2018-01-05T15:26:47.000109
1,515,166,007.000109
27,883
pythondev
help
<@Pandora> is that an editor?
2018-01-05T15:28:41.000187
Majorie
pythondev_help_Majorie_2018-01-05T15:28:41.000187
1,515,166,121.000187
27,884
pythondev
help
vscode's debugger
2018-01-05T15:28:53.000336
Pandora
pythondev_help_Pandora_2018-01-05T15:28:53.000336
1,515,166,133.000336
27,885
pythondev
help
<@Pandora> see the `items()` in your first screenshot? it's a dict
2018-01-05T15:28:54.000462
Garrett
pythondev_help_Garrett_2018-01-05T15:28:54.000462
1,515,166,134.000462
27,886
pythondev
help
oh that looks nice
2018-01-05T15:29:11.000384
Majorie
pythondev_help_Majorie_2018-01-05T15:29:11.000384
1,515,166,151.000384
27,887
pythondev
help
Aye
2018-01-05T15:29:13.000283
Pandora
pythondev_help_Pandora_2018-01-05T15:29:13.000283
1,515,166,153.000283
27,888
pythondev
help
<@Majorie> I'm really liking VSCode for Python. The debugger is really nice (not that I have much experience with other editors)
2018-01-05T15:30:06.000429
Pandora
pythondev_help_Pandora_2018-01-05T15:30:06.000429
1,515,166,206.000429
27,889
pythondev
help
but it works for me
2018-01-05T15:30:12.000337
Pandora
pythondev_help_Pandora_2018-01-05T15:30:12.000337
1,515,166,212.000337
27,890
pythondev
help
Yea, I looked into it a little while back and I was pretty impressed. Just using sublime/command line for now
2018-01-05T15:32:54.000232
Majorie
pythondev_help_Majorie_2018-01-05T15:32:54.000232
1,515,166,374.000232
27,891
pythondev
help
Microsoft just recently hired the developer who makes the Python extension in VSCode so I imagine the whole experience will get better as it goes
2018-01-05T15:34:55.000125
Pandora
pythondev_help_Pandora_2018-01-05T15:34:55.000125
1,515,166,495.000125
27,892
pythondev
help
The debugging has improved since I've started using Python a few months ago
2018-01-05T15:35:07.000274
Pandora
pythondev_help_Pandora_2018-01-05T15:35:07.000274
1,515,166,507.000274
27,893
pythondev
help
one of the nicer things about python is its one of the few free intellij IDEs, so there’s that too
2018-01-05T15:35:15.000241
Brande
pythondev_help_Brande_2018-01-05T15:35:15.000241
1,515,166,515.000241
27,894
pythondev
help
(not saying anything bad about vscode - im a big proponent of use what you like :slightly_smiling_face: )
2018-01-05T15:35:36.000611
Brande
pythondev_help_Brande_2018-01-05T15:35:36.000611
1,515,166,536.000611
27,895
pythondev
help
most of the intellij ides have a free version?
2018-01-05T15:36:38.000219
Floy
pythondev_help_Floy_2018-01-05T15:36:38.000219
1,515,166,598.000219
27,896
pythondev
help
or am I wrong?
2018-01-05T15:36:42.000507
Floy
pythondev_help_Floy_2018-01-05T15:36:42.000507
1,515,166,602.000507
27,897
pythondev
help
nope, there are like 2?
2018-01-05T15:36:49.000076
Brande
pythondev_help_Brande_2018-01-05T15:36:49.000076
1,515,166,609.000076
27,898
pythondev
help
hence the “one of the few free”
2018-01-05T15:36:56.000528
Brande
pythondev_help_Brande_2018-01-05T15:36:56.000528
1,515,166,616.000528
27,899
pythondev
help
i think the only other free one is IDEA, and _maybe_ the go one but thats because its beta iirc
2018-01-05T15:37:03.000395
Brande
pythondev_help_Brande_2018-01-05T15:37:03.000395
1,515,166,623.000395
27,900
pythondev
help
ah, yeah. webstorm was a 30 day trial
2018-01-05T15:37:28.000136
Floy
pythondev_help_Floy_2018-01-05T15:37:28.000136
1,515,166,648.000136
27,901
pythondev
help
or on people’s .edu accounts :smile:
2018-01-05T15:37:56.000552
Brande
pythondev_help_Brande_2018-01-05T15:37:56.000552
1,515,166,676.000552
27,902
pythondev
help
’-)
2018-01-05T15:38:17.000343
Floy
pythondev_help_Floy_2018-01-05T15:38:17.000343
1,515,166,697.000343
27,903
pythondev
help
Hrmm...so I figured out how to use the generator properly and get the value I wanted but it broke my len() usage.
2018-01-05T15:38:36.000427
Pandora
pythondev_help_Pandora_2018-01-05T15:38:36.000427
1,515,166,716.000427
27,904
pythondev
help
who would do that... :sweat_smile:
2018-01-05T15:38:38.000101
Leanora
pythondev_help_Leanora_2018-01-05T15:38:38.000101
1,515,166,718.000101
27,905
pythondev
help
lol
2018-01-05T15:39:09.000379
Garrett
pythondev_help_Garrett_2018-01-05T15:39:09.000379
1,515,166,749.000379
27,906
pythondev
help
<@Pandora> `len()` usage of what?
2018-01-05T15:39:34.000199
Brande
pythondev_help_Brande_2018-01-05T15:39:34.000199
1,515,166,774.000199
27,907
pythondev
help
A generator object
2018-01-05T15:39:46.000125
Pandora
pythondev_help_Pandora_2018-01-05T15:39:46.000125
1,515,166,786.000125
27,908
pythondev
help
I’d also like to help, not just derail this
2018-01-05T15:39:48.000009
Brande
pythondev_help_Brande_2018-01-05T15:39:48.000009
1,515,166,788.000009
27,909
pythondev
help
there’s no way to get the length of a generator unless you want to consume it at the same time
2018-01-05T15:40:30.000474
Brande
pythondev_help_Brande_2018-01-05T15:40:30.000474
1,515,166,830.000474
27,910
pythondev
help
Looks as if there might be a `sum()` function
2018-01-05T15:41:47.000246
Pandora
pythondev_help_Pandora_2018-01-05T15:41:47.000246
1,515,166,907.000246
27,911
pythondev
help
but you won’t know the length until it’s fully exhausted
2018-01-05T15:41:53.000521
Brande
pythondev_help_Brande_2018-01-05T15:41:53.000521
1,515,166,913.000521
27,912
pythondev
help
why do you need the length?
2018-01-05T15:42:12.000494
Garrett
pythondev_help_Garrett_2018-01-05T15:42:12.000494
1,515,166,932.000494
27,913
pythondev
help
So I have a subscription reference object in a user model and I wanna check for the existence of this object as well as check that it is valid (it has a method that returns a Boolean) `return self.oop_subscription and not self.oop_subscription.valid()` This is how I'm doing this right now. Is there a better way to do...
2018-01-05T15:42:29.000462
Hank
pythondev_help_Hank_2018-01-05T15:42:29.000462
1,515,166,949.000462
27,914
pythondev
help
<@Garrett> I use one for simple text changes. If == 1 the text reads `email` if &gt; 1 it reads `emailS`
2018-01-05T15:43:22.000206
Pandora
pythondev_help_Pandora_2018-01-05T15:43:22.000206
1,515,167,002.000206
27,915
pythondev
help
`email(s)`
2018-01-05T15:43:39.000716
Garrett
pythondev_help_Garrett_2018-01-05T15:43:39.000716
1,515,167,019.000716
27,916
pythondev
help
:wink:
2018-01-05T15:43:41.000228
Garrett
pythondev_help_Garrett_2018-01-05T15:43:41.000228
1,515,167,021.000228
27,917
pythondev
help
but I do have an instance that counts the number of attachments
2018-01-05T15:43:46.000191
Pandora
pythondev_help_Pandora_2018-01-05T15:43:46.000191
1,515,167,026.000191
27,918
pythondev
help
<@Hank> you can set a value of `oop_subscription` in the `__init__` of the class, that way there is a default and you don’t have to check that it exists, only the `valid()` call
2018-01-05T15:43:53.000385
Brande
pythondev_help_Brande_2018-01-05T15:43:53.000385
1,515,167,033.000385
27,919
pythondev
help
Business logic is dependent on it not existing, actually.
2018-01-05T15:44:44.000288
Hank
pythondev_help_Hank_2018-01-05T15:44:44.000288
1,515,167,084.000288
27,920
pythondev
help
if the number of attachments is greater than 0 it continues the logic to extract them but if not it says no attachment founds and writes it to the log file
2018-01-05T15:45:05.000411
Pandora
pythondev_help_Pandora_2018-01-05T15:45:05.000411
1,515,167,105.000411
27,921
pythondev
help
okay, another option would be making `valid` a function you pass `self.oop_subscription` to, but you’ll still be checking for the existence there
2018-01-05T15:45:47.000061
Brande
pythondev_help_Brande_2018-01-05T15:45:47.000061
1,515,167,147.000061
27,922
pythondev
help
generally, though (moving forward), it is better to have business logic based on truthy/falsey values, not just existence. it makes for messy code sometimes
2018-01-05T15:46:37.000293
Brande
pythondev_help_Brande_2018-01-05T15:46:37.000293
1,515,167,197.000293
27,923