« first day (2174 days earlier)      last day (2791 days later) » 

5:00 PM
"I'm getting this odd error every time I don't enter an even number."
 
what's odd about it? it's an odd exception
Great..But what exception is it? It's odd.
Yes I got that...but
 
In reality I'm actually writing a rotate function that can only rotate in multiples of ninety.
 
ParityError
 
RightError "I'm getting the right error every time I don't enter a multiple of 90 degrees."
 
Make the argument an integer that 90 is multiplied by?
Then just check if it's negative
 
5:02 PM
def rotate(half_radians):
Or, no, that doesn't work
Why do I keep thinking there are two radians in a circle
 
because there are two pi
and pi ~ 1
 
"Why do you think that's right?" "It's not right." "You just said it was."
 
why not reduce parameters so that every integer is valid?
multiples of 90 -> use n for n*90
if only even n is OK, use multiples of 180 -> use n for n*180, any integer n
 
I'll just make an enum with ninety=0, one_eighty = 1, ... problem solved
 
RTFMException
 
5:05 PM
that should be a cv reason
 
wim
>>> d = {}
Object {}
>>> d[999999999999999999999] = 'hello'
"hello"
>>> d[1000000000000000000000]
"hello"
js y u so crazy!
 
Cus its js
 
is it because the key is a float?
 
js needs no reason
 
What should come first when designing an app, the db schema or the classes?
 
wim
5:12 PM
this language is so broken
I've been lumped with some ajax stuff at work, can't wait to get back to python's relative sanity again ..
 
Python spoiled us.
 
@TomasZubiri the idea
 
That's bound to get me into a design phase that lasts a month.
 
The real answer is "it doesn't matter, and use SQLAlchemy".
 
Is it similar to Djangos model thingy?
 
user559633
5:17 PM
@TomasZubiri The code that needs the db schema.
 
user559633
You rarely know what your DB needs to handle until it's time to ask something persistent
 
You are right Tristan.
 
he always is
 
Trightstan we call him
 
5:21 PM
The first words of my post ;)
 
hehe
All I want is to persist my objects and MAYBE have fast searches. I don't want to care about databases and queries and thingimajjigies. Is SQLAlchemy for me?
 
user559633
I wouldn't say that I'm always right and am willing to believe that I'm mostly wrong. On the topic of "when should I build $X", I've cleared enough forests for houses that never ended up getting built to make decent suggestions.
 
user559633
@TomasZubiri Based on "object...I don't want to care about databases and queries and thingimajjigies", SQLAlchemy or some ORM is definitely a good idea.
 
user559633
What's the purpose of the "App"? Work/school/personal learning?
 
is it tristan, or tristan's helmet that is full of wisdom here. This is very confusing.
 
5:32 PM
Side project for my CV, for my future new job.
 
That's good. A coder who codes even when free is a good coder. :)
 
user559633
@TomasZubiri If it's a webapp and going on your CV, just get something visual up and only focus on learning how the parts work.
 
:) But lunch break's over now:(
 
user559633
Which is to say, unless you want to go into design, don't worry about ~~pretty~~ or UX.
 
my $0.02, once you get sqlalchemy tied in and working, for the ongoing incremental cost of adding the model in sqlalchemy gets me much goodness in return.
 
5:35 PM
Sold
I didn't even think about the visual part yet.
I'm making an app that gets tournament results from different APIs.
Identifies which players are the same accross different sites/tournaments, and assigns them ELO scores and rankings.
It feels like it's a common pattern of a problem.
 
user559633
Yeah, this is pretty common ETL + interface pattern.
 
Interview done.
 
@Ffisegydd were you the viewer?
 
I was one of them.
 
nice
did they all fall before the mighty?
 
