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
Misread whoops
2019-02-27T11:33:39.982800
Lillia
pythondev_help_Lillia_2019-02-27T11:33:39.982800
1,551,267,219.9828
11,121
pythondev
help
A handy trick is that strings are addressable like lists, so `str[i]` is the `i`th character.
2019-02-27T11:34:17.983600
Sasha
pythondev_help_Sasha_2019-02-27T11:34:17.983600
1,551,267,257.9836
11,122
pythondev
help
Right right so if i'm looking for the first character all i have to do is ask it to return str[0], right?
2019-02-27T11:35:05.984200
Demetrice
pythondev_help_Demetrice_2019-02-27T11:35:05.984200
1,551,267,305.9842
11,123
pythondev
help
Bingo.
2019-02-27T11:35:14.984400
Sasha
pythondev_help_Sasha_2019-02-27T11:35:14.984400
1,551,267,314.9844
11,124
pythondev
help
There we go, I think this is what i was looking for. Thank You. :taco: <@Sasha>
2019-02-27T11:37:15.984500
Demetrice
pythondev_help_Demetrice_2019-02-27T11:37:15.984500
1,551,267,435.9845
11,125
pythondev
help
So i had to change it to this because it was failing cases where the word started with not a letter. But now it's failing cases where there's a hyphenated word like metal-oxide cause it'll miss the "o" I know i could iterate the whole string looking for the '-' but i'm not sure what i'd do after that. Is there a more beautiful solution?
2019-02-27T11:52:41.985400
Demetrice
pythondev_help_Demetrice_2019-02-27T11:52:41.985400
1,551,268,361.9854
11,126
pythondev
help
You may want to look into using <https://docs.python.org/3/library/stdtypes.html#str.isalpha>
2019-02-27T11:55:46.986500
Lillia
pythondev_help_Lillia_2019-02-27T11:55:46.986500
1,551,268,546.9865
11,127
pythondev
help
<@Demetrice> you could remove non-letter characters, I guess?
2019-02-27T11:56:05.986900
Carlo
pythondev_help_Carlo_2019-02-27T11:56:05.986900
1,551,268,565.9869
11,128
pythondev
help
Just so you don't have to keep having the list of letters
2019-02-27T11:56:29.987600
Lillia
pythondev_help_Lillia_2019-02-27T11:56:29.987600
1,551,268,589.9876
11,129
pythondev
help
Hey, I am looking for sql help, if anyone is good at sql. I have a select statement, for example `select * from foo bar = true` and I want to run a subquery, it that query returns no results. In python this would be an `or`, so basically I want a sql ternary, `_results if (select * from foo) else (select * from bar)`
2019-02-27T11:57:16.988700
Genesis
pythondev_help_Genesis_2019-02-27T11:57:16.988700
1,551,268,636.9887
11,130
pythondev
help
anyone know how to do that in sql?
2019-02-27T11:57:23.988900
Genesis
pythondev_help_Genesis_2019-02-27T11:57:23.988900
1,551,268,643.9889
11,131
pythondev
help
<@Genesis> you might have better luck in <#C3X4T24LB|databases>
2019-02-27T11:58:02.989400
Ashley
pythondev_help_Ashley_2019-02-27T11:58:02.989400
1,551,268,682.9894
11,132
pythondev
help
```&gt;&gt;&gt; re.compile(r'[^\w]').split('This is a test of oft-difficult magic') ['This', 'is', 'a', 'test', 'of', 'oft', 'difficult', 'magic']```
2019-02-27T11:58:10.989500
Melynda
pythondev_help_Melynda_2019-02-27T11:58:10.989500
1,551,268,690.9895
11,133
pythondev
help
That kind of thing is going to be almost impossible
2019-02-27T11:58:52.990300
Jonas
pythondev_help_Jonas_2019-02-27T11:58:52.990300
1,551,268,732.9903
11,134
pythondev
help
```&gt;&gt;&gt; ''.join([word[0] for word in re.compile(r'[^\w]').split('This is a test of oft-difficult magic')]) 'Tiatoodm'```
2019-02-27T11:58:53.990400
Melynda
pythondev_help_Melynda_2019-02-27T11:58:53.990400
1,551,268,733.9904
11,135
pythondev
help
Ideally you'd model your database to not need queries like that.
2019-02-27T11:59:13.990800
Jonas
pythondev_help_Jonas_2019-02-27T11:59:13.990800
1,551,268,753.9908
11,136
pythondev
help
ya, it would be easy in code, but the problem is I am trying to do metrics in grafana, so its getting a little messy :wink:
2019-02-27T12:00:22.991400
Genesis
pythondev_help_Genesis_2019-02-27T12:00:22.991400
1,551,268,822.9914
11,137
pythondev
help
Thanks! I was able to clean it up a bit with that. I thought there must have been a better way. So now my core code looks better. But i still need to think of a solution to that problem
2019-02-27T12:00:41.991500
Demetrice
pythondev_help_Demetrice_2019-02-27T12:00:41.991500
1,551,268,841.9915
11,138
pythondev
help
If I were you, I'd break this down into two parts: getting the list of words (without symbols), and appending the first letters. The second part is easy (you already did it). I'd look into splitting on multiple characters, for example. Split on both whitespace and hyphens.
2019-02-27T12:07:23.992100
Lillia
pythondev_help_Lillia_2019-02-27T12:07:23.992100
1,551,269,243.9921
11,139
pythondev
help
Here i'll put it back in the main chat. I thought i had something but i might be on the wrong train of thought again
2019-02-27T12:08:05.992600
Demetrice
pythondev_help_Demetrice_2019-02-27T12:08:05.992600
1,551,269,285.9926
11,140
pythondev
help
So now python is telling me it has an issue with the way i'm using isalpha. But i just tested that. I think it's issue is with something else i did. What i was thinking was i would replace the "-" with a white space then try to re-split it. That may not be ideal
2019-02-27T12:09:02.992800
Demetrice
pythondev_help_Demetrice_2019-02-27T12:09:02.992800
1,551,269,342.9928
11,141
pythondev
help
the x.replace on line 7 should be x.split
2019-02-27T12:09:44.993300
Demetrice
pythondev_help_Demetrice_2019-02-27T12:09:44.993300
1,551,269,384.9933
11,142
pythondev
help
Do your replacement before anything else
2019-02-27T12:11:14.993600
Lillia
pythondev_help_Lillia_2019-02-27T12:11:14.993600
1,551,269,474.9936
11,143
pythondev
help
Because you are trying to split on those spaces
2019-02-27T12:11:26.993900
Lillia
pythondev_help_Lillia_2019-02-27T12:11:26.993900
1,551,269,486.9939
11,144
pythondev
help
:thumbsup_all:
2019-02-27T12:11:30.994100
Lillia
pythondev_help_Lillia_2019-02-27T12:11:30.994100
1,551,269,490.9941
11,145
pythondev
help
<@Demetrice> did my replies in this thread not work for you? <https://pythondev.slack.com/archives/C07EFMZ1N/p1551286361985400>
2019-02-27T12:11:53.994800
Melynda
pythondev_help_Melynda_2019-02-27T12:11:53.994800
1,551,269,513.9948
11,146
pythondev
help
Honestly i didn't even see that. It went up top for some reason. I'm looking at it now. It looks so much simpler than mine
2019-02-27T12:14:13.995600
Demetrice
pythondev_help_Demetrice_2019-02-27T12:14:13.995600
1,551,269,653.9956
11,147
pythondev
help
You did it in one line of code. :anguished::upside_down_face: what does the [^\w] mean? How does it know how to look for words like that?
2019-02-27T12:16:39.996400
Demetrice
pythondev_help_Demetrice_2019-02-27T12:16:39.996400
1,551,269,799.9964
11,148
pythondev
help
It's "word character" in regex, it'll split on anything that isn't alphanum or underscore
2019-02-27T12:18:57.997000
Lillia
pythondev_help_Lillia_2019-02-27T12:18:57.997000
1,551,269,937.997
11,149
pythondev
help
The technology is called regular expressions, often shortened to regex, or even `re` since that's the name of the module in Python. They're _super_ useful, though quite hard to read and write. There's _lots_ written about them online. :slightly_smiling_face:
2019-02-27T12:20:46.998600
Melynda
pythondev_help_Melynda_2019-02-27T12:20:46.998600
1,551,270,046.9986
11,150
pythondev
help
You can play with them on sites like <http://regexr.com/4987v|regexr.com/4987v>
2019-02-27T12:21:12.999100
Melynda
pythondev_help_Melynda_2019-02-27T12:21:12.999100
1,551,270,072.9991
11,151
pythondev
help
I see. So that would really solve this problem instantly. I've been trying to fix my version too for practice but it's just not picking doing what i want. My logic must be off
2019-02-27T12:22:02.999900
Demetrice
pythondev_help_Demetrice_2019-02-27T12:22:02.999900
1,551,270,122.9999
11,152
pythondev
help
This looks like it will replace <http://regex101.com|regex101.com> for me, thanks!
2019-02-27T12:22:07.000200
Lillia
pythondev_help_Lillia_2019-02-27T12:22:07.000200
1,551,270,127.0002
11,153
pythondev
help
Do you still need `if y[0].isalpha():` if you've removed the hyphens?
2019-02-27T12:23:00.000500
Lillia
pythondev_help_Lillia_2019-02-27T12:23:00.000500
1,551,270,180.0005
11,154
pythondev
help
I think `replace()` returns a modified copy of the string, rather than changing the original.
2019-02-27T12:23:30.000800
Sasha
pythondev_help_Sasha_2019-02-27T12:23:30.000800
1,551,270,210.0008
11,155
pythondev
help
Indeed, remove line 3, change 4 to `for y in words.replace('-', ' ').split():` and it works
2019-02-27T12:24:05.001000
Melynda
pythondev_help_Melynda_2019-02-27T12:24:05.001000
1,551,270,245.001
11,156
pythondev
help
Yeah you can just do `for y in words.replace('-', ' ').split():`
2019-02-27T12:24:11.001200
Lillia
pythondev_help_Lillia_2019-02-27T12:24:11.001200
1,551,270,251.0012
11,157
pythondev
help
Great minds think alike! :smile:
2019-02-27T12:24:30.001400
Melynda
pythondev_help_Melynda_2019-02-27T12:24:30.001400
1,551,270,270.0014
11,158
pythondev
help
I blame my slow corporate VPN :smile:
2019-02-27T12:25:12.001700
Lillia
pythondev_help_Lillia_2019-02-27T12:25:12.001700
1,551,270,312.0017
11,159
pythondev
help
:taco: <@Melynda> <@Lillia> <@Sasha>
2019-02-27T12:28:09.001900
Demetrice
pythondev_help_Demetrice_2019-02-27T12:28:09.001900
1,551,270,489.0019
11,160
pythondev
help
Thanks a bunch
2019-02-27T12:28:20.002100
Demetrice
pythondev_help_Demetrice_2019-02-27T12:28:20.002100
1,551,270,500.0021
11,161
pythondev
help
Yw!
2019-02-27T12:30:25.002300
Lillia
pythondev_help_Lillia_2019-02-27T12:30:25.002300
1,551,270,625.0023
11,162
pythondev
help
Now in order to pass i need to make my result uppercase
2019-02-27T12:30:50.002500
Demetrice
pythondev_help_Demetrice_2019-02-27T12:30:50.002500
1,551,270,650.0025
11,163
pythondev
help
But result.upper isn't working
2019-02-27T12:30:54.002700
Demetrice
pythondev_help_Demetrice_2019-02-27T12:30:54.002700
1,551,270,654.0027
11,164
pythondev
help
I'm trying it at different stages of the code looking for the desired result
2019-02-27T12:31:10.002900
Demetrice
pythondev_help_Demetrice_2019-02-27T12:31:10.002900
1,551,270,670.0029
11,165
pythondev
help
Define "isn't working"?
2019-02-27T12:31:20.003100
Melynda
pythondev_help_Melynda_2019-02-27T12:31:20.003100
1,551,270,680.0031
11,166
pythondev
help
It definitely _works_: ```&gt;&gt;&gt; 'test'.upper() 'TEST'```
2019-02-27T12:31:34.003300
Melynda
pythondev_help_Melynda_2019-02-27T12:31:34.003300
1,551,270,694.0033
11,167
pythondev
help
So i wanted it all in caps so i tried changing this to result += y[1]. to result += y[1].upper()
2019-02-27T12:32:09.003500
Demetrice
pythondev_help_Demetrice_2019-02-27T12:32:09.003500
1,551,270,729.0035
11,168
pythondev
help
But it didn't seem to change anything
2019-02-27T12:32:13.003700
Demetrice
pythondev_help_Demetrice_2019-02-27T12:32:13.003700
1,551,270,733.0037
11,169
pythondev
help
Oh i needed to change both i think
2019-02-27T12:32:34.003900
Demetrice
pythondev_help_Demetrice_2019-02-27T12:32:34.003900
1,551,270,754.0039
11,170
pythondev
help
You shouldn't have to reference `y[1]` anywhere anymore
2019-02-27T12:33:13.004200
Lillia
pythondev_help_Lillia_2019-02-27T12:33:13.004200
1,551,270,793.0042
11,171
pythondev
help
All your words will be alpha numeric only now
2019-02-27T12:33:24.004400
Lillia
pythondev_help_Lillia_2019-02-27T12:33:24.004400
1,551,270,804.0044
11,172
pythondev
help
Yeah okay then some of this code is redundant hang on
2019-02-27T12:33:51.004600
Demetrice
pythondev_help_Demetrice_2019-02-27T12:33:51.004600
1,551,270,831.0046
11,173
pythondev
help
Well i think i need it for this test case specifically. Because otherwise it'll return a blank space for the 3rd word "The Road _Not_ Taken"
2019-02-27T12:35:37.004800
Demetrice
pythondev_help_Demetrice_2019-02-27T12:35:37.004800
1,551,270,937.0048
11,174
pythondev
help
"The Road _Not_ Taken"
2019-02-27T12:35:55.005000
Demetrice
pythondev_help_Demetrice_2019-02-27T12:35:55.005000
1,551,270,955.005
11,175
pythondev
help
The not is nested in underscores
2019-02-27T12:36:01.005200
Demetrice
pythondev_help_Demetrice_2019-02-27T12:36:01.005200
1,551,270,961.0052
11,176
pythondev
help
`split()` will handle that
2019-02-27T12:36:08.005400
Lillia
pythondev_help_Lillia_2019-02-27T12:36:08.005400
1,551,270,968.0054
11,177
pythondev
help
```&gt;&gt;&gt; 'a a'.split() ['a', 'a'] ```
2019-02-27T12:36:13.005600
Lillia
pythondev_help_Lillia_2019-02-27T12:36:13.005600
1,551,270,973.0056
11,178
pythondev
help
Oh you need to replace the underscores too
2019-02-27T12:36:37.005800
Lillia
pythondev_help_Lillia_2019-02-27T12:36:37.005800
1,551,270,997.0058
11,179
pythondev
help
Forgot you weren't doing that
2019-02-27T12:36:43.006000
Lillia
pythondev_help_Lillia_2019-02-27T12:36:43.006000
1,551,271,003.006
11,180
pythondev
help
This is why you should use the regex solution, by the way. You can specify `[^a-zA-Z]` to split on all non-letters.
2019-02-27T12:37:32.006200
Lillia
pythondev_help_Lillia_2019-02-27T12:37:32.006200
1,551,271,052.0062
11,181
pythondev
help
When retrieving something from a map, how do I make it work when no "pair" is found in the map?
2019-02-27T14:04:53.007500
Genaro
pythondev_help_Genaro_2019-02-27T14:04:53.007500
1,551,276,293.0075
11,182
pythondev
help
<@Genaro> You are getting that because you are getting `None` from some (all) of your `get(x)` calls, and None is not a string that can be used by join
2019-02-27T14:09:22.009100
Clemmie
pythondev_help_Clemmie_2019-02-27T14:09:22.009100
1,551,276,562.0091
11,183
pythondev
help
You have a couple of options. If you just want to skip non-matching chars then use `pairs.get(x, '')` - that will return the empty string as a default when the lookup fails
2019-02-27T14:10:23.010400
Clemmie
pythondev_help_Clemmie_2019-02-27T14:10:23.010400
1,551,276,623.0104
11,184
pythondev
help
if you want it to fails, or return an empty string, or some other functionality when there is a mismatch, use a try except clause
2019-02-27T14:10:53.011100
Clemmie
pythondev_help_Clemmie_2019-02-27T14:10:53.011100
1,551,276,653.0111
11,185
pythondev
help
None
2019-02-27T14:11:48.011200
Clemmie
pythondev_help_Clemmie_2019-02-27T14:11:48.011200
1,551,276,708.0112
11,186
pythondev
help
ahhhh awesome! I changed it to `pairs.get(x, x)` so it just returns the original character if no match is found :slightly_smiling_face:
2019-02-27T14:12:27.012200
Genaro
pythondev_help_Genaro_2019-02-27T14:12:27.012200
1,551,276,747.0122
11,187
pythondev
help
Hi all, I get the in bytes value of a "tif" file from the database and want to know how many photos it has in that file. I wanted to do this whole process in memory in the most effective way. I have this so far:
2019-02-27T14:12:36.012500
Phebe
pythondev_help_Phebe_2019-02-27T14:12:36.012500
1,551,276,756.0125
11,188
pythondev
help
thank you very much <@Clemmie>
2019-02-27T14:12:38.012900
Genaro
pythondev_help_Genaro_2019-02-27T14:12:38.012900
1,551,276,758.0129
11,189
pythondev
help
<@Phebe> Can you be a little more specific? The question how many photos are in an image file is hard to understand. By definition it is one - unless you want to do something much deeper like edge detection to separate out several photos that were, say, scanned into a single file
2019-02-27T14:17:23.015600
Clemmie
pythondev_help_Clemmie_2019-02-27T14:17:23.015600
1,551,277,043.0156
11,190
pythondev
help
Looks like TIFF files are a little weird in that they can contain multiple pages.
2019-02-27T14:18:40.016000
Sasha
pythondev_help_Sasha_2019-02-27T14:18:40.016000
1,551,277,120.016
11,191
pythondev
help
Really? ok then
2019-02-27T14:18:53.016300
Clemmie
pythondev_help_Clemmie_2019-02-27T14:18:53.016300
1,551,277,133.0163
11,192
pythondev
help
this is tif file is a file that contains several photos
2019-02-27T14:19:32.016700
Phebe
pythondev_help_Phebe_2019-02-27T14:19:32.016700
1,551,277,172.0167
11,193
pythondev
help
I guess then <@Phebe>, you are looking for someone who understands the tif format definition
2019-02-27T14:19:58.017300
Clemmie
pythondev_help_Clemmie_2019-02-27T14:19:58.017300
1,551,277,198.0173
11,194
pythondev
help
<https://stackoverflow.com/questions/18602525/python-pil-for-loop-to-work-with-multi-image-tiff>
2019-02-27T14:20:20.017600
Sasha
pythondev_help_Sasha_2019-02-27T14:20:20.017600
1,551,277,220.0176
11,195
pythondev
help
There's also `imreadmulti()` in OpenCV: <https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html#ga4dd47c9ae3d55cc42286cff005825e31>
2019-02-27T14:24:58.018100
Sasha
pythondev_help_Sasha_2019-02-27T14:24:58.018100
1,551,277,498.0181
11,196
pythondev
help
Thanks <@Sasha> I will analyze, the problem I get the tif file in bytes through the database
2019-02-27T14:24:59.018200
Phebe
pythondev_help_Phebe_2019-02-27T14:24:59.018200
1,551,277,499.0182
11,197
pythondev
help
That shouldn't be a problem... image APIs can usually deal with that, and if they need a file-like object, you can wrap the bytes in a `StringIO`.
2019-02-27T14:27:07.019200
Sasha
pythondev_help_Sasha_2019-02-27T14:27:07.019200
1,551,277,627.0192
11,198
pythondev
help
<@Sasha> Thank you, I'll follow this line of reasoning.
2019-02-27T14:29:46.019400
Phebe
pythondev_help_Phebe_2019-02-27T14:29:46.019400
1,551,277,786.0194
11,199
pythondev
help
<@Sasha> I found the solution through this post
2019-02-27T14:54:35.020000
Phebe
pythondev_help_Phebe_2019-02-27T14:54:35.020000
1,551,279,275.02
11,200
pythondev
help
Great!
2019-02-27T14:58:49.020400
Sasha
pythondev_help_Sasha_2019-02-27T14:58:49.020400
1,551,279,529.0204
11,201
pythondev
help
``` for val in iterator: print(val) print(val) # last value ```
2019-02-27T15:12:58.021500
Coleen
pythondev_help_Coleen_2019-02-27T15:12:58.021500
1,551,280,378.0215
11,202
pythondev
help
Why doesn't this work, and how can I make it work?
2019-02-27T15:13:05.021700
Coleen
pythondev_help_Coleen_2019-02-27T15:13:05.021700
1,551,280,385.0217
11,203
pythondev
help
Are you getting an error, or something other than what you expect?
2019-02-27T15:15:01.022200
Clemmie
pythondev_help_Clemmie_2019-02-27T15:15:01.022200
1,551,280,501.0222
11,204
pythondev
help
<@Olimpia> What is the content of interator
2019-02-27T15:27:10.022800
Phebe
pythondev_help_Phebe_2019-02-27T15:27:10.022800
1,551,281,230.0228
11,205
pythondev
help
?
2019-02-27T15:27:12.023000
Phebe
pythondev_help_Phebe_2019-02-27T15:27:12.023000
1,551,281,232.023
11,206
pythondev
help
value = '' for val in interator: print(val) value = val print(value) <@Olimpia>
2019-02-27T15:28:26.023300
Phebe
pythondev_help_Phebe_2019-02-27T15:28:26.023300
1,551,281,306.0233
11,207
pythondev
help
I always wonder what is happening on the other side in cases like this... do people post a question and then go to lunch, hoping to see the answer when they come back?
2019-02-27T15:29:15.024000
Sasha
pythondev_help_Sasha_2019-02-27T15:29:15.024000
1,551,281,355.024
11,208
pythondev
help
I would assume so
2019-02-27T15:30:19.024400
Ashley
pythondev_help_Ashley_2019-02-27T15:30:19.024400
1,551,281,419.0244
11,209
pythondev
help
You don't need that
2019-02-27T15:30:29.024500
Lillia
pythondev_help_Lillia_2019-02-27T15:30:29.024500
1,551,281,429.0245
11,210
pythondev
help
```↪ cat test.py; and python test.py for x in range(2): print(x) print(x) 0 1 1 ```
2019-02-27T15:30:40.025400
Lillia
pythondev_help_Lillia_2019-02-27T15:30:40.025400
1,551,281,440.0254
11,211
pythondev
help
Local time on this one is 10:30pm - question-&gt;sleep-&gt;answer?
2019-02-27T15:30:47.025700
Clemmie
pythondev_help_Clemmie_2019-02-27T15:30:47.025700
1,551,281,447.0257
11,212
pythondev
help
The variable exists
2019-02-27T15:30:49.025800
Lillia
pythondev_help_Lillia_2019-02-27T15:30:49.025800
1,551,281,449.0258
11,213
pythondev
help
create a variable before for
2019-02-27T15:32:26.026000
Phebe
pythondev_help_Phebe_2019-02-27T15:32:26.026000
1,551,281,546.026
11,214
pythondev
help
it was question -&gt; dinner -&gt; answer in my case
2019-02-27T15:34:49.026700
Coleen
pythondev_help_Coleen_2019-02-27T15:34:49.026700
1,551,281,689.0267
11,215
pythondev
help
What did you decide to do? As written it should work
2019-02-27T15:35:25.027600
Clemmie
pythondev_help_Clemmie_2019-02-27T15:35:25.027600
1,551,281,725.0276
11,216
pythondev
help
yes i realized it actually does what i want
2019-02-27T15:36:02.027900
Coleen
pythondev_help_Coleen_2019-02-27T15:36:02.027900
1,551,281,762.0279
11,217
pythondev
help
Oh, perfect1
2019-02-27T15:36:07.028100
Clemmie
pythondev_help_Clemmie_2019-02-27T15:36:07.028100
1,551,281,767.0281
11,218
pythondev
help
its just that in my code the iterator was empty
2019-02-27T15:36:18.028600
Coleen
pythondev_help_Coleen_2019-02-27T15:36:18.028600
1,551,281,778.0286
11,219
pythondev
help
so the last print was failing
2019-02-27T15:36:29.028900
Coleen
pythondev_help_Coleen_2019-02-27T15:36:29.028900
1,551,281,789.0289
11,220