« first day (3622 days earlier)      last day (1327 days later) » 

4:12 AM
@Aran-Fey Oh yeah I forgot it . Lol 😂
 
 
2 hours later…
5:59 AM
Hi, need my help?
 
 
2 hours later…
8:21 AM
cbg
 
 
1 hour later…
9:49 AM
Mureinik answering a blatant dupe :(
 
It's just part of the background noise of people explaining that dictionaries have one value per key...
Something about pearls and sand, I assume.
 
 
2 hours later…
12:21 PM
Current mood
 
What troubles you? Corporate bureaucracy still?
 
Yeah. It's all going to work out eventually but I have a bit more broken glass to crawl through
 
At least your desk is in a non-combusted state still, I hope
 
12:34 PM
Hmm, the businessy stock images in this pdf still have alt text indicating they were downloaded from google image search... Naughty BigCorp not going through the proper channels
 
This is what all those ethics trainings have prepared you for
 
[I look contemplatively at the big red "become whistleblower" button before me]
 
1:14 PM
@AndrasDeak ethic training? I'd be more worried about managers clicking on click-bait and phishing stuff when I see that
Though that might be because I just had to clean up a network where that happened and my mood currently match's Kevin's :P
Newest "fun" thing to do on web-conferences: Sneeze and then count how many people put on facemasks to avoid the virtual germs.
Bonus points if your sneeze is so epic it gets more than 5
 
user11006952
@inspectorG4dget Is this Hangouts for SO mods/chat regulars?
 
@Pax for python chat people who feel like participating
100% community-driven and voluntary
 
user11006952
@AndrasDeak Some talking points sound interesting. Will passive participation be welcomed? That is, simply listening to what people are saying? I doubt I have anything to contribute given my level of experience.
 
1:30 PM
I'm not one of the organizers but I'm absolutely sure that everyone is welcome :)
the inspector can confirm this later
 
user11006952
@AndrasDeak Alright. Thanks.
 
How to convert binary to utf-8 using libraries?
this doesn't work in python3
 
"doesn't work"?
ah, two decodes
 
doesn't work:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'
 
@iaeliyen that's not the error I'd expect
perhaps you could combine "convert binary-looking string to bytes" with "convert bytes to unicode"
 
1:38 PM
@AndrasDeak yeah, you are right, I fixed that.
 
yeah, that's more like it
 
1:56 PM
@iaeliyen do you happen to have an MCVE? there isn't any canonical binary type in Python.
 
I've a string with 1 and 0, I am required to convert it into utf-8
literally 1 and 0: '1100001010100011'
 
I assume we should just roll with the premise, and not question why you start with this in the first place, yes? Or can you change the source of the data?
 
code challenge site
 
I see.
The data is big endian, I presume?
 
yes.
on reading some docs, I know how to figure out individual characters out of individual character binary, but it seems impossible to justify the right partition to figure out the whole string.
 
2:06 PM
So then just chunk them up in groups of 8 (bytes), inspect the leading bit to see whether you need to attach the next byte, then convert each group using chr.
 
yeah, I can do that. Thanks.
 
@iaeliyen Not sure if I'm understanding the issue correctly, but a byte/bit-stream of UTF-8 cannot be pre-partitioned into characters. You need to inspect each character to know its length, so the position of later characters depends on earlier characters.
 
The answer in that link would probably work if you used bytes.fromhex instead of .decode(hex)
>>> s = '1101100110000110110110011000001011011000101001111101100010101000'
>>> f"{int(s,2):x}"
'd986d982d8a7d8a8'
>>> bytes.fromhex(f"{int(s,2):x}")
b'\xd9\x86\xd9\x82\xd8\xa7\xd8\xa8'
>>> bytes.fromhex(f"{int(s,2):x}").decode()
'نقاب'
This might be one of those situations where the code challenge is made completely trivial thanks to Python's robust stdlib
If you want to preserve the fun, try doing it without fromhex, using 8 digit chunks etc etc
 
int also has to_bytes, which safes on the intermediate hex conversion.
 
I half-suspected such a thing existed but I must have overlooked it in the dir()
 
2:15 PM
it's a bit unwieldy as you need to compute the byte count.
 
