« first day (3617 days earlier)      last day (1338 days later) » 

7:08 AM
hi
 
@TanishSarmah then how do i run it in the terminal cuz i usually just go and click on the run button
@Adithya hi
 
@lushain Just right click on any part of the code and you 'll see there "Run python file in terminal" just click on that and you're done!
 
user13780186
7:29 AM
hello
 
8:44 AM
Hi
 
8:56 AM
@BeginnerCoder Hi :)
 
9:09 AM
Or cbg as we like to say here. Don't ask me why.
 
How's everybody doing today?
 
@Hakaishin Absolutely fine :) , How are you doin'?
 
We've just had our first national "raise every alarm siren" day. Apparently, it's a good thing we didn't need that in the past. listens to the sound of silence
 
I am having difficulty understanding the sequence generated for this algorithem..
14
Q: Programming: Minimum steps required to convert a binary number to zero

roger_thatI was working on a programming exercise and was stuck on figuring out the correct algorithm. Here is the problem: Given a decimal number, how many minimum possible steps are required to convert this to zero provided: Change the bit i if the next bit i+1 is '1' and all the other bi...

1000→1001→1011→1010→1110→1111→1101→1100→0100→0101→0111→0110→0010→0011→0001→0000
Considering rules:
Change the bit i if the next bit i+1 is '1' and all the other bits i+2 and later are 0
Change the last bit without restriction
1000

i = 0
rule1: false
rule2: 1001 (perfect)
i = 1
rule1 = true (1101)
rule2 = true (1100)

so I feel the second in this sequence will be 1100 but rather 1011
Or may be I am doing something wrong or perhaps misunderstood the problem
Can any one please let me know what really I am missing or doing wrong?
 
9:27 AM
@MisterMiyagi we've had that in the city for years. First Monday of every month at 11 AM I think. Fun times.
@BasheerKharoti "i" doesn't loop. The first rule means "if there's an i such that ..., flip that bit". There can be at most one i that applies at a time.
In 1001 the second zero qualifies
 
@AndrasDeak does that mean "i" will remain 0 in this case?
 
@MisterMiyagi where do you live? I thought these drills are standard once a year in most countries
 
@BasheerKharoti there's no i!
Step 1: 1000 doesn't qualify for rule 1; flip last bit. Step 2: 1001 qualifies for first rule, turns into 1011, flip last bit, 1010.
Step 3: rule 1 applies again, flipping the first zero
 
I am just curious about this how rule 1 applies to the following?
Step 2: 1001 qualifies for first rule, turns into 1011
 
imagine a function change_for_rule_one() that does a step: the i is inside this function
 
9:36 AM
@AndrasDeak I'm used to local weekly tests, and remember the old days when they dug up WW2 bombs every now and then. This one was supposed to raise national awareness™.
@Hakaishin Germany.
 
@BasheerKharoti the third bit is 0, after comes 1, and there are no more bits
So for 1001 there is i=2 which applies
 
@AndrasDeak "if there's an i such that ..., flip that bit".... what can we think of "i" in this case? 1?
 
@BasheerKharoti Have you tried writing down the rule in a language you are familiar with?
 
@MisterMiyagi I am just trying to understand the rules first, the coding isn't difficult
 
It is basically looking for the pattern x1$, x10$, x100$, ... where $ is the end of the number.
 
9:41 AM
I am just doing some paper work
 
@MisterMiyagi ah, yes. Constant vigilance!
 
@BasheerKharoti I'm feeling like the first rule is ambiguous. Does the i+2'th bit have to exist?
I would expect 1101 to match rule 1
 
@MisterMiyagi 1101 is the result of rule 1; then comes rule 2
the ambiguity is that it's not "rule 2 unless rule 1" but rather "rule 1 then rule 2"
 
So they are 1 then 2? I was assuming 1 or 2.
 
yes
figuring out what an ambiguous task really is is left as an exercise to the reader
 
9:51 AM
Meh. I deeply dislike exercises with so much room for interpretation. :/
 
You know that game where people stand in a line and whisper a sentence from ear to ear? This is that game. We don't know the source.
 
Guys, the other day I was answering a question, and the guy changed his profile, into something offensive. Could you help me flag it?
 
