« first day (3322 days earlier)      last day (1625 days later) » 
00:00 - 20:0020:00 - 00:00

12:08 AM
Is there a sane way to distinguish an "IT-Server" where they just point to a big box of hardware, and a server that is just listening on a port to serve content? Twice in one week I've run into this confusion from others. In my head I have a distinction but I feel pretty hopeless expressing it.
 
"server hardware" or "server box" vs. "server process"?
 
That's not gonna clarify anything for the asker though :/
Nov 16 at 10:44, by roganjosh
What is a server to you?
And now this question where I think I just did a woeful attempt at explaining the difference in comments
I just keep doubling back on the info in my mind. It'd be nice if anyone knows a good resource for this distinction
 
I suspect that question is going to get closed, but do I sympathize with OP lmao.
And no, I don't have a source for the distinction you want, I have been searching for it long and wide.
 
(It probably should be closed but it's shown my own ineptitude at expressing the difference so it might elucidate something for me too :) )
 
@roganjosh IMHO this is one of those questions SO wouldn't allow, I know SO thinks it's a not good question, but I still deep down think it is a good question.
 
12:22 AM
But I think I should have a clear answer to it myself
 
wim
I like how the IPython tokenizer highlights tokens
 
@roganjosh The closest is the "Three Tier Organization" explanation on the Wikipedia
@wim Haven't switch to JupyterLab yet?
 
wim
@Dair feature bloat
 
@roganjosh However "The application contains the business logic" is such a cop-out lmao.
 
@Dair Not keen on it at all. All 3 could live on 1 machine - a single "server" as it is often stated :P
Oh well, I'll try babble my way through. I do understand the confusion, though, when people see "server"
 
12:29 AM
From the comments in the question you linked: "SQLite through Django as our database instead of Dynamo" that sounds like a concrete mistake...
 
So is Django as a server
 
I mean idk Dynamo is good or not, but SQLite sounds questionable...
Oh wait, nvm they say as proof of concept, then it isn't as bad I guess.
@roganjosh You should ask @davidism about this. I have little doubt he can answer your question.
 
If you spend time with IT who have done no programming ever, they will just refer the the whole thing as "the server" and it's easy for people to think they just come as self-contained packages, and maybe Django docs can be completely misread if you have that mindset
 
wim
@roganjosh no.
Django is a framework
 
@wim "so is django as as server"
 
wim
12:33 AM
oops sorry
 
I wasn't suggesting it was, I was saying it was misguided
 
wim
yeap I misread
 
No worries :)
 
wim
hah, this guy
you can't make it up. just goes with the flow and shoots from the hip
 
1:04 AM
sup yall
 
cbg
 
1:40 AM
In our product environment, we have NFS file servers, NFS clients, and our product in the middle doing network traffic optimization. In the test platform, I run a REST server on the NFS client so I can drive file system traffic per our test scripts - that always takes about an extra 30 minutes to get across - "But wait, that's the client. But you say it's a 'server'?"
 
 
3 hours later…
4:28 AM
"For Unicode support, a special string of the strings type is getting common, as Unicode characters can be of arbitrary length, even in UTF-32. This enables efficient character-indexing by pushing the complexities of the character set into the string type."
what is this talking about? is there a word missing or something?
 
wim
weird. I thought the whole point of UTF-32 was that it was a fixed length encoding.
 
text = 'Robert Pontius, Wilmington – 6-4, 195 senior'

print([s.strip() for s in text.replace('–', ',').split(',')])

'''
trying to get the following output:

Robert Pontius, Wilmington, 6-4, 195, senior
'''
I've handled the emdash but still want to split last 2 columns by comma.
 
wim
@tripleee the edit that added it is here, if you want to ask the author directly.
 
4:44 AM
@wim yeah, I was thinking of approaching them
@αԋɱҽԃαмєяιcαη with a single example, text.replace('195 senior', '195, senior') and if you need us to generalize from that, we need to get an idea of what sort of generalization you are looking for
 
once you see the output. you will understand my target.
 
it takes eons ... and it's not using pandas for anything
so you want to put a comma before "senior" or "junior" at the end of string?
 
Just fixed it now.
if '-' in item.text:
    a = [s.strip() for s in item.text.replace('–', ',').split(',')]
    a[-1:] = a[-1].split()
    print(a)
thanks @tripleee
regarding pandas, I'm going to use it now as i will convert the text data to excel.
 
