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
ah ok that sounds good, as at the moment I am using script, and I can only run the whole script! It would be useful to test individual functions as well!
2018-02-28T07:48:35.000497
Milo
pythondev_help_Milo_2018-02-28T07:48:35.000497
1,519,804,115.000497
36,524
pythondev
help
that’s the responsibility of your testing code
2018-02-28T07:51:01.000025
Floy
pythondev_help_Floy_2018-02-28T07:51:01.000025
1,519,804,261.000025
36,525
pythondev
help
eg, write tests with unittest, pytest, etc
2018-02-28T07:51:10.000053
Floy
pythondev_help_Floy_2018-02-28T07:51:10.000053
1,519,804,270.000053
36,526
pythondev
help
in that case I would take a hard look at using a testing framework like pytest to test each function. Test driven development is powerful! Also, a personal code smell for me is if the functions can’t be broken down into testable pieces it is too unwieldy.
2018-02-28T07:51:16.000269
Katrina
pythondev_help_Katrina_2018-02-28T07:51:16.000269
1,519,804,276.000269
36,527
pythondev
help
:point_up:
2018-02-28T07:51:24.000229
Floy
pythondev_help_Floy_2018-02-28T07:51:24.000229
1,519,804,284.000229
36,528
pythondev
help
Hi guys! I need help here...Im using openpyxl to read some excel files...I do some processing to these and the output im trying to write it to a csv file using the csv library...the problem is that when i try to write rows the typical encode error appears: "UnicodeEncodeError: 'ascii' codec can't encode character u'\xd...
2018-02-28T08:39:23.000414
Pearlie
pythondev_help_Pearlie_2018-02-28T08:39:23.000414
1,519,807,163.000414
36,529
pythondev
help
are you using python 2 or 3?
2018-02-28T08:39:56.000400
Floy
pythondev_help_Floy_2018-02-28T08:39:56.000400
1,519,807,196.0004
36,530
pythondev
help
3
2018-02-28T08:40:00.000455
Pearlie
pythondev_help_Pearlie_2018-02-28T08:40:00.000455
1,519,807,200.000455
36,531
pythondev
help
2 sorry
2018-02-28T08:40:16.000222
Pearlie
pythondev_help_Pearlie_2018-02-28T08:40:16.000222
1,519,807,216.000222
36,532
pythondev
help
that’s what I thought, since most errors like that were solved with python3
2018-02-28T08:40:41.000568
Floy
pythondev_help_Floy_2018-02-28T08:40:41.000568
1,519,807,241.000568
36,533
pythondev
help
might want to read this SO answer
2018-02-28T08:42:32.000606
Floy
pythondev_help_Floy_2018-02-28T08:42:32.000606
1,519,807,352.000606
36,534
pythondev
help
<https://stackoverflow.com/a/35444608/214892>
2018-02-28T08:42:33.000411
Floy
pythondev_help_Floy_2018-02-28T08:42:33.000411
1,519,807,353.000411
36,535
pythondev
help
tl;dr, if you’re getting the same error when manually encoding, you’re probably using the wrong encoding
2018-02-28T08:43:08.000387
Floy
pythondev_help_Floy_2018-02-28T08:43:08.000387
1,519,807,388.000387
36,536
pythondev
help
what I would try is this: `rowList.append(u'{}'.format(cell.value))`
2018-02-28T08:43:57.000422
Floy
pythondev_help_Floy_2018-02-28T08:43:57.000422
1,519,807,437.000422
36,537
pythondev
help
Okk thanks! If i cant solve this problem whit this i will try it in python 3
2018-02-28T08:46:48.000442
Pearlie
pythondev_help_Pearlie_2018-02-28T08:46:48.000442
1,519,807,608.000442
36,538
pythondev
help
specifically this should fix it on line 15: `rowList = [cell.value.encode('utf-8') for cell in row]`
2018-02-28T08:47:44.000328
Zack
pythondev_help_Zack_2018-02-28T08:47:44.000328
1,519,807,664.000328
36,539
pythondev
help
I don’t think the above code would work on python 2 at all though - is that `open` imported from the `codecs` module to override the built-in?
2018-02-28T08:49:48.000168
Zack
pythondev_help_Zack_2018-02-28T08:49:48.000168
1,519,807,788.000168
36,540
pythondev
help
the builtin `open` doesn’t take an encoding argument in python 2
2018-02-28T08:50:05.000596
Zack
pythondev_help_Zack_2018-02-28T08:50:05.000596
1,519,807,805.000596
36,541
pythondev
help
Yes im using the codecs.open module
2018-02-28T08:52:30.000527
Pearlie
pythondev_help_Pearlie_2018-02-28T08:52:30.000527
1,519,807,950.000527
36,542
pythondev
help
<@Yukiko> slack allows you to format your code. <https://get.slack.help/hc/en-us/articles/202288908-Format-your-messages#code-blocks>
2018-02-28T08:53:14.000374
Floy
pythondev_help_Floy_2018-02-28T08:53:14.000374
1,519,807,994.000374
36,543
pythondev
help
FWIW, I’m having a hard time understanding your code
2018-02-28T08:53:54.000593
Floy
pythondev_help_Floy_2018-02-28T08:53:54.000593
1,519,808,034.000593
36,544
pythondev
help
Thanks! will do it.
2018-02-28T08:54:23.000033
Yukiko
pythondev_help_Yukiko_2018-02-28T08:54:23.000033
1,519,808,063.000033
36,545
pythondev
help
<@Pearlie> ah, okay - then in that case yeah the thing I mentioned about line 15 should help you then
2018-02-28T08:54:30.000383
Zack
pythondev_help_Zack_2018-02-28T08:54:30.000383
1,519,808,070.000383
36,546
pythondev
help
also, strip the parens from `fa = (d*c)`
2018-02-28T08:54:36.000188
Floy
pythondev_help_Floy_2018-02-28T08:54:36.000188
1,519,808,076.000188
36,547
pythondev
help
no need for that here
2018-02-28T08:54:40.000078
Floy
pythondev_help_Floy_2018-02-28T08:54:40.000078
1,519,808,080.000078
36,548
pythondev
help
the key bit is that your data is being read in with open and decoded from utf-8 to a unicode object, but when you go to write it out, it needs to encode it so it uses the default encoding, ascii, which doesn’t know how to encode all the values you have
2018-02-28T08:55:28.000139
Zack
pythondev_help_Zack_2018-02-28T08:55:28.000139
1,519,808,128.000139
36,549
pythondev
help
couple things I notice. first, you’re using lots of unnecessary parenthesis. `final_amount = (a*(1+(b/d)))` `fa = (d*c)` aren’t necessary
2018-02-28T08:58:20.000554
Floy
pythondev_help_Floy_2018-02-28T08:58:20.000554
1,519,808,300.000554
36,550
pythondev
help
second, you might want to read <https://docs.python.org/3/library/math.html#math.pow> for clarification
2018-02-28T08:59:15.000664
Floy
pythondev_help_Floy_2018-02-28T08:59:15.000664
1,519,808,355.000664
36,551
pythondev
help
cool! ill change and look into it! thanks! :smile:
2018-02-28T09:00:20.000225
Yukiko
pythondev_help_Yukiko_2018-02-28T09:00:20.000225
1,519,808,420.000225
36,552
pythondev
help
<@Zack> oh okk, i try it with the solution u have me but im having the same error with another character now..i will keep trying with other encoders i think
2018-02-28T09:01:26.000311
Pearlie
pythondev_help_Pearlie_2018-02-28T09:01:26.000311
1,519,808,486.000311
36,553
pythondev
help
do you know what the file was encoded with originally?
2018-02-28T09:03:06.000248
Zack
pythondev_help_Zack_2018-02-28T09:03:06.000248
1,519,808,586.000248
36,554
pythondev
help
No
2018-02-28T09:03:55.000684
Pearlie
pythondev_help_Pearlie_2018-02-28T09:03:55.000684
1,519,808,635.000684
36,555
pythondev
help
ah. that can make it difficult then. you could try opening it in a good text editor and switching encodings until you get the one that seems correct
2018-02-28T09:05:40.000363
Zack
pythondev_help_Zack_2018-02-28T09:05:40.000363
1,519,808,740.000363
36,556
pythondev
help
then use that to change the encoding on live 5 - but you should keep line 15 at utf-8, it’s a good choice for general encoding of files
2018-02-28T09:06:13.000094
Zack
pythondev_help_Zack_2018-02-28T09:06:13.000094
1,519,808,773.000094
36,557
pythondev
help
Hi all - how can I import a variable created in an init file into another file?
2018-02-28T12:45:12.000091
Lesia
pythondev_help_Lesia_2018-02-28T12:45:12.000091
1,519,821,912.000091
36,558
pythondev
help
`from module_name import variable`
2018-02-28T12:45:36.000829
Garrett
pythondev_help_Garrett_2018-02-28T12:45:36.000829
1,519,821,936.000829
36,559
pythondev
help
I'm getting a 'no module found' error
2018-02-28T12:46:20.000437
Lesia
pythondev_help_Lesia_2018-02-28T12:46:20.000437
1,519,821,980.000437
36,560
pythondev
help
I think it has to do with how AWS flattens their files.
2018-02-28T12:46:41.000575
Lesia
pythondev_help_Lesia_2018-02-28T12:46:41.000575
1,519,822,001.000575
36,561
pythondev
help
Is the file that's importing the variable in the same module as `__init__.py`?
2018-02-28T12:47:06.000098
Garrett
pythondev_help_Garrett_2018-02-28T12:47:06.000098
1,519,822,026.000098
36,562
pythondev
help
``` root_module -- init.py -- child_module ---- file ```
2018-02-28T12:48:35.000001
Lesia
pythondev_help_Lesia_2018-02-28T12:48:35.000001
1,519,822,115.000001
36,563
pythondev
help
I am trying to import a variable created in the root module's init into 'file'
2018-02-28T12:49:07.000174
Lesia
pythondev_help_Lesia_2018-02-28T12:49:07.000174
1,519,822,147.000174
36,564
pythondev
help
`from .. import var` maybe?
2018-02-28T12:49:22.000652
Garrett
pythondev_help_Garrett_2018-02-28T12:49:22.000652
1,519,822,162.000652
36,565
pythondev
help
Let's give it a go
2018-02-28T12:49:45.000286
Lesia
pythondev_help_Lesia_2018-02-28T12:49:45.000286
1,519,822,185.000286
36,566
pythondev
help
<@Garrett> ValueError: Attempted relative import beyond toplevel package
2018-02-28T12:59:56.000748
Lesia
pythondev_help_Lesia_2018-02-28T12:59:56.000748
1,519,822,796.000748
36,567
pythondev
help
o.O
2018-02-28T13:00:09.000824
Garrett
pythondev_help_Garrett_2018-02-28T13:00:09.000824
1,519,822,809.000824
36,568
pythondev
help
Hello! Got a bit of a weird problem. We've got a custom library we import by appending it to the sys.path, and then a regular `import ourlib` statement. Works fine and has for years. We just set up nosetests for running unit tests, and we've been running them in a docker container with Python 2.6 (we're stuck on that d...
2018-02-28T13:08:14.000034
Shea
pythondev_help_Shea_2018-02-28T13:08:14.000034
1,519,823,294.000034
36,569
pythondev
help
I'm trying to add a string value to this endpoint assignment:`response = self.weconnect_test.get('/api/v1/businesses/' + str(biz_id) +'/reviews')`
2018-02-28T13:20:33.000700
Hans
pythondev_help_Hans_2018-02-28T13:20:33.000700
1,519,824,033.0007
36,570
pythondev
help
The idea is that the actual `api` endpoint is this: `response = self.weconnect_test.get('/api/v1/businesses/&lt;businessId&gt;/reviews')`
2018-02-28T13:21:50.000367
Hans
pythondev_help_Hans_2018-02-28T13:21:50.000367
1,519,824,110.000367
36,571
pythondev
help
And I want `str(biz_id)` to replace `&lt;businessId&gt;` in this as the `id` I've received.
2018-02-28T13:22:50.000633
Hans
pythondev_help_Hans_2018-02-28T13:22:50.000633
1,519,824,170.000633
36,572
pythondev
help
I tried the above line with `str(id)` and it is returning the following error: `json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
2018-02-28T13:25:31.000486
Hans
pythondev_help_Hans_2018-02-28T13:25:31.000486
1,519,824,331.000486
36,573
pythondev
help
<@Hans> does `weconnect_test` attempt to decode the response? that’s not with the call itself, it’s the response not being proper JSON
2018-02-28T13:28:21.000789
Brande
pythondev_help_Brande_2018-02-28T13:28:21.000789
1,519,824,501.000789
36,574
pythondev
help
I must say I'm still not too sure how `json` works in `python`. Tried reading this but it wasn't particularly enlightening: <http://docs.python-guide.org/en/latest/scenarios/json/>
2018-02-28T13:34:52.000420
Hans
pythondev_help_Hans_2018-02-28T13:34:52.000420
1,519,824,892.00042
36,575
pythondev
help
what does `resp.get_data()` look like?
2018-02-28T13:38:22.000511
Brande
pythondev_help_Brande_2018-02-28T13:38:22.000511
1,519,825,102.000511
36,576
pythondev
help
it looks like your first response isnt returning anything properly, because you dont have a `businessId` in the URL. you should be checking for a response status code before attempting to deal with the response. you’re making too many assumptions on how things will come from the API. The error you are getting is that y...
2018-02-28T13:42:51.000880
Brande
pythondev_help_Brande_2018-02-28T13:42:51.000880
1,519,825,371.00088
36,577
pythondev
help
leni1, json must follow a certain structure. It looks like a python list,tuple, dict because of the [],(,),{} when in fact it is text. The act of turning json into python as well as the opposite direction is called serializing/deserializing. This aspect is rarely (never?) explained, it is assumed in the documentati...
2018-02-28T13:46:42.000369
Monroe
pythondev_help_Monroe_2018-02-28T13:46:42.000369
1,519,825,602.000369
36,578
pythondev
help
<@Brande> `resp.get_data()` is this: `&lt;bound method BaseResponse.get_data of &lt;Response streamed [500 INTERNAL SERVER ERROR]&gt;&gt;`
2018-02-28T13:48:55.000526
Hans
pythondev_help_Hans_2018-02-28T13:48:55.000526
1,519,825,735.000526
36,579
pythondev
help
When I try printing it out
2018-02-28T13:49:01.000574
Hans
pythondev_help_Hans_2018-02-28T13:49:01.000574
1,519,825,741.000574
36,580
pythondev
help
<@Monroe> thanks for the link. Will read.
2018-02-28T13:49:41.000305
Hans
pythondev_help_Hans_2018-02-28T13:49:41.000305
1,519,825,781.000305
36,581
pythondev
help
Hey guys, let’s see if somebody can help out on this topic. I have an API REST which is getting data out of a MongoDB. Initially the idea was extract tennis matches and points per set/round so what we have is `get_match_results(matchID)` and `get_player_records(playerID, matchID)` and storing methods ( `save_match(jso...
2018-02-28T13:58:05.000330
Corine
pythondev_help_Corine_2018-02-28T13:58:05.000330
1,519,826,285.00033
36,582
pythondev
help
so, you really have a couple options here
2018-02-28T13:59:15.000854
Floy
pythondev_help_Floy_2018-02-28T13:59:15.000854
1,519,826,355.000854
36,583
pythondev
help
one, you can calculate those stats on insert/save
2018-02-28T13:59:25.000219
Floy
pythondev_help_Floy_2018-02-28T13:59:25.000219
1,519,826,365.000219
36,584
pythondev
help
or two, you can include a range or some other parameter and calculate the stats on retrieval
2018-02-28T13:59:43.000838
Floy
pythondev_help_Floy_2018-02-28T13:59:43.000838
1,519,826,383.000838
36,585
pythondev
help
overall, it really depends on what kind of approach you want
2018-02-28T14:00:04.000112
Floy
pythondev_help_Floy_2018-02-28T14:00:04.000112
1,519,826,404.000112
36,586
pythondev
help
and I would say, unless you’re expecting user load in the area of tens or hundreds of requests/second, worrying about load at this point is premature optimization
2018-02-28T14:00:38.000170
Floy
pythondev_help_Floy_2018-02-28T14:00:38.000170
1,519,826,438.00017
36,587
pythondev
help
cool
2018-02-28T14:01:08.000221
Corine
pythondev_help_Corine_2018-02-28T14:01:08.000221
1,519,826,468.000221
36,588
pythondev
help
The idea they have is basically : we have this match coming into the API, we would really like to have the average points of the player for the match and historical . So I’d just include the two methods
2018-02-28T14:01:22.000033
Corine
pythondev_help_Corine_2018-02-28T14:01:22.000033
1,519,826,482.000033
36,589
pythondev
help
Just out of my curiosity, is there any book/resource/field where I can read more about this topic ? I came across redis but that looks extremely overkilling
2018-02-28T14:02:22.000115
Corine
pythondev_help_Corine_2018-02-28T14:02:22.000115
1,519,826,542.000115
36,590
pythondev
help
ok. why did you pick mongo for this?
2018-02-28T14:03:59.000166
Floy
pythondev_help_Floy_2018-02-28T14:03:59.000166
1,519,826,639.000166
36,591
pythondev
help
because all this data looks structured
2018-02-28T14:04:06.000486
Floy
pythondev_help_Floy_2018-02-28T14:04:06.000486
1,519,826,646.000486
36,592
pythondev
help
so why use a nosql db for structured data?
2018-02-28T14:04:16.000851
Floy
pythondev_help_Floy_2018-02-28T14:04:16.000851
1,519,826,656.000851
36,593
pythondev
help
Good question
2018-02-28T14:04:25.000067
Corine
pythondev_help_Corine_2018-02-28T14:04:25.000067
1,519,826,665.000067
36,594
pythondev
help
because the guy who created the system is parsing a log coming from a tv server. It generates a JSON and apparently it also includes the “coach team”
2018-02-28T14:05:27.000169
Corine
pythondev_help_Corine_2018-02-28T14:05:27.000169
1,519,826,727.000169
36,595
pythondev
help
so that you will have: Match, Place, Date, Player1,2,3,4,team and equipement
2018-02-28T14:06:21.000478
Corine
pythondev_help_Corine_2018-02-28T14:06:21.000478
1,519,826,781.000478
36,596
pythondev
help
the latter ones can come in whatever shape
2018-02-28T14:06:44.000746
Corine
pythondev_help_Corine_2018-02-28T14:06:44.000746
1,519,826,804.000746
36,597
pythondev
help
(are dicts, I mean)
2018-02-28T14:07:54.000838
Corine
pythondev_help_Corine_2018-02-28T14:07:54.000838
1,519,826,874.000838
36,598
pythondev
help
alright, so you have a nosql component. I would say postgres is a good fit here, but that’s not affecting your question
2018-02-28T14:08:07.000353
Floy
pythondev_help_Floy_2018-02-28T14:08:07.000353
1,519,826,887.000353
36,599
pythondev
help
at the end of the day I can swithc to postgre and Ignore the equipment and team
2018-02-28T14:08:34.000017
Corine
pythondev_help_Corine_2018-02-28T14:08:34.000017
1,519,826,914.000017
36,600
pythondev
help
alright. regardless, this is a pretty simple (IMO) thing to do
2018-02-28T14:08:55.000271
Floy
pythondev_help_Floy_2018-02-28T14:08:55.000271
1,519,826,935.000271
36,601
pythondev
help
so, you’re interested in more info about rest API design?
2018-02-28T14:09:12.000304
Floy
pythondev_help_Floy_2018-02-28T14:09:12.000304
1,519,826,952.000304
36,602
pythondev
help
in python, specifically?
2018-02-28T14:09:20.000088
Floy
pythondev_help_Floy_2018-02-28T14:09:20.000088
1,519,826,960.000088
36,603
pythondev
help
correct
2018-02-28T14:10:19.000561
Corine
pythondev_help_Corine_2018-02-28T14:10:19.000561
1,519,827,019.000561
36,604
pythondev
help
it can be in whatever languange
2018-02-28T14:10:31.000115
Corine
pythondev_help_Corine_2018-02-28T14:10:31.000115
1,519,827,031.000115
36,605
pythondev
help
i suppose I can port it
2018-02-28T14:10:38.000575
Corine
pythondev_help_Corine_2018-02-28T14:10:38.000575
1,519,827,038.000575
36,606
pythondev
help
<https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api>
2018-02-28T14:10:57.000565
Floy
pythondev_help_Floy_2018-02-28T14:10:57.000565
1,519,827,057.000565
36,607
pythondev
help
that’s something that’s pretty good there
2018-02-28T14:11:04.000492
Floy
pythondev_help_Floy_2018-02-28T14:11:04.000492
1,519,827,064.000492
36,608
pythondev
help
Cool, thank you mate
2018-02-28T14:11:14.000638
Corine
pythondev_help_Corine_2018-02-28T14:11:14.000638
1,519,827,074.000638
36,609
pythondev
help
sorry for bother you guys again but I didn't find an approach for separate database per tenant to use with postgres to convert my web service in a multi tenant solution anyone has any suggestion ?
2018-02-28T14:23:08.000576
Logan
pythondev_help_Logan_2018-02-28T14:23:08.000576
1,519,827,788.000576
36,610
pythondev
help
how knowledgeable are you regarding dbs and pg?
2018-02-28T14:28:17.000257
Floy
pythondev_help_Floy_2018-02-28T14:28:17.000257
1,519,828,097.000257
36,611
pythondev
help
<https://www.pgcon.org/2017/schedule/events/1131.en.html>
2018-02-28T14:28:28.000583
Floy
pythondev_help_Floy_2018-02-28T14:28:28.000583
1,519,828,108.000583
36,612
pythondev
help
Help
2018-02-28T14:55:22.000690
Jenna
pythondev_help_Jenna_2018-02-28T14:55:22.000690
1,519,829,722.00069
36,613
pythondev
help
what’s the most optimal way of doing this?
2018-02-28T14:59:10.000261
Jenna
pythondev_help_Jenna_2018-02-28T14:59:10.000261
1,519,829,950.000261
36,614
pythondev
help
I feel like my way isn’t efficient
2018-02-28T14:59:25.000030
Jenna
pythondev_help_Jenna_2018-02-28T14:59:25.000030
1,519,829,965.00003
36,615
pythondev
help
i was trying to use `groupby` method, but it looks like i have to do `merhcantA` and `merchantB` seperately
2018-02-28T15:01:51.000749
Jenna
pythondev_help_Jenna_2018-02-28T15:01:51.000749
1,519,830,111.000749
36,616
pythondev
help
do you get this data from some api?
2018-02-28T15:11:32.000236
Meredith
pythondev_help_Meredith_2018-02-28T15:11:32.000236
1,519,830,692.000236
36,617
pythondev
help
sorry I saw my question now and I didn't explain properly, the problem is I didn't find in <https://djangopackages.org/grids/g/multi-tenancy/> nothing that can solve my problem with one database per tenant
2018-02-28T15:12:01.000464
Logan
pythondev_help_Logan_2018-02-28T15:12:01.000464
1,519,830,721.000464
36,618
pythondev
help
do you store it in database/file?
2018-02-28T15:13:46.000692
Meredith
pythondev_help_Meredith_2018-02-28T15:13:46.000692
1,519,830,826.000692
36,619
pythondev
help
this is the closer one <https://github.com/citusdata/django-multitenant> but it share tables between tenants and I just want that each tenant will have one database and all the tenants have the same functionality
2018-02-28T15:16:38.000259
Logan
pythondev_help_Logan_2018-02-28T15:16:38.000259
1,519,830,998.000259
36,620
pythondev
help
sounds like you have a large challenge on your hands
2018-02-28T15:21:12.000269
Floy
pythondev_help_Floy_2018-02-28T15:21:12.000269
1,519,831,272.000269
36,621
pythondev
help
how essential is this requirement to you?
2018-02-28T15:21:25.000057
Floy
pythondev_help_Floy_2018-02-28T15:21:25.000057
1,519,831,285.000057
36,622
pythondev
help
I have a time `2018-02-28T19:16:30.000Z` that I want to format into datetime, then turn it into a unix timestamp. However when the unixtimestamp gets read, it says its 1970-01-01 - Does anyone know why this happens? ``` time = 2018-02-28T19:16:30.000Z // just pasted here for example, actually from a json file date_conv...
2018-02-28T15:25:22.000512
Lorrine
pythondev_help_Lorrine_2018-02-28T15:25:22.000512
1,519,831,522.000512
36,623