user559633
5:43 PM
Interviewer? I hardly knew her (that's why we brought her in for a question/answer session)
 
They didn't survive the process.
 
user559633
Oh no :(
 
was it a pythonic test?
 
user559633
Okay, your first reaction is going to be to panic and call the police. You're going to want to fight that urge.
 
5:46 PM
 
Who upvoted the dupe >:(
 
@Kevin ?
nhipe.png
what's the hipe about?
 
oooh, QC's old identicon
web.archive usually works...
 
@DSM hey tell me your level #1 and level #2 questions :P Im curious still (I told mine (find name in list, and then gcd (after explaining very well what GCD is))
 
5:49 PM
)
 
Today's theme is "doing things the hard way"
Hmm I guess I should directly ping @QuestionC if I want him to know I reverse-engineered his av
 
lol fizzy im curious about your programming questions they failed as well ... im shocked at the poor quality of the candidates we get most of the time...(see my coding questions above)
 
(For the record, I can't actually comment on any of the interview, so anything I say is a joke)
 
@AndrasDeak I tried it on http://chat.stackoverflow.com/users/3294441/questionc but I got "Page cannot be displayed due to robots.txt."
 
well, you need the main user
that's what web archive has scraped, usually
 
5:52 PM
Kay.
 
0
Q: Difference between (import module_name) and (from module_name import *)

Ahmed NezarWhats is the difference between import module_name and from module_name import *. As I read, both imports all functions from the module

Not a duplicate
I was going to answer:
There will be a difference in how you call functions from that module.

import module_name
module_name.function()

from module_name import *
function()
 
user559633
@TomasZubiri Is a duplicate. Read the duplicate.
 
128-pixel version there
 
Mine's bigger B-)
 
5:53 PM
It's how you use it
I prefer natural
 
:-P
 
@TomasZubiri a) your answer doesn't even describe what's going on, and b) is already covered by the dupe.
 
But the question is different.....
 
I'll agree that the dupe could use a broader explanation of how * works in relation to _ and __all__, but there's likely another dupe that covers that too.
 
user559633
@TomasZubiri But if the answers solve the question...
 
5:56 PM
Only the last part of the question answers it.
 
user559633
I understand that I'm arguing that the asker should actually bother to read something, which is silly, because if that was a reality, he/she would have read the documentation.
 
62
A: `from ... import` vs `import .`

sapamMany people have already explained about import vs from, so I want to try to explain a bit more under the hood, where the actual difference lies. First of all, let me explain exactly what the basic import statements do. import X Imports the module X, and creates a reference to that module i...

This covers all the points that has been asked for.
 
user559633
from low_quality_question import *
 
@TomasZubiri for future reference, regardless of the status of this dupe, your first reaction to a fundamental question like that should be to find a dupe, not to post a brief answer.
 
@BhargavRao So do the python docs
 
user559633
5:58 PM
There's easier ways to get rep if that was your motivation
 
@TomasZubiri Yes. We closed it as a dupe as the target covers the required answer. If we were to write RTFM, the docs has them all, then the post is too broad.
 
Found an actual dupe.
http://stackoverflow.com/questions/12270954/difference-between-import-x-and-from-x-import
So in the end it doesn't even matter
 
2 mins ago, by davidism
@TomasZubiri for future reference, regardless of the status of this dupe, your first reaction to a fundamental question like that should be to find a dupe, not to post a brief answer.
4 mins ago, by davidism
I'll agree that the dupe could use a broader explanation of how * works in relation to _ and __all__, but there's likely another dupe that covers that too.
 
♪ All we are is dust in the wind ♪
 
Aren't these two the same?
 
6:03 PM
1 minute difference by same user called sapam, almost "spam":P
minor changes to avoid auto-dupe flag
 
Why wasn't the moderator auto flag raised there?
 
no chance that they're different, 2-page long answers 1 minute apart
 
@AndrasDeak Nope, Look at the first revision
 
maybe it was raised, and dismissed
if the questions are not dupable, dupe answers can be called for
the second one has also been Mortensen'd
 
@AndrasDeak Nope, If they are not dupes, then the user must tailor his answer according to the post.
89
Q: Is it acceptable to add a duplicate answer to several questions?

Won'tLet's say there is a user who has found a satisfactory answer to a common question asked on Stack Overflow (or other Stack Exchange website). This answer may be a snippet of code, or an addon, or a framework, or something else. Is it acceptable for this user to formulate an answer for one que...

 
6:04 PM
that's a lost of rep gathered
 
> Already many people explain about `import` vs `from`, even i wanna try to explain bit more under the hood, where are all the places it got changes:
> Already many people explained about `import` vs `from`, even i wanna try to explain bit more under the hood, where are all the places it got changes:
note "explain" vs "explained" in the first line
I'd say intentional shady behaviour to avoid autoflag
 
Anyone raising a mod flag?
 
you
I expect it to be declined, anyway:P But good luck:)
sources: 1 vs 2
 
