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
<@Kurtis> instead of mixing parsing and socket interaction, you should decouple them like this: ``` import io stream = io.BytesIO() while True: chunk = socket.recv(4096) stream.write(chunk) payloads = parse(stream) # list of parsed payloads for payload in payloads: do_useful_stuff_with(payload...
2018-03-05T23:45:41.000196
Aleida
pythondev_help_Aleida_2018-03-05T23:45:41.000196
1,520,293,541.000196
37,524
pythondev
help
`parse` function should read from the `BytesIO` stream as much data as it needs
2018-03-05T23:46:00.000178
Aleida
pythondev_help_Aleida_2018-03-05T23:46:00.000178
1,520,293,560.000178
37,525
pythondev
help
If the stream does not contain all necessary data, `parse` function should simply return the execution back to the loop
2018-03-05T23:46:31.000216
Aleida
pythondev_help_Aleida_2018-03-05T23:46:31.000216
1,520,293,591.000216
37,526
pythondev
help
let me fix the snippet a bit
2018-03-05T23:46:50.000151
Aleida
pythondev_help_Aleida_2018-03-05T23:46:50.000151
1,520,293,610.000151
37,527
pythondev
help
So if `parse` can't actually parse a single payload from the stream, it should simply return an empty list
2018-03-05T23:47:46.000121
Aleida
pythondev_help_Aleida_2018-03-05T23:47:46.000121
1,520,293,666.000121
37,528
pythondev
help
would it make sense to check if not chunk after recv it?
2018-03-05T23:49:09.000206
Kurtis
pythondev_help_Kurtis_2018-03-05T23:49:09.000206
1,520,293,749.000206
37,529
pythondev
help
to avoid calling the functions on an empty chunk?
2018-03-05T23:49:26.000096
Kurtis
pythondev_help_Kurtis_2018-03-05T23:49:26.000096
1,520,293,766.000096
37,530
pythondev
help
Well, it's kind of a tricky question. No, I don't think it is good to put this check right after `recv` because the data can be received partially due to the closed connection, and you won't figure that until you try to parse a stream that isn't yet consumed till its end
2018-03-05T23:52:32.000024
Aleida
pythondev_help_Aleida_2018-03-05T23:52:32.000024
1,520,293,952.000024
37,531
pythondev
help
So you really should deal with that situation, and you need to know how many payloads you actually parsed when the stream isn't consumed yet
2018-03-05T23:53:05.000234
Aleida
pythondev_help_Aleida_2018-03-05T23:53:05.000234
1,520,293,985.000234
37,532
pythondev
help
brilliant, I appreciate the help
2018-03-05T23:53:34.000051
Kurtis
pythondev_help_Kurtis_2018-03-05T23:53:34.000051
1,520,294,014.000051
37,533
pythondev
help
How can we extract CNAME of a cloud machine via Python to send an email ?
2018-03-06T02:02:38.000071
Tammi
pythondev_help_Tammi_2018-03-06T02:02:38.000071
1,520,301,758.000071
37,534
pythondev
help
<@Tammi> your question is unclear. Can you show an example?
2018-03-06T02:07:08.000292
Aleida
pythondev_help_Aleida_2018-03-06T02:07:08.000292
1,520,302,028.000292
37,535
pythondev
help
Actually I have to send email from a cloud machine. mail['FROM'] part should have something like user@'CNAME' kind of a thing
2018-03-06T02:08:15.000104
Tammi
pythondev_help_Tammi_2018-03-06T02:08:15.000104
1,520,302,095.000104
37,536
pythondev
help
Still unclear. Please read <https://www.mikeash.com/getting_answers.html>
2018-03-06T02:20:04.000013
Aleida
pythondev_help_Aleida_2018-03-06T02:20:04.000013
1,520,302,804.000013
37,537
pythondev
help
I have a list, how do i run loop or enumerate only last 3 indexes of the list ? eg lst=[11,22,33,44,55] i want to run loop something similar , for `index in range(len(lst)-3,len(lst))`
2018-03-06T02:25:28.000005
Refugia
pythondev_help_Refugia_2018-03-06T02:25:28.000005
1,520,303,128.000005
37,538
pythondev
help
great thanks..
2018-03-06T02:41:56.000062
Refugia
pythondev_help_Refugia_2018-03-06T02:41:56.000062
1,520,304,116.000062
37,539
pythondev
help
Is dynamic form composition better than having multiple forms on the same page (in flask)
2018-03-06T04:08:09.000198
Milo
pythondev_help_Milo_2018-03-06T04:08:09.000198
1,520,309,289.000198
37,540
pythondev
help
Anyone have a good approach to read a file that is one directory back
2018-03-06T04:26:52.000290
Kelsey
pythondev_help_Kelsey_2018-03-06T04:26:52.000290
1,520,310,412.00029
37,541
pythondev
help
some programatic approach instead of hardcoding the full path
2018-03-06T04:27:06.000084
Kelsey
pythondev_help_Kelsey_2018-03-06T04:27:06.000084
1,520,310,426.000084
37,542
pythondev
help
<@Kelsey> one directory back from what?
2018-03-06T04:29:07.000361
Aleida
pythondev_help_Aleida_2018-03-06T04:29:07.000361
1,520,310,547.000361
37,543
pythondev
help
from the current working directory that the python file is on
2018-03-06T04:29:24.000546
Kelsey
pythondev_help_Kelsey_2018-03-06T04:29:24.000546
1,520,310,564.000546
37,544
pythondev
help
actually its not one directory back
2018-03-06T04:30:02.000189
Kelsey
pythondev_help_Kelsey_2018-03-06T04:30:02.000189
1,520,310,602.000189
37,545
pythondev
help
the file and the folder is in the same directory
2018-03-06T04:30:10.000587
Kelsey
pythondev_help_Kelsey_2018-03-06T04:30:10.000587
1,520,310,610.000587
37,546
pythondev
help
So the very first thing you need to calculate is where your script is located. You can google that easily. After you have a full, absolute path you can use `pathlib` to construct path of the file in question using the directory name (where your script is located) and the filename
2018-03-06T04:34:48.000171
Aleida
pythondev_help_Aleida_2018-03-06T04:34:48.000171
1,520,310,888.000171
37,547
pythondev
help
see `__file__`, which gives you the path to the current running file
2018-03-06T05:09:29.000091
Lynnette
pythondev_help_Lynnette_2018-03-06T05:09:29.000091
1,520,312,969.000091
37,548
pythondev
help
`foo = os.path.dirname(os.path.realpath(__file__))` is your current directory
2018-03-06T05:11:53.000400
Lynnette
pythondev_help_Lynnette_2018-03-06T05:11:53.000400
1,520,313,113.0004
37,549
pythondev
help
```import os foo = os.path.dirname(os.path.realpath(__file__)) foo2 = os.path.dirname(foo) print('Current directory: {0}'.format(foo)) print('One folder up from here: {0}'.format(foo2)) ```
2018-03-06T05:13:46.000002
Lynnette
pythondev_help_Lynnette_2018-03-06T05:13:46.000002
1,520,313,226.000002
37,550
pythondev
help
There are several type or error while developing python code, how do i capture those error into variable ? i wanted to print these into my excel
2018-03-06T06:56:41.000151
Refugia
pythondev_help_Refugia_2018-03-06T06:56:41.000151
1,520,319,401.000151
37,551
pythondev
help
I couldnd find anything in general, most of the example i found on internet was related with specific error type.
2018-03-06T06:57:10.000131
Refugia
pythondev_help_Refugia_2018-03-06T06:57:10.000131
1,520,319,430.000131
37,552
pythondev
help
you'd use a try/except to catch errors
2018-03-06T06:58:43.000200
Lynnette
pythondev_help_Lynnette_2018-03-06T06:58:43.000200
1,520,319,523.0002
37,553
pythondev
help
```try: 1 / 0 except Exception as why: print(why.args) ```
2018-03-06T07:00:13.000474
Lynnette
pythondev_help_Lynnette_2018-03-06T07:00:13.000474
1,520,319,613.000474
37,554
pythondev
help
import logging is this i have to use ?
2018-03-06T07:00:19.000103
Refugia
pythondev_help_Refugia_2018-03-06T07:00:19.000103
1,520,319,619.000103
37,555
pythondev
help
it wors great...thanks <@Lynnette>
2018-03-06T07:03:41.000104
Refugia
pythondev_help_Refugia_2018-03-06T07:03:41.000104
1,520,319,821.000104
37,556
pythondev
help
works*
2018-03-06T07:03:53.000077
Refugia
pythondev_help_Refugia_2018-03-06T07:03:53.000077
1,520,319,833.000077
37,557
pythondev
help
be careful with this. it catches __all__ exceptions
2018-03-06T07:04:23.000182
Lynnette
pythondev_help_Lynnette_2018-03-06T07:04:23.000182
1,520,319,863.000182
37,558
pythondev
help
including ctrl+c, etc
2018-03-06T07:04:32.000412
Lynnette
pythondev_help_Lynnette_2018-03-06T07:04:32.000412
1,520,319,872.000412
37,559
pythondev
help
couple of more question. do i need to place all my code(say 100 lines of code) in side try part. And how i capture entire text of the message like "ZeroDivisionError: division by zero" ?
2018-03-06T07:04:35.000268
Refugia
pythondev_help_Refugia_2018-03-06T07:04:35.000268
1,520,319,875.000268
37,560
pythondev
help
yes i would like to capture all text of error we see on python console during execution
2018-03-06T07:06:05.000028
Refugia
pythondev_help_Refugia_2018-03-06T07:06:05.000028
1,520,319,965.000028
37,561
pythondev
help
you need to look into the traceback module then.
2018-03-06T07:06:24.000056
Lynnette
pythondev_help_Lynnette_2018-03-06T07:06:24.000056
1,520,319,984.000056
37,562
pythondev
help
`import traceback; traceback.print_exc()`
2018-03-06T07:06:36.000065
Lynnette
pythondev_help_Lynnette_2018-03-06T07:06:36.000065
1,520,319,996.000065
37,563
pythondev
help
let me check this
2018-03-06T07:06:55.000101
Refugia
pythondev_help_Refugia_2018-03-06T07:06:55.000101
1,520,320,015.000101
37,564
pythondev
help
also useful is the the logging module’s `exception` logging function. it’ll print your message along with the exception stack trace
2018-03-06T07:07:54.000180
Zack
pythondev_help_Zack_2018-03-06T07:07:54.000180
1,520,320,074.00018
37,565
pythondev
help
handy when you want to print exception information in a handled exception, but continue on and do something else
2018-03-06T07:08:25.000286
Zack
pythondev_help_Zack_2018-03-06T07:08:25.000286
1,520,320,105.000286
37,566
pythondev
help
```try: print(1/0) except : var = traceback.format_exc().splitlines() print("Line no ",var[-1])```
2018-03-06T08:03:18.000103
Refugia
pythondev_help_Refugia_2018-03-06T08:03:18.000103
1,520,323,398.000103
37,567
pythondev
help
this prints the last line from the error. how do i get the line number as well ?
2018-03-06T08:03:49.000441
Refugia
pythondev_help_Refugia_2018-03-06T08:03:49.000441
1,520,323,429.000441
37,568
pythondev
help
```raceback (most recent call last): File "D:\Crypto bot\Test.py", line 14, in &lt;module&gt; print(start) NameError: name 'start' is not defined```
2018-03-06T08:04:36.000338
Refugia
pythondev_help_Refugia_2018-03-06T08:04:36.000338
1,520,323,476.000338
37,569
pythondev
help
like here line 14 was having the error
2018-03-06T08:04:48.000266
Refugia
pythondev_help_Refugia_2018-03-06T08:04:48.000266
1,520,323,488.000266
37,570
pythondev
help
``` try: print(1/0) except Exception as e: print(e) ```
2018-03-06T08:05:17.000074
Micki
pythondev_help_Micki_2018-03-06T08:05:17.000074
1,520,323,517.000074
37,571
pythondev
help
let me try
2018-03-06T08:05:33.000433
Refugia
pythondev_help_Refugia_2018-03-06T08:05:33.000433
1,520,323,533.000433
37,572
pythondev
help
that also gives the error text, but not the line number
2018-03-06T08:06:59.000033
Refugia
pythondev_help_Refugia_2018-03-06T08:06:59.000033
1,520,323,619.000033
37,573
pythondev
help
ah yeah my bad I'm used to `log.exception`
2018-03-06T08:07:35.000211
Micki
pythondev_help_Micki_2018-03-06T08:07:35.000211
1,520,323,655.000211
37,574
pythondev
help
```except Exception, e: T, V, TB = sys.exc_info() ``` to use this i have to import sys module :smile:
2018-03-06T08:07:41.000314
Refugia
pythondev_help_Refugia_2018-03-06T08:07:41.000314
1,520,323,661.000314
37,575
pythondev
help
``` import traceback try: print(1/0) except Exception as e: traceback.print_exc() ```
2018-03-06T08:09:43.000179
Micki
pythondev_help_Micki_2018-03-06T08:09:43.000179
1,520,323,783.000179
37,576
pythondev
help
nope. i have to store the exception in variable so i can log into excel sheet
2018-03-06T08:11:51.000126
Refugia
pythondev_help_Refugia_2018-03-06T08:11:51.000126
1,520,323,911.000126
37,577
pythondev
help
lolwut
2018-03-06T08:13:03.000281
Zack
pythondev_help_Zack_2018-03-06T08:13:03.000281
1,520,323,983.000281
37,578
pythondev
help
:smile: is that bad idea ?
2018-03-06T08:14:26.000445
Refugia
pythondev_help_Refugia_2018-03-06T08:14:26.000445
1,520,324,066.000445
37,579
pythondev
help
just the prospect of logging exceptions in an excel spreadsheet sounds awful to me. :stuck_out_tongue:
2018-03-06T08:15:29.000011
Zack
pythondev_help_Zack_2018-03-06T08:15:29.000011
1,520,324,129.000011
37,580
pythondev
help
are you trying to tack exception occurrences?
2018-03-06T08:15:48.000345
Zack
pythondev_help_Zack_2018-03-06T08:15:48.000345
1,520,324,148.000345
37,581
pythondev
help
I'm pretty sure you can setup the `logging` module to a csv file
2018-03-06T08:16:31.000217
Micki
pythondev_help_Micki_2018-03-06T08:16:31.000217
1,520,324,191.000217
37,582
pythondev
help
i want to see what are the most common type or error i come across throughout the course of development. i m absolutely new to programming and trying to build something and at the end of month or two it would be intresting to see my mistakes while coding
2018-03-06T08:17:14.000403
Refugia
pythondev_help_Refugia_2018-03-06T08:17:14.000403
1,520,324,234.000403
37,583
pythondev
help
<https://stackoverflow.com/questions/19765139/what-is-the-proper-way-to-do-logging-in-csv-file>
2018-03-06T08:17:25.000372
Floy
pythondev_help_Floy_2018-03-06T08:17:25.000372
1,520,324,245.000372
37,584
pythondev
help
you should check out services like sentry
2018-03-06T08:17:55.000234
Zack
pythondev_help_Zack_2018-03-06T08:17:55.000234
1,520,324,275.000234
37,585
pythondev
help
they’ll allow you to gather information about your exceptions, alert, see stack traces, etc
2018-03-06T08:18:17.000086
Zack
pythondev_help_Zack_2018-03-06T08:18:17.000086
1,520,324,297.000086
37,586
pythondev
help
while sentry is a good thing, doing that for a beginner, as <@Refugia> has said he/she is, is pretty technical
2018-03-06T08:18:43.000318
Floy
pythondev_help_Floy_2018-03-06T08:18:43.000318
1,520,324,323.000318
37,587
pythondev
help
is it? pretty easy to integrate it
2018-03-06T08:18:58.000057
Zack
pythondev_help_Zack_2018-03-06T08:18:58.000057
1,520,324,338.000057
37,588
pythondev
help
certainly seems less soul crushing than trying to export it all to an excel spreadsheet. :slightly_smiling_face:
2018-03-06T08:19:09.000459
Zack
pythondev_help_Zack_2018-03-06T08:19:09.000459
1,520,324,349.000459
37,589
pythondev
help
log to csv file and open it in excel
2018-03-06T08:19:22.000287
Floy
pythondev_help_Floy_2018-03-06T08:19:22.000287
1,520,324,362.000287
37,590
pythondev
help
couple that with you’ve now learned how to use a valuable tool for running production code, and seems like a win-win to me
2018-03-06T08:19:50.000421
Zack
pythondev_help_Zack_2018-03-06T08:19:50.000421
1,520,324,390.000421
37,591
pythondev
help
lol basically i have dashboard sheet in my excel, i print at what time i ran my script, total execution time, and status of script.
2018-03-06T08:20:23.000211
Refugia
pythondev_help_Refugia_2018-03-06T08:20:23.000211
1,520,324,423.000211
37,592
pythondev
help
so whnever i tweak my code, or find an alternate way to achieve the same thing, i compare my result with previous run
2018-03-06T08:21:15.000267
Refugia
pythondev_help_Refugia_2018-03-06T08:21:15.000267
1,520,324,475.000267
37,593
pythondev
help
sentry if pretty easy to set up
2018-03-06T08:21:54.000198
Micki
pythondev_help_Micki_2018-03-06T08:21:54.000198
1,520,324,514.000198
37,594
pythondev
help
but you send your code to them so might not be allowed where you work
2018-03-06T08:22:07.000041
Micki
pythondev_help_Micki_2018-03-06T08:22:07.000041
1,520,324,527.000041
37,595
pythondev
help
hmmm thats good to know
2018-03-06T08:22:28.000589
Refugia
pythondev_help_Refugia_2018-03-06T08:22:28.000589
1,520,324,548.000589
37,596
pythondev
help
but setting up proper logging is very important and a good learning opportunity
2018-03-06T08:22:34.000304
Micki
pythondev_help_Micki_2018-03-06T08:22:34.000304
1,520,324,554.000304
37,597
pythondev
help
<@Micki> it does? I just figured it was a combination of logs and stats for hosts
2018-03-06T08:23:05.000231
Brande
pythondev_help_Brande_2018-03-06T08:23:05.000231
1,520,324,585.000231
37,598
pythondev
help
truly agree
2018-03-06T08:23:15.000290
Refugia
pythondev_help_Refugia_2018-03-06T08:23:15.000290
1,520,324,595.00029
37,599
pythondev
help
yeah setting up logging is useful as well
2018-03-06T08:23:21.000414
Zack
pythondev_help_Zack_2018-03-06T08:23:21.000414
1,520,324,601.000414
37,600
pythondev
help
<@Brande> well it send your log and the traceback so there are some parts of your code
2018-03-06T08:23:44.000084
Micki
pythondev_help_Micki_2018-03-06T08:23:44.000084
1,520,324,624.000084
37,601
pythondev
help
and they have filters / algorithm to trash user specific data
2018-03-06T08:24:15.000113
Micki
pythondev_help_Micki_2018-03-06T08:24:15.000113
1,520,324,655.000113
37,602
pythondev
help
Ah yeah that’s pretty common. I thought for some reason they may straight up want code :scream:
2018-03-06T08:25:06.000161
Brande
pythondev_help_Brande_2018-03-06T08:25:06.000161
1,520,324,706.000161
37,603
pythondev
help
for JS services like that often do
2018-03-06T08:25:55.000128
Zack
pythondev_help_Zack_2018-03-06T08:25:55.000128
1,520,324,755.000128
37,604
pythondev
help
which is obviously less of an issue given the client has a form of the source anyway
2018-03-06T08:26:18.000154
Zack
pythondev_help_Zack_2018-03-06T08:26:18.000154
1,520,324,778.000154
37,605
pythondev
help
yeah I'm talking for python. Not sure what their js client does
2018-03-06T08:29:01.000208
Micki
pythondev_help_Micki_2018-03-06T08:29:01.000208
1,520,324,941.000208
37,606
pythondev
help
JS just needs it to map the minified source back to something a little more human friendly
2018-03-06T08:29:28.000363
Zack
pythondev_help_Zack_2018-03-06T08:29:28.000363
1,520,324,968.000363
37,607
pythondev
help
The only problem I have is when linking to github they ask too much permission
2018-03-06T08:33:07.000249
Micki
pythondev_help_Micki_2018-03-06T08:33:07.000249
1,520,325,187.000249
37,608
pythondev
help
They have an open issue about it but I think it's because the github permissions are not precise enough
2018-03-06T08:33:37.000415
Micki
pythondev_help_Micki_2018-03-06T08:33:37.000415
1,520,325,217.000415
37,609
pythondev
help
yeah I think that’s GitHub, I’ve seen that at Circle as well
2018-03-06T08:33:55.000445
Zack
pythondev_help_Zack_2018-03-06T08:33:55.000445
1,520,325,235.000445
37,610
pythondev
help
otherwise I'm pretty happy with it for <@Hyo> and I believe <@Rafael> is too
2018-03-06T08:33:57.000502
Micki
pythondev_help_Micki_2018-03-06T08:33:57.000502
1,520,325,237.000502
37,611
pythondev
help
Agreed, sentry is pretty solid
2018-03-06T08:40:11.000257
Rafael
pythondev_help_Rafael_2018-03-06T08:40:11.000257
1,520,325,611.000257
37,612
pythondev
help
is there a catch in using `sheetname.max_row` ? it keeps giving me incorrect row number. i was using this to find the last non empty cell/row in my sheet
2018-03-06T09:40:56.000497
Refugia
pythondev_help_Refugia_2018-03-06T09:40:56.000497
1,520,329,256.000497
37,613
pythondev
help
<@Refugia> which lib? if you haven’t said which library you’re using, its a good idea to include it with your question
2018-03-06T09:52:56.000520
Floy
pythondev_help_Floy_2018-03-06T09:52:56.000520
1,520,329,976.00052
37,614
pythondev
help
ye my bad, `openpyxl` library i m using
2018-03-06T09:53:53.000602
Refugia
pythondev_help_Refugia_2018-03-06T09:53:53.000602
1,520,330,033.000602
37,615
pythondev
help
somehow that count has started from 50, and every time i rerun the code it keeps incrementing. even though i have empty rows. its bhaving like somewhere its getting cashed
2018-03-06T09:56:09.000521
Refugia
pythondev_help_Refugia_2018-03-06T09:56:09.000521
1,520,330,169.000521
37,616
pythondev
help
Not sure if you figured this out by now, but you don't check your response from your GET request. I wouldn't be surprised if you were getting throttled, denied, or something. You'd do this like so: ```request = requests.get(glob) if request.status_code == requests.codes.ok: # do work else: # display error and e...
2018-03-06T10:11:21.000639
Noreen
pythondev_help_Noreen_2018-03-06T10:11:21.000639
1,520,331,081.000639
37,617
pythondev
help
more information from the docs: <http://docs.python-requests.org/en/master/user/quickstart/#response-status-codes>
2018-03-06T10:13:09.000488
Noreen
pythondev_help_Noreen_2018-03-06T10:13:09.000488
1,520,331,189.000488
37,618
pythondev
help
Anyone know how to limit github search results to the past n days?
2018-03-06T10:42:18.000551
Brande
pythondev_help_Brande_2018-03-06T10:42:18.000551
1,520,332,938.000551
37,619
pythondev
help
e.g., `is:pr org:&lt;org&gt; archived:false is:open` - you can do it by explicit date but I’d like a rolling 30 day window
2018-03-06T10:42:45.000533
Brande
pythondev_help_Brande_2018-03-06T10:42:45.000533
1,520,332,965.000533
37,620
pythondev
help
Anyone using PyCharm to generate HTML coverage reports with pytest? It's including the PyCharm helper modules in the report and I'm wondering if there is a way to change that
2018-03-06T11:32:53.000944
Grazyna
pythondev_help_Grazyna_2018-03-06T11:32:53.000944
1,520,335,973.000944
37,621
pythondev
help
Hello, any celery experts here ?
2018-03-06T13:18:55.000771
Emmie
pythondev_help_Emmie_2018-03-06T13:18:55.000771
1,520,342,335.000771
37,622
pythondev
help
You should just ask your question
2018-03-06T13:19:10.000393
Garrett
pythondev_help_Garrett_2018-03-06T13:19:10.000393
1,520,342,350.000393
37,623