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
when you open a file, you specify the mode
2019-02-02T08:41:27.656600
Hiroko
pythondev_help_Hiroko_2019-02-02T08:41:27.656600
1,549,096,887.6566
6,121
pythondev
help
<https://www.pythonforbeginners.com/files/reading-and-writing-files-in-python>
2019-02-02T08:41:31.656900
Mica
pythondev_help_Mica_2019-02-02T08:41:31.656900
1,549,096,891.6569
6,122
pythondev
help
as in read, write, append, etc
2019-02-02T08:41:40.657200
Hiroko
pythondev_help_Hiroko_2019-02-02T08:41:40.657200
1,549,096,900.6572
6,123
pythondev
help
pretty much what <@Mica> said
2019-02-02T08:41:48.657500
Hiroko
pythondev_help_Hiroko_2019-02-02T08:41:48.657500
1,549,096,908.6575
6,124
pythondev
help
so right now you’re opening the file in read-only mode
2019-02-02T08:42:04.657800
Hiroko
pythondev_help_Hiroko_2019-02-02T08:42:04.657800
1,549,096,924.6578
6,125
pythondev
help
yes
2019-02-02T08:42:12.658000
Viviana
pythondev_help_Viviana_2019-02-02T08:42:12.658000
1,549,096,932.658
6,126
pythondev
help
i tried to write
2019-02-02T08:42:19.658200
Viviana
pythondev_help_Viviana_2019-02-02T08:42:19.658200
1,549,096,939.6582
6,127
pythondev
help
but it erased that first line
2019-02-02T08:42:28.658700
Viviana
pythondev_help_Viviana_2019-02-02T08:42:28.658700
1,549,096,948.6587
6,128
pythondev
help
and write only that second line
2019-02-02T08:42:37.659300
Viviana
pythondev_help_Viviana_2019-02-02T08:42:37.659300
1,549,096,957.6593
6,129
pythondev
help
ok
2019-02-02T08:42:46.659800
Hiroko
pythondev_help_Hiroko_2019-02-02T08:42:46.659800
1,549,096,966.6598
6,130
pythondev
help
so you just want to replace that one word in the file?
2019-02-02T08:43:00.660200
Hiroko
pythondev_help_Hiroko_2019-02-02T08:43:00.660200
1,549,096,980.6602
6,131
pythondev
help
but i want to change only second line
2019-02-02T08:43:03.660500
Viviana
pythondev_help_Viviana_2019-02-02T08:43:03.660500
1,549,096,983.6605
6,132
pythondev
help
that’s much trickier
2019-02-02T08:43:05.660600
Hiroko
pythondev_help_Hiroko_2019-02-02T08:43:05.660600
1,549,096,985.6606
6,133
pythondev
help
yes <@Hiroko>
2019-02-02T08:43:20.661200
Viviana
pythondev_help_Viviana_2019-02-02T08:43:20.661200
1,549,097,000.6612
6,134
pythondev
help
yes
2019-02-02T08:43:24.661500
Viviana
pythondev_help_Viviana_2019-02-02T08:43:24.661500
1,549,097,004.6615
6,135
pythondev
help
so, when you open a file, there’s a “seek” position which is where the read or write starts
2019-02-02T08:43:51.662000
Hiroko
pythondev_help_Hiroko_2019-02-02T08:43:51.662000
1,549,097,031.662
6,136
pythondev
help
when you open in write mode that seek position is set at the start of the file and overwrites everything after that
2019-02-02T08:44:19.662800
Hiroko
pythondev_help_Hiroko_2019-02-02T08:44:19.662800
1,549,097,059.6628
6,137
pythondev
help
yes i know that also
2019-02-02T08:44:21.663000
Viviana
pythondev_help_Viviana_2019-02-02T08:44:21.663000
1,549,097,061.663
6,138
pythondev
help
when you open in append, its at the end of the file content, and adds after that point
2019-02-02T08:44:37.663600
Hiroko
pythondev_help_Hiroko_2019-02-02T08:44:37.663600
1,549,097,077.6636
6,139
pythondev
help
ok tell me about seek method please
2019-02-02T08:44:39.663900
Viviana
pythondev_help_Viviana_2019-02-02T08:44:39.663900
1,549,097,079.6639
6,140
pythondev
help
how to seek to that particular word
2019-02-02T08:44:59.664400
Viviana
pythondev_help_Viviana_2019-02-02T08:44:59.664400
1,549,097,099.6644
6,141
pythondev
help
in a file
2019-02-02T08:45:03.664600
Viviana
pythondev_help_Viviana_2019-02-02T08:45:03.664600
1,549,097,103.6646
6,142
pythondev
help
have you looked in stack overflow
2019-02-02T08:45:29.664800
Hiroko
pythondev_help_Hiroko_2019-02-02T08:45:29.664800
1,549,097,129.6648
6,143
pythondev
help
eg `python replace single line in file`
2019-02-02T08:45:36.665100
Hiroko
pythondev_help_Hiroko_2019-02-02T08:45:36.665100
1,549,097,136.6651
6,144
pythondev
help
yes i looked it only change s whole file
2019-02-02T08:46:23.666400
Viviana
pythondev_help_Viviana_2019-02-02T08:46:23.666400
1,549,097,183.6664
6,145
pythondev
help
It might be easier for him to use `readlines` on the file object, string replace the second entry, and then write the joined lines back to the file.
2019-02-02T10:20:30.667800
Carmen
pythondev_help_Carmen_2019-02-02T10:20:30.667800
1,549,102,830.6678
6,146
pythondev
help
can you please give a code for that <@Carmen>
2019-02-02T11:43:09.668300
Viviana
pythondev_help_Viviana_2019-02-02T11:43:09.668300
1,549,107,789.6683
6,147
pythondev
help
To a first approximation: ``` with open("filename.txt", 'r') as infile: lines = infile.readlines() lines[1].replace('old string', 'new string') with open("output_file.txt", 'w') as outfile: combined_lines = "\n".join(lines) outfile.write(combined_lines) ```
2019-02-02T11:52:59.668800
Carmen
pythondev_help_Carmen_2019-02-02T11:52:59.668800
1,549,108,379.6688
6,148
pythondev
help
Coz I'm not making it.
2019-02-02T12:48:34.669100
Valeri
pythondev_help_Valeri_2019-02-02T12:48:34.669100
1,549,111,714.6691
6,149
pythondev
help
I'm getting that from an API
2019-02-02T12:48:43.669300
Valeri
pythondev_help_Valeri_2019-02-02T12:48:43.669300
1,549,111,723.6693
6,150
pythondev
help
None
2019-02-02T12:58:55.669800
Janessa
pythondev_help_Janessa_2019-02-02T12:58:55.669800
1,549,112,335.6698
6,151
pythondev
help
<@Janessa> you can. You can also to something like this: ``` self.my_data, self.my_labels = data, labels ```
2019-02-02T13:04:31.671100
Ashley
pythondev_help_Ashley_2019-02-02T13:04:31.671100
1,549,112,671.6711
6,152
pythondev
help
the parenthesis are optional, as commas (`,`) are what determine a tuple is being used
2019-02-02T13:04:50.671600
Ashley
pythondev_help_Ashley_2019-02-02T13:04:50.671600
1,549,112,690.6716
6,153
pythondev
help
so it's the same thing as saying this: ``` self.my_data, self.my_labels = (data, labels) ``` or this: ``` my_stuff = (data, labels) self.my_data, self.my_labels = my_stuff) ```
2019-02-02T13:05:40.672400
Ashley
pythondev_help_Ashley_2019-02-02T13:05:40.672400
1,549,112,740.6724
6,154
pythondev
help
thanks
2019-02-02T13:06:41.673400
Janessa
pythondev_help_Janessa_2019-02-02T13:06:41.673400
1,549,112,801.6734
6,155
pythondev
help
In python 3, you can even get super fancy with the `*` operator to handle asymmetrical amounts of objects on either side of the `=` operator. For example: ``` x = 1, 2, 3, 4, 5 a, b, *c = x print(a) print(b) print(c) ``` which would print out ``` 1 2 [3, 4, 5] ```
2019-02-02T13:08:11.674500
Ashley
pythondev_help_Ashley_2019-02-02T13:08:11.674500
1,549,112,891.6745
6,156
pythondev
help
np!
2019-02-02T13:08:21.674700
Ashley
pythondev_help_Ashley_2019-02-02T13:08:21.674700
1,549,112,901.6747
6,157
pythondev
help
Lengthy question to follow...
2019-02-02T15:39:13.676600
Bea
pythondev_help_Bea_2019-02-02T15:39:13.676600
1,549,121,953.6766
6,158
pythondev
help
Hey there, I am fairly new to Python, having only written little self contained scripts, importing standard packages. I am trying to create a script that is a little more complex, but I am running into an issue with circular import errors. My file structure looks like this: ```start.py content/ crud.py content...
2019-02-02T15:39:14.676800
Bea
pythondev_help_Bea_2019-02-02T15:39:14.676800
1,549,121,954.6768
6,159
pythondev
help
Sorry for the crickets, but as you note it's not a trivial problem. My best suggestion would be if there's some way you could pass in a reference to the `MainMenu` into the `Cancel` function, so it doesn't have to know that it's returning to a `MainMenu` specifically, but just returning to whatever menu object it was o...
2019-02-02T16:00:57.679400
Sasha
pythondev_help_Sasha_2019-02-02T16:00:57.679400
1,549,123,257.6794
6,160
pythondev
help
Hmm... Yeah, I'll give that a try. Thanks, <@Sasha>
2019-02-02T16:04:10.680100
Bea
pythondev_help_Bea_2019-02-02T16:04:10.680100
1,549,123,450.6801
6,161
pythondev
help
Wondering if anyone can comment on this code snippet. Is there a better way to do what im doing here
2019-02-02T16:06:00.680200
Caridad
pythondev_help_Caridad_2019-02-02T16:06:00.680200
1,549,123,560.6802
6,162
pythondev
help
essentially when this object is created, i want to validate that the file , passed in as a parameter actually exists
2019-02-02T16:06:48.681300
Caridad
pythondev_help_Caridad_2019-02-02T16:06:48.681300
1,549,123,608.6813
6,163
pythondev
help
also the use of `self._file_path` as a private attribute, is it common convention to work with private attributes and the `@property` decorator in this way
2019-02-02T16:08:09.682600
Caridad
pythondev_help_Caridad_2019-02-02T16:08:09.682600
1,549,123,689.6826
6,164
pythondev
help
if it works it works. what is the question?
2019-02-02T16:11:03.682900
Bernita
pythondev_help_Bernita_2019-02-02T16:11:03.682900
1,549,123,863.6829
6,165
pythondev
help
just wondering if there is a better way of doing this, maybe something not as verbose, im guessing maybe not
2019-02-02T16:11:53.683600
Caridad
pythondev_help_Caridad_2019-02-02T16:11:53.683600
1,549,123,913.6836
6,166
pythondev
help
also is it possible to not have the private attribute at all?
2019-02-02T16:12:30.684100
Caridad
pythondev_help_Caridad_2019-02-02T16:12:30.684100
1,549,123,950.6841
6,167
pythondev
help
I do IT support and I'm trying to help some GIS folks I support (I might even get to do/use some ArcPy). Does anyone have any suggestions for learning some GIS basics?
2019-02-02T16:26:42.686000
Marth
pythondev_help_Marth_2019-02-02T16:26:42.686000
1,549,124,802.686
6,168
pythondev
help
I'm partially asking here since I wasn't sure if GIS is considered a part of, or similar to, data science? So I thought there might be some overlap.
2019-02-02T16:29:05.686900
Marth
pythondev_help_Marth_2019-02-02T16:29:05.686900
1,549,124,945.6869
6,169
pythondev
help
Learning Geospatial Analysis with Python - Second Edition <https://www.amazon.com/dp/1783552425/>
2019-02-02T16:52:57.687500
Hiroko
pythondev_help_Hiroko_2019-02-02T16:52:57.687500
1,549,126,377.6875
6,170
pythondev
help
I don't know if this is an algorithmic issue or a Python issue, but my greedy approach to 2D peak finding is blowing out the recursion stack.
2019-02-02T16:53:07.687900
Theresia
pythondev_help_Theresia_2019-02-02T16:53:07.687900
1,549,126,387.6879
6,171
pythondev
help
None
2019-02-02T16:53:41.688000
Theresia
pythondev_help_Theresia_2019-02-02T16:53:41.688000
1,549,126,421.688
6,172
pythondev
help
<@Hiroko> Thanks!
2019-02-02T16:54:07.688800
Marth
pythondev_help_Marth_2019-02-02T16:54:07.688800
1,549,126,447.6888
6,173
pythondev
help
I'm new here, so if I'm violating community standards in anything I do, please pardon me.
2019-02-02T16:54:15.689000
Theresia
pythondev_help_Theresia_2019-02-02T16:54:15.689000
1,549,126,455.689
6,174
pythondev
help
<@Marth> Those are more geared to open source gis with python.
2019-02-02T16:55:22.689800
Hiroko
pythondev_help_Hiroko_2019-02-02T16:55:22.689800
1,549,126,522.6898
6,175
pythondev
help
gotcha. I'm guessing that there are probably differences, but many of the core concepts will be (hopefully) transferrable. In my searching, I also found a slack community "The Spatial Community" (my request to join is pending) that I'm also hoping will be able to help. Otherwise, I'll do what I usually do and just d...
2019-02-02T16:58:06.692000
Marth
pythondev_help_Marth_2019-02-02T16:58:06.692000
1,549,126,686.692
6,176
pythondev
help
it's easy to do in Python - there's a relatively low recursion default limit. If you can change that to iterative it's usually preferred. if the algorithm is amenable to memoization you can decorate with @functools.lru_cache but idk if that would help
2019-02-02T17:01:21.692100
Bethany
pythondev_help_Bethany_2019-02-02T17:01:21.692100
1,549,126,881.6921
6,177
pythondev
help
Yeah, I'm over there too but not recently
2019-02-02T17:03:56.692700
Hiroko
pythondev_help_Hiroko_2019-02-02T17:03:56.692700
1,549,127,036.6927
6,178
pythondev
help
I think there are a couple people here that are atSC as well
2019-02-02T17:04:25.693400
Hiroko
pythondev_help_Hiroko_2019-02-02T17:04:25.693400
1,549,127,065.6934
6,179
pythondev
help
Nice! Certainly looks (based on the website) like a much smaller community. Though, I'm so new to GIS...all info is helpful info.
2019-02-02T17:05:51.694500
Marth
pythondev_help_Marth_2019-02-02T17:05:51.694500
1,549,127,151.6945
6,180
pythondev
help
My newest notebook: <https://github.com/paulgureghian/Machine_Learning_with_SciKit_Learn/blob/master/SKLearn_AdaBoost.ipynb>
2019-02-02T18:13:40.694900
Clayton
pythondev_help_Clayton_2019-02-02T18:13:40.694900
1,549,131,220.6949
6,181
pythondev
help
question
2019-02-02T19:33:35.695700
Marc
pythondev_help_Marc_2019-02-02T19:33:35.695700
1,549,136,015.6957
6,182
pythondev
help
if im using zip even though I cast it to a list for some reason im returning a generator object
2019-02-02T19:33:49.696100
Marc
pythondev_help_Marc_2019-02-02T19:33:49.696100
1,549,136,029.6961
6,183
pythondev
help
None
2019-02-02T19:34:12.696200
Marc
pythondev_help_Marc_2019-02-02T19:34:12.696200
1,549,136,052.6962
6,184
pythondev
help
that’s what zip does, though
2019-02-02T19:43:58.696600
Hiroko
pythondev_help_Hiroko_2019-02-02T19:43:58.696600
1,549,136,638.6966
6,185
pythondev
help
it returns an iterator of tuples
2019-02-02T19:44:10.697000
Hiroko
pythondev_help_Hiroko_2019-02-02T19:44:10.697000
1,549,136,650.697
6,186
pythondev
help
if you want to cast it to a list, use a list comprehension
2019-02-02T19:44:19.697300
Hiroko
pythondev_help_Hiroko_2019-02-02T19:44:19.697300
1,549,136,659.6973
6,187
pythondev
help
thats waht im doing?
2019-02-02T20:09:05.697500
Marc
pythondev_help_Marc_2019-02-02T20:09:05.697500
1,549,138,145.6975
6,188
pythondev
help
i cast it to a list and I use list comprehension in that code
2019-02-02T20:09:29.697800
Marc
pythondev_help_Marc_2019-02-02T20:09:29.697800
1,549,138,169.6978
6,189
pythondev
help
<@Hiroko>?
2019-02-02T20:19:54.698100
Marc
pythondev_help_Marc_2019-02-02T20:19:54.698100
1,549,138,794.6981
6,190
pythondev
help
The code as posted has an unbalanced bracket. Is it different from what you're running?
2019-02-02T20:21:21.698600
Sasha
pythondev_help_Sasha_2019-02-02T20:21:21.698600
1,549,138,881.6986
6,191
pythondev
help
i just didnt copy paste
2019-02-02T20:21:57.698800
Marc
pythondev_help_Marc_2019-02-02T20:21:57.698800
1,549,138,917.6988
6,192
pythondev
help
all the way
2019-02-02T20:21:58.699000
Marc
pythondev_help_Marc_2019-02-02T20:21:58.699000
1,549,138,918.699
6,193
pythondev
help
None
2019-02-02T20:22:05.699200
Marc
pythondev_help_Marc_2019-02-02T20:22:05.699200
1,549,138,925.6992
6,194
pythondev
help
Oh, I see. You actually are ending up with a one-element list containing a generator. Remove the parens in the last line if you want to get an n-element list.
2019-02-02T20:24:31.700300
Sasha
pythondev_help_Sasha_2019-02-02T20:24:31.700300
1,549,139,071.7003
6,195
pythondev
help
Ah, so that returns 2 elements in a list and if i wanted to join those again id have to run another join?
2019-02-02T20:25:59.700800
Marc
pythondev_help_Marc_2019-02-02T20:25:59.700800
1,549,139,159.7008
6,196
pythondev
help
Yeah, the `i` there is a two-element tuple as output by `zip`, so you're string-joining the pairs, but not joining all of the items together.
2019-02-02T20:28:51.701800
Sasha
pythondev_help_Sasha_2019-02-02T20:28:51.701800
1,549,139,331.7018
6,197
pythondev
help
okay thanks
2019-02-02T20:29:21.702000
Marc
pythondev_help_Marc_2019-02-02T20:29:21.702000
1,549,139,361.702
6,198
pythondev
help
Code not Working
2019-02-03T00:37:52.703500
Viviana
pythondev_help_Viviana_2019-02-03T00:37:52.703500
1,549,154,272.7035
6,199
pythondev
help
I think `replace` returns a modified copy rather than altering a string in place, so you'd want `lines[1] = lines[1].replace(...)`
2019-02-03T00:50:18.704300
Sasha
pythondev_help_Sasha_2019-02-03T00:50:18.704300
1,549,155,018.7043
6,200
pythondev
help
ok thanks for the helps guys
2019-02-03T01:09:04.704600
Viviana
pythondev_help_Viviana_2019-02-03T01:09:04.704600
1,549,156,144.7046
6,201
pythondev
help
my doubt is '\n' is for new line how to represent spaces ??
2019-02-03T06:14:20.705200
Viviana
pythondev_help_Viviana_2019-02-03T06:14:20.705200
1,549,174,460.7052
6,202
pythondev
help
Hi <@Clemmie>, apologies I got called away. Great help :taco: . My next mission is to understand regex a whole lot more
2019-02-03T06:58:39.705300
Britt
pythondev_help_Britt_2019-02-03T06:58:39.705300
1,549,177,119.7053
6,203
pythondev
help
You don’t
2019-02-03T07:03:17.706000
Hiroko
pythondev_help_Hiroko_2019-02-03T07:03:17.706000
1,549,177,397.706
6,204
pythondev
help
It’s built into the string
2019-02-03T07:03:32.706500
Hiroko
pythondev_help_Hiroko_2019-02-03T07:03:32.706500
1,549,177,412.7065
6,205
pythondev
help
Now if we’re talking urls or file paths, that’s different
2019-02-03T07:03:59.707300
Hiroko
pythondev_help_Hiroko_2019-02-03T07:03:59.707300
1,549,177,439.7073
6,206
pythondev
help
If I have a float `a=0.1234` how can I get another float `b=0.12` from `a` which has only 2 decimal places?
2019-02-03T07:25:19.708400
Coleen
pythondev_help_Coleen_2019-02-03T07:25:19.708400
1,549,178,719.7084
6,207
pythondev
help
`b = float("{0:.2f}".format(a))` ?
2019-02-03T07:27:51.709700
Coleen
pythondev_help_Coleen_2019-02-03T07:27:51.709700
1,549,178,871.7097
6,208
pythondev
help
Use a decimal
2019-02-03T07:33:09.710000
Hiroko
pythondev_help_Hiroko_2019-02-03T07:33:09.710000
1,549,179,189.71
6,209
pythondev
help
If you want that level of precision
2019-02-03T07:33:28.710500
Hiroko
pythondev_help_Hiroko_2019-02-03T07:33:28.710500
1,549,179,208.7105
6,210
pythondev
help
You mean switch all floats to Decimal?
2019-02-03T07:36:24.710900
Coleen
pythondev_help_Coleen_2019-02-03T07:36:24.710900
1,549,179,384.7109
6,211
pythondev
help
or just use it for conversion?
2019-02-03T07:36:31.711200
Coleen
pythondev_help_Coleen_2019-02-03T07:36:31.711200
1,549,179,391.7112
6,212
pythondev
help
If your situation calls for fixed decimal places and strict precision, use a decimal instead. However if you need to use floats, the string conversion is the way to go
2019-02-03T07:45:42.714100
Hiroko
pythondev_help_Hiroko_2019-02-03T07:45:42.714100
1,549,179,942.7141
6,213
pythondev
help
<@Coleen> use round() function a = 0.1234 b = round(a, 2) print(b)
2019-02-03T08:20:12.716200
Lanette
pythondev_help_Lanette_2019-02-03T08:20:12.716200
1,549,182,012.7162
6,214
pythondev
help
Hello everyone, I need one help please help me there is one file ``` constants ``` in my project folder. Now when i do relative import in some other file say file 2 ``` from constants import constants(object in constants file) ``` then python throws error ``` ValueError: Attempted relative import in non-package ```. ...
2019-02-03T09:16:16.720100
Carissa
pythondev_help_Carissa_2019-02-03T09:16:16.720100
1,549,185,376.7201
6,215
pythondev
help
btw, `from constants import constants(object in constants file) ` is not valid
2019-02-03T09:19:23.721800
Hiroko
pythondev_help_Hiroko_2019-02-03T09:19:23.721800
1,549,185,563.7218
6,216
pythondev
help
so if you have something inside `constants`, like a class or function, you can do `from constants import SomeClass, some_function`
2019-02-03T09:19:53.722500
Hiroko
pythondev_help_Hiroko_2019-02-03T09:19:53.722500
1,549,185,593.7225
6,217
pythondev
help
also, you can use `.constants` to denote relative import
2019-02-03T09:21:07.723400
Hiroko
pythondev_help_Hiroko_2019-02-03T09:21:07.723400
1,549,185,667.7234
6,218
pythondev
help
note the period
2019-02-03T09:21:11.723600
Hiroko
pythondev_help_Hiroko_2019-02-03T09:21:11.723600
1,549,185,671.7236
6,219
pythondev
help
but Constants is a class in Constants file
2019-02-03T09:21:28.723800
Carissa
pythondev_help_Carissa_2019-02-03T09:21:28.723800
1,549,185,688.7238
6,220