Yeah, doesn't save too many characters, but meh
>>> print(int(s,2).to_bytes(len(s)//8, "big").decode())
نقاب
 
hm, toying with this low-level makes me wish for better stream support. :/
 
Re: rolling with the premise, I find that I need to convert binary-looking strings into text on a surprisingly frequent basis. Mostly because techie-oriented media will often use it to hide easter eggs in plain sight
Fortunately most sources separate the bytes with spaces so I don't have to do any chunking
A simple "".join(chr(int(x,2)) for x in s.split()) suffices
 
@MisterMiyagi I did that, like this:
binary_to_utf8=lambda b:''.join([chr(int(''.join(i),2)) for i in __import__('re').findall(r'110([^_]{5})_10([^_]{6})|1110([^_]{4})_10([^_]{6})_10([^_]{6})|1{4}0([^_]{3})_10([^_]{6})_10([^_]{6})_10([^_]{6})|0([^_]{7})','_'.join([b[i:i+8] for i in range(0,len(b),8)]))])
 
👀
 
2:29 PM
but there was a shorter solution, which just used bytes() after slicing the whole string in 8
 
Don't take it the wrong way, but that is horrible code.
 
def binary_to_utf8(b):
    k = '_'.join([b[i:i+8] for i in range(0,len(b), 8)])
    R = re.findall(r'110([^_]{5})_10([^_]{6})|1110([^_]{4})_10([^_]{6})_10([^_]{6})|11110([^_]{3})_10([^_]{6})_10([^_]{6})_10([^_]{6})|0([^_]{7})',k)
    return ''.join([chr(int(''.join(i),2)) for i in R])
better?
 
note that the end result is not "utf8", it's a string (text)
 
I'm curious how you constructed that regex
 
I have no idea why this uses re
 
2:31 PM
@MisterMiyagi because anything worth doing is worth overdoing
 
@Kevin that was obvious, I ain't that noob :D
 
I guess it's looking for byte sequences that indicate the size of each utf8 character?
 
@AndrasDeak admittedly, that is kinda motivating me to proceed with my own megalomaniacal plans
 
@Kevin It is figuring out the actual binary in the layout of utf-8, and discard the leading binaries.
 
If the regex pattern was on multiple lines and had comments, I might consider it acceptably readable
 
2:35 PM
cool, I knew that regex supports comment, but thought that it is unusual because I never seen any regex with comment, now I know that it is usual
 
re.VERBOSE is good for this kind of thing
 
verbose regex, when a regular regex wasn't bad enough
 
Honestly, I'd expect a for-loop explicitly inspecting the string patterns. E.g. if byte.startswith("110"): # take next n bytes
Either do it low-level or high-level, not high-low-level. :/
 
R = re.findall("""
  110([^_]{5})_10([^_]{6})|                         #two byte code point
 1110([^_]{4})_10([^_]{6})_10([^_]{6})|             #three byte code point
11110([^_]{3})_10([^_]{6})_10([^_]{6})_10([^_]{6})| #four byte code point
0([^_]{7})                                          one byte code point
""",k, re.x)
Something like that, I didn't test it
 
you can also use string literal concatenation for this. saves you the cryptic RE flag
In [26]: (
    ...: "110([^_]{5})_10([^_]{6})"  # 2 byte
    ...: "|"
    ...: "1110([^_]{4})_10([^_]{6})_10([^_]{6})" # 3 byte
    ...: "|"
    ...: "..."
    ...: )
Out[26]: '110([^_]{5})_10([^_]{6})|1110([^_]{4})_10([^_]{6})_10([^_]{6})|...'
 
2:40 PM
A for loop would be a bit of a pain because you'd need to track state in between iterations
Or, hmm
 
code it. you know that you want to.
 
You're right ಠ_ಠ
I may need assexps for this...
 
Can anyone help me verify ? pastebin.com/j3mtE50j
 
This might sound flippant, but serious question: does it work when you try it?
 
@Kevin No it doesn't hence asking , I get "405 :The method is not allowed for the requested URL."
 
2:50 PM
Ok
You never can tell these days. Sometimes we get people coming in here asking "can someone run this and tell me what it does?"
Time to open my dusty Django tome
Hacky for-loop utf8 parser complete. Spoiler warning for iaeliyen, obviously
It's not perfect because it happily parses, say, a code point with first byte 0xxxxxxx and three 10xxxxxx bytes following it, which is decidedly not valid utf8.
Rejecting all bad utf8 would require a bit of statefulness
 
EAFP :P
 
I see you are also sorely missing a "and the next n items too, please" in a for-loop
 
I would like an iteration-controlling block that lets me jump forward and backwards etc, but I'm uncertain about whether I'd want for loops specifically to have that power
 
so far I've just gone with repeatedly next'ing the iterable, e.g.
for bit in bit_stream:
    yield [bit, *(next(bit_stream) for _ in range(7))]
I'd really like for slicing to work as islice for generators and non-sliceable iterables
 
3:06 PM
I thought about a nexty approach but I didn't want to think through the possible cases where I'd need to catch StopIteration
just in case a cheeky user passes in "111100000"
 
since StopIteration means the input is faulty, it's the user's problem.
Pro Tip: You do not need to handle invalid JSON ever, since invalid JSON is by definition not JSON and therefor outside the domain of JSON handling handle code.
 
Wise.
I feel much better about the times that the KevinScript interpreter exits with no output when it encounters a SyntaxError. Hey, what you gave me isn't valid KS, you're lucky I'm not segfaulting
You need a KevinScript and everything-but-KevinScript parser if you need descriptive errors
 
We need more nasal demons to weed out the unworthy.
 
So I finally got my project to compile. Let the "error: expected ‘;’ before x" begin :D
 
3:21 PM
Very nice. As expected, a proper parser frees the developer from having to track state themselves.
Which is why I didn't rag on iaeliyen too much for using regex -- a parser can be nice to have even if its syntax is symbol soup
 
@Kevin lmao how does that work out for them ?
 
We say "download Python yourself and find out" and they shake their fist at us
 
Download python lol, strange dialog
 
Going back to your Django problem, are both fields inside a <form> element?
 
Yes they are, here's the full code : pastebin.com/mCjakv3z
I am not using Django, justsimple python , HTML and Bootstrap
 
3:29 PM
Ok
How does your Python script talk to the http server, then?
cgi?
 
Oh if you mean by server, I use flask
 
Wait, what?
 
That is indeed what I meant
 
Flask routes will only accept GET requests by default, so you'd need to add POST to methods on the route. But what's Flask doing in the middle of that?
 
Why does stuff always work in one way and not the other.
 
3:35 PM
I ask myself that every day
 
@roganjosh I did add a POST method
@Kevin All I did was just change regular HTML to Bootstrap components.
 
I wouldn't expect bootstrap to mess things up but I'm no expert
 
@AshwinPhadke the trick is doing it the working way
 
You've boiled our profession down to its simplest principle!
 
Flask isn't a server. I'm relatively confident that django and flask actually share a lot of components for their development servers bundled with them. So I'm at a loss why flask needs to be a proxy in your django application
 
3:41 PM
@AndrasDeak Well that looks like an website from the IE age then.
@roganjosh It is not a django application
 
I may have complicated the issue by bringing up Django at all. Sorry about that
I'm not very good at distinguishing web frameworks by eye
 
@AshwinPhadke my apologies, I got mislead by it being raised and then looking on a mobile view. That's my bad
 
It's okay y'all, no stress :-P .
 
Where do you define the actual endpoint of your flask app? You've shown some of the body, but not the actual decorator and function definition (assuming you chose that method)
 
Usually one of us would have demanded an MCVE by now. Patience must be in high supply today ;-)
 
3:46 PM
lucky for Ashwin I don't touch web dev
 
I will answer the question if it is converted into C# ASP.NET
Try deleting your dlls and rebuilding, that usually works for me
 
lol it looks like everyone here wants to solve issues except python xD
 
@AshwinPhadke This is something I'm more confident about now. if request.method == 'POST' is not enough; it won't get that far. The app enpoint will reject it at app.route('/something') if you don't pass methods=['GET', POST]. To be fair to them, there's been a bit of misreading that sent us in different directions so i don't mind pulling it back in line
 
I want to solve Python issues, but I allocated my skill points wrong during character creation
 
@roganjosh Yes you might be correct, I just happen to change the upload files method and reverted to the old build and it works.
 
3:49 PM
@Kevin You need 3 more levels to gather enough skill points to learn Parseltongue
 
What I feels is that the bootstrap upload file component isn't posting anything at all
@Kevin ah
 
@AshwinPhadke Different issue. I'm just looking at the 405. For anything else you'll need an MCVE
 
@roganjosh Yes, thanks for the help
Where do you folks suggest I host my Python computer vision app, Heroku is out of question due to space limits.
 
that feeling when you have to maintain salvage Py2 and constantly check whether feature X was supported back then... :/
 
just assume it works and when users complain tell them it's an issue with the interpreter
 
3:58 PM
from __future__ import entirety_of_3_point_8
Pypy needs to design a matroyshka doll of interpreters that lets you use each Python version to emulate the version that comes after it
 
@AndrasDeak technically, I'm the user-by-proxy. Any complaints from the user to the maintainer will end in a recursive, never-ending cycle of counter complaints.
 
@Kevin but that could prove that python 3 is Turing complete
 
At some point, they can lock away the babbling mess of future me and call it 24/7 customer support.
@AndrasDeak Decently sure it's proven that Python3 cannot be Turing complete.
Common knowledge, practically.
 
Ok, in that case Python 2.7 will emulate each 3.X version, but 3.N will not emulate 3.(N+1)
 
Come to think of it, I'm kinda sure RPython is still Python2
 
4:04 PM
Our target audience is 2.5 through 2.7 anyway
 
shame on you, Kevin, for leaving the 2.3-2.4 users in the dust
 
2.3-2.4 users are dust by now, except for the odd outlier that fell into a tar pit
8
 
5:05 PM
cbg
 

« first day (3622 days earlier)      last day (1327 days later) »