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
<@Kym> Wonderful Git Guide, thank you
2017-10-06T12:09:41.000001
Seema
pythondev_help_Seema_2017-10-06T12:09:41.000001
1,507,291,781.000001
96,203
pythondev
help
can you pass a class into a subclass and have it keep all previous properties?
2017-10-06T12:32:44.000433
Winnie
pythondev_help_Winnie_2017-10-06T12:32:44.000433
1,507,293,164.000433
96,204
pythondev
help
sure, define class properties in `__init__`
2017-10-06T12:34:43.000048
Meg
pythondev_help_Meg_2017-10-06T12:34:43.000048
1,507,293,283.000048
96,205
pythondev
help
unless the subclass overwrites them, you’ll have the superclass properties the same
2017-10-06T12:35:02.000367
Meg
pythondev_help_Meg_2017-10-06T12:35:02.000367
1,507,293,302.000367
96,206
pythondev
help
like
2017-10-06T12:35:19.000115
Winnie
pythondev_help_Winnie_2017-10-06T12:35:19.000115
1,507,293,319.000115
96,207
pythondev
help
I have a function that generates a superclass
2017-10-06T12:35:35.000423
Winnie
pythondev_help_Winnie_2017-10-06T12:35:35.000423
1,507,293,335.000423
96,208
pythondev
help
is it possible to pass that superclass into the subclass instead or repeating the function and adding more elements?
2017-10-06T12:36:15.000291
Winnie
pythondev_help_Winnie_2017-10-06T12:36:15.000291
1,507,293,375.000291
96,209
pythondev
help
uhh, generates a superclass?
2017-10-06T12:37:04.000030
Meg
pythondev_help_Meg_2017-10-06T12:37:04.000030
1,507,293,424.00003
96,210
pythondev
help
I think you’re mixing up OOP basics.
2017-10-06T12:37:26.000266
Meg
pythondev_help_Meg_2017-10-06T12:37:26.000266
1,507,293,446.000266
96,211
pythondev
help
in your init of the subclass, have it take in properties you want set.
2017-10-06T12:37:47.000066
Meg
pythondev_help_Meg_2017-10-06T12:37:47.000066
1,507,293,467.000066
96,212
pythondev
help
superclass should have fields already set via its own init
2017-10-06T12:38:05.000529
Meg
pythondev_help_Meg_2017-10-06T12:38:05.000529
1,507,293,485.000529
96,213
pythondev
help
``` class A(object): ... class B(A): ... def make_A(data) -&gt; A: .... def make_B(data): B(make_A(data), data[-1]) ```
2017-10-06T12:38:53.000500
Winnie
pythondev_help_Winnie_2017-10-06T12:38:53.000500
1,507,293,533.0005
96,214
pythondev
help
in B, define an `__init__`
2017-10-06T12:39:18.000096
Meg
pythondev_help_Meg_2017-10-06T12:39:18.000096
1,507,293,558.000096
96,215
pythondev
help
that will call `super(A, self).__init__()` with the required properties
2017-10-06T12:39:34.000194
Meg
pythondev_help_Meg_2017-10-06T12:39:34.000194
1,507,293,574.000194
96,216
pythondev
help
I'm a bit confused
2017-10-06T12:40:20.000099
Winnie
pythondev_help_Winnie_2017-10-06T12:40:20.000099
1,507,293,620.000099
96,217
pythondev
help
what does passing A into super do?
2017-10-06T12:40:29.000299
Winnie
pythondev_help_Winnie_2017-10-06T12:40:29.000299
1,507,293,629.000299
96,218
pythondev
help
because the code I'm working on passes B into super (in the B class)
2017-10-06T12:40:47.000620
Winnie
pythondev_help_Winnie_2017-10-06T12:40:47.000620
1,507,293,647.00062
96,219
pythondev
help
```class A(object): def __init__(self, a, b, c): self.a = a self.b = b self.c = c class B(A): def __init__(self, a, b, c, d): super().__init(a, b, c) self.d = d ```
2017-10-06T12:41:55.000287
Meg
pythondev_help_Meg_2017-10-06T12:41:55.000287
1,507,293,715.000287
96,220
pythondev
help
that’s for python3
2017-10-06T12:42:08.000137
Meg
pythondev_help_Meg_2017-10-06T12:42:08.000137
1,507,293,728.000137
96,221
pythondev
help
``` class B(A): def __init__(self, a, b, c, d): super(B, self).__init(a, b, c) self.d = d ``` that's the code I'm working with
2017-10-06T12:43:20.000538
Winnie
pythondev_help_Winnie_2017-10-06T12:43:20.000538
1,507,293,800.000538
96,222
pythondev
help
ok, so B is a subclass of A
2017-10-06T12:43:44.000237
Meg
pythondev_help_Meg_2017-10-06T12:43:44.000237
1,507,293,824.000237
96,223
pythondev
help
and you’re already instanciating properties that B inherits from A
2017-10-06T12:43:58.000212
Meg
pythondev_help_Meg_2017-10-06T12:43:58.000212
1,507,293,838.000212
96,224
pythondev
help
in addition, if you have a method defined in A that’s not replicated in B, its still accessible from B
2017-10-06T12:44:37.000254
Meg
pythondev_help_Meg_2017-10-06T12:44:37.000254
1,507,293,877.000254
96,225
pythondev
help
eg, ```class A(object): def some_func(self, t): # do something inst = B(...args) inst.some_func('some_value')``` is perfectly valid
2017-10-06T12:45:37.000182
Meg
pythondev_help_Meg_2017-10-06T12:45:37.000182
1,507,293,937.000182
96,226
pythondev
help
so, unless I’m missing something here, you already have everything you need
2017-10-06T12:45:52.000555
Meg
pythondev_help_Meg_2017-10-06T12:45:52.000555
1,507,293,952.000555
96,227
pythondev
help
right
2017-10-06T12:46:31.000110
Winnie
pythondev_help_Winnie_2017-10-06T12:46:31.000110
1,507,293,991.00011
96,228
pythondev
help
I understand the OOP
2017-10-06T12:46:38.000087
Winnie
pythondev_help_Winnie_2017-10-06T12:46:38.000087
1,507,293,998.000087
96,229
pythondev
help
but I'm trying to figure out the correct syntax
2017-10-06T12:46:49.000189
Winnie
pythondev_help_Winnie_2017-10-06T12:46:49.000189
1,507,294,009.000189
96,230
pythondev
help
``` class A(object): ... class B(A): ... def make_A(data) -&gt; A: return A(data[0], int(data[1])) def make_B(data): # is this possible? B(make_A(data), data[-1]) ```
2017-10-06T12:47:28.000074
Winnie
pythondev_help_Winnie_2017-10-06T12:47:28.000074
1,507,294,048.000074
96,231
pythondev
help
what is make_A?
2017-10-06T12:47:47.000026
Sirena
pythondev_help_Sirena_2017-10-06T12:47:47.000026
1,507,294,067.000026
96,232
pythondev
help
just do `B(data)`
2017-10-06T12:48:07.000573
Meg
pythondev_help_Meg_2017-10-06T12:48:07.000573
1,507,294,087.000573
96,233
pythondev
help
if you just want an A object, `make_A(data)` should instead just be `A(data)`
2017-10-06T12:48:19.000656
Sirena
pythondev_help_Sirena_2017-10-06T12:48:19.000656
1,507,294,099.000656
96,234
pythondev
help
make_A parses a json and takes out the appropriate fields to put in the args
2017-10-06T12:48:47.000573
Winnie
pythondev_help_Winnie_2017-10-06T12:48:47.000573
1,507,294,127.000573
96,235
pythondev
help
if you want a B object that inherits A, just do B(data) and in your B.__init__(), include whatever funky manipulations you want to the vars inherited from A
2017-10-06T12:49:13.000155
Sirena
pythondev_help_Sirena_2017-10-06T12:49:13.000155
1,507,294,153.000155
96,236
pythondev
help
yah, so you probably want ```class B(A): def __init__(self, json): parse_my_json_and_do_things(self, json)```
2017-10-06T12:50:44.000199
Sirena
pythondev_help_Sirena_2017-10-06T12:50:44.000199
1,507,294,244.000199
96,237
pythondev
help
there is a design pattern called a 'factory pattern' where functions return instances of objects, but I don't get the sense that is what you want in this case (I could be wrong)
2017-10-06T12:52:11.000037
Sirena
pythondev_help_Sirena_2017-10-06T12:52:11.000037
1,507,294,331.000037
96,238
pythondev
help
It's what I want, I think. But I also think its what I can't have :stuck_out_tongue:
2017-10-06T12:52:48.000213
Winnie
pythondev_help_Winnie_2017-10-06T12:52:48.000213
1,507,294,368.000213
96,239
pythondev
help
because this repo's factories are outside the classes
2017-10-06T12:53:08.000223
Winnie
pythondev_help_Winnie_2017-10-06T12:53:08.000223
1,507,294,388.000223
96,240
pythondev
help
do you normally construct your objects from something other than json?
2017-10-06T12:55:28.000476
Sirena
pythondev_help_Sirena_2017-10-06T12:55:28.000476
1,507,294,528.000476
96,241
pythondev
help
so I guess what I was asking is, can you pass the initliasations of a class to a subclass and have it inherit them maybe something like ``` B(**make_a(data).variables, data[-1]) ```
2017-10-06T12:57:07.000241
Winnie
pythondev_help_Winnie_2017-10-06T12:57:07.000241
1,507,294,627.000241
96,242
pythondev
help
factories are something loosely along the lines of ```class A: def __init__(self, initdata): class B: def __init__(self, initdata): def factory(type, data): if(type == 'A'): return A(data) elif(type == 'B'): return B(data)```
2017-10-06T12:57:13.000559
Sirena
pythondev_help_Sirena_2017-10-06T12:57:13.000559
1,507,294,633.000559
96,243
pythondev
help
I think this repo does both
2017-10-06T12:57:49.000394
Winnie
pythondev_help_Winnie_2017-10-06T12:57:49.000394
1,507,294,669.000394
96,244
pythondev
help
<https://github.com/carpedm20/fbchat/blob/master/fbchat/graphql.py#L106> if you're intrested
2017-10-06T12:58:56.000247
Winnie
pythondev_help_Winnie_2017-10-06T12:58:56.000247
1,507,294,736.000247
96,245
pythondev
help
I'm adding a "graphql_to_room" function, where it's a copy of the above but instead with extra fields and idk, it just felt wrong
2017-10-06T13:00:16.000267
Winnie
pythondev_help_Winnie_2017-10-06T13:00:16.000267
1,507,294,816.000267
96,246
pythondev
help
it looks more like it's accepting a GraphQL object and returning a Group object, but the GraphQL object is mostly just a blob of query data, so it could contain all sorts of things
2017-10-06T13:04:54.000006
Sirena
pythondev_help_Sirena_2017-10-06T13:04:54.000006
1,507,295,094.000006
96,247
pythondev
help
so this is very similar to a factory, but it uses a bunch of functions rather than a class to determine which object to return
2017-10-06T13:05:39.000341
Sirena
pythondev_help_Sirena_2017-10-06T13:05:39.000341
1,507,295,139.000341
96,248
pythondev
help
if you have a graphql blob of 'room' data, then adding a graphql_to_room function would make sense, just mimic what's in most of these other functions
2017-10-06T13:06:16.000200
Sirena
pythondev_help_Sirena_2017-10-06T13:06:16.000200
1,507,295,176.0002
96,249
pythondev
help
yeah
2017-10-06T13:06:26.000393
Winnie
pythondev_help_Winnie_2017-10-06T13:06:26.000393
1,507,295,186.000393
96,250
pythondev
help
but instead of reapating code, could I get the graphql group function to do some of the work for me?
2017-10-06T13:06:56.000210
Winnie
pythondev_help_Winnie_2017-10-06T13:06:56.000210
1,507,295,216.00021
96,251
pythondev
help
it would depend on what's in your room data
2017-10-06T13:07:50.000595
Sirena
pythondev_help_Sirena_2017-10-06T13:07:50.000595
1,507,295,270.000595
96,252
pythondev
help
down at the bottom of your file it defines a bunch of graphql types
2017-10-06T13:08:12.000450
Sirena
pythondev_help_Sirena_2017-10-06T13:08:12.000450
1,507,295,292.00045
96,253
pythondev
help
there isn't one for a room, but if you add it, then you can query a room
2017-10-06T13:08:25.000255
Sirena
pythondev_help_Sirena_2017-10-06T13:08:25.000255
1,507,295,305.000255
96,254
pythondev
help
if it is meaningfully related to a group, then you might get the group function to do some work for you
2017-10-06T13:08:38.000631
Sirena
pythondev_help_Sirena_2017-10-06T13:08:38.000631
1,507,295,318.000631
96,255
pythondev
help
well, a room is just a group with some extra things, so it inherits from it
2017-10-06T13:09:06.000553
Winnie
pythondev_help_Winnie_2017-10-06T13:09:06.000553
1,507,295,346.000553
96,256
pythondev
help
but assuming a room is not a group with additions, and a group is not a room with additions, it's probably most sensible to write a separate independent function
2017-10-06T13:09:18.000020
Sirena
pythondev_help_Sirena_2017-10-06T13:09:18.000020
1,507,295,358.00002
96,257
pythondev
help
ah
2017-10-06T13:09:22.000208
Sirena
pythondev_help_Sirena_2017-10-06T13:09:22.000208
1,507,295,362.000208
96,258
pythondev
help
then yah
2017-10-06T13:09:24.000381
Sirena
pythondev_help_Sirena_2017-10-06T13:09:24.000381
1,507,295,364.000381
96,259
pythondev
help
The problem is, I don't know *how* to get it to do some work for me :stuck_out_tongue:
2017-10-06T13:09:53.000354
Winnie
pythondev_help_Winnie_2017-10-06T13:09:53.000354
1,507,295,393.000354
96,260
pythondev
help
what does your `class Room:` look like?
2017-10-06T13:11:06.000516
Sirena
pythondev_help_Sirena_2017-10-06T13:11:06.000516
1,507,295,466.000516
96,261
pythondev
help
not to be confused with `classroom`
2017-10-06T13:11:34.000592
Patty
pythondev_help_Patty_2017-10-06T13:11:34.000592
1,507,295,494.000592
96,262
pythondev
help
and then what does your graphql room query look like?
2017-10-06T13:19:53.000353
Sirena
pythondev_help_Sirena_2017-10-06T13:19:53.000353
1,507,295,993.000353
96,263
pythondev
help
I think it's likely that you'll not be able to reuse graphql_to_group because it's returning a Group object from a group query, and you're going to have to write a new query for a room object
2017-10-06T13:22:08.000212
Sirena
pythondev_help_Sirena_2017-10-06T13:22:08.000212
1,507,296,128.000212
96,264
pythondev
help
<https://github.com/ekohilas/fbchat/blob/rooms/fbchat/graphql.py#L121>
2017-10-06T13:22:27.000330
Winnie
pythondev_help_Winnie_2017-10-06T13:22:27.000330
1,507,296,147.00033
96,265
pythondev
help
and I don't know the ins and outs of how that all works, but it seems like the graphql queries don't exactly have inheritance
2017-10-06T13:22:43.000369
Sirena
pythondev_help_Sirena_2017-10-06T13:22:43.000369
1,507,296,163.000369
96,266
pythondev
help
my idea is that I call the data on the graphql_room and then just unpack it's data into Room()?
2017-10-06T13:23:44.000577
Winnie
pythondev_help_Winnie_2017-10-06T13:23:44.000577
1,507,296,224.000577
96,267
pythondev
help
yeah, I see why you might want to have some code reuse, and I suppose it's a little bit of a style question, but I think it will end up less readable
2017-10-06T13:25:25.000025
Sirena
pythondev_help_Sirena_2017-10-06T13:25:25.000025
1,507,296,325.000025
96,268
pythondev
help
at times, it can be a tough balancing act between competing priorities
2017-10-06T13:26:16.000321
Meg
pythondev_help_Meg_2017-10-06T13:26:16.000321
1,507,296,376.000321
96,269
pythondev
help
DRY, style, readability, etc
2017-10-06T13:26:37.000279
Meg
pythondev_help_Meg_2017-10-06T13:26:37.000279
1,507,296,397.000279
96,270
pythondev
help
you might get by with something like ```def graphql_to_room_or_group(rog): if rog.get('image') is None: rog['image'] = {} c_info = get_customization_info(rog) if(rog.get('thread_admins')): return Room(many args) else: # not a room return Group(many args)```
2017-10-06T13:31:58.000346
Sirena
pythondev_help_Sirena_2017-10-06T13:31:58.000346
1,507,296,718.000346
96,271
pythondev
help
but it's still going to be a lot of similar code duplicated
2017-10-06T13:32:17.000679
Sirena
pythondev_help_Sirena_2017-10-06T13:32:17.000679
1,507,296,737.000679
96,272
pythondev
help
alternately, you could modify your Room.__init() to include a Group argument
2017-10-06T13:33:48.000177
Sirena
pythondev_help_Sirena_2017-10-06T13:33:48.000177
1,507,296,828.000177
96,273
pythondev
help
isn't there a way to get the fields from a group and just put them into a room as **kwargs
2017-10-06T13:35:19.000378
Winnie
pythondev_help_Winnie_2017-10-06T13:35:19.000378
1,507,296,919.000378
96,274
pythondev
help
```class Room(Group): def __init__(normal args, group=None): if group is not None: init_using_group_object() else: # us normal args to construct superclass values init_using_normal_args() self.admits = admins # . . . etc with the other room-specific args```
2017-10-06T13:35:23.000414
Sirena
pythondev_help_Sirena_2017-10-06T13:35:23.000414
1,507,296,923.000414
96,275
pythondev
help
wait what if I did
2017-10-06T13:40:41.000581
Winnie
pythondev_help_Winnie_2017-10-06T13:40:41.000581
1,507,297,241.000581
96,276
pythondev
help
``` def graphql_to_room(room): return Room( room['thread_key']['thread_fbid'], **vars(graphql_to_group(room)), admins = set([node.get('id') for node in room.get('thread_admins')]), approval_mode = bool(room.get('approval_mode')), approval_requests = set([node.get('id') for node in room['thread_queue_metatdata'].get('approval_requests')), join_link = room['joinable_mode'].get('link'), privacy_mode = bool(room.get('privacy_mode')), ) ```
2017-10-06T13:41:59.000033
Winnie
pythondev_help_Winnie_2017-10-06T13:41:59.000033
1,507,297,319.000033
96,277
pythondev
help
that would probably work too, I think
2017-10-06T13:46:20.000168
Sirena
pythondev_help_Sirena_2017-10-06T13:46:20.000168
1,507,297,580.000168
96,278
pythondev
help
as long as you don't reuse any argument names in both classes or anything surprising like that
2017-10-06T13:48:50.000489
Sirena
pythondev_help_Sirena_2017-10-06T13:48:50.000489
1,507,297,730.000489
96,279
pythondev
help
Sublime Text 3, has anyone used it / does anyone currently use it? Anything that caught your attention good or bad?
2017-10-06T14:32:45.000233
Seema
pythondev_help_Seema_2017-10-06T14:32:45.000233
1,507,300,365.000233
96,280
pythondev
help
<@Seema> we have <#C5CAD2J67|editors> where people chat about them, mostly it comes down to personal preference
2017-10-06T14:45:00.000286
Patty
pythondev_help_Patty_2017-10-06T14:45:00.000286
1,507,301,100.000286
96,281
pythondev
help
Oh, interesting, it didn't show up in my channel list, I'll check it out.
2017-10-06T14:45:48.000516
Seema
pythondev_help_Seema_2017-10-06T14:45:48.000516
1,507,301,148.000516
96,282
pythondev
help
I like to imagine that channel is just one continuous vim vs emacs flame war
2017-10-06T14:46:42.000502
Junita
pythondev_help_Junita_2017-10-06T14:46:42.000502
1,507,301,202.000502
96,283
pythondev
help
its vim heavy, which is why im not in it :slightly_smiling_face:
2017-10-06T14:47:10.000605
Patty
pythondev_help_Patty_2017-10-06T14:47:10.000605
1,507,301,230.000605
96,284
pythondev
help
better find some fireproof underwear first before heading in there :slightly_smiling_face:
2017-10-06T14:47:12.000306
Meg
pythondev_help_Meg_2017-10-06T14:47:12.000306
1,507,301,232.000306
96,285
pythondev
help
hahaha
2017-10-06T14:47:24.000025
Seema
pythondev_help_Seema_2017-10-06T14:47:24.000025
1,507,301,244.000025
96,286
pythondev
help
besides, psh. vim, emacs, etc
2017-10-06T14:47:38.000464
Meg
pythondev_help_Meg_2017-10-06T14:47:38.000464
1,507,301,258.000464
96,287
pythondev
help
`ed` is where its at
2017-10-06T14:47:43.000368
Meg
pythondev_help_Meg_2017-10-06T14:47:43.000368
1,507,301,263.000368
96,288
pythondev
help
:smile:
2017-10-06T14:47:55.000012
Meg
pythondev_help_Meg_2017-10-06T14:47:55.000012
1,507,301,275.000012
96,289
pythondev
help
if you can actually use ed to get work done, I'll pay to watch
2017-10-06T14:49:20.000451
Sirena
pythondev_help_Sirena_2017-10-06T14:49:20.000451
1,507,301,360.000451
96,290
pythondev
help
I've had to use it for minor edits once or twice, and it was painful
2017-10-06T14:49:39.000027
Sirena
pythondev_help_Sirena_2017-10-06T14:49:39.000027
1,507,301,379.000027
96,291
pythondev
help
nah, just kidding. FWIW, I use vim by default when on the server
2017-10-06T14:51:51.000017
Meg
pythondev_help_Meg_2017-10-06T14:51:51.000017
1,507,301,511.000017
96,292
pythondev
help
but just mainly text entry, cut and paste
2017-10-06T14:52:00.000398
Meg
pythondev_help_Meg_2017-10-06T14:52:00.000398
1,507,301,520.000398
96,293
pythondev
help
the higher functionality is just :whoosh: over my head
2017-10-06T14:52:13.000275
Meg
pythondev_help_Meg_2017-10-06T14:52:13.000275
1,507,301,533.000275
96,294
pythondev
help
Hey everybody! I have a question on mocking... I have a function where I want to mock a DBSession.flush() method inside it to a time.sleep(30), to test a race condition there. Do you think that is possible?
2017-10-06T17:20:05.000055
Juliette
pythondev_help_Juliette_2017-10-06T17:20:05.000055
1,507,310,405.000055
96,295
pythondev
help
if you're testing a race condition, might want to `time.sleep(random.randint(low, high))`
2017-10-06T17:24:09.000033
Sirena
pythondev_help_Sirena_2017-10-06T17:24:09.000033
1,507,310,649.000033
96,296
pythondev
help
unless you're pretty sure 30 is the magic number
2017-10-06T17:24:15.000253
Sirena
pythondev_help_Sirena_2017-10-06T17:24:15.000253
1,507,310,655.000253
96,297
pythondev
help
I haven't tried it, but mock the flush method with a side_effect pointing to a function where you call time.sleep?
2017-10-06T17:27:09.000162
Tanya
pythondev_help_Tanya_2017-10-06T17:27:09.000162
1,507,310,829.000162
96,298
pythondev
help
<https://docs.python.org/3/library/unittest.mock-examples.html#side-effect-functions-and-iterables>
2017-10-06T17:27:13.000260
Tanya
pythondev_help_Tanya_2017-10-06T17:27:13.000260
1,507,310,833.00026
96,299
pythondev
help
Thank you guys
2017-10-06T17:49:19.000223
Juliette
pythondev_help_Juliette_2017-10-06T17:49:19.000223
1,507,312,159.000223
96,300
pythondev
help
:slightly_smiling_face:
2017-10-06T17:49:30.000009
Juliette
pythondev_help_Juliette_2017-10-06T17:49:30.000009
1,507,312,170.000009
96,301
pythondev
help
Getting this error when attempting to create a sqlalchemy db table
2017-10-06T18:47:44.000050
Myong
pythondev_help_Myong_2017-10-06T18:47:44.000050
1,507,315,664.00005
96,302