okie dokie, it's been around for a while
 
6:08 PM
Yeah, I'll flag it. I've got a canned flag description for these cases.
Oh, And I hit 10k flags today. ;)
 
congrats:)
 
Thanks
 
your arm must be tired
Is it bad if I consider upvotes to be buffer-for-downvoting-answers?
 
Hmm, Did not get ya.
 
which part?:)
 
6:14 PM
@davidism stackoverflow.com/questions/39754711/… Seems you've got an admirer.
 
@AndrasDeak The buffer-for-downvoting-answers part.
Downvote based on content. Nothing else. Even if a poor question has a good answer, upvote the answer.
 
If you're saying "is it bad to upvote a currently-negative question that I think deserves a score of zero?" yeah it kind of violates the principles of democracy by making chronologically later votes count more than earlier ones, in effect
 
@BhargavRao of course. But it still costs me rep:D
I answer so rarely nowadays that I can see my rep decrease
 
@MorganThrapp :-|
 
I just meant that after a few upvotes I can finally downvote in peace:P
 
6:16 PM
> Thanks #Davidism for saying NO
 
The effect is more prominent on sites where you can rate 0-5 stars. People commenting "this deserves three stars, but it's at two, so I voted five" are applying disproportionate influence over the rating compared to the people that voted what they thought it was really worth
 
Sounds like an anti-drug PSA.
 
@MorganThrapp took me a while to figure out that I need to look at the revision history:)
 
@AndrasDeak Oh, yeah, it got edited out.
 
@AndrasDeak Haha, Gotcha. Yeah, that's not an issue
 
user559633
6:17 PM
Hashtag Davidism
 
People counter-voting piss me off too, just to be clear
 
@tristan #Hashtag
 
user559633
//Hashtag #davidism
 
Oh I see you're saying "is it bad to think of 'points I got for being upvoted' as 'ammunition to use while downvoting others'?" I guess that's a different subject entirely
 
everybody should play hash tag and chill
 
user559633
6:18 PM
nethack and chill
 
davidism.hash_tagger.
 
@Kevin yeah, but not from a moral point of view, more like state of general cynism:D
 
Also, if anyone wants to burn some close votes, that question could definitely use it.
 
I've been fully saturated in cynicism W.R.T. SO since about 40k rep, so I can't say
 
oh, right
I'd love to comment "@jonrsharpe can you explain How To Ask a good question?", but even I can tell that it would be more annoying than amusing
 
6:21 PM
I'm staying out of this one, next time he can hashtag everyone else too.
 
Nethack's a fun game. One time I went source diving through it and found an easter egg that apparently nobody had ever discussed online before: if you polymorph into a xorn and travel to the very edge of the map and apply a stethoscope to the impenetrable wall, it says "you hear the sound of faint typing" implying that it's the fourth wall
 
aww:)
 
For what it's worth I think you chose the wrong close reason, since there is an mcve. Unclear would have been better, since it's unclear why they're doing that.
 
Yeah, the original revision didn't have one. It probably should've been unclear after that.
 
Nethack has lots of silly messages that only occur in weirdly rare circumstances. Like if you turn into a metal-eating monster and eat a trident, it says "That was pure chewing satisfaction", a reference to Trident Gum.
 
6:27 PM
Speaking of net*. anyone play netrunner? I haven't and it looks interesting.
 