or with regex, a[-1] = re.sub(r'(?<!,)(\s+(se|ju)nior)$', r',\1', a[-1])
friends don't let friends use Excel
oh you wanted to split it to a separate field? then no (or do the re.sub before splitting on commas)
 
@tripleee LoL
i think that my split is correct better than applying regex on many words. such as senior, junior and sophomore
 
4:57 AM
really depends on your data -- regex can help if there is a modest amount of variation but if it's completely rigid, of course just split on the last space
 
5:09 AM
why i can't create variable to hold list unpacking ?
ops got it. var = *mylist,
 
5:34 AM
if "sellers_item_identification" in item.keys():
item_data["item"]["sellers_item_identification"] = item[
"sellers_item_identification"
].replace(" ", "")
how can i pass this if item_data["item"]["sellers_item_identification"] value is not present , now it's showing AttributeError: 'str' object has no attribute 'keys'
 
we have no idea what item or item_data contains, are you perhaps simply using the wrong variable name (i.e. should they all be item_data)?
 
the error message seems to indicate that item is a string. your code seems to indicate you think item is a dictionary.
Also, if you paste any further code, please take a second to look at our code formatting guide in chat
 
yeah it's a directory , when values extracting from a pdf file some values stored in item_data["item"]["sellers_item_identification"] and in some odd cases there will be no values in item_data["item"]["sellers_item_identification"] during that case it showing the error . so i need to pass when there are no values in item_data["item"]["sellers_item_identification"]
 
you mean a dictionary
 
yeah dictionory
 
5:42 AM
And note, item vs item_data are two different things.
 
and the error message very much confirms that item is a string
and if you mean if "sellers_item_identification" in item_data.keys() that can be abbreviated to just if "sellers_item_identification" in item_data
or perhaps you mean if "sellers_item_identification" in item_data["item"]
 
item.keys()dict_keys(['sellers_item_identification', 'name', 'description','buyers_item_identification','invoiced_quantity', 'price_amount', 'line_extension_amount'])
@tripleee yeah
simply my question is , how can i pass a if clause if the value in containing nothing
 
@navaneethkt Could you rephrase this sentence to make it clearer?
 
there is still no way to make sense of this, are you in a loop where sometimes item does contain a dict but sometimes a string?
 
What does "containing nothing" mean? Is the key present, and the value is an empty string like ''? Or the key is present, and the value is None? Or something else entirely?
@tripleee FWIW, I've decided to assume that particular error message was a red herring.
 
5:55 AM
recbg
 
bah, probably a good assumption, but also increasingly looking like a waste of time
 
import requests
from bs4 import BeautifulSoup
import pandas as pd


r = requests.get('https://cumberlink.com/sports/high-school/football/pa-football-writers-all-state-team-class-a-a-and/article_4d286757-a501-5b5b-b3be-cfebc06ef455.html')
soup = BeautifulSoup(r.content, 'html.parser')
for item in soup.findAll('div', {"class": "subscriber-only"}):
    if '-' in item.text:
        a = [s.strip() for s in item.text.replace('–', ',').split(',')]
        a[-1:] = a[-1].split()
        pd.DataFrame(a).to_excel('output.xlsx', header=False, index=False)
unable to convert text to xlsx
 
@αԋɱҽԃαмєяιcαη what exactly happens? This is too vague.
Also, a recommendation is to actually just create the dataframe first, and actually see that it looks like how you think it did.
 
@ParitoshSingh here's the output if you run the code. repl.it/@AmericanY/Test
@ParitoshSingh trying to put this output into xlsx
 
6:10 AM
At the risk of being deliberately vague, Are you sure the dataframe looks like how you think it does? (hint: It won't. Don't just write to excel, assign the dataframe to a variable. Print it out at the end)
 
@ParitoshSingh you are correct. i printed it. it's not looks like what i wanted it to be
 
Correct. The issue is, you're creating the dataframe inside the loop. So it only eats up one row, and spits out a dataframe on that.
You need to collect all the rows first, perhaps appending each row (a is not really a great name for it) into another list.
Convert everything into a dataframe only at the end of it all outside the loop.
 
6:25 AM
@ParitoshSingh thank you very very much
i usually respect people who explain well.
you saved my time and gave me the correct track
 
Anytime
 
6:55 AM
`if "sellers_item_identification" in item.keys() and "sellers_item_identification" in item_data["item"].keys():
item_data["item"]["sellers_item_identification"] = item[
"sellers_item_identification"
].replace(" ", "")
else:
pass`

