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
Hi, all! I have three functions, which needed to be executed in series: if first successful then run the second, then the third. Should I use nested if's, or it's better with `if func1 and func2 and func3:` code?
2019-01-31T16:25:40.446500
Lamonica
pythondev_help_Lamonica_2019-01-31T16:25:40.446500
1,548,951,940.4465
5,721
pythondev
help
Do they throw exceptions if they are not successful? If so you should do ``` try: func1() func2() func3() except <ThrownExceptions>: #error handling ```
2019-01-31T16:29:31.447800
Clemmie
pythondev_help_Clemmie_2019-01-31T16:29:31.447800
1,548,952,171.4478
5,722
pythondev
help
If they return True/False I would wrap them in exception wrappers like so:
2019-01-31T16:30:29.448700
Clemmie
pythondev_help_Clemmie_2019-01-31T16:30:29.448700
1,548,952,229.4487
5,723
pythondev
help
<@Clemmie> well, that looks great! Thanks :) :taco: Yes, they just return True/False yet, but I rewrite it.
2019-01-31T16:32:00.450100
Lamonica
pythondev_help_Lamonica_2019-01-31T16:32:00.450100
1,548,952,320.4501
5,724
pythondev
help
None
2019-01-31T16:32:02.450200
Clemmie
pythondev_help_Clemmie_2019-01-31T16:32:02.450200
1,548,952,322.4502
5,725
pythondev
help
Or change return signatures , sure
2019-01-31T16:32:27.450900
Clemmie
pythondev_help_Clemmie_2019-01-31T16:32:27.450900
1,548,952,347.4509
5,726
pythondev
help
I've sometimes used the pattern `okay = func1(); okay = okay and func2();` etc. to use the boolean technique while still keeping each one on a different un-nested line.
2019-01-31T16:36:43.453100
Sasha
pythondev_help_Sasha_2019-01-31T16:36:43.453100
1,548,952,603.4531
5,727
pythondev
help
You could also do ``` funcs = [func1, func2, func3] for func in funcs: f = func() if not f: break ```
2019-01-31T16:39:00.454600
Clemmie
pythondev_help_Clemmie_2019-01-31T16:39:00.454600
1,548,952,740.4546
5,728
pythondev
help
or even better ``` funcs = [func1, func2, func3] for func in funcs: if not func(): break ```
2019-01-31T16:40:37.456700
Clemmie
pythondev_help_Clemmie_2019-01-31T16:40:37.456700
1,548,952,837.4567
5,729
pythondev
help
Actually does `all()` do the right thing?
2019-01-31T16:41:13.457800
Sasha
pythondev_help_Sasha_2019-01-31T16:41:13.457800
1,548,952,873.4578
5,730
pythondev
help
Looks like it will, but not obvious that you can use it for flow control of run subsequent if earlier is True
2019-01-31T16:42:43.460300
Clemmie
pythondev_help_Clemmie_2019-01-31T16:42:43.460300
1,548,952,963.4603
5,731
pythondev
help
Yeah, I don't remember whether it short-circuits or not.
2019-01-31T16:43:10.461600
Sasha
pythondev_help_Sasha_2019-01-31T16:43:10.461600
1,548,952,990.4616
5,732
pythondev
help
Though all() does appear to stop flow when it encounters False, so it would work
2019-01-31T16:43:11.461700
Clemmie
pythondev_help_Clemmie_2019-01-31T16:43:11.461700
1,548,952,991.4617
5,733
pythondev
help
<@Clemmie>, I like the latter proposal. If all arguments are identical (or there are no) And this is a good candidate for a separate function, as for me (similar to `all`)
2019-01-31T16:43:14.462000
Franklin
pythondev_help_Franklin_2019-01-31T16:43:14.462000
1,548,952,994.462
5,734
pythondev
help
at least according to the `equivalent to` section of the docs
2019-01-31T16:43:25.462400
Clemmie
pythondev_help_Clemmie_2019-01-31T16:43:25.462400
1,548,953,005.4624
5,735
pythondev
help
<@Franklin> You can even handle non-identical method signatures by having well crafted **kwargs passed
2019-01-31T16:44:10.463600
Clemmie
pythondev_help_Clemmie_2019-01-31T16:44:10.463600
1,548,953,050.4636
5,736
pythondev
help
hm, could you give an example please?
2019-01-31T16:44:57.464300
Franklin
pythondev_help_Franklin_2019-01-31T16:44:57.464300
1,548,953,097.4643
5,737
pythondev
help
None
2019-01-31T16:47:45.464500
Clemmie
pythondev_help_Clemmie_2019-01-31T16:47:45.464500
1,548,953,265.4645
5,738
pythondev
help
pretty cool! thanks :slightly_smiling_face:
2019-01-31T16:49:23.465200
Franklin
pythondev_help_Franklin_2019-01-31T16:49:23.465200
1,548,953,363.4652
5,739
pythondev
help
Sorry, also need to catch `**kwargs` in the function definitions, editing
2019-01-31T16:49:39.465600
Clemmie
pythondev_help_Clemmie_2019-01-31T16:49:39.465600
1,548,953,379.4656
5,740
pythondev
help
I got the idea
2019-01-31T16:49:49.465800
Franklin
pythondev_help_Franklin_2019-01-31T16:49:49.465800
1,548,953,389.4658
5,741
pythondev
help
:thumbsup:
2019-01-31T16:50:17.466100
Clemmie
pythondev_help_Clemmie_2019-01-31T16:50:17.466100
1,548,953,417.4661
5,742
pythondev
help
<@Clemmie> Thanks! That was very interesting, didn't know about such method.
2019-01-31T16:53:52.467100
Lamonica
pythondev_help_Lamonica_2019-01-31T16:53:52.467100
1,548,953,632.4671
5,743
pythondev
help
Been struggling with what I should be learning next. I'm comfortable with the basics, but I feel like I really struggle when it comes to design and planning. Everything I write lately feels ugly and inefficient.
2019-01-31T18:05:09.467500
Brady
pythondev_help_Brady_2019-01-31T18:05:09.467500
1,548,957,909.4675
5,744
pythondev
help
Any resources you suggest? Books? Courses? Talks?
2019-01-31T18:05:37.468000
Brady
pythondev_help_Brady_2019-01-31T18:05:37.468000
1,548,957,937.468
5,745
pythondev
help
No worries! :smile:
2019-01-31T18:11:58.468100
Melynda
pythondev_help_Melynda_2019-01-31T18:11:58.468100
1,548,958,318.4681
5,746
pythondev
help
I have question about transitions
2019-01-31T18:38:00.469100
Micki
pythondev_help_Micki_2019-01-31T18:38:00.469100
1,548,959,880.4691
5,747
pythondev
help
I initialise states through machine call
2019-01-31T18:38:15.469500
Micki
pythondev_help_Micki_2019-01-31T18:38:15.469500
1,548,959,895.4695
5,748
pythondev
help
but when I call method in transitions it dosent get called
2019-01-31T18:38:37.470000
Micki
pythondev_help_Micki_2019-01-31T18:38:37.470000
1,548,959,917.47
5,749
pythondev
help
the class object gets initialised with states
2019-01-31T18:51:08.470400
Micki
pythondev_help_Micki_2019-01-31T18:51:08.470400
1,548,960,668.4704
5,750
pythondev
help
as the first init state call gets through
2019-01-31T18:51:23.470800
Micki
pythondev_help_Micki_2019-01-31T18:51:23.470800
1,548,960,683.4708
5,751
pythondev
help
Can you show code? Hard to help without
2019-01-31T19:07:24.471700
Hiroko
pythondev_help_Hiroko_2019-01-31T19:07:24.471700
1,548,961,644.4717
5,752
pythondev
help
sure
2019-01-31T19:07:50.472500
Micki
pythondev_help_Micki_2019-01-31T19:07:50.472500
1,548,961,670.4725
5,753
pythondev
help
<@Brady> maybe try a project? Something that interests you, maybe relates to a hobby?
2019-01-31T19:08:08.473100
Hiroko
pythondev_help_Hiroko_2019-01-31T19:08:08.473100
1,548,961,688.4731
5,754
pythondev
help
states = [ 'state_null', 'state_init', 'state_connected', 'state_up', 'state_down'] transitions = [ {'trigger': 'go_state_init', 'source': ['state_null', 'state_connected', 'state_down'], 'dest': 'state_init', 'before': 'do_state_init', ...
2019-01-31T19:08:09.473200
Micki
pythondev_help_Micki_2019-01-31T19:08:09.473200
1,548,961,689.4732
5,755
pythondev
help
these are states
2019-01-31T19:08:15.473400
Micki
pythondev_help_Micki_2019-01-31T19:08:15.473400
1,548,961,695.4734
5,756
pythondev
help
and related entry points
2019-01-31T19:08:26.473700
Micki
pythondev_help_Micki_2019-01-31T19:08:26.473700
1,548,961,706.4737
5,757
pythondev
help
self.machine = Machine(model=self, states=OpenoltDevice.states, transitions=OpenoltDevice.transitions, send_event=True, initial='state_null') self.go_state_init()
2019-01-31T19:08:59.473900
Micki
pythondev_help_Micki_2019-01-31T19:08:59.473900
1,548,961,739.4739
5,758
pythondev
help
go_state_init is called
2019-01-31T19:09:15.474200
Micki
pythondev_help_Micki_2019-01-31T19:09:15.474200
1,548,961,755.4742
5,759
pythondev
help
and then post_init is also get called
2019-01-31T19:09:26.474500
Micki
pythondev_help_Micki_2019-01-31T19:09:26.474500
1,548,961,766.4745
5,760
pythondev
help
post init starts indications thread
2019-01-31T19:10:12.474800
Micki
pythondev_help_Micki_2019-01-31T19:10:12.474800
1,548,961,812.4748
5,761
pythondev
help
self.indications_thread_handle = threading.Thread( target=self.indications_thread)
2019-01-31T19:10:47.475000
Micki
pythondev_help_Micki_2019-01-31T19:10:47.475000
1,548,961,847.475
5,762
pythondev
help
self.indications_thread_handle.setDaemon(True) self.indications_thread_handle.start()
2019-01-31T19:11:03.475200
Micki
pythondev_help_Micki_2019-01-31T19:11:03.475200
1,548,961,863.4752
5,763
pythondev
help
but in indication thread
2019-01-31T19:11:13.475500
Micki
pythondev_help_Micki_2019-01-31T19:11:13.475500
1,548,961,873.4755
5,764
pythondev
help
self.go_state_connected()
2019-01-31T19:11:38.475700
Micki
pythondev_help_Micki_2019-01-31T19:11:38.475700
1,548,961,898.4757
5,765
pythondev
help
dosent get called
2019-01-31T19:11:44.475900
Micki
pythondev_help_Micki_2019-01-31T19:11:44.475900
1,548,961,904.4759
5,766
pythondev
help
```states = [ 'state_null', 'state_init', 'state_connected', 'state_up', 'state_down'] transitions = [ {'trigger': 'go_state_init', 'source': ['state_null', 'state_connected', 'state_down'], 'dest': 'state_init', 'before': 'do_state_init', ...
2019-01-31T19:32:04.476100
Leana
pythondev_help_Leana_2019-01-31T19:32:04.476100
1,548,963,124.4761
5,767
pythondev
help
I'm trying to import from the same directory. My directory is marked as "Sources root" but my imports still cant find what they need from my first script. Anyone see what I'm missing? ps, db + others come from "basic.py"
2019-01-31T21:31:30.477000
Randal
pythondev_help_Randal_2019-01-31T21:31:30.477000
1,548,970,290.477
5,768
pythondev
help
<@Randal> Looks like you have a period instead of a comma on the line 65 that threw the error.
2019-01-31T23:01:14.479400
Sasha
pythondev_help_Sasha_2019-01-31T23:01:14.479400
1,548,975,674.4794
5,769
pythondev
help
Man, that's a good eye. I look at that and my eye slid right over it.
2019-01-31T23:02:01.479800
Carmen
pythondev_help_Carmen_2019-01-31T23:02:01.479800
1,548,975,721.4798
5,770
pythondev
help
When I try to print list, it's getting one slash in the list, any one can help on this
2019-01-31T23:45:42.483300
Sandy
pythondev_help_Sandy_2019-01-31T23:45:42.483300
1,548,978,342.4833
5,771
pythondev
help
How it adding one more slash
2019-01-31T23:46:13.484000
Sandy
pythondev_help_Sandy_2019-01-31T23:46:13.484000
1,548,978,373.484
5,772
pythondev
help
How to avoid that extra slash
2019-01-31T23:48:12.484800
Sandy
pythondev_help_Sandy_2019-01-31T23:48:12.484800
1,548,978,492.4848
5,773
pythondev
help
The extra slash is added to escape the slash that you’ve entered. If you loop over each list item and print it, you’ll see that the second slash isn’t really there.
2019-01-31T23:54:31.486000
Marla
pythondev_help_Marla_2019-01-31T23:54:31.486000
1,548,978,871.486
5,774
pythondev
help
It’s there, it just doesn’t show up when you print that item.
2019-01-31T23:55:24.486400
Marla
pythondev_help_Marla_2019-01-31T23:55:24.486400
1,548,978,924.4864
5,775
pythondev
help
Thanks<@Marla>, I'll try out actual need where required the complete string list
2019-02-01T01:02:16.489400
Sandy
pythondev_help_Sandy_2019-02-01T01:02:16.489400
1,548,982,936.4894
5,776
pythondev
help
I thought it may create problem while do complete list for some expression
2019-02-01T01:03:33.490900
Sandy
pythondev_help_Sandy_2019-02-01T01:03:33.490900
1,548,983,013.4909
5,777
pythondev
help
I want same list when pass the list, is there way to avoid
2019-02-01T01:58:20.493400
Sandy
pythondev_help_Sandy_2019-02-01T01:58:20.493400
1,548,986,300.4934
5,778
pythondev
help
The escaping is perfectly normal. It's just a difference in the `repr()` versus `str()` format of a string. In fact, you should be adding the escapes in your source... the only reason it works now is because `"\*"` is not a defined escape sequence, but if you try the same with `"\rajesh"`, it'll be an error.
2019-02-01T02:01:21.495300
Sasha
pythondev_help_Sasha_2019-02-01T02:01:21.495300
1,548,986,481.4953
5,779
pythondev
help
Thanks for support :relaxed:, still am could not understand the escape. We should not use "\*" in list . print ["ss\*", "St"]
2019-02-01T02:50:35.495400
Sandy
pythondev_help_Sandy_2019-02-01T02:50:35.495400
1,548,989,435.4954
5,780
pythondev
help
None
2019-02-01T03:02:01.495600
Janessa
pythondev_help_Janessa_2019-02-01T03:02:01.495600
1,548,990,121.4956
5,781
pythondev
help
I was wondering what's the best way to insert a string between the single quotes in `str = "Field ' ' is required."`
2019-02-01T03:09:09.497000
Valeri
pythondev_help_Valeri_2019-02-01T03:09:09.497000
1,548,990,549.497
5,782
pythondev
help
you could do `my_string.replace("' '", "'hello world'")`
2019-02-01T03:15:36.497600
Jimmy
pythondev_help_Jimmy_2019-02-01T03:15:36.497600
1,548,990,936.4976
5,783
pythondev
help
<@Jimmy> Sorry I have `my_str = "Field '' is required."`
2019-02-01T03:17:04.498200
Valeri
pythondev_help_Valeri_2019-02-01T03:17:04.498200
1,548,991,024.4982
5,784
pythondev
help
Without the space
2019-02-01T03:17:20.498400
Valeri
pythondev_help_Valeri_2019-02-01T03:17:20.498400
1,548,991,040.4984
5,785
pythondev
help
then you can remove the spacefrom the first argument
2019-02-01T03:17:35.498800
Jimmy
pythondev_help_Jimmy_2019-02-01T03:17:35.498800
1,548,991,055.4988
5,786
pythondev
help
Tried
2019-02-01T03:17:54.499400
Valeri
pythondev_help_Valeri_2019-02-01T03:17:54.499400
1,548,991,074.4994
5,787
pythondev
help
replace just replace the first arg in the target string by the second
2019-02-01T03:17:56.499600
Jimmy
pythondev_help_Jimmy_2019-02-01T03:17:56.499600
1,548,991,076.4996
5,788
pythondev
help
That doesn't work
2019-02-01T03:17:57.499700
Valeri
pythondev_help_Valeri_2019-02-01T03:17:57.499700
1,548,991,077.4997
5,789
pythondev
help
``` &gt;&gt;&gt; a = "Field '' is required." &gt;&gt;&gt; a.replace("''", "hello") 'Field hello is required.' ```
2019-02-01T03:18:32.499900
Jimmy
pythondev_help_Jimmy_2019-02-01T03:18:32.499900
1,548,991,112.4999
5,790
pythondev
help
``` a = "Field {} is required." b = "hello" a.format(b) ```
2019-02-01T03:20:04.500800
Zella
pythondev_help_Zella_2019-02-01T03:20:04.500800
1,548,991,204.5008
5,791
pythondev
help
Well I need the quotes as well
2019-02-01T03:20:10.501000
Valeri
pythondev_help_Valeri_2019-02-01T03:20:10.501000
1,548,991,210.501
5,792
pythondev
help
<@Zella> I can't modify `my_str`
2019-02-01T03:20:25.501500
Valeri
pythondev_help_Valeri_2019-02-01T03:20:25.501500
1,548,991,225.5015
5,793
pythondev
help
<@Jimmy> I need to insert stuff not replace
2019-02-01T03:20:54.502000
Valeri
pythondev_help_Valeri_2019-02-01T03:20:54.502000
1,548,991,254.502
5,794
pythondev
help
hope I'm making sense
2019-02-01T03:21:13.502200
Valeri
pythondev_help_Valeri_2019-02-01T03:21:13.502200
1,548,991,273.5022
5,795
pythondev
help
if you need to insert stuff between `'` you can replace that with more text that are also between `'`
2019-02-01T03:21:45.502900
Jimmy
pythondev_help_Jimmy_2019-02-01T03:21:45.502900
1,548,991,305.5029
5,796
pythondev
help
<@Valeri> maybe set another variable.
2019-02-01T03:21:59.503000
Zella
pythondev_help_Zella_2019-02-01T03:21:59.503000
1,548,991,319.503
5,797
pythondev
help
``` &gt;&gt;&gt; a = "Field '' is required." &gt;&gt;&gt; a.replace("''", "'hello world'") "Field 'hello world' is required." ```
2019-02-01T03:22:19.503200
Jimmy
pythondev_help_Jimmy_2019-02-01T03:22:19.503200
1,548,991,339.5032
5,798
pythondev
help
Well this seems hackish
2019-02-01T03:22:42.503400
Valeri
pythondev_help_Valeri_2019-02-01T03:22:42.503400
1,548,991,362.5034
5,799
pythondev
help
I'm certainly not "inserting" stuff between quotes
2019-02-01T03:22:58.503800
Valeri
pythondev_help_Valeri_2019-02-01T03:22:58.503800
1,548,991,378.5038
5,800
pythondev
help
I'm replacing it and getting my stuff done
2019-02-01T03:23:13.504200
Valeri
pythondev_help_Valeri_2019-02-01T03:23:13.504200
1,548,991,393.5042
5,801
pythondev
help
a string is immutable so in the end it doesn't really matter
2019-02-01T03:25:16.505300
Jimmy
pythondev_help_Jimmy_2019-02-01T03:25:16.505300
1,548,991,516.5053
5,802
pythondev
help
<@Valeri> so your end string would be: "Field x required", right?!
2019-02-01T03:25:22.505600
Zella
pythondev_help_Zella_2019-02-01T03:25:22.505600
1,548,991,522.5056
5,803
pythondev
help
but you could also do something like this if you prefer
2019-02-01T03:25:24.505800
Jimmy
pythondev_help_Jimmy_2019-02-01T03:25:24.505800
1,548,991,524.5058
5,804
pythondev
help
``` &gt;&gt;&gt; a = "Field '' is required." &gt;&gt;&gt; i = a.find("'") &gt;&gt;&gt; a[:i] + "'hello world' " + a[:i] "Field 'hello world' Field " ```
2019-02-01T03:25:28.506000
Jimmy
pythondev_help_Jimmy_2019-02-01T03:25:28.506000
1,548,991,528.506
5,805
pythondev
help
`a[:i+1] + "hello world" + a[i+1:]` to be more exact
2019-02-01T03:26:30.506300
Jimmy
pythondev_help_Jimmy_2019-02-01T03:26:30.506300
1,548,991,590.5063
5,806
pythondev
help
<@Valeri> if you do `my_str = "Field '{}' required."` and then do `my_str.format('test')` your `my_str` should still be the same at the end. That doesn't change the initial value.
2019-02-01T03:31:05.508600
Zella
pythondev_help_Zella_2019-02-01T03:31:05.508600
1,548,991,865.5086
5,807
pythondev
help
<@Zella> You're missing the point
2019-02-01T03:31:57.508900
Valeri
pythondev_help_Valeri_2019-02-01T03:31:57.508900
1,548,991,917.5089
5,808
pythondev
help
I can't change `my_str` from `"Field '' is required."` to `"Field '{}' required."` as you're suggesting
2019-02-01T03:32:35.509500
Valeri
pythondev_help_Valeri_2019-02-01T03:32:35.509500
1,548,991,955.5095
5,809
pythondev
help
Otherwise this would have been pretty straightforward, don't you think?
2019-02-01T03:33:01.510100
Valeri
pythondev_help_Valeri_2019-02-01T03:33:01.510100
1,548,991,981.5101
5,810
pythondev
help
I indeed think but I couldn't understand why "you can't change your string" but now I do. Sorry about my attempts. Can you explain exactly what you have? Is the value you want to insert in a variable?
2019-02-01T03:37:16.510500
Zella
pythondev_help_Zella_2019-02-01T03:37:16.510500
1,548,992,236.5105
5,811
pythondev
help
yes
2019-02-01T03:39:50.510700
Valeri
pythondev_help_Valeri_2019-02-01T03:39:50.510700
1,548,992,390.5107
5,812
pythondev
help
right
2019-02-01T03:39:53.510900
Valeri
pythondev_help_Valeri_2019-02-01T03:39:53.510900
1,548,992,393.5109
5,813
pythondev
help
Doesn't work like this: `my_str = "Field '' is required."` `field_name = "test"` and then `my_str.replace("''", field_name)`
2019-02-01T03:43:40.511100
Zella
pythondev_help_Zella_2019-02-01T03:43:40.511100
1,548,992,620.5111
5,814
pythondev
help
hello, i have t ocreate a finction to flatten data in python tensorflow for mnist dataset wich labels will be binary..so far i have done this but mt data has a shape of (60000,28,28): and the error is ValueError: cannot reshape array of size 47040000 into shape (1,1680000) def flatten (self, data): flatt_data=...
2019-02-01T04:01:00.511400
Janessa
pythondev_help_Janessa_2019-02-01T04:01:00.511400
1,548,993,660.5114
5,815
pythondev
help
Yes it does
2019-02-01T04:05:02.511500
Valeri
pythondev_help_Valeri_2019-02-01T04:05:02.511500
1,548,993,902.5115
5,816
pythondev
help
It seems hackish like I mentioned before
2019-02-01T04:05:14.511700
Valeri
pythondev_help_Valeri_2019-02-01T04:05:14.511700
1,548,993,914.5117
5,817
pythondev
help
<@Jimmy> I took your advice. Thanks :smile:
2019-02-01T04:05:29.512100
Valeri
pythondev_help_Valeri_2019-02-01T04:05:29.512100
1,548,993,929.5121
5,818
pythondev
help
<@Zella> <@Jimmy> :taco:
2019-02-01T04:05:43.512500
Valeri
pythondev_help_Valeri_2019-02-01T04:05:43.512500
1,548,993,943.5125
5,819
pythondev
help
yep, it does. Just out of curiosity, why can't you change your variable `my_str`?
2019-02-01T04:06:45.512600
Zella
pythondev_help_Zella_2019-02-01T04:06:45.512600
1,548,994,005.5126
5,820