@idjaw I keep meaning to get into it. It looks like a good mix of MTG and not being so broke I live in a cardboard box.
I'm starting to get sick of Hearthstone, and I need a new TCG.
 
DSM
Another day, another unsuccessful interview. Kids, LEARN SOME PYTHON
 
As in, interviewing someone or being interviewed?
 
Hey, I'm looking for a job if you want to offer me relocation. ;)
 
@DSM my condolences.
 
6:36 PM
A visa (from the Latin charta visa, meaning "paper which has been seen") is a conditional authorization granted by a country (typically to a foreigner) to enter and temporarily remain within, or to leave that country. Visas typically include limits on the duration of the foreigner's stay, territory within the country they may enter, the dates they may enter, or the number of permitted visits. Visas are associated with the request for permission to enter a country and thus are, in some countries, distinct from actual formal permission for an alien to enter and remain in the country. In each instance...
omg no
 
@DSM is it that they just don't know python, or that they don't know programming and they don't know Python?
 
DSM
@corvid: you were lucky enough to miss my rant the other day, I guess. We're interviewing interns.
 
@DSM my son writes Python and more: github.com/MageJohn
19, keen lad.
 
what's hard about it? Easy to find web dev interns at least
 
DSM
@WayneWerner: yesterday's was both; today's was Python in particular.
 
6:36 PM
German passport is now better than Finnish :/
 
I want an automation bot to go about doing X Y Z things on the interface it needs to work with. At any point the interface can throw an error message that will disturb the automation bot's ability to recognize images it is referencing. In order to overcome this I felt that if I could have two scripts running in parallel but know the other's state (( error found, error script lets bot script know to respond A B C ways to clear the error )) ... Is "Threading" what I am looking for?
 
How come? Finnish is finnished?
 
@MartijnPieters ah your son is 19 already :D
 
DSM
@corvid: we're not hiring for web dev, though, we're hiring [mystery number-related field] + Python interns.
 
Numbers, there's your problem
 
6:37 PM
I was guessing lower teens
 
user559633
If I guess the number, do I win the job?
 
user559633
 
@MartijnPieters How is he at Pass the Shuriken?
 
DSM
@tristan: sometimes one has to seize authority. So I declare: yes.
 
user559633
1!
 
6:39 PM
@DSM so they're like "no one will actually notice that I cannot program in Python, now how hard can it be, could learn it in a day if I am chosen"
 
DSM
(quickly adds some lines) Ah, sorry, tristan, the number was 4. We'll contact you if future opportunities develop.
 