@solid.py take one of their posts, find the "flag" link under it, "needs moderator attention". Explain in detail.
 
I ran out of flags for the day :P
 
How? Close flags?
 
9:56 AM
Is there a limit to flag people in a day?
 
yes
 
Maybe it's because of my rep, there is a counter in the dialog box, where it said 10, now its 0.
 
Yeah, you start with something like 10, and get up to something like 50 or 100 if you have a lot of helpful flags
so not rep, but number of helpful flags
 
@MisterMiyagi I too was assuming the same
 
 
1 hour later…
11:02 AM
@MisterMiyagi It is basically 1 or 2
I just tried with code
 
11:32 AM
That code also unconditionally applies rule 1 then rule 2. It does not skip rule 2 if rule 1 already applied.
 
it does so
if(!appliedFirstRule) { then 2} <-- !
I am currently just running out of time for few cases
 
 
1 hour later…
1:12 PM
@Beginner check out the code formatting guide
 
1:24 PM
@Beginner and please don't ask for help here with fresh questions on the main site as per our rules
 
1:35 PM
Hello, i have an issue with QTabWidget.
I want it's tab to have fixed height according to it's contents.
Is that possible?
I am trying this with QtDesigner.
 
Is it unpythonic to attach a cli as a static method to a class like in the example below?

from urllib.request import urlopen


class Box():
    def __init__(self, url, save=False):
        self.url = url
        self.save = save
        self.content = None

    def fetch(self):
        res = urlopen(self.url)
        print(res)

    @staticmethod
    def cli():
        import sys
        url = sys.argv[1]
        b = Box(url)
        b.fetch()


if __name__ == "__main__":
    Box.cli()
 
@ex080 what purpose does it serve that you put that cli in that class?
 
Two reasons. I want to be able to use the Box objects in other pieces of code but also would like to occasionally just use it via cli. In this way I can import Box and use it as needed in other work or I could call the static method on the class via main and use it that way. Is there a better way to accomplish that?
 
1:50 PM
Other than just importing the cli when you need it, and importing the Box when you need it?
 
No other reasons than that. Yeap.
 
I'm not much of a design expert so all I can say is that your code looks really weird to me
 
I just don't want to be breaking python patterns.
Well that's a dummy example, but does the static method CLI the weird part?
 
cli() seems to be a top-level thing that uses the underlying library. It seems weird to me to plug that functionality inside a class of the library. And the Box you create in the cli() method would also have a .cli method... it's just weird
 
ahh I see
ok
 
1:53 PM
@ex080 well people tend to say that classes are overused, so only use class functionality when you need it. If your method doesn't use any state from the class, and it doesn't really have to do with the rest of the class functionality-wise, there's little reason to put it there
 
I will make CLI its own thing and call box there.
 
It looks to me as if your Cow class had a build_new_farm method
 
Yeap I totally get it now.
 
OK :)
 
needs to be it's own thing as a small script that calls box
thank you for helping me think through it
 
1:55 PM
That would make more sense to me, yeah. One little import isn't a terrible price to pay for clear responsibility.
@ex080 no problem
 
 
1 hour later…
3:19 PM
hi
 
3:52 PM
Oh, nice. The SO syntax highlighting gets a lot closer-aligned with my actual editor. The fact that Python and HTML were the demo cases plays well into my court :)
 
What should I learn first..Django or Flask..?
@kr8gz Hello
 
It's not really a sensible question because they both do very similar things and it's too easy to be derailed by personal opinion. Flask has a lower barrier to entry than Django but I know at least one person who will tell me that it doesn't really teach you proper design because of thread-locals, among other things. I don't want to be drawn on the question too much. Pick one :)
 
Hi, I use this cli --html in one of my python library. Btw, there is a conflict appearing with another library with the same cli --html that uses it.
argparse.ArgumentError: argument --html: conflicting option string: --html
this is the arror
Is there a way that we both can use the same cli cmd
 
4:16 PM
if you did, then it would be impossible to distinguish which action was intended. I would therefor think that it would not be possible... but that's just me
 
