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
<@Jimmy> would this skip the key?
2019-01-22T03:53:30.098100
Conrad
pythondev_help_Conrad_2019-01-22T03:53:30.098100
1,548,129,210.0981
3,521
pythondev
help
idk, I'm testing it :smile:
2019-01-22T03:53:50.098500
Jimmy
pythondev_help_Jimmy_2019-01-22T03:53:50.098500
1,548,129,230.0985
3,522
pythondev
help
`{k: v.replace('Zimmer', '').replace('m2', '') if v is not None else v for k, v in a.items()}`
2019-01-22T03:54:22.099300
Jimmy
pythondev_help_Jimmy_2019-01-22T03:54:22.099300
1,548,129,262.0993
3,523
pythondev
help
This will keep the key
2019-01-22T03:54:25.099500
Jimmy
pythondev_help_Jimmy_2019-01-22T03:54:25.099500
1,548,129,265.0995
3,524
pythondev
help
the other one remove the key
2019-01-22T03:54:33.099800
Jimmy
pythondev_help_Jimmy_2019-01-22T03:54:33.099800
1,548,129,273.0998
3,525
pythondev
help
hmm
2019-01-22T03:54:39.100100
Conrad
pythondev_help_Conrad_2019-01-22T03:54:39.100100
1,548,129,279.1001
3,526
pythondev
help
wowow, what is happening there
2019-01-22T03:54:47.100800
Bernita
pythondev_help_Bernita_2019-01-22T03:54:47.100800
1,548,129,287.1008
3,527
pythondev
help
but I would advise against using that. A bit too complicated if you are not familliar
2019-01-22T03:54:58.101100
Jimmy
pythondev_help_Jimmy_2019-01-22T03:54:58.101100
1,548,129,298.1011
3,528
pythondev
help
would probably be nicer to have expanded code instead of a comprehension
2019-01-22T03:55:00.101300
Conrad
pythondev_help_Conrad_2019-01-22T03:55:00.101300
1,548,129,300.1013
3,529
pythondev
help
in this case
2019-01-22T03:55:03.101500
Conrad
pythondev_help_Conrad_2019-01-22T03:55:03.101500
1,548,129,303.1015
3,530
pythondev
help
yeah
2019-01-22T03:55:04.101700
Conrad
pythondev_help_Conrad_2019-01-22T03:55:04.101700
1,548,129,304.1017
3,531
pythondev
help
``` ads = {} try: for k, v in dik.iteritems(): if v is None: ads[k] = None else: ads[k] = .... (do all replacements here) except AttributeError: .... ```
2019-01-22T03:56:29.102800
Conrad
pythondev_help_Conrad_2019-01-22T03:56:29.102800
1,548,129,389.1028
3,532
pythondev
help
Where do these `None` come from?
2019-01-22T03:57:08.103200
Chester
pythondev_help_Chester_2019-01-22T03:57:08.103200
1,548,129,428.1032
3,533
pythondev
help
<@Chester> scraping
2019-01-22T03:57:17.103400
Bernita
pythondev_help_Bernita_2019-01-22T03:57:17.103400
1,548,129,437.1034
3,534
pythondev
help
so want to place it as a NaN in my table
2019-01-22T03:57:36.104200
Bernita
pythondev_help_Bernita_2019-01-22T03:57:36.104200
1,548,129,456.1042
3,535
pythondev
help
Can you make it to insert an empty string instead of `None`?
2019-01-22T03:57:36.104300
Chester
pythondev_help_Chester_2019-01-22T03:57:36.104300
1,548,129,456.1043
3,536
pythondev
help
that is actually cleaner
2019-01-22T03:58:42.105100
Bernita
pythondev_help_Bernita_2019-01-22T03:58:42.105100
1,548,129,522.1051
3,537
pythondev
help
cool. thanks
2019-01-22T03:58:48.105300
Bernita
pythondev_help_Bernita_2019-01-22T03:58:48.105300
1,548,129,528.1053
3,538
pythondev
help
I am trying to create a upvote-downvote api using python(flask) using dictionaries i.e there is no connection to any database yet. Is this possible or should I atleast have a functioning U.I connected to a database?
2019-01-22T04:16:03.108500
Laveta
pythondev_help_Laveta_2019-01-22T04:16:03.108500
1,548,130,563.1085
3,539
pythondev
help
where are you going to store the dict?
2019-01-22T04:18:46.111200
Jettie
pythondev_help_Jettie_2019-01-22T04:18:46.111200
1,548,130,726.1112
3,540
pythondev
help
In an empty list. Just appending to it
2019-01-22T04:20:17.112000
Laveta
pythondev_help_Laveta_2019-01-22T04:20:17.112000
1,548,130,817.112
3,541
pythondev
help
it will _probably_ work with a development server, since it's single-threaded
2019-01-22T04:25:46.112700
Jettie
pythondev_help_Jettie_2019-01-22T04:25:46.112700
1,548,131,146.1127
3,542
pythondev
help
it won't persist across service restarts though, and won't work in serious production where number of workers is &gt;1
2019-01-22T04:26:09.113400
Jettie
pythondev_help_Jettie_2019-01-22T04:26:09.113400
1,548,131,169.1134
3,543
pythondev
help
Okay. Thankyou.
2019-01-22T04:35:45.113700
Laveta
pythondev_help_Laveta_2019-01-22T04:35:45.113700
1,548,131,745.1137
3,544
pythondev
help
'''class counterupvotes: def __init__(self, upvote = ''): self.upvotes_database = [] def add_upvote(self): new_upvote = { "upvote": self.upvote } self.upvotes_database.append(new_upvote) class counterdownvotes: def __init__(self, downvote = ''): self....
2019-01-22T04:37:46.115200
Laveta
pythondev_help_Laveta_2019-01-22T04:37:46.115200
1,548,131,866.1152
3,545
pythondev
help
you can use `from collections import defaultdict`
2019-01-22T04:45:40.115700
Jettie
pythondev_help_Jettie_2019-01-22T04:45:40.115700
1,548,132,340.1157
3,546
pythondev
help
and initialize as `defaultdict(int)`
2019-01-22T04:45:46.115900
Jettie
pythondev_help_Jettie_2019-01-22T04:45:46.115900
1,548,132,346.1159
3,547
pythondev
help
it will do `if key not in dict: dict[key] = int()` behind the scenes, and `int()` returns 0
2019-01-22T04:46:24.116600
Jettie
pythondev_help_Jettie_2019-01-22T04:46:24.116600
1,548,132,384.1166
3,548
pythondev
help
Okay. Thanks
2019-01-22T05:42:55.117300
Laveta
pythondev_help_Laveta_2019-01-22T05:42:55.117300
1,548,135,775.1173
3,549
pythondev
help
When we call `del` on an object, what does it delete from? What's the equivalent of this in Java?
2019-01-22T06:09:56.119200
Rosa
pythondev_help_Rosa_2019-01-22T06:09:56.119200
1,548,137,396.1192
3,550
pythondev
help
You can think of `del foo` as an opposite operation to a variable assignment, `foo = 1`
2019-01-22T06:10:57.120000
Chester
pythondev_help_Chester_2019-01-22T06:10:57.120000
1,548,137,457.12
3,551
pythondev
help
Most of the time you don't need to `del` something explicitly
2019-01-22T06:11:10.120300
Chester
pythondev_help_Chester_2019-01-22T06:11:10.120300
1,548,137,470.1203
3,552
pythondev
help
What?
2019-01-22T06:12:16.120700
Chester
pythondev_help_Chester_2019-01-22T06:12:16.120700
1,548,137,536.1207
3,553
pythondev
help
I don't understand, `foo = 1` isn't that assigning 1 to foo, sorry I'm new to Python. So we can still do `del foo` again
2019-01-22T06:12:55.121300
Rosa
pythondev_help_Rosa_2019-01-22T06:12:55.121300
1,548,137,575.1213
3,554
pythondev
help
Uh, you should really read a book first. Mark Lutz is nice
2019-01-22T06:13:29.122000
Chester
pythondev_help_Chester_2019-01-22T06:13:29.122000
1,548,137,609.122
3,555
pythondev
help
when you do `foo = 1` you create an object "int" with an initial value of 1. This is stored in memory. If you do `del foo` it finds the object called foo and removes it from memory
2019-01-22T06:13:52.122700
Mica
pythondev_help_Mica_2019-01-22T06:13:52.122700
1,548,137,632.1227
3,556
pythondev
help
i think
2019-01-22T06:13:55.123000
Mica
pythondev_help_Mica_2019-01-22T06:13:55.123000
1,548,137,635.123
3,557
pythondev
help
I'm reading a Python book already but not that one :simple_smile:
2019-01-22T06:14:04.123300
Rosa
pythondev_help_Rosa_2019-01-22T06:14:04.123300
1,548,137,644.1233
3,558
pythondev
help
AFAIK there is no such equivalent in java because java doesn't have a reference counting mechanism
2019-01-22T06:14:14.123700
Chester
pythondev_help_Chester_2019-01-22T06:14:14.123700
1,548,137,654.1237
3,559
pythondev
help
I think I've figured out what I was really looking to understand, "Memory management in Python".
2019-01-22T06:16:50.123800
Rosa
pythondev_help_Rosa_2019-01-22T06:16:50.123800
1,548,137,810.1238
3,560
pythondev
help
<@Mica> it doesn't remove the object from memory
2019-01-22T06:44:05.124700
Jettie
pythondev_help_Jettie_2019-01-22T06:44:05.124700
1,548,139,445.1247
3,561
pythondev
help
it decreases the reference counter and that's it
2019-01-22T06:44:15.125000
Jettie
pythondev_help_Jettie_2019-01-22T06:44:15.125000
1,548,139,455.125
3,562
pythondev
help
aah ok, the reference counter, being the number of references to the object?
2019-01-22T06:44:34.125400
Mica
pythondev_help_Mica_2019-01-22T06:44:34.125400
1,548,139,474.1254
3,563
pythondev
help
yes
2019-01-22T06:44:41.125600
Jettie
pythondev_help_Jettie_2019-01-22T06:44:41.125600
1,548,139,481.1256
3,564
pythondev
help
it may or may not reach 0 after `del`
2019-01-22T06:44:54.126100
Jettie
pythondev_help_Jettie_2019-01-22T06:44:54.126100
1,548,139,494.1261
3,565
pythondev
help
if it does, it's deleted. if it doesn't, well, hopefully it can be garbage collected some time soon
2019-01-22T06:45:17.127100
Jettie
pythondev_help_Jettie_2019-01-22T06:45:17.127100
1,548,139,517.1271
3,566
pythondev
help
but maybe not :))
2019-01-22T06:45:21.127500
Jettie
pythondev_help_Jettie_2019-01-22T06:45:21.127500
1,548,139,521.1275
3,567
pythondev
help
aahh cool <@Jettie> for the correction! :taco:
2019-01-22T06:45:24.127600
Mica
pythondev_help_Mica_2019-01-22T06:45:24.127600
1,548,139,524.1276
3,568
pythondev
help
This message was deleted.
2019-01-22T06:50:30.127900
Alejandrina
pythondev_help_Alejandrina_2019-01-22T06:50:30.127900
1,548,139,830.1279
3,569
pythondev
help
I moved this to <#C080T8XT2|job_board> .
2019-01-22T06:53:01.128000
Karoline
pythondev_help_Karoline_2019-01-22T06:53:01.128000
1,548,139,981.128
3,570
pythondev
help
Man, that's an &gt;1600 page book! Haha, maybe good as a reference, not what I need now
2019-01-22T06:58:49.128200
Rosa
pythondev_help_Rosa_2019-01-22T06:58:49.128200
1,548,140,329.1282
3,571
pythondev
help
would like to convert some strings in my dict to int. what kind of boolean could I use to skip over letters. ``` ads = {key:'aword', key:'10'} ads = {k: int(v) for k, v in ads.items()} &gt;&gt;&gt; error since 'aword' cannot be an int ```
2019-01-22T09:21:29.131300
Bernita
pythondev_help_Bernita_2019-01-22T09:21:29.131300
1,548,148,889.1313
3,572
pythondev
help
by skip over letters, you mean keep strings as is?
2019-01-22T09:23:18.131800
Conrad
pythondev_help_Conrad_2019-01-22T09:23:18.131800
1,548,148,998.1318
3,573
pythondev
help
skip the value 'aword', convert the string '10' into digits
2019-01-22T09:23:40.132200
Bernita
pythondev_help_Bernita_2019-01-22T09:23:40.132200
1,548,149,020.1322
3,574
pythondev
help
``` def parse_int(val): if val.isdigit(): return int(val) else: return val ads = {k: parse_int(v) for k, v in ads.items()} ```
2019-01-22T09:24:49.133500
Conrad
pythondev_help_Conrad_2019-01-22T09:24:49.133500
1,548,149,089.1335
3,575
pythondev
help
isdigit()
2019-01-22T09:26:06.133800
Bernita
pythondev_help_Bernita_2019-01-22T09:26:06.133800
1,548,149,166.1338
3,576
pythondev
help
genius. never heard of it
2019-01-22T09:26:09.134000
Bernita
pythondev_help_Bernita_2019-01-22T09:26:09.134000
1,548,149,169.134
3,577
pythondev
help
<@Conrad> :+1:
2019-01-22T09:26:23.134300
Bernita
pythondev_help_Bernita_2019-01-22T09:26:23.134300
1,548,149,183.1343
3,578
pythondev
help
or if you want to subscribe to the “ask forgiveness rather than permission” philosophy, ```try: return int(val) except ValueError: return val ```
2019-01-22T09:29:45.135300
Hiroko
pythondev_help_Hiroko_2019-01-22T09:29:45.135300
1,548,149,385.1353
3,579
pythondev
help
Does anyone know how I would go about referencing the jsonToCsv Python module (<https://github.com/kata198/jsonToCsv>) with a variable I'm using to store raw, unformatted JSON? I'm seeing examples where a catted example is being piped into the module and it then goes to work processing into CSV format?
2019-01-22T11:48:30.137600
Granville
pythondev_help_Granville_2019-01-22T11:48:30.137600
1,548,157,710.1376
3,580
pythondev
help
If I understand your question, it looks like the module has a `convertToCsv()` method which takes a string and outputs CSV lines.
2019-01-22T11:55:23.138500
Sasha
pythondev_help_Sasha_2019-01-22T11:55:23.138500
1,548,158,123.1385
3,581
pythondev
help
Thanks! Is there anything I need to supply to the 'self' parameter if I call the parameter in this way? jsonToCsv.convertToCsv(json_variable)
2019-01-22T12:01:06.140900
Granville
pythondev_help_Granville_2019-01-22T12:01:06.140900
1,548,158,466.1409
3,582
pythondev
help
no
2019-01-22T12:02:36.141100
Hiroko
pythondev_help_Hiroko_2019-01-22T12:02:36.141100
1,548,158,556.1411
3,583
pythondev
help
gotcha, thanks again!
2019-01-22T12:07:44.141800
Granville
pythondev_help_Granville_2019-01-22T12:07:44.141800
1,548,158,864.1418
3,584
pythondev
help
It looks like the module might require a format string to set up how you want the data values mapped to columns, etc.
2019-01-22T12:09:31.142500
Sasha
pythondev_help_Sasha_2019-01-22T12:09:31.142500
1,548,158,971.1425
3,585
pythondev
help
If CSV is your end product, check out something like `jq`
2019-01-22T12:13:12.142900
Jonas
pythondev_help_Jonas_2019-01-22T12:13:12.142900
1,548,159,192.1429
3,586
pythondev
help
and make your tool output json: `your_tool.py | jq "@csv"`. Less code is always better
2019-01-22T12:13:51.143700
Jonas
pythondev_help_Jonas_2019-01-22T12:13:51.143700
1,548,159,231.1437
3,587
pythondev
help
Thanks <@Jonas>. I'm going with jsonToCsv because of nested JSON arrays. <@Sasha> yea, I may look into that a little later once I see what the initial output will look like.
2019-01-22T13:19:02.145700
Granville
pythondev_help_Granville_2019-01-22T13:19:02.145700
1,548,163,142.1457
3,588
pythondev
help
Why doesn't this work if text is a global variable?
2019-01-22T13:47:56.145800
Nenita
pythondev_help_Nenita_2019-01-22T13:47:56.145800
1,548,164,876.1458
3,589
pythondev
help
but this works
2019-01-22T13:49:06.146100
Nenita
pythondev_help_Nenita_2019-01-22T13:49:06.146100
1,548,164,946.1461
3,590
pythondev
help
You are using the global keyword incorrectly. You use it inside a block that would otherwise create a local variable. Your first should be ``` text = None def do_something(x): global text text = x do_something("hi") print(text) ```
2019-01-22T13:51:44.147900
Clemmie
pythondev_help_Clemmie_2019-01-22T13:51:44.147900
1,548,165,104.1479
3,591
pythondev
help
The reason your second worked is because you didn’t do anything global. You kept and used every variable in their local scope.
2019-01-22T13:52:21.148700
Clemmie
pythondev_help_Clemmie_2019-01-22T13:52:21.148700
1,548,165,141.1487
3,592
pythondev
help
I hesitated to answer this, mostly because the use of `global` is _almost_ always the wrong choice. In particular, your second snippet is pythonically written as ``` def do_something(x): return x text = do_something("hi") print(text) ```
2019-01-22T13:54:38.151000
Clemmie
pythondev_help_Clemmie_2019-01-22T13:54:38.151000
1,548,165,278.151
3,593
pythondev
help
all that makes sense. I am deciding to use a global variable because I don't want to have to re-arrange all my functions into a class, but I may just do it to save the hassle of a global variable.
2019-01-22T13:57:09.152100
Nenita
pythondev_help_Nenita_2019-01-22T13:57:09.152100
1,548,165,429.1521
3,594
pythondev
help
With all I have written atm, I was able to setup the global variable fairly quickly. Thanks for the brief/quick explanation.
2019-01-22T14:05:15.153100
Nenita
pythondev_help_Nenita_2019-01-22T14:05:15.153100
1,548,165,915.1531
3,595
pythondev
help
Happy to help. If you ever have to show the code to another python dev, be ready to defend those globals :sweat_smile:
2019-01-22T14:06:43.154200
Clemmie
pythondev_help_Clemmie_2019-01-22T14:06:43.154200
1,548,166,003.1542
3,596
pythondev
help
I found PEP-420 that addresses Namespace Packages: <https://www.python.org/dev/peps/pep-0420/>
2019-01-22T14:07:44.154300
Vita
pythondev_help_Vita_2019-01-22T14:07:44.154300
1,548,166,064.1543
3,597
pythondev
help
thats what i see a lot
2019-01-22T14:09:13.154900
Nenita
pythondev_help_Nenita_2019-01-22T14:09:13.154900
1,548,166,153.1549
3,598
pythondev
help
as soon as i first researched global variables (because i used them frequently in vba for excel), I was telling myself "stay away...:zany_face:".
2019-01-22T14:11:11.156300
Nenita
pythondev_help_Nenita_2019-01-22T14:11:11.156300
1,548,166,271.1563
3,599
pythondev
help
+1 to avoiding global variables. Refactoring your code now will probably be easier than refactoring it 6 months from now when you've forgotten the details :wink:
2019-01-22T14:12:01.156900
Chanell
pythondev_help_Chanell_2019-01-22T14:12:01.156900
1,548,166,321.1569
3,600
pythondev
help
I've yet to run into a situation where I couldn't get around using globals
2019-01-22T14:12:39.157400
Claudine
pythondev_help_Claudine_2019-01-22T14:12:39.157400
1,548,166,359.1574
3,601
pythondev
help
they make me feel dirty
2019-01-22T14:12:48.157700
Claudine
pythondev_help_Claudine_2019-01-22T14:12:48.157700
1,548,166,368.1577
3,602
pythondev
help
Yeah, I would deny a pull on code review if I saw a global
2019-01-22T14:15:29.158400
Clemmie
pythondev_help_Clemmie_2019-01-22T14:15:29.158400
1,548,166,529.1584
3,603
pythondev
help
same
2019-01-22T14:15:34.158600
Claudine
pythondev_help_Claudine_2019-01-22T14:15:34.158600
1,548,166,534.1586
3,604
pythondev
help
and then throw something at the dev who submitted it
2019-01-22T14:15:48.159000
Claudine
pythondev_help_Claudine_2019-01-22T14:15:48.159000
1,548,166,548.159
3,605
pythondev
help
i keep a collection of small items that have been thrown at me
2019-01-22T14:16:01.159300
Claudine
pythondev_help_Claudine_2019-01-22T14:16:01.159300
1,548,166,561.1593
3,606
pythondev
help
Unless they are a junior python dev - then throw some love and knowledge
2019-01-22T14:16:45.159700
Clemmie
pythondev_help_Clemmie_2019-01-22T14:16:45.159700
1,548,166,605.1597
3,607
pythondev
help
Ok, going to clean the vomit off my desk now
2019-01-22T14:16:53.160000
Clemmie
pythondev_help_Clemmie_2019-01-22T14:16:53.160000
1,548,166,613.16
3,608
pythondev
help
As someone new to python, this has been a helpful conversation re: globals :+1:
2019-01-22T14:35:39.161700
Marth
pythondev_help_Marth_2019-01-22T14:35:39.161700
1,548,167,739.1617
3,609
pythondev
help
<@Chanell> so true haha
2019-01-22T14:42:45.162000
Nenita
pythondev_help_Nenita_2019-01-22T14:42:45.162000
1,548,168,165.162
3,610
pythondev
help
With pytest if you want to assert that two objects are the same (same attributes) is it as simple as `assert obj1 == obj2`, is it better to do `assert obj1.id == obj2.id` for attributes on the object
2019-01-22T15:04:25.163300
Caridad
pythondev_help_Caridad_2019-01-22T15:04:25.163300
1,548,169,465.1633
3,611
pythondev
help
Or `assertEquals`
2019-01-22T15:05:38.164000
Hiroko
pythondev_help_Hiroko_2019-01-22T15:05:38.164000
1,548,169,538.164
3,612
pythondev
help
Thank you <@Hiroko>! :taco:
2019-01-22T15:09:41.164700
Caridad
pythondev_help_Caridad_2019-01-22T15:09:41.164700
1,548,169,781.1647
3,613
pythondev
help
`assertEquals` is a deprecated alias for the newer `assertEqual`, though both still work.
2019-01-22T16:34:30.166400
Marla
pythondev_help_Marla_2019-01-22T16:34:30.166400
1,548,174,870.1664
3,614
pythondev
help
I always get the two mixed up :smile:
2019-01-22T16:35:53.166600
Hiroko
pythondev_help_Hiroko_2019-01-22T16:35:53.166600
1,548,174,953.1666
3,615
pythondev
help
that darn `s`
2019-01-22T16:35:57.166800
Hiroko
pythondev_help_Hiroko_2019-01-22T16:35:57.166800
1,548,174,957.1668
3,616
pythondev
help
with pytest, I would recommend always trying to use just plain `assert`
2019-01-22T16:49:15.167300
Ashley
pythondev_help_Ashley_2019-01-22T16:49:15.167300
1,548,175,755.1673
3,617
pythondev
help
pytest knows how to compare the most common object types, and will give you a readable output for failed tests
2019-01-22T16:50:02.168000
Ashley
pythondev_help_Ashley_2019-01-22T16:50:02.168000
1,548,175,802.168
3,618
pythondev
help
I would also recommend defining a `__eq__` for custom classes so they can be compared directly
2019-01-22T16:51:00.169100
Ashley
pythondev_help_Ashley_2019-01-22T16:51:00.169100
1,548,175,860.1691
3,619
pythondev
help
you can even use a pytest hook to handle the output of that failed comparison and tell pytest where to find it using a setup.py entry point
2019-01-22T16:52:08.170000
Ashley
pythondev_help_Ashley_2019-01-22T16:52:08.170000
1,548,175,928.17
3,620