user559633
:[ But I'm meant to be the developer...
 
... a strategy that they realize was doomed right from start when the Data Science Man starts the interview
 
DSM
@AnttiHaapala: today's candidate said that she had led a Django project. Possibly in the sense of managed, but not in the sense of coded, it turns out.
 
I'd want to be employed in a place where I could actually fail the interview...
 
6:40 PM
@davidism I'm scared to play it with him.
 
Ugliest non-joke code I wrote this month: print(zip(*sorted(zip(sorted(b), sorted(enumerate(a), key=lambda x:x[1])), key=lambda x: x[1][0]))[0])
 
user559633
@AnttiHaapala Some sort of motivational speaker position, then?
 
user559633
@Kevin To find out who wrote that, I'd go to the parking lot and look for a new car that still has its temporary plates.
 
I could apply for a position at Despair Inc... but I guess I wouldn't fail
 
Are they competitors with Feel Good, Inc. ?
 
6:43 PM
they're the world-famous seller of demotivational posters
 
@Kevin lambda lambda lambda lambda sorted sorted, zip zip oooh it's a zip
 
""I don't want to work at any job that would have me as an employee" ~ Groucho Marx" ~ Morgan Thrapp
 
@KevinMGranger ^ I had that by my desk ~10 years ago at my then-workplace, US-based company.
 
Threading, indeed it works :D
 
I worked with a guy who had this framed on his desk:
 
6:45 PM
A broken jpg?
 
yes
A nice frame, too. Like you'd expect a picture of his family or something, and then you see that
 
It took me more time to realize what's going on than I'd care to admit.
 
Same, actually
 
@Kevin So why not just sort by a then? zip(*sorted(zip(a, b)))[1]
 
@KevinMGranger I wonder what the Mentor Graphics GM thought about me on his visit to Oulu :P
 
6:47 PM
@MartijnPieters I think the OP said he tried that and it didn't give him what he wanted
 
@Kevin found the question..
 
( this is the question in question, to be clear)
 
DSM
Are we trying to beat Kevin after-the-fact?
 
@Kevin aww thanks
 
I don't know how that anchor link got there <_<
 
6:49 PM
@AndrasDeak so was it the same kevin?
or different
 
OP is another Kevin, or a very badly disguised sock puppet
 
@IljaEverilä changed his username after there was another Ilja...
 
Different, barring Fight-Club-esque scenarios
 
even his identicon has a similar shade
 
DSM
We have the two regular Kevins (KMS and KMG), then there's pseudo-Kevin (NY Kevin, maybe?) and now ANOTHER Kevin? That's too many.
 
6:50 PM
@AnttiHaapala though perhaps shouldn't have, as it provided some hilarity
 
can't find tht question...
 
@Kevin: right, see what I misunderstood.
 
I suspect there's an easier way to do this but the critical thinking portion of my brain shut down once I got the checkmark.
 
lol:D
thanks
 
6:53 PM
lol that khajvah then
 
DSM
@khajvah is a lot wittier than he gets credit for.
 
Everyone is either witty or intentionally doing ironic non-witty shtick which is itself a witty act. This is what I choose to believe.
 
in reality we're all dumbasses masquerading as fake-dumb geniuses
 
Aaaand I've reached semantic satiation on "witty" in only three uses.
 
@ŁukaszRogalski please read this before sending users to code review:)
 
7:00 PM
btw,
 
though I see you're active there
 
support for variable annotations was completed in PyCharm
 
but from what I gather (from outside CR), the question in that form would not be well-received
@AnttiHaapala you successfully stuck it to the man
 
... will be in the next release
 
Rhubarb guys, See ya tomorrow
 
7:02 PM
Rbrb, BR.
 
rbrb
 
asdfasfddsaf
SHITSHITSHIT
 
pgettext not in Python 3.6
 
Was it supposed to be?
 
7:05 PM
no, it should've been in in python 2.6 or so...
but no one cares for important things
 
Is pgettext important?
 
yes
for localization
 
What percentage of Python users would agree that pgettext is important?
Remember that the community is full of rubes like myself.
 
I've seen it come up in Flask-Babel.
They need a workaround to support plural versions of strings.
 
7:11 PM
pgettext('asking about gender', 'Sex?')
ngettext is the plural
 
Oh, nevermind then, what's p?
 
now every single solution: flask-babel, zope translationstring etc, need to NIH
pgettext is for adding context.
 
P for Context, very sensible.
 
user559633
P_articular_ iirc
 
(P)lease_provide_context
 
7:14 PM
@Kevin rube? Is that the name of a Ruby spy wearing a Python coat?
 
In this context it's defined as "Americans who forget that not everyone speaks American"
 
The ‘p’ in ‘pgettext’ stands for “particular”: pgettext fetches a particular translation of the msgid.
 
user559633
I think I read about it in the translation of PO files/gnu translation
 
@tristan you did
 
Is that for where the same phrase has different meanings in different places? I'm super out of my depth with i18n.
 
7:15 PM
and I didn't know that before
yes
I need to program everything all the time with i18n in mind
 
It's something I really wish I understood, but I haven't found a good resource yet.
 
user559633
I'm pretty out of depth with i18n/l<whatever>n.
 
user559633
@davidism I'll do a write-up when I go back into it in earnest in ~2 months
 
I get extra confused with Flask-Babel, WTForms, and Flask-WTF because it doesn't seem like the three interact at all.
 
user559633
Context will be a web application that supports english/russian.
 