4:30 PM
or I can modify my cli argument upon the conflicts; is there a way I can do it @inspectorG4dget
I dont want to remove --html since it was already in use by lots of users; if I can do any modifications it would be really nice
I use pytest. Both the libs use the same pytest as base.
it's really tricky
 
5:07 PM
@PrashanthSams which libraries provide these CLIs? Usually, an application has a CLI, not a library.
Or asked differently: Why do you have to use the other library's CLI?
 
5:34 PM
cbg
can someone help me understanding this behavior for pd.to_numeric with df.apply

df = pd.DataFrame({"A":list("abc"),"B":list("123")})
out1 = df.apply(pd.to_numeric,errors='coerce')
out2 = df.apply(lambda x: pd.to_numeric(x, errors='ignore'))
print(df,'\n',out1,'\n',out2)
A  B
0  a  1
1  b  2
2  c  3
     A  B
0 NaN  1
1 NaN  2
2 NaN  3
    A  B
0  a  1
1  b  2
2  c  3
Cant figure what i am missing to look into
 
@anky, which part is unexpected in the output?
(I get the same output btw)
 
At a guess, it's flipping the axis for apply but it's gonna take some time to get through the code :)
 
@zabop I am in version '0.25.1' and I get np.nan for column A in out1 whereas not in out2
 
yeah I think its because
"If ‘coerce’, then invalid parsing will be set as NaN"
"If ‘ignore’, then invalid parsing will return the input."
oh ok lemme check my version...
 
@roganjosh i see , valuable tip :) there is no documentation about the behavior with lambda (I guess)
 
5:49 PM
Actually, wait, yeah. You have coerce in one example and ignore in the other. Now I'm not sure what the difference is that confuses you
 
@zabop Ahh my gawd,, too much for today i guess
@roganjosh I cant believe that
sorry..!!
 
Happens :)
 
no worries! :)
 
rbrb for today, really need to get off main as well :P
 
it is not that important, but pretty cool
the python related thing to it is
there is this "picture", from characters:
 
5:52 PM
came in to say thanks @zabop @roganjosh rbrb now :)
 
how can I generate something similar with python? or a more broader question: what should I search for, if I'd like to create similar "picture"s?
@anky welcome! :) was happy to help
 
6:12 PM
@zabop "ascii art" perhaps
 
@AndrasDeak thanks, that indeed gave relevant results!
 
7:06 PM
cabbage
Is it possible to perform upsert using SQL alchemy with "on_conflict_do_update" and having multiple constraints
 
7:22 PM
@AndyRogers please stop asking about PHP here
 
thanks, good luck!!!
 
you too
 
Sigh... I took the week off, but I have to refresh my work email every thirty minutes while I wait for the very important thing to be sent to me
I would have liked a timeframe smaller than "we'll get in touch eventually"
 
@Kevin why are you being sent a very important thing on a week off?
 
The company had the temerity to schedule a big reorganization this week, and I have to tick some boxes to keep them from incinerating my desk
 
7:27 PM
any decent corporation should have the inertia to wait two to three weeks after such deadlines ;)
 
Yeah, the odds are pretty good that the next time I go into the office there would simply be a "todo: incinerate" post it note on the desk, which I could easily discard.
But there's a 1% chance that there will be no note, but rather a desk-sized pile of cinders, so I'll err on the side of caution
 
corollary: 100% remote
 
I left two brand new flash drives in the upper right drawer that I don't want to see melted into slag
 
That... that is the main concern :P
<says while still having a trusty flash drive in my pocket... at a restaurant>
 
Mm hmm, I already took my rubber duck home with me, so the drives are now the most valuable personal property still there.
 
 
2 hours later…
10:00 PM
Heh, I've just had to download an app, take a photo of my driver's license, give my passport number, and take a selfie, and it goes "nah, our servers done broke. Try again later". Stuff like this...
 
these online coupons are getting out of control
 
10:31 PM
Part of me thinks "ha ha ha, 10% off trainers" and the other part of me thinks "you now have everything for an alternate identity for your govt. spy with a mundane life"
but it didn't work
 
11:12 PM
@roganjosh It says it didn't work...
 

« first day (3617 days earlier)      last day (1338 days later) »