item and item_data are dictinories but showing an error : AttributeError: 'str' object has no attribute 'keys'
 
The moment you have this error, print them out
Looks like we're back on square one
You think they are dictionaries. But the code does not lie. Trust the error messages
 
i'll show the pdb results:

Pdb) item
{'sellers_item_identification': 'WB315-800', 'name': 'WaBack DN315 inkl. tätn.ring, kona', 'description': '', 'buyers_item_identification': '2360098', 'invoiced_quantity': '2019-04-15', 'price_amount': '38 800,00 10,0', 'line_extension_amount': '34 920,00'}


(Pdb) item_data
{'period': {}, 'allowance_charge': [{'reason': '', 'percentage': '', 'charge': '', 'amount': ''}], 'item': {'additional_item_property': []}, 'price': {}}
item_data.keys()
dict_keys(['period', 'allowance_charge', 'item', 'price'])

item.keys()
dict_keys(['sellers_item_identification', 'name', 'description', 'buyers_item_identification', 'invoiced_quantity', 'price_amount', 'line_extension_amount'])
 
4 mins ago, by Paritosh Singh
The moment you have this error, print them out
 
what you mean?
 
It doesn't matter if they started out with dictionaries, at the time of the error, the message is clear.
Most likely, you overwrote item somewhere.
 
7:03 AM
@navaneethkt Paritosh is asking you to run this code print(item)
 
cbg
 
If it's still not clear, or If im mistaken, can you prepare a mcve?
cbg Arne!
 
cbg
 
1 hour ago, by tripleee
there is still no way to make sense of this, are you in a loop where sometimes item does contain a dict but sometimes a string?
 
@tripleee yes
 
7:12 AM
so the proper solution is probably to not use the same variable for both purposes
but if you have to, inspect the type before plunging ahead
if isinstance(item, dict) and "sellers_item_identification" in item
that's usually best avoided, it basically tells you that something earlier in your code is wrong
 
7:29 AM
At this point I'm reasonably sure you have a dataframe of strings that represent JSON objects. The df headers give you a dictionary, but stored against those keys is what looks to be a dictionary but it's just a string that you failed to deserialize
 
@tripleee are you familiar with selenium ?
 
nope
 
 
1 hour later…
8:49 AM
I am facing an issue with this code -> with mock.patch.dict('os.environ', {'VAR_NAME': 100}):
In command line, if the env var VAR_NAME is not set and I run pytest there are no issues. However if I do SET VAR_NAME=999 and then run pytest, then the mock takes the value as 999 and not 100. Any ideas?
 
not sure I follow, but environment variables are always strings, is that your problem? You should have 'VAR_NAME': '100'
 
No, that was an example - My problem is that the os environment var is not using mocked value. When I set the env var via command line via command line, it does notget overriden by mock
 
9:11 AM
Separate question: Just like 'flask run' supports FLASK_APP variable, do you know if waitress supports such an env variable
 
9:52 AM
Morning, quick question. Should I use pyjwt or authlib for jwt?
 
@Markus check the library section on jwt.io for a feature list. if they support what you want, either is fine
 
Ok. thanks
 
10:23 AM
Please can you suggest me any links to python and Flask architecture guidelines
 
 
1 hour later…
11:45 AM
Anyone used nltk with flask?
 
I'm a beginner, which web framework should i learn ?
 
Is it good practice to use: nltk.download() in app.py or should be done using other approaches outside of the code?
 
Whether good or not, nltk download is a one time thing no? I'd do it outside my code flow
@quangthang anything you like. beyond that, it's just opinions. Look at the most popular frameworks online and pick any one really. Generally things to look for are good documentation, active community, and popularity
Once you familiarise yourself with one framework, then perhaps you can start looking at the various options out there and start comparing them
 
nltk.download() just gives a popup - its an interactive install - looking at the approaches outside code flow now
 
using nltk in production is never a good idea
scrapy is much better for that
 
12:01 PM
Does scrapy actually substitute everything nltk can do? the google search leaves me confused as to why those two would be considered competitors.
with a disclaimer that i dont know scrapy, and i only know nltk a little. I just always assumped nltk offered helpful functions for nlp.
 
12:22 PM
i remember that i solved such case before but i forgot how . ibb.co/3NYNX7J
instead of using .encode('utf-8')
 
.decode('utf-8')?
or try .decode('utf-16')?
 