7:17 PM
WTForms knows nothing about Flask-Babel, Flask-WTF has strings beyond WTForms and adds support for Flask-Babel, but doesn't translate it's own strings, etc. Can't figure out how groups of dependencies find out what to do.
 
@davidism they probably don't
 
It occurs to me that my users are probably much more international than the average American programmer's, but our client is basically like "lol well they'll just have to learn to read English then"
 
user559633
AFAIK, the relationship there would be Flask-WTF calls a function with the language+intent that's handled by babel, and it passes the response of that function call on to the user
 
It's very circuitous. I took a day to try to map out how Babel, Flask-Babel, Flask-WTF, WTForms, and gettext are interacting and couldn't figure it out.
 
Does it take a day for the gravicon to update in chat?
 
7:21 PM
A writeup would be pretty cool.
@QuestionC yeah, blame caching.
 
@davidism you forgot jinja :P
and jinja i18n
 
user559633
messages_data = {"Greeting": {"en": "Hello!", "ru": "привет"}}
return (messages_data["Greeting"]["en"])
 
@Kevin No. I hit F12 and attempted to find the link but just got an icon for gravatar.com
 
user559633
i think is a very simplified/naive kind-of-idea of what it's doing
 
very...
 
7:23 PM
Unless copying from tristran counts as me figuruing it out.
 
gettext uses the actual English language message as the id
thus:
 
user559633
where the message is hashed and on miss it returns english, no?
 
{"en": {"Hello": "Hello"}, 'ru': {"Hello": "привет"}, 'vi': {"Hello": "Xin chào!"}}
 
I bet internationalization gets hard when you're dynamically forming messages like "{verb} the {adjective} {noun}" and it turns out that some languages don't put the parts of speech in that particular order
 
This was all inspired by me trying to figure out what to do with all the i18n PRs on WTForms and Flask-WTF. Couldn't figure out what was going on, so couldn't justify merging them yet.
 
7:24 PM
return messages_data.get(locale, {}).get(message, message)
 
user559633
Yeah, keyed on the language to support loading new languages
 
@Kevin well, I do that myself, I use format strings
 
Beautiful day out, working from the yard. Someone upwind from me is smoking. Gross.
 
user559633
@WayneWerner Go upwind of him and start shooting up. Show him who's boss.
 
_('{user} archived the project {project}.')
@Kevin ^I store the msgid, and the metadata of the actors, objects in the DB, the users get the notifications in their locale.
 
7:29 PM
137
A: What is the rule for adjective order?

tchristI am reminded of how J.R.R. Tolkien’s mother once famously corrected him at a very early age when he said ‘a green great dragon’. She told him that it had to be ‘a great green dragon’, but when he asked her why, she couldn’t answer, thereby starting him down the road of puzzling over matters lin...

 
user559633
I currently do a (intent='archived_project', [{'user': ..., 'project': ...}]) approach.
 
@tristan I assume you mean heroin and not firearms.
Academic, though, because I have neither
 
@tristan that's what I do
I just simplified it a bit :D
 
@AnttiHaapala I really thought you were replying to chat.stackoverflow.com/transcript/message/33152358#33152358 for a moment
 
@tristan
@register
class ProjectArchived(NotificationType):
    classes = 'project'
    message = _('{changer} archived the project {project}.')
 
7:34 PM
anybody got a hammer?
 
the classname is the one that is saved...
 
user559633
Where classes='project' is the context?
 
cbg
 
@AndrasDeak I wouldn't consider that a dupe
 
somebody else doesn't either, wait a sec
 
7:38 PM
 
they have a:3 and want {"a": 3}. It's close, but ast.literal_eval wouldn't be what they want at all
 
they're right
I didn't check the dupe's answer
already 2 answers, hooray
 
they really just need something like dict(thing.split() for thing in text.split(',')) I think.
 
one by Antti:D
 
I feel like garbage collection removes generators that aren't referenced by anything, but for some reason I'm full of doubt all of a sudden. =_=;
 
7:39 PM
trolly Antti
 
