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
And no worries :slightly_smiling_face:
2018-01-12T09:54:28.000515
Brande
pythondev_help_Brande_2018-01-12T09:54:28.000515
1,515,750,868.000515
28,824
pythondev
help
Thank you!
2018-01-12T09:54:38.000326
Adan
pythondev_help_Adan_2018-01-12T09:54:38.000326
1,515,750,878.000326
28,825
pythondev
help
having trouble wrapping my head around this `lambda` ```error_code = ", ".join(map(lambda email: email["error_code"], emails))``` `emails` is a group
2018-01-12T10:19:31.000687
Theressa
pythondev_help_Theressa_2018-01-12T10:19:31.000687
1,515,752,371.000687
28,826
pythondev
help
ultimately we get a list of errors I just don't understand the lambda that well
2018-01-12T10:21:44.000260
Theressa
pythondev_help_Theressa_2018-01-12T10:21:44.000260
1,515,752,504.00026
28,827
pythondev
help
the lambda is basically an inline function that receives one argument, the email dict, and returns `email["error_code"]`
2018-01-12T10:26:27.000272
Zack
pythondev_help_Zack_2018-01-12T10:26:27.000272
1,515,752,787.000272
28,828
pythondev
help
it’s equivalent to: ``` def get_error_code(email): return email["error_code"] error_code = ", ".join(map(get_error_code, emails)) ```
2018-01-12T10:27:34.000445
Zack
pythondev_help_Zack_2018-01-12T10:27:34.000445
1,515,752,854.000445
28,829
pythondev
help
ah
2018-01-12T10:27:56.000055
Theressa
pythondev_help_Theressa_2018-01-12T10:27:56.000055
1,515,752,876.000055
28,830
pythondev
help
and so we ultimately get a list of error codes with the `join` and `map` methods?
2018-01-12T10:28:27.000485
Theressa
pythondev_help_Theressa_2018-01-12T10:28:27.000485
1,515,752,907.000485
28,831
pythondev
help
yup, map basically just exists to apply a function to every element in the emails list
2018-01-12T10:29:00.000696
Zack
pythondev_help_Zack_2018-01-12T10:29:00.000696
1,515,752,940.000696
28,832
pythondev
help
ooooooooooooooooooh
2018-01-12T10:29:16.000053
Theressa
pythondev_help_Theressa_2018-01-12T10:29:16.000053
1,515,752,956.000053
28,833
pythondev
help
\*click\*
2018-01-12T10:29:23.000264
Theressa
pythondev_help_Theressa_2018-01-12T10:29:23.000264
1,515,752,963.000264
28,834
pythondev
help
it’s not very frequently used in python, more pythonic might be:
2018-01-12T10:29:57.000570
Zack
pythondev_help_Zack_2018-01-12T10:29:57.000570
1,515,752,997.00057
28,835
pythondev
help
`error_code = ", ".join([email["error_code"] for email in emails])`
2018-01-12T10:30:27.000092
Zack
pythondev_help_Zack_2018-01-12T10:30:27.000092
1,515,753,027.000092
28,836
pythondev
help
yah I like that you can execute an inline for loop within `[ ]` to generate the list
2018-01-12T10:33:19.000204
Theressa
pythondev_help_Theressa_2018-01-12T10:33:19.000204
1,515,753,199.000204
28,837
pythondev
help
thanks very much <@Zack> :taco:
2018-01-12T10:34:04.000751
Theressa
pythondev_help_Theressa_2018-01-12T10:34:04.000751
1,515,753,244.000751
28,838
pythondev
help
om nom nom. np
2018-01-12T10:34:19.000153
Zack
pythondev_help_Zack_2018-01-12T10:34:19.000153
1,515,753,259.000153
28,839
pythondev
help
now on to figure out why it's generating a blank list :joy:
2018-01-12T10:34:47.000177
Theressa
pythondev_help_Theressa_2018-01-12T10:34:47.000177
1,515,753,287.000177
28,840
pythondev
help
are you using the right key?
2018-01-12T10:39:12.000442
Floy
pythondev_help_Floy_2018-01-12T10:39:12.000442
1,515,753,552.000442
28,841
pythondev
help
:smile:
2018-01-12T10:39:13.000241
Floy
pythondev_help_Floy_2018-01-12T10:39:13.000241
1,515,753,553.000241
28,842
pythondev
help
that's what I think is wrong
2018-01-12T10:39:59.000516
Theressa
pythondev_help_Theressa_2018-01-12T10:39:59.000516
1,515,753,599.000516
28,843
pythondev
help
there's 2 classes in this script
2018-01-12T10:40:08.000027
Theressa
pythondev_help_Theressa_2018-01-12T10:40:08.000027
1,515,753,608.000027
28,844
pythondev
help
one calls a generator `get_bounced_emails` from our Mailgun API
2018-01-12T10:40:27.000228
Theressa
pythondev_help_Theressa_2018-01-12T10:40:27.000228
1,515,753,627.000228
28,845
pythondev
help
which yields specific JSON arrays based on the hey
2018-01-12T10:40:49.000076
Theressa
pythondev_help_Theressa_2018-01-12T10:40:49.000076
1,515,753,649.000076
28,846
pythondev
help
such as
2018-01-12T10:40:50.000875
Theressa
pythondev_help_Theressa_2018-01-12T10:40:50.000875
1,515,753,650.000875
28,847
pythondev
help
``` for evt in mail_events["items"]: yield { "event": evt["event"], "timestamp": evt["timestamp"], "to": evt["message"]["headers"]["to"], "recipient": evt["recipient"], "subject": evt["message"...
2018-01-12T10:40:58.000614
Theressa
pythondev_help_Theressa_2018-01-12T10:40:58.000614
1,515,753,658.000614
28,848
pythondev
help
if I slap a pdb in there each `evt` array returns something
2018-01-12T10:41:26.000328
Theressa
pythondev_help_Theressa_2018-01-12T10:41:26.000328
1,515,753,686.000328
28,849
pythondev
help
but I believe the output format method which was the lambda is doing something that I don't expect, and perhaps the key is wrong like you said
2018-01-12T10:42:14.000167
Theressa
pythondev_help_Theressa_2018-01-12T10:42:14.000167
1,515,753,734.000167
28,850
pythondev
help
I'm sorry if none of that made sense because it's all in my head at this point
2018-01-12T10:42:29.000314
Theressa
pythondev_help_Theressa_2018-01-12T10:42:29.000314
1,515,753,749.000314
28,851
pythondev
help
does each event have a value at this indices? `["delivery-status"]["code"]`
2018-01-12T10:44:26.000629
Brande
pythondev_help_Brande_2018-01-12T10:44:26.000629
1,515,753,866.000629
28,852
pythondev
help
yep, if I put a `pdb` in there and call `evt["delivery-status"]["code"]` I get some stuff
2018-01-12T10:45:15.000223
Theressa
pythondev_help_Theressa_2018-01-12T10:45:15.000223
1,515,753,915.000223
28,853
pythondev
help
this generator serves up information to build a list in a method `find_bounced_emails`, which calls ```em_gen = list(self.mailgun.get_bounced_emails(self.time_from, self.time_to))```
2018-01-12T10:46:04.000551
Theressa
pythondev_help_Theressa_2018-01-12T10:46:04.000551
1,515,753,964.000551
28,854
pythondev
help
ahh write out `email` and `event` it makes the code a lot easier to follow. anyway, where is the generator actually used?
2018-01-12T10:49:27.000161
Brande
pythondev_help_Brande_2018-01-12T10:49:27.000161
1,515,754,167.000161
28,855
pythondev
help
yah sorry that I'm just copying the code directly at this point
2018-01-12T10:49:59.000274
Theressa
pythondev_help_Theressa_2018-01-12T10:49:59.000274
1,515,754,199.000274
28,856
pythondev
help
1 sec had to answer a coworkers question
2018-01-12T10:51:58.000110
Theressa
pythondev_help_Theressa_2018-01-12T10:51:58.000110
1,515,754,318.00011
28,857
pythondev
help
so..
2018-01-12T10:51:59.000140
Theressa
pythondev_help_Theressa_2018-01-12T10:51:59.000140
1,515,754,319.00014
28,858
pythondev
help
the generator is `get_bounced_emails` (above) which yields certain values within a JSON array (the for loop above em_gen)
2018-01-12T10:52:44.000879
Theressa
pythondev_help_Theressa_2018-01-12T10:52:44.000879
1,515,754,364.000879
28,859
pythondev
help
then we build a class object ```for rule in self.email_rules: self.bounced_emails[rule] = filter(lambda x: x["subject"] and self.email_rules[rule]['regex'].match(x["subject"]), em_gen) self.bounced_emails[rule].sort(key=lambda x: x["subject"])```
2018-01-12T10:53:29.000589
Theressa
pythondev_help_Theressa_2018-01-12T10:53:29.000589
1,515,754,409.000589
28,860
pythondev
help
once `self.bounced_emails` is defined it is used to build a group as such ```bounced_emails_by_subject = itertools.groupby(self.bounced_emails[email], lambda bounce: bounce["subject"])```
2018-01-12T10:54:24.000713
Theressa
pythondev_help_Theressa_2018-01-12T10:54:24.000713
1,515,754,464.000713
28,861
pythondev
help
sorry I keep getting asked questions
2018-01-12T10:56:51.000760
Theressa
pythondev_help_Theressa_2018-01-12T10:56:51.000760
1,515,754,611.00076
28,862
pythondev
help
pesky coworkers
2018-01-12T10:56:54.000312
Theressa
pythondev_help_Theressa_2018-01-12T10:56:54.000312
1,515,754,614.000312
28,863
pythondev
help
sorry this is too much split over little snippets to really follow easily :confused:
2018-01-12T10:57:41.000471
Brande
pythondev_help_Brande_2018-01-12T10:57:41.000471
1,515,754,661.000471
28,864
pythondev
help
i completely understand
2018-01-12T10:57:52.000173
Theressa
pythondev_help_Theressa_2018-01-12T10:57:52.000173
1,515,754,672.000173
28,865
pythondev
help
I don't expect anyone to follow along this is just me venting
2018-01-12T10:58:01.000509
Theressa
pythondev_help_Theressa_2018-01-12T10:58:01.000509
1,515,754,681.000509
28,866
pythondev
help
at this point
2018-01-12T10:58:08.000456
Theressa
pythondev_help_Theressa_2018-01-12T10:58:08.000456
1,515,754,688.000456
28,867
pythondev
help
I've been picking away at this script for a day now so I'd have to have you sit next to me for a day to explain it haha
2018-01-12T10:58:26.000633
Theressa
pythondev_help_Theressa_2018-01-12T10:58:26.000633
1,515,754,706.000633
28,868
pythondev
help
<@Brande> :taco: for listening
2018-01-12T10:58:36.000649
Theressa
pythondev_help_Theressa_2018-01-12T10:58:36.000649
1,515,754,716.000649
28,869
pythondev
help
sounds like a good use case for <#C8QT0J83V|rubber_ducky>
2018-01-12T10:59:01.000416
Floy
pythondev_help_Floy_2018-01-12T10:59:01.000416
1,515,754,741.000416
28,870
pythondev
help
:smile:
2018-01-12T10:59:02.000532
Floy
pythondev_help_Floy_2018-01-12T10:59:02.000532
1,515,754,742.000532
28,871
pythondev
help
ooooh! i forgot that was just added
2018-01-12T10:59:09.000887
Theressa
pythondev_help_Theressa_2018-01-12T10:59:09.000887
1,515,754,749.000887
28,872
pythondev
help
WHen I run this code I get the correct returned value but when i run the localhost:10310 I get this error about resource and request.
2018-01-12T11:07:58.000069
Niesha
pythondev_help_Niesha_2018-01-12T11:07:58.000069
1,515,755,278.000069
28,873
pythondev
help
```from twisted.internet import reactor from twisted.web.resource import Resource from twisted.web.server import Site import time class ClockPage(Resource): isLeaf = True def render_GET(self, request): return "the local time is %s" % (time.ctime(),) resource = ClockPage() factory = Site(resource) re...
2018-01-12T11:08:04.000848
Niesha
pythondev_help_Niesha_2018-01-12T11:08:04.000848
1,515,755,284.000848
28,874
pythondev
help
So here value is correct but resource and request are having issues and then in the terminal i get no returned error. How should I think aabou tthis issue.
2018-01-12T11:09:05.000052
Niesha
pythondev_help_Niesha_2018-01-12T11:09:05.000052
1,515,755,345.000052
28,875
pythondev
help
<@Niesha> it’s the same thing as yesterday where Twisted is expecting bytestrings but python3 doesn’t default to them
2018-01-12T11:14:31.000044
Brande
pythondev_help_Brande_2018-01-12T11:14:31.000044
1,515,755,671.000044
28,876
pythondev
help
<@Brande> I guess my thought process doesn't know where to go when i think " Okay well I ahve the right returned value, but resource and request are upset. Because I am returning a string. and if I were to put a b on the return line it would get an error. Is it the value of time.ctime that I need to figure out how to ...
2018-01-12T11:19:49.000894
Niesha
pythondev_help_Niesha_2018-01-12T11:19:49.000894
1,515,755,989.000894
28,877
pythondev
help
``` return b"the local time is %s" % (time.ctime(),)``` this returns return b"the local time is %s" % (time.ctime(),)... So i guess this error is referring mre to (time.ctime) not the first part?
2018-01-12T11:21:21.000195
Niesha
pythondev_help_Niesha_2018-01-12T11:21:21.000195
1,515,756,081.000195
28,878
pythondev
help
what version of python are you running?
2018-01-12T11:22:53.000444
Brande
pythondev_help_Brande_2018-01-12T11:22:53.000444
1,515,756,173.000444
28,879
pythondev
help
py3
2018-01-12T11:23:24.000758
Niesha
pythondev_help_Niesha_2018-01-12T11:23:24.000758
1,515,756,204.000758
28,880
pythondev
help
<@Brande>
2018-01-12T11:23:27.000597
Niesha
pythondev_help_Niesha_2018-01-12T11:23:27.000597
1,515,756,207.000597
28,881
pythondev
help
3. what?
2018-01-12T11:23:34.000668
Brande
pythondev_help_Brande_2018-01-12T11:23:34.000668
1,515,756,214.000668
28,882
pythondev
help
3.6.2
2018-01-12T11:23:38.000829
Niesha
pythondev_help_Niesha_2018-01-12T11:23:38.000829
1,515,756,218.000829
28,883
pythondev
help
okay, and what is the exact error you are getting when you use bytestrings?
2018-01-12T11:24:22.000680
Brande
pythondev_help_Brande_2018-01-12T11:24:22.000680
1,515,756,262.00068
28,884
pythondev
help
``` File "C:/Users/jessica/PycharmProjects/Twisted/chapter4/4.5dynamic_content.py", line 10, in render_GET return b"the local time is %s" % (time.ctime(),) builtins.TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'str'```
2018-01-12T11:24:46.000773
Niesha
pythondev_help_Niesha_2018-01-12T11:24:46.000773
1,515,756,286.000773
28,885
pythondev
help
change `%s` to `%a`
2018-01-12T11:26:47.000015
Brande
pythondev_help_Brande_2018-01-12T11:26:47.000015
1,515,756,407.000015
28,886
pythondev
help
`%s` is for unicode strings, which is what `time.ctime()` returns
2018-01-12T11:27:26.000631
Brande
pythondev_help_Brande_2018-01-12T11:27:26.000631
1,515,756,446.000631
28,887
pythondev
help
also, no need for the parens around it or the trailing comma
2018-01-12T11:27:48.000763
Brande
pythondev_help_Brande_2018-01-12T11:27:48.000763
1,515,756,468.000763
28,888
pythondev
help
`return b"the local time is %a" % time.ctime()`
2018-01-12T11:28:06.000623
Brande
pythondev_help_Brande_2018-01-12T11:28:06.000623
1,515,756,486.000623
28,889
pythondev
help
You're magic. how come typing in the python console type(time.ctime() ) or type(ctime()) doesn't work ?
2018-01-12T11:28:12.000649
Niesha
pythondev_help_Niesha_2018-01-12T11:28:12.000649
1,515,756,492.000649
28,890
pythondev
help
:taco: <@Brande>
2018-01-12T11:28:24.000824
Niesha
pythondev_help_Niesha_2018-01-12T11:28:24.000824
1,515,756,504.000824
28,891
pythondev
help
huh, does for me
2018-01-12T11:29:41.000214
Brande
pythondev_help_Brande_2018-01-12T11:29:41.000214
1,515,756,581.000214
28,892
pythondev
help
``` &gt;&gt;&gt; import time &gt;&gt;&gt; type(time.ctime()) &lt;class 'str'&gt;```
2018-01-12T11:29:54.000598
Brande
pythondev_help_Brande_2018-01-12T11:29:54.000598
1,515,756,594.000598
28,893
pythondev
help
same for me
2018-01-12T11:30:29.000505
Floy
pythondev_help_Floy_2018-01-12T11:30:29.000505
1,515,756,629.000505
28,894
pythondev
help
it probably would have helped if i had imported time. Okay I see now.
2018-01-12T11:30:31.000412
Niesha
pythondev_help_Niesha_2018-01-12T11:30:31.000412
1,515,756,631.000412
28,895
pythondev
help
Hah yep, that would do it :slightly_smiling_face:
2018-01-12T11:30:41.000423
Brande
pythondev_help_Brande_2018-01-12T11:30:41.000423
1,515,756,641.000423
28,896
pythondev
help
yeah, if you’re in the shell and you exit, the previous sessions imports aren’t activated
2018-01-12T11:30:52.000103
Floy
pythondev_help_Floy_2018-01-12T11:30:52.000103
1,515,756,652.000103
28,897
pythondev
help
when you start a shell session, try to get in the frame of mind that you’re starting from a clean whiteboard
2018-01-12T11:31:16.000739
Floy
pythondev_help_Floy_2018-01-12T11:31:16.000739
1,515,756,676.000739
28,898
pythondev
help
So your logic was time.ctime() is a str and since %s is being used for the variable for that i have go to see what type or variable letter has the bytes value?
2018-01-12T11:31:42.000738
Niesha
pythondev_help_Niesha_2018-01-12T11:31:42.000738
1,515,756,702.000738
28,899
pythondev
help
when it comes to printing things out, I tend to prefer `format`
2018-01-12T11:32:13.000038
Floy
pythondev_help_Floy_2018-01-12T11:32:13.000038
1,515,756,733.000038
28,900
pythondev
help
How would you have used format?
2018-01-12T11:32:32.000547
Niesha
pythondev_help_Niesha_2018-01-12T11:32:32.000547
1,515,756,752.000547
28,901
pythondev
help
eg `'some text {}'.format(some_value)`
2018-01-12T11:32:40.000575
Floy
pythondev_help_Floy_2018-01-12T11:32:40.000575
1,515,756,760.000575
28,902
pythondev
help
you have a string, and it has a format method
2018-01-12T11:32:55.000191
Floy
pythondev_help_Floy_2018-01-12T11:32:55.000191
1,515,756,775.000191
28,903
pythondev
help
if you include `{}` in it, then the parameters you pass to it are added to the string
2018-01-12T11:33:22.000221
Floy
pythondev_help_Floy_2018-01-12T11:33:22.000221
1,515,756,802.000221
28,904
pythondev
help
python3.6 takes this a step further with f-strings, but this might be a good place to start
2018-01-12T11:33:40.000487
Floy
pythondev_help_Floy_2018-01-12T11:33:40.000487
1,515,756,820.000487
28,905
pythondev
help
<@Floy> `format` doesn’t work with bytestrings
2018-01-12T11:33:43.000887
Brande
pythondev_help_Brande_2018-01-12T11:33:43.000887
1,515,756,823.000887
28,906
pythondev
help
I’m thinking something like this `b'the local time is {}'.format(time.ctime())`
2018-01-12T11:34:25.001154
Floy
pythondev_help_Floy_2018-01-12T11:34:25.001154
1,515,756,865.001154
28,907
pythondev
help
but you can do `'hi {}'.format('dd82').encode()`
2018-01-12T11:34:27.000044
Brande
pythondev_help_Brande_2018-01-12T11:34:27.000044
1,515,756,867.000044
28,908
pythondev
help
that too
2018-01-12T11:34:35.000385
Floy
pythondev_help_Floy_2018-01-12T11:34:35.000385
1,515,756,875.000385
28,909
pythondev
help
yeah that will error :slightly_smiling_face:
2018-01-12T11:34:35.000634
Brande
pythondev_help_Brande_2018-01-12T11:34:35.000634
1,515,756,875.000634
28,910
pythondev
help
ah, right
2018-01-12T11:34:48.000142
Floy
pythondev_help_Floy_2018-01-12T11:34:48.000142
1,515,756,888.000142
28,911
pythondev
help
:brainfart:
2018-01-12T11:35:02.000508
Floy
pythondev_help_Floy_2018-01-12T11:35:02.000508
1,515,756,902.000508
28,912
pythondev
help
as of 3.4 or 3.5 (i forget which) `%` works on bytes
2018-01-12T11:35:16.000275
Brande
pythondev_help_Brande_2018-01-12T11:35:16.000275
1,515,756,916.000275
28,913
pythondev
help
what makes no sense is that twisted isn’t handling this at another level instead of making everything _have_ to be bytestrings
2018-01-12T11:35:34.000273
Brande
pythondev_help_Brande_2018-01-12T11:35:34.000273
1,515,756,934.000273
28,914
pythondev
help
one thing I like about format is it allows you to pass in whatever type without needing to use a `%` format type placeholder
2018-01-12T11:36:12.000197
Floy
pythondev_help_Floy_2018-01-12T11:36:12.000197
1,515,756,972.000197
28,915
pythondev
help
yeah, `%` makes it easier to shoot yourself in the foot with encodings
2018-01-12T11:36:50.000087
Brande
pythondev_help_Brande_2018-01-12T11:36:50.000087
1,515,757,010.000087
28,916
pythondev
help
<@Isaura> doesn;t look like your virtualenv is active?
2018-01-12T11:36:53.000791
Floy
pythondev_help_Floy_2018-01-12T11:36:53.000791
1,515,757,013.000791
28,917
pythondev
help
but congrats <@Niesha> because you’re getting down one of the trickier things in python: string encodings :slightly_smiling_face:
2018-01-12T11:37:27.000517
Brande
pythondev_help_Brande_2018-01-12T11:37:27.000517
1,515,757,047.000517
28,918
pythondev
help
:smile:
2018-01-12T11:37:38.000106
Floy
pythondev_help_Floy_2018-01-12T11:37:38.000106
1,515,757,058.000106
28,919
pythondev
help
with java for me, it was null pointer exceptions
2018-01-12T11:37:49.000584
Floy
pythondev_help_Floy_2018-01-12T11:37:49.000584
1,515,757,069.000584
28,920
pythondev
help
and javascript was equality comparisons
2018-01-12T11:37:59.000265
Floy
pythondev_help_Floy_2018-01-12T11:37:59.000265
1,515,757,079.000265
28,921
pythondev
help
i just had a flashback to undergrad, thanks <@Floy>
2018-01-12T11:38:04.000621
Brande
pythondev_help_Brande_2018-01-12T11:38:04.000621
1,515,757,084.000621
28,922
pythondev
help
javascript holy trinity of equality
2018-01-12T11:38:21.000548
Floy
pythondev_help_Floy_2018-01-12T11:38:21.000548
1,515,757,101.000548
28,923