2
Q: VSCode - Output window says "UnicodeEncodeError" when I try to print unicode

neoleiI just started to use VSCode on some python scripts. When I try to print something like: print('%s' % string.decode('utf-8')) I get following error in output window: UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-20: ordinal not in range(128) I know it probably bec...

found the main issue for it. code-runner plugin.
 
html is not a great name for a response object, and you really should be using .text instead of .content
 
Windows is using cp1252 and that's what is causing the issue
 
 
1 hour later…
1:34 PM
@ParitoshSingh it's not a drop in, but the idea behind scrapy was that it contains good implementations of the parts from nltk that you'd wanna use in production. the idea behind nltk is that it is first and foremost a learning tool
 
I see
We are currently using a tokenizer from nltk, i assume that itself isn't too big of a deal
side note. i just had a heart attack and about 15 minutes of not being able to access a server remotely after firing a restart command. I thought i broke something. Culprit? Windows updates. :)
 
Hi guys, I would like to show you a library I released recently, any feedback or reported issue or feature request is appreciated.
The library is python-benedict, it is a dict subclass dict subclass with keypath support, I/O shortcuts (Base64, CSV, JSON, TOML, XML, YAML, query-string) and many other utilities.

It is open-source on GitHub: https://github.com/fabiocaccamo/python-benedict
 
1:55 PM
I'm not sure what the point of your dict_util module is. Couldn't you have implemented all those functions in a class that your benedict then inherits from?
that way you wouldn't need a bajillion def foo(self): dict_util.foo(self) methods
 
2:16 PM
cbg
 
2:29 PM
@FabioCaccamo You should add some docstrings to your methods, so that it's much easier for a user. github.com/fabiocaccamo/python-benedict/issues/2
 
Good night
can someone confirm if this is a python code?
def hello(): String = "Hello"
 
it looks like Python yes, though conventionally the variable's name should be lower case
def hello():
    string = "Hello"
 
I am doing this coding "test" and they asked me to say what the output would be of some small code snipets
 
in and of itself it doesn't do anything useful
 
but this would not output anything right
 
2:34 PM
@IvoMerchiers Most importantly, put the docstrings on the parts visible to the user, i.e., on the benedict class. Internal docstrings are helpful too, but the visible API is most important. Also, if you put some doctest strings or example code in the API docstrings, that serves as helpful and easily accessed documentation.
 
and like most question are like this...
 
no, it just declares a function which doesn't do anything
or rather, it declares a variable and then promptly forgets it, and returns nothing
 
I wonder if they tried to use a python syntax to mean "a method that returns a string that says 'hello' "
so weird...
 
that would be return "hello"
 
the other question:
 
2:35 PM
and a method would be inside a class, and have a self parameter
 
def contains(one: int, ls: List[int]): Boolean = ls.contains(one)
 
@FelipeOliveira - I hope you're not planning to post all your test questions here?
 
no, I am just curious about it, makes no sense to me
 
it's Python with type annotations, it says that one should be an int and that ls should be a list of int (but Python itself does not currently enforce this)
and again the uppercase Boolean looks out of whack, capitalized symbols are generally class names
 
yes, and it is basically creating a Boolean = variable that receives the boolean operator for whether the list contains the int that was passed in the parameters
 
2:37 PM
well, that function's gonna produce some output (an error) if you call it with a list
 
and of course putting a single method call in a function seems pretty pointless, to the point of being vaguely offensive
 
I email the guy who sent me the test to double check it, it doesn`t make sense to me...
I am no expert in python, but I tried running some of these codes, just to be sure and yeah, it wouldn`t output anything
 
Yes, tell him that you posted it to this group and that we all said it is some of the worst Python code we have ever seen
 
@PaulMcG hahaha I will!
 
cbg, and maybe I'm wrong about this, but wouldn't this throw an error since there is actually no contains function for a list, but only the dunder __contains__?
 
2:39 PM
AttributeError: 'list' object has no attribute 'contains'
I asked them if this is one of those kinds of tests where they want you to spot bugs, cause if isn't it, then I'm lost
 
Yes, it should more properly be 'one in ls', which will resolve to ls.__contains__(one)
 
Exactly. The 'proper' way to write this pointless function would be

```def contains(one: int, ls: List[int]):
boolean = one in ls```
 
The best thing is, it is for a java position...
 
I'd also point out that I wouldn't recommend type annotations, given it has no backwards compatibility with python 2.7
 