user559633
@Ffisegydd "Although the ASA is a non-statutory body (which means it can’t interpret or enforce legislation), it does have the power to have advertisements which breach its code of advertising practice removed—a process which of course prevents them from being used again. " seems like kind of a pointless action as the game has already run its course
 
bah, I give up on that question
 
True, but amusing nonetheless.
 
user559633
Yeah, an amusing gesture.
 
@Augusta I'm pretty sure they do get removed.
 
7:44 PM
@AndrasDeak hey mine was fun :D
it asked for shortest, not safest :D
 
def f():
    try:
        for i in range(10):
            yield i
    finally:
        print "Argh, I'm being destroyed!"

def g():
    print "Creating generator."
    x = f()
    print "Iterating generator."
    next(x)
    print "removing reference to generator."
    del x
    print "removed."

g()
 
I imagine they do, too, but I was wondering what would happen if you had a generator set to a class attribute, but something reassigns the attr while the generator is running. Does the generator just sit there, waiting for an update that can't come?
 
Creating generator.
Iterating generator.
removing reference to generator.
Argh, I'm being destroyed!
removed.
 
class MyClass(object):
    def __init__(self):
        self.gen = self._make_gen(10)
    def _make_gen(self, lapse):
        n = 0
        while n < lapse:
            n += 1
            yield
            if n > 8:
                self.gen = None
        while True:
            yield
    def update(self):
        if self.gen:
            self.gen.next()
More like that
The generator never actually stops iterating, it's just never mentioned again. I should assume that this gets cleaned.
It's not like it refers back to itself or something.
 
Hmm, I wonder if weakref would be useful here for testing that empirically...
 
7:49 PM
I'd go back and look at my old gc experiments but I wasn't sure if there wasn't someone here who could laugh at me and tell me what's really going on first. :D
 
Well, that was fun
import ast
text = 'a:1,b:2'
print({val[0]: ast.literal_eval(val[1]) for val in (_.split(':') for _ in text.split(','))})
 
x = MyClass()
gen_ref = weakref.ref(x.gen)
for i in range(20):
    x.update()
    print(gen_ref)
 
@Ffisegydd is this blown out of proportion? Or are there legitimate shenanigans at work here
 
that's probably the most robust solution that doesn't require something extra wonky
 
What do the following parse into? a:b:1,c:2 a,b:1,c:3 a:b:1,c:2davidism 21 secs ago
 
7:50 PM
That wonky is certainly enough wonky for me
 
This prints eight-ish weakrefs to a generator object, followed by twelve-ish dead weakrefs. Conclusion: generators do get collected when they have no referents, even if they haven't finished yielding all their possible values.
 
@davidism Excellent question ;)
 
The problem is that it's either under-specified or non-regular, which means you can't just split stuff. Should be closed as unclear until the op explains what they actually want.
This smells like an XY problem.
 
Incidentally, does anyone know if finally is guaranteed to occur during garbage collection? I didn't see any indication either way when I glanced through the docs.
 
I refuse to remove my answer!
I will get my 2 rep back through deletion!
 
7:54 PM
Also a':1,b:2 and a}:1,b:2
 
I've got half a mind to ask on the main site.
 
I don't know, but I'm pretty sure the only time it doesn't is with a crash or os._exit.
 
@Kevin Cool, cheers! :D
 
Yeah I expect nothing is truly guaranteed for particularly abrupt program terminations
 
Mm, just so.
Probably I should just run the generator out instead.
 
7:58 PM
@Kevin What kind of finally? I'm not sure where you would get into a finally condition unless you're talking about a generator that has a finally and the generator gets collected?
 
@WayneWerner Yeah, a finally inside a generator being collected is exactly what I had in mind.
 
The thing is, in my example, the generator never stops iterating, so it never raises StopIteration.
Is that a problem..? I suppose not?
I've never been super-de-duper clear on finally. :s
 
Same, I've only used them like twice in "serious" code
 

« first day (2174 days earlier)      last day (2791 days later) »