!!! Bad code formatting in chat claims another victim
@KieranMoynihan I would say that is a recommendation for type annotations
 
2:41 PM
Damn, these were my first two messages, and already I got the formatting wrong :D
 
Hey! Why the hate for 2.7... :(
 
You can't mix code formatting with non format
 
Yeah, I'm used to python with no type annotations, but it's been a while
 
Thanks Paul, I'll read through the code formatting guide :)
 
Thank you and sorry to bother you all with this ugly code
 
2:43 PM
And just yesterday I got my bronze badge!
 
The type annotation does make a certain amount of sense given it's for a java position, just to make them as similar as possible. Doesn't explain why they don't just test your java though...
 
I'm starting to think that is actually a pseudo-code inspired in python or something
 
Because a Java snippet would require much more tedious/useless boilerplate (a class, a "void main(String[] args)" method, calls to "System.out.writeln" or whatever).
(Java-fu is a bit rusty, but you get my meaning)
 
Yes, it requires you to write much more code than python
 
I've typically seen System.out.println :P
 
2:46 PM
that language looks like a python/kotlin hybrid to be honest
replace def with fun and it's valid kotlin I think
 
def contains(one: int, ls: List[int]): Boolean = ls.contains(one)

I think the answer to this is along the lines of "Method which returns true or false, if the one parameter is in the ls List parameter"
 
@Aran-Fey There is someone with a profile on CodeGolf that says they like StandardML because how can you not like a language that defines functions with fun.
 
Except the method doesn't actually return anything, just assigns a local variable
 
@PaulMcG I think this is pseudo code...
 
Doesn't ruby implicitly return the last computed value? That would work here then
 
2:49 PM
yes, that is why I think is a pseudo-code
 
I think the code mentioned is some bastardization of python. It's like a pseudo-lambda where the return is implicit. They use = which is not used like that in Python but other languages it is.
 
the best part it is a google docs test, theres no compiler, and the code is an Image, not even an actual snippet
red flags all around
 
@Dair that's nothing, it only really gets interesting when you define methods with meth ;P
 
/me calling broker to short Google
 
@Aran-Fey Are there any languages like that? Maybe I should make one like that... (I suspect it's a joke, but just in the slim chance there are langauges like that)
 
2:51 PM
haha, I'm not aware of any, no
 
Oh wait, the test was sent in Google docs, not that it was from google. /me hastily calling broker back
 
Not to be outdone someone at an Ivy decides to use add instead of meth for academic variant.
 
 meth cook(supply):
    return '%s kilos' % (supply / 13)
 
this reminds me I need to learn about ATS at some point.
 
"Don't use feature X because Python 2.7 doesn't support it" is becoming less and less of a convincing argument, now that it's End Of Life is 41 days away. At that point we're firmly out of the territory of "whoa, have a little consideration for people who haven't ported yet!" and in the territory of "If you haven't ported yet, you have nobody to blame but yourself"
 
2:59 PM
Some organizations move slower than others. cough government cough
 
@Kevin Remember, pypy 2.7 impl eats advent of code tho (according to wim)
@KieranMoynihan I'm surprised you're not writing in MUMPS or Cobol still..
 
The organizations that haven't yet crossed the finish line yet probably never will unless we give them a little nudge in the right direction. That nudge being, completely dropping support and collectively agreeing to scorn them
I'm fine if people continue to use 2.7 as long as they want. But I don't want them to be able to dictate what I'm allowed to do anymore.
 
raise YouAreNotMyDadException
 
@Kevin "There is a time when the operation of Python 2.7 becomes so odious, makes you so sick at heart, that you can't take part. You can't even passively take part! And you've got to put your bodies upon the opcodes and upon the parsers, upon the execution branches, upon all the large integers, and you've got to make it stop! And you've got to indicate to the people who run it, to the people who own it — that unless you're free, Python 2.7 will be prevented from working at all!"
- Mario Savio probably
 
I notice some regulars refer to 2.7 as "Pythoff", as if to imply it's a completely distinct language from Python. This is a compelling idea. "don't use 3.X-exclusive features since a Pythoff user can't run it" is analogous to "don't use features that Python has and Ruby doesn't, or else Ruby users can't run it". I don't see any other language communities pressuring their devs into writing only polyglots.
 
3:06 PM
import vader
try: AD
except YouAreNotMyDadException: vader.say("No, I am your father")
 
Gonna take it no one has heard of Mario Savio lol.
 
I wouldn't suggest that for everything, but something as simple as a two line snippet of code will run in Python 3 but not in 2.7 because of the inclusion of some type annotations, which probably aren't necessary.
 
@KieranMoynihan Well, yeah. Types are largely irrelevant at two lines are so... But at scale with a large amount of codes types help keep you organized.
(Although, then again, you can make dumb mistakes even at two lines and types can help with those too)
 
especially for short snippets, type hints help a lot to define the entire context not part of the snippet.
 
I would think the context of the function should be made clear by the function and parameter names
 
3:12 PM
Annotating a single function is not, by itself, very useful. But making sure a two line piece of example code is Pythoff-compatible is also not very useful. I think the former is more useful than the latter, however minuscule they both may be
 
@KieranMoynihan Yeah, but will everyone on your team do that? I can easily check and prevent integration into the code base if there is no type specified, but making sure the comment is sufficiently well defined is much harder.
 
@KieranMoynihan there are some things that function and variable name cannot make clear unless violating best practices.
 
"Type annotations, at any scale, are not useful" is a separate concern that I do not wish to address, except with the parting thought that the language developers typically do not add useless features to the language
 
as soon as a name includes a type name, that's a good sign to use an annotation instead
 
@Kevin Walrus.
 
3:16 PM
@Kevin that's a trust I do not generally share anymore. Syntax maybe, features not.
doing async, typing and packaging recently does not raise optimism.
 
rbrb.
 
3:34 PM
@ParitoshSingh there is a very mean article from the author of scrapy somewhere on the internet where he criticizes the tokenizing models from nltk in particular. mostly the fact that they are dated artifacts by now that noone understands or knows how to rebuild.
 
Huh, interesting.
 
3:51 PM
is there some fast way to do a method lookup the way operators/statements do? I currently manually do type(source).__aiter__.__get__(source, type(source)), which is slow, incomplete, and totally not liked by type checkers.
 
Forgive my ignorance, could you explain what that code is doing? What does method lookup mean?
 
that's not really correct, you actually want vars(type(source))['__aiter__']
also, I'm not sure if dundermethods' __get__ is invoked at all
apparently it is
Which means the code I wrote to check if a class implements a dundermethod is wrong... again
 
whoops? :D
 
wim
do we delvote typo questions? or just close them?
 
I delvote them if they won't be roomba'd
 
4:04 PM
@Aran-Fey does vars search the mro?
 
Whoops. Nope.
 
dir() might
 
well, that only gives you the names though
 
@Aran-Fey strictly speaking, they are invoked if present.
I'm caught in a downwards spiral of "whoops, forgot that one"... :/
 
wow, CPython sure has a lot of stuff to do under the hood
 
4:11 PM
It's totally not a problem if you have access to C slots and a compiler. Doing it in Python is cringe-worthy.
ponders Cython
 
wim
@MisterMiyagi packaging is all third party
what wrong with async syntax? I like it ..
 
syntax is fine, ecosystem is crap. Plus, async with + yield is fundamentally broken. So is async for + break.
 
wim
I mean it's a bummer that we had to take a detour via "@coroutine" and "yield from" before getting to "async def" and "await" .... but we got there eventually
 
one can't even enumerate in async...
 
wim
@roganjosh just saw this one ...
 
4:27 PM
that 1 rep seems to be from a suspension
 
wim
thank you sherlock holmes :)
 
@wim sometimes it's nice to take the "scenic route"? :p
 
wim
somehow I doubt we'll be seeing them 2024, when Facebook acquires a near-bankrupt Stack Overflow at bargain basement price, and adds Oculus Rift support to the ask a question wizard
 
I was gonna say "could have been a new user", but I seem to have missed the boat on timing
 
@wim importlib.resources is not. The various PEPs on metadata are not.
"it's third party" is nice and all until said third party grinds to a halt to catch up with theory
 
4:51 PM
Had a weird blip in my rep - early yesterday I achieved the 50K mark, but then later in the day, dropped back down to 49,975 with no rep activity indicators. Not really complaining, just puzzled
 
oh sometimes, a deleted user induces a rep-change. And it doesn't always show up on the standard rep-reports. IIRC, you'll need to click on "show deleted users" or some such esoteric checkbox
 
wim
hmm, fair call on importlib.resources
@PaulMcG look on the bright side, you get to cross the 50k mark twice! 🎉
 
just checked. It's "show removed posts"
 
Ah, of course
 
wim
backwards compat is the bane .. without such strict rules there, you could just deprecate distutils, remove failed experiments such as namespace packaging and path files, ratify entry points...
 
4:59 PM
yeah, packaging is a mess :/
flit publishes
 
wim
yeah, so this fundamental part of a programming language is missing for 20 years now, but hey, at least assignment expressions helps avoid calling len twice*
*ᶦᵗ ᵐᵃʸ ʰᵃᵛᵉ ᵇᵉᵉⁿ ᵖᵒˢˢᶦᵇˡᵉ ᵗᵒ ᵃᵛᵒᶦᵈ ᶜᵃˡˡᶦⁿᵍ ˡᵉⁿ ᵗʷᶦᶜᵉ ʷᶦᵗʰᵒᵘᵗ ᵃˢˢᶦᵍⁿᵐᵉⁿᵗ ᵉˣᵖʳᵉˢˢᶦᵒⁿˢ
ᵖˡᵉᵃˢᵉ ᶜᵒⁿˢᵘˡᵗ ʸᵒᵘʳ ᵈᵒᶜᵗᵒʳ ᵇᵉᶠᵒʳᵉ ᵘˢᶦⁿᵍ ʷᵃˡʳᵘˢ
 
I called my doctor, he said "put the lime in the coconut, drink 'em both together"
 
You know when you have 3 different python installs, and one of them stops working for no reason
almost brings a tear to my eye
 
Did 2.7 break?
 
heh
I wouldn't blame 2.7, but yes one of my 2.7 installs did break
 
5:12 PM
morning cabbage
 
@wim argh. That while loop example...
cries walrus tears
 
@wim yep, that's the other I was thinking of when I said I knew of another. Alas, I also don't know what happened there.
 
5:47 PM
@MisterMiyagi actually that's one of the least atrocious use cases
 
wim
6:13 PM
@MYGz Apparently I cannot delete a question with answers anymore, so I guess I'll have to suffer the herd continuing to downvote it... — wogsland Jan 26 '17 at 13:43
bahahaa
feature or bug?
 
Feature. >0 score answers block Q self-deletion.
community can do them a favour if merited
 
wim
it was a rhetorical
just think it's kind of funny that you can't delete embarrassing questions if somebody correctly answers them and gets an upvote. you have to wear your shame
 
Well if they deserved the upvote then content would be lost, who are you to decide to delete it etc.
probably primarily a defense mechanism against homework deletions and other leeching
 
Yup... the logic is any upvoted answer or more than one non-deleted answer or an accepted answer (but the question asked can just unaccept in that case) blocks question self-deletion
 
@AndrasDeak I seriously dislike how it promotes everyone hacking together the same workaround, instead of someone implementing __iter__. Just one minor version ago, this would have been a horrible anti-pattern.
 
6:26 PM
it would've been a syntax error :P
Which someone would that be and what would it entail?
Making next check the condition or something?
 
yes. like for countless other Iterable objects out there.
 
wim
there are good reasons why you can't do that for file like objects
data might be temporarily unavailable, but the iterator is not actually exhausted
that code is bugged anyway, because it is not handling this case correctly (blocked io)
you might reasonably ask "does that mean file objects break the iterator protocol?" yes, they do.
 
They do?
 
wim
yep
iterators need to continue raising StopIteration repeatedly after the first stop, if they don't do so they're deemed "broken"
 
How do you make a file object not do that?
 
6:36 PM
if a file is written to while it is read, iter(:file) may go from exhausted to non-exhausted
 
wim
you just write more data to the file
 
since it is doing that anyway, where's the problem in doing the same for an iterable version of file.read?
 
wim
there was some problem with it that guido explained pretty well. something to do with EOF signal , I forget the details now
 
That's a no repro for me. Though it can be achieved by calling seek
 
wim
you can't repro that?
>>> f1 = open('/tmp/blah.txt', 'w')
>>> f1.write('x')
1
>>> f1.flush()
>>> f2 = open('/tmp/blah.txt', 'r')
>>> next(f2)
'x'
>>> next(f2)
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
<ipython-input-6-f5ad2eedec0d> in <module>
----> 1 next(f2)

StopIteration:
>>> f1.write('y')
1
>>> f1.flush()
>>> next(f2)
'y'
there's another problem with the walrus while loop example, generally f.read(256) only promises to return at most 256 bytes. So at best the comment "# Loop over fixed length blocks" is misleading, and at worst it's a terrible bug (corrupting data in a pipeline, or crash your program at runtime, and not easy to catch in testing).
 
6:46 PM
@wim Hmm, I can repro that. I guess I forgot to flush? Not sure
 
wim
yeah you probably got misled by line buffering
 
I'm 99% sure I wrote a newline
 
@wim I'm fully convinced that some strict C-like .read with EOF iter could be ill-defined, but that walrus example unambiguously defines some iteration. This can be provided as an iterator. Whether the operation itself is sensible or not, well...
 
wim
@MisterMiyagi Found it - Guido calls bullshit on that.
 
@wim I'm guessing we're going to have to stick with "egg man" for you goo goo g'joob and all that
 
@wim One person's "broken" is another person's "catchable exception". I really dislike iterators and generators that just keep raising StopIteration. Too easy to accidentally reuse a generator, which on subsequent use looks like an empty sequence. I wrote a SafeGenerator wrapper that yields all the items, raises StopIteration, and then raises ExhaustedGeneratorError on all subsequent __next__ calls.
Because I tripped over code like valids = [obj for obj in seq if obj.id in set(sequence_of_validated_ids_that_turned_out_to_be_a_generator)]
The set contained valid ids when checking the first obj, but was empty for all subsequent objs
(I could also have been accused of trying to do too much in the list comp...)
 
@wim I do not see how this applies to iteration. What Guido denies is checking EOF without any IO. An iterating-read by definition does IO.
LBYL iteration doesn't work on files, EAFP iteration does.
 
curious: has anyone actually met Guido (I'll take IRC/other chats as well). I'm curious about his rhetoric when he's off the record
 
wim
7:10 PM
@PaulMcG I'm not taking a side here, I'm quoting the docs on the iterator protocol which literally deem them "broken".
Whether you like the behavior or not, the fact is that they are breaking protocol as documented
this is "practicality beats purity", and all that ...
@inspectorG4dget I've met him several times
nice guy - very down-to-earth, humble and approachable
 
interesting; and good to hear. I might have expected a little differently, given "Bullshit. The EOFness that you're after (according to your own
definition) is not the same as the EOFness of the stdio stream.", specifically the "bullshit" part, which probably comes across more aggressive than he intended
 
wim
he's dutch
they are just direct like that, it's not mean
 
ahh.. I see
 
wim
people should travel more and experience other cultures
so they can keep an open mind and don't get offended so easily, jumping to conclusions
i'm not saying there aren't rude dutch people, but the average dutch person might be considered rude to the uninitiated
 
I do have a lot on my travel wishlist, but I think my problem is more along the lines of putting my personal heros on a pedestal
 
wim
7:20 PM
and the average american might be considered "ingenuine" (is that a word?) to someone dutch, they might mistake an american intention of being tactful as being fake
 
@inspectorG4dget I've traded emails with him, I sent him some notes on PEG and packrat parsing that I've tripped over with pyparsing (like lru_cache cuts your recursion limit in half; and a modest FIFO packrat cache can be 99.9% as effective as a never-purging cache, and much friendlier on the memory usage).
@wim Maybe "disingenuous" but that might still not be what you are shooting for
 
wim
i'm not sure
you know when you meet someone that is perfectly friendly even if they don't like you, so it can be hard to determine if someone is genuinely friendly or just being polite?
 
whether ingenuine is actually a word (accord to SO it isn't), I think it gets the meaning across.
"Not genuine", "Wearing a mask", "Pretending to be something you aren't"
By "pretending to be something you aren't" I mean multiple things:

pretending to be happy when you aren't
pretending to like someone when you don't
etc.
 
7:40 PM
Anyone have a good canonical for copying objects? OP is confused at how to deal with a function that mutates a value when they want to keep a copy of the original around: stackoverflow.com/questions/58961994/…
This one is pretty good regarding the discussion of references, but marked as a dupe to list copying by @Aran-Fey : stackoverflow.com/questions/6793872/…
Maybe that second one can be un-duped and modified so that its not specifically asking about lists? Or maybe a better question can be found in general...
 
I mean, it is an exact duplicate, so I don't see a reason to reopen it
 
wim
7:58 PM
I had not seen that answer, it's a good one stackoverflow.com/a/6794990/674039
 
@wim this is interesting. I've heard similar things from my friends who've lived in Denmark. I kinda like the directness, which strips away the need to interpret an underlying meaning
 
00:00 - 20:0020:00 - 00:00

« first day (3322 days earlier)      last day (1625 days later) »