« first day (2727 days earlier)      last day (2236 days later) » 
00:00 - 20:0020:00 - 00:00

12:00 AM
I might have to take back my star. I readit as being lazy with votes given.
 
@Aran-Fey Wow, finally
@Aran-Fey I can imagine 😂
 
Pffft. As if I could 5 things that deserve to be upvoted out there
 
I barely have python bronze. Gold is a long way off for me.
@Aran-Fey I think you a word
 
I'm working towards the free mug and t-shirt and knowledge
 
I'm just here for the tshirt.
 
12:03 AM
I'll want to get to 200k at some point but it won't be nearly as quick as the first 100k
 
@Code-Apprentice I should hope not :p \O/
 
@Code-Apprentice Yep, I definitely a word. Too late to fix now :/
 
I would have it if it was grammatically correct ;)
 
Who needs grammar?
 
@wim unfortunately none of the docs I have found tell me how to set it in conftest.py You can, though, define pytest_cmdline_preparse(args) in conftest.py. The docs aren't what I'd call crystal clear, though, so you may need to do some ferkling.
See also this issue concerning the deprecation of that function. Quite the little chase around the docs here!
 
12:11 AM
Ferkling? Is that a word?
@Simon it's your move
 
Oh thanks I forgot.
 
It's all good. I often go all day without making any moves in several games I have going
 
@Code-Apprentice "When I use a word," said Humpty ... perhaps I invented it with college buddies back in the 1970s, but it seems sufficiently onomatopoeic thta I've used it ever since them to mean noodling round in the guts of somethiung.
But of course that could just be me.
 
wim
12:36 AM
yeah, I found the deprecated thing, and then found a better way to do what I wanted through the plugin manager
gosh, pytest internals are tough to wade through
now I have a new issue .. the request.config.getoption("--log-format") correctly reflects a --log-format passed in via cmd line, but not one set by setup.cfg file
the one set in setup.cfg does works (can see it has effect in console) but the request.config.getoption("--log-format") is None
aha, parsed configs are in config.option.NAME hmm, nope
 
Wow, anyone hear about what happenedat YouTube today?
 
yup
 
 
1 hour later…
1:51 AM
@Code-Apprentice wht happend
 
2:50 AM
hey guys, i tried posing this on the main SO, but is there any way I can pass instrctions to a rendered pdf response via django to do things like start at max width?
 
3:07 AM
@Prateek All I heard was police responded to "a shooting incident"
 
wim
@user2357112 Does anything important still use the old-skool getitem iteration?
can't think of anything off the top of my head
kinda surprised they didn't remove that from iterator protocol in Python 3 actually
 
3:29 AM
@Prateek there was a shooting. You can google for more details.
 
Very strong on backward compatibility, Python. Does little harm to keep it for objects with no __iter__ method
People may have written their own classes that use it, so it still gets tried when you iterate over such objects
 
3:45 AM
@wim There's plenty of real-life code that defines __getitem__ (with or without __len__) without defining __iter__ (or inheriting collections.abc.Sequence to get it for free). And it can very occasionally be a useful micro-optimization. There's two core devs who insist that it's a vitally important part of Python, and, as far as I can tell, none of the others care either way.
Also, remember that collections.Sequence came quite a few versions after iter, and was basically brand new and untested in 3.0, so the idea that you could just inherit Sequence if you want your old-skool sequences to be iterable didn't go over very well. Plus, while the original proposal would have built Sequence out of Sized, Reversible, and Iterable, providing a way to handle semi-sequences, that was deferred from 3.0 (and only finally made it in for 3.6).
 
wim
Pardon, I should have said "anything standard library" not "anything important"
 
4:02 AM
I think the email package is still full of them. I wouldn't be surprised if tkinter/IDLE, turtle, etc. had some uses. There's a lot of very old code in the stdlib.
Actually, multiprocessing.Array and friends are old-skool, and the list proxy used by Manager explicitly doesn't proxy __iter__ but instead relies on fallback to the old-skool protocol to force iteration to be proxied through __getitem__.
That one even kind of makes sense.
 
wim
Huh, just got a gold . Well thats useless because people usually put anyway.
 
4:20 AM
Why is there no python-1.x tag for "why" questions that go back to before PEPs existed (which usually means before 1.6/2.0)?
 
wim
not enough questions I guess
IIRC newly created tags eventually get killed (by an automated system) if they aren't used enough
 
I wasn't really serious about that. 90% of those questions are worthless, and 90% of the rest, the asker would have no idea that he's asking about Python 1.4 rather than 2.3 or whatever, so it would almost never be helpful.
Of course we're only a few years away from 4.0. The first references to it are already in the docs (because anything deprecated in 3.7 becomes illegal in 4.0 by default). I wonder what will happen to the python-3.x tag after that?
(2.7 will already be out of support by then, but that doesn't mean people will stop asking and answering questions about 2.7 on SO; it just means more and more of them will be useless "How come I can't find a python 2.7 on my distro" cruft.)
 
5:05 AM
cbg all
I've upvoted over 5 questions in a row in tag:python ! Good day for that!
Does anyone have experience using GraphQL with a Python based web framework?
 
5:24 AM
Todat python-dev was discussion the possibility of moving to calendrical versioning, though I'm pleased to say that Guido apparently remains unconvinced of the need to change.
 
5:47 AM
Obviously the next version should just be X. Nobody ever needs a higher number than X. Except maybe XP.
Either that, or just go to integer versions, like RedHat 9, where they made a big marketing deal out of the fact that "You don't need to wait for a .1 version, because there's no such thing as .0 with RedHat"… and then released a 9.1 a few months later anyway.
 
6:27 AM
Morning cbg
 
cbg all
 
6:43 AM
cbg
 
6:59 AM
Why are there so many more upvotes than there used to be for answers that are mostly nonsense and incorrect where they say anything? Are there people who go around giving upvotes out of pity or something?
There are also upvotes on pure "gimme-codes" questions, sometimes on ones where it isn't remotely clear what codes the OP wants us to give. Why?
 
Been wondering about the same. Feels like almost every question gets automatic +1.
 
It's more like 1 in 5 questions seemingly at random. But that's actually even worse. If every question got a free +1, they'd all end up sorting roughly the same, but if some of them arbitrarily get a free +1, when you look for unanswered positive-voted questions, that search doesn't actually do any good.
What do you do with a user who adds a bunch of irrelevant tags, and then openly says "I'm just tagging as much as I can to get help faster"?
Never mind; it turns out that explaining it to him actually worked, for once! That's always nice.
 
7:22 AM
there should be a badge for that, "helped a newbie be a better human being"
 
cbg
 
7:40 AM
cbg
 
 
1 hour later…
8:56 AM
cbg
can I rollback the last "pip install"?
oh well, I did "pip uninstall -r requirements.txt"
it's not a truly revert, but I think it'll work for my case
 
9:47 AM
@abarnert partly because people don't downvote enough
@wim tags only die if they run out of posts. But if anyone runs into a low-item tag they might burninate it. Your 3.x gold is precious; quite often people do forget the main tag. Now you can hammer before retagging \o/
 
@Neoares I tend to use virtualenvironments along with version control so that I can blow away the changes if something goes wrong with package changes
 
@shuttle87 I use virtualenv
precisely, I forget to enter the env before doing the install
that's why I wanted to rollback
 
oh :(
 
so I just did pip uninstall -r requirements.txt
 
Yeah that sucks when that happens
 
10:01 AM
I should've imagined since it asked me for sudo permissions
 
sudo exits the venv anyways, or not?
since it essentially changes the user?
 
no
envs and users have nothing to do
when you run virtualenv to create an environment, it will be just created with you as user
except (I guess) you run virtualenv with sudo
nvm, I misread you
:D
idk if it exits the env... in my case I wasn't even inside
 
10:16 AM
I'm forever doing that with conda - create an env, then install stuff without activating the env first. My root environment looks pretty ugly as a result.
 
do it without permission
so when it asks you for it, you'll know you're installing on root
 
The root environment is the base of the conda installation, and gets used whenever you haven't specifically activated an environment. Nothing to do with superuser
 
oh, that root
I thought you were talking about the actual root
the one
 
In the past I've dumped all my venvs and re-installed conda then re-created them. I wish there were some recipe to restore it. That's why I wrote "my root environment" and not "root's environment".
 
10:46 AM
Cbg
 
11:10 AM
Hello there, I've been following this flask tutorial Flask Tutorial Web Development with Python and I'm pretty new here... So I was wondering if I could add this to the [flask] tag. What is the proper procedure?
 
@pedrez what do you mean by "add to the [flask] tag"? Literally the flask tag wiki info?
 
@AndrasDeak Yep! Exactly The flask tag wiki info
 
You could submit an edit suggestion I believe, but anyway I don't think tutorial links are a good fit for tag wikis.
Tag wikis are to specify what the tag is about and guide usage. Whoever wants to find tutorials should look on google or other search engines.
hmm, that being said, now I see the existing wiki is full of such stuff :/
let me reconsider that
 
Ok, thanks. I'm pretty new to this resource at SO. I'm still forming an opinion about it, but I may say that it was the most handful wiki that I found to meet the flask community
 
OK, apparently there are more than a few tutorials linked in the tag wiki, both free and paid. So I'll let flask-savvy people assess whether this specific instance of a youtube-based tutorial series should be added :)
 
11:18 AM
Thanks!
 
You probably can always suggest an edit to any tag wiki, but then it has to go through peer-review. It's probably best to discuss such changes here first, which is exactly what you did, so let's wait and see :) Sorry for my mixed signals
 
Ok, I will wait. My goal here is actually getting in touch with the community that is still using flask nowadays. I'm really glad If I can find them here
 
Some people here use Flask
 
yup
 
Great, so you anyone here can tell why the official site seems to be so old? I would almost say that it is not been actively developed anymore
Or better saying maintained
 
11:30 AM
@pedrez It uses a standard template for docs (Sphinx), which itself is pretty ancient by now. But I don't see how that makes it "old". If anything, documentation should always be crisp, clear and easy-to-read and navigate.
@pedrez 2000 watchers with 3200+ commits, and you could submit your own PR...
 
Ok, I'm trying to understand and evaluating the framework for a project... It seems easy to get up and running, but I was a little afraid when I checked that the latest release was almost a year ago Flask on Pypi and that the snippets dated mainly from 2012 Official Flask / Snippets.
 
> Snippets are unofficial and unmaintained.

This is an archived view of user-submitted snippets. Despite being hosted on the Flask site, they are not official. No Flask maintainer has curated or checked the snippets for security, correctness, or design.
that explains the snippets ^
 
Ok! You're right
 
Also, github.com/pallets/flask/releases/tag/0.12.2 suggests 558 commits to master since that release, not entirely sure of the release cycle. But again, flask is a micro framework, it doesn't / shouldn't need to make frequent releases (except for critical bugs)
Might be gearing towards a 1.0 release github.com/pallets/flask/milestone/2 (Due by April 9, 2018 97% complete)
 
11:46 AM
yep... it seems to be really robust... Would you suggest any CMS boilerplates? I'm about to start playing with Flask-CMS and Quokka
 
I've been really satisfied with Flask for my own website API usage. It's fast, snappy and keeps itself out of the way, you can easily augment it with your own sauce since it's sooo tidy.
 
Thanks, I can see now... the community is still working on it
 
@pedre
 
@pedrez sorry, I don't have much experience with Flask to suggest a good CMS, someone else might chip in though.
 
@AshishNitinPatil Thanks anyway!
 
11:51 AM
@pedrez, sorry, i'm still getting the hang of SO chat. I've banded with a gang of friends to create a community for artists at www.unhideschool.com. Our website is angular and we use a flask powered API for all the data munching needs.

I don't know if I could recommend Flask with a CMS because flask is soooo bare that you may need a lot of modules to accomplish that.

I don't have much experience in other frameworks but maybe that task is more fit to Django?
 
Wagtail can be a good CMS choice if you go the Django route
 
@Cadu Oh, you're Brazilian! Me too! Nice work! I was looking for a solution that would allow a non-tech team to manage, write, publish and edit... I CMS, especially an admin backend would be a must...
I will evaluate also Wagtail as @shuttle87 suggested.
@shuttle87 thanks!
 
@pedrez Hope that helps!
 
@pedrez While you are evaluating Django CMSs, do use this for the research - djangopackages.org/grids/g/cms
@Cadu well said!
 
12:16 PM
For Flask, the best CMS currently looks to be Quokka, but it's document-based, not SQL-based if that matters. Certainly worth a look, and maintained - the last commit was six days ago.
 
12:33 PM
Hey guys, I'm trying to do some operations on pandas and I might need a bit of guidance. Suppose I have a column A, and in this column, I have 10 differents data (indexed 0 to 9). I want to make certain operations on this data in order to produce more columns (suppose Z and Y here). What functions should I look into ?

I'm thinking about performing my actions on my column A, creating a new df, and use `pd.concat()` between these 2 dataframes.
 
Quokka looks as though it builds CMSes; it's not a CMS itself?
 
12:53 PM
cbg. all
 
@Mr.Zeus Zeus? Wow big
 
???
 
@Mr.Zeus your nick
 
Sorry, but what exactly do you mean by "big"?
 
@Mr.Zeus you have the nick of a greek god
 
1:00 PM
ya, bit of a mythology nerd
 
it was like if my nick was Mr.Yahve
 
Thanks for noticing, you have made my day, no joke.
 
@Mr.Zeus not a greek god, The greek god
@Mr.Zeus np
 
I acutely prefer Poseidon, but Zeus is more marketable, lol
Then again Poseidon is quite markeable, but Mr.Zeus has a nice ring to it.
 
1:38 PM
@Mr.Zeus and with all that lightning gravatar going for you, it's quite good :D
 
\o cbg
 
Is it a good practice to use __init__.py to group modules in a folder together?
For example: I have a folder wfc_helper/gui/ that contains add_job_frame.py and logon_frame.py
Which means my import statement is from wfc_helper.gui.add_job_frame import AddJobFrame.
Can I use init to simplify that import to from wfc_helper.gui import AddJobFrame?
 
@StevenVascellaro If it removes underlying implementation / module-separation details while preserving readability / access for outside usage, then why not?!
 
Sweet, thanks
Wasn't sure if it was Pythonic to do so
 
That's pretty much exactly what __init__.py is for - turning the internal structure of your package into a public api
 
1:48 PM
So would I add import wfc_helper.gui.add_job_frame to init?
Nevermind. It was from wfc_helper.gui.add_job_frame import AddJobFrame
 
@MooingRawr o\
 
@StevenVascellaro kevin'd (that's what I was going to tell)
 
cabbage!
 
@StevenVascellaro It's also useful if you want to protect users from project restructuring. By offering via the init file you can move AddJobFrame to another file and projects that use it don't need to change their import statement, only the one in the project's own init file needs to reflect the move.
 
Is there a way in python to get \the adjacent cell value of a particular cell
in an excel spreadsheet that is
 
1:54 PM
@Arne Right now my project is v0.x, so it's not being shared. I'll be sure to make use of that once I hit v1.x
 
@Anarach I'm sure there is. It would be a pretty terrible excel module if it couldn't do that. It does depend on the library you use though, so we can't really answer your question.
 
I got it .. :-D.. Just when I gave up got It.
 
question Not sure if we can like help delete the question or not but they have secret twitter keys on thier original question which can be seen in the edit history.
 
Even if it's deleted, 10k+ users can still see it
 
Thats a shame then.
I figured as much but wanted to check here to see if there was anything.
 
2:06 PM
The only reasonable thing that OP can do is to get new tokens ASAP
 
Yep, that sucks. Hopefully no one decides to go post on his twitter haha
 
Doesn't flagging help in such questions? I remember I did that once, but don't remember what happened to the post though.
(I assume it gets nuked right after)
 
I flagged it earlier for close. Hopefully I dont get scolded for doing so lol
 
For closing is different, it should be flagged for mod intervention.
I did it anyway (close + mod intervention).
 
Sounds good. I think I choose close. I guess mod intervention sounds correct now that I think about it more. Whoops
 
2:11 PM
np, just remember for next time :)
 
@RobertGrant It should be possible if the devs knew about __rsub__. You can do builtin_type_instance - my_special_class_instance and still get a special class back.
>>> class Fred:
...     def __rsub__(self, other):
...             return "pancakes"
...
>>> 23 - Fred()
'pancakes'
I think I'll try to construct an MCVE.
 
2:29 PM
Recap for those who weren't listening to my problem from sixteen hours ago: while using SqlAlchemy, I found that my query produced different results based on how I was doing arithmetic on a DateTime field within the filter clause. But AFAICT the two approaches should behave the same.
Here is the MCVE . Requires SqlAlchemy, but the script creates the db and such for you.
I notice that the generated pseudo-sql is different:
>>> print(session.query(Record).filter(now - Record.date < datetime.timedelta(hours=8)).statement)
SELECT record.id, record.date
FROM record
WHERE :date_1 - record.date < :param_1
>>>
>>>
>>> print(session.query(Record).filter(Record.date > now - datetime.timedelta(hours=8)).statement)
SELECT record.id, record.date
FROM record
WHERE record.date > :date_1
Maybe the subtraction works differently depending on whether it's done by Python or by the database
Whoops there's a typo in my comments, I meant "within the last eight hours", not "within the last hour". But that doesn't change the substance of the actual problem
maybe it has something to do with the way timedeltas are parameterized. Let's say that hypothetically they get turned into integers representing the number of elapsed milliseconds. Let's also say that when sql subtracts two dates, the result is an integer representing the number of elapsed seconds. This would explain why approach #1 is returning all rows; because one-day-in-seconds is smaller than eight-hours-in-milliseconds.
Approach 2 doesn't send any timedeltas to the db at all, so there's no opportunity for unit mismatches
 
wim
2:50 PM
Origami-Folded Hydrogel Paper Instantly Generates 110 Volts of Electricity ..... do you think I should tell the IEEE that rubbing a balloon on my sweater generates "20,000 Volts of Electricity"?
 
Mile High Cabbage!
 
Antti, I'm kinda envious of you.... you are the closest person to being a physical cloud with all the flying, anyways cbg
Goal for life: to be a cloud and not care about anything :D
 
DSM
So-I-guess-JD's-arm-is-okay cabbage for all.
 
I guess it's time to make a question on the main site. Likelihood of immediate dupe closure: 90%
 
@ZackTarr yup, mod flag -> redact by mod
 
3:05 PM
@AnttiHaapala u're back!
 
ProTip: Flying a lot is considered by many as not_fun
 
I never fly a lot but I prefer the train
 
@AndrasDeak same here
 
wim
flying is fun if it's business class .. not fun if it's economy
 
best travels are by train
 
wim
3:08 PM
and either way you get irradiated big time
 
I've seen more horror movies about trains in Europe than about planes
 
@piRSquared errhhh ...?
 
Yammit @AndyK am I going to have to look them up? Give me a moment (-:
 
@wim I am in business class now
 
@piRSquared that's because poor people who have time for films can only travel by train
 
3:11 PM
@wim meh
 
@WayneWerner lol
 
Does Snowpiercer count as a train horror?
 
@AndrasDeak sci-fi - social genre, I would say
 
Or am I confusing scary and awful again
 
snowpiercer had a bit of soylent green in it, to me
 
3:14 PM
Won in Sci-Fi/Horror category
 
@piRSquared like get out was a horror movie. Lol
 
I grew up laughing at all horror movies. To me, the genre is defined as comedy with blood, ghosts, or both.
I liked "Get Out". My wife hated it.
 
wim
Why do people downvote questions just because they had a bad idea?! Is it like you never had a bad idea ever in your career? I don't get it.
 
I agree
 
wim
These are often perfectly answerable questions. 1) explain why it's a bad idea, and 2) suggest what's a better idea instead 3) collect your rep
 
DSM
3:20 PM
I once managed to shame people in the comments into upvoting a question which got a lot of early unjustified downvotes. I felt pretty good about that.
 
I get it... some people vote with they initial emotional response. It is bad form to do so, but there is nothing to stop it.
 
@piRSquared shaming seems to work
 
wim
This rant was motivated by the smart_import idea. It was on -3 when I saw it ...
seems to have recovered now :)
will try the shaming next time
 
with an undownvote +3 upvotes. Yeah, that seems a reasonable idea to have as a question.
 
wim
member for 9 months, cute animal for profile pic, reasonable problem to solve but lacking the knowledge about how to best approach it ... first question on the site, showed own attempt.. downvoted to oblivion ... kinda bad user experience
 
3:26 PM
looks easily googleable to me
 
The deed is done. Start the stopwatch until someone calls me a buffoon and links to the documentation that clearly explains why I shouldn't be doing it this way
 
@piRSquared I scared the hell of my gf. We were watching it last summer, she was scared but focus on the movie. And here comes a big big fly, that I'm trying to kill it by smashing it between my hands. But of course, it did not happen. But my GF just jumped out of the sofa due to the sound of the clapping, screaming at me and wondering what I was thinking/doing ...
rb folks
 
rbrb @AndyK
 
wim
@Kevin might want to mention your db backend
oh sorry, I see sqlite now
 
@wim upvoted both
 
wim
3:33 PM
@Kevin oooh, I know this one :) and it's a very interesting part of sqlalchemy internals
 
Cool.
 
@Kevin true
 
@DSM I like how we are playing small ball, singles and doubles. I enjoy watching a string of singles and doubles rather than relying on heavy hits.
 
wim
Nice MCVE btw. I will leave this one for someone else since I already rep-capped today, but if it's still answered tomorrow I'll add it.
 
I have only one other engaged reader and I get the impression that he doesn't have sqlalchemy installed, so take your time
 
wim
3:50 PM
if you want a subtle hint, look here
 
@wim, rep-cap yes, tag-points-cap no.
 
wim
I only know about this because I wrote the same bug once, and went spelunking to find sqlalchemy's dirty secret
 
I'm just surprised that I haven't been hammered yet. Do people not usually write queries to find rows within date ranges? I would have thought that was like databases 101
Expected response: 'people do that kind of query all the time, but they do it with the recommended approach, .filter(sqlalchemy.datetime_is_after(Record.date, hours_ago=8)), which you would know if you read more than one and a half pages of documentation'
 
is there a fancy way of getting all combination of several numeric variables?
 
@Mosho itertools.combinations ?
 
4:00 PM
:o
 
DSM
I predict the answer will involve itertools, for certain values of "fancy"..
 
Windows appears to be updating against my wishes, prepare for possible radio silence from me
 
hmm, not sure about combinations
 
DSM
If only there were a way for you to be more specific about your goals. ;-)
 
x = [1,2,3]
y = [4,5,6]
z = [7,8,9]
combination = [(1,4,7), (1,4,8), ... , (3,6,8), (3,6,9]
 
wim
4:02 PM
@Kevin More or less. There is a similar bug where you have to use Model.field.in_([my, list]) instead of Model.field in [my, list]. Unfortunately sqlalchemy has some leaky abstractions.
 
DSM
Looks like you want itertools.product(x, y, z).
 
trying
 
No! Try not! Do or do not. There is no try.
3
 
omnom Rudolf was very tasty
 
wim
4:20 PM
There is a dupe. Took me a while to find it again, because the manifestation of the same issue was through quite different means, but the answer is there. I didn't hammer your question, but left it as a comment.
 
@Mosho this is a cartesian product you are looking for?
 
@shuttle87 yeah, it worked with product
@DSM thanks
 
The connection isn't immediately obvious to me, besides a likely root cause of "sqlalchemy doesn't support that kind of query because it would be really hard to implement". Maybe I need to poke around the issue tracker details.
 
wim
Perhaps it's not a good enough dupe. In the cases that work, you're comparing an InstrumentedAttribute to a datetime. In the cases that don't, you're comparing a BinaryExpression to a datetime.
Perhaps it's not a good enough dupe. In the cases that work, you're comparing an InstrumentedAttribute to a datetime. In the cases that don't, you're comparing a BinaryExpression to a datetime timedelta instance.
 
5:06 PM
vaultah, forgive me if it's been pointed out already, but you've got a little... points at avatar
 
:D
 
@wim Bad idea questions where the OP would know it's a bad idea if they did even the minimal amount of research are worth downvoting because they prove the OP didn't do even the minimal amount of research. Bad idea questions where the OP would only know it's a bad idea if they had a lot of experience in things that aren't directly related to what they're trying to do are not worth downvoting, and that seems to be the case with the question you linked.
I think the problem is that many voters don't do the minimal amount of research to determine which kind of bad idea the question is. Which means we should downvote their downvotes. :)
 
> Is it like you never had a bad idea ever in your career?
I've never had a bad idea in my career. Just ideas the world wasn't ready for.
13
 
DSM
That sounds like something which should be on a mug or a poster.
 
@KevinMGranger "Let's put off the backup until Monday, because we need to use the weekend to run this massive live database migration script" was an idea the world wasn't ready for. Or at least our investors weren't ready for the consequences.
 
5:12 PM
That fits with my philosphy. Who needs backups when you have data nihilism: did you really need that data?
3
 
For a 90s startup, I told the CTO we could save a lot of money on backup tapes because we still haven't worked out a way to recover from backup, so we're just going to go out of business anyway if the servers go down. I was hoping he would take the hint and let me put work in the schedule to build and test and recovery plan, but instead he agreed with me and stopped buying tapes. Fortunately, we went out of business without ever having the servers go down, so I guess he was right.
 
wim
couldn't recover from backup? were you encrypting your backups and then burning the private key or something?
can someone tell me what the title "'twickler" means?
seen here and here
 
twickler, n. One who twickles
 
5:30 PM
@wim: It comes from here.
Short for Softwareentwickler.
 
wim
ah okay.
so not the urban dictionary twickle then.
 
It never is
 
5:46 PM
@wim It wasn't really the backups that were the problem, but the fact that our system assumed distributed consistency but didn't do anything to guarantee it, and if things got off by more than a little bit it would just catastrophically spiral into unrecoverable hell. Restoring the main db from backup would be more than enough to trigger that, but it was hardly the only thing that could. Just having a server update its clock incorrectly meant that server's whole region had to be wiped out…
 
wim
 
@wim I think SO is full of people who upvote things just because "if this sounds too smart for me to understand, it must be a good answer".
 
Is there a sane way of passing a class as a string, or looking up a class from a string?
I was looking over my multi-frame tkinter answer
6
A: Switch between two frames in tkinter

Steven VascellaroTo switch frames in tkinter, destroy the old frame then replace it with your new frame. While Bryan Oakley's frame stacking is a clever solution, it keeps every frame active at once. This has an unintended side effect that lets users select widgets from other frames by pressing Tab. I have modi...

And I realized the frame classes have cyclic-dependencies
 
6:02 PM
Depends on what you mean by "sane". You can always look up anything by name if you have its namespace. For classes, that namespace is typically either the current module's globals, or some other module that you have a reference to, so it's globals()[name] or getattr(othermodule, name).
But I don't think you have a problem in the first place. The dependencies on the other classes are only inside the __init__ methods, not in the class definitions themselves, right? And none of the __init__ methods are going to be called until after all of the classes are defined. And they're all just referencing the class as a normal global. If so, Python's global lookup is intentionally designed to make that just work the way you'd want it to.
Also, you have screenshots in your answer, so… it must run as intended, or you couldn't have gotten those screenshots, right?
 
@abarnert I’m more so running into growing pains in a larger app when my frame classes are in separate files
 
If you need your frames to have names, let the user (programmer) choose those names. I'd give the SampleApp class a dict of {'name': frame_object} that maps those names to frames, a register_frame(name, frame_object) method that adds names/frames to that dict, and change the parameter of the switch_frame method to a name instead of a frame object
 
If you don't have any top-level code besides the class definitions, circular imports aren't a problem. If that doesn't work, you're basically designing a plugin system, which means either a registration mechanism for plugins, or a reflection/discovery mechanism from the plugin manager. But if you have a static set of plugins, you can collapse either one of those down to just a static dict display in the main app.
In other words: import frame1, frame2, frame3 then frames = {'frame1': frame1.Frame1, 'frame2': frame2.Frame2, 'frame3': frame3.Frame3}, and then just pass a reference to frames or a get function or some object that wraps it up down into each frame class's constructor.
 
6:26 PM
@Aran-Fey I like that solution. I believe the accepted answer did something similar
 
6:40 PM
I wish I could contact people who post random facts on the internet on decently reputed sites... (Or well, high google-rating sites)
quora.com/Is-science-a-belief-system the "top" answer there states "yes", which is a directly offensive to anyone indulging in any form of scientific research. I'm almost looking for a way to report it so that gets removed.
 
cbg everyone
 
6:57 PM
Hmm, since FunctionType doesn't have a documented constructor, is it safe to assume that you're not supposed to manually instantiate functions?
 
wim
manually?
you mean dynamically?
 
dynamically, but without exec :P
 
wim
I'm trying to imagine a crazy enough use-case to warrant that
But not coming up with anything
 
Basically I'm trying to rewrite a function's signature. Revisiting this old answer of mine‌​.
 
wim
you could always use the 3-argument version of type and __call__
 
7:07 PM
not sure what that means
 
If you want to construct a function object manually, you can, but you'd be getting deep into implementation-specific, version-specific, highly fiddly details.
 
FunctionType is documented in the interactive interpreter, but not in the docs. Which I always took to mean that using it for exploratory purposes is fine, but using it for deployed code is bad.
 
Well, I have a working solution. I could get a slightly better solution if I could dynamically instantiate a function, but it's not the end of the world if I can't. I'll just fall back to using the solution I have right now.
 
Or, at least, if you use it in deployed code, you should wrap it up in something that has big scary warnings about which versions of which interpreters it works with, a la byteplay.
Function objects are mutable, so you can always just make an arbitrary function and change all of its attributes (which are documented) to point at the ones you want, but that seems more hacky than constructing one on the fly…
 
wim
@Aran-Fey it means do your magic with a callable class instead
functions are supposed to be simple def things
 
7:12 PM
@wim The fun part is trying to get your __init__ to set up __closure__ without grubbing through frames. :) But yeah, hopefully his working solution isn't expected to work with closure cells, so…
 
wim
to make the code object you gonna need compile and exec anyway
if there's a way to do that without exec or eval (or a monkeypatch "cheat"), then it's above my pay grade
 
I think I'll just post a question on SO
 
If you're going to call FunctionType manually, you might as well call CodeType manually.
 
But the CodeType constructor has soooo many parameters, it's scary
 
I'm not sure what the problem at hand is, but… Modifying/creating function objects out of existing code objects can definitely be useful. For binding in different argument default values, for example.
 
7:17 PM
ooga booga booga
 
Problem is, I'm not sure how to modify the function's code to get a functioning function (pun intended) with a different signature as the result
 
If you want to monkey with code objects, on the other hand, you definitely want to use byteplay or bytecode (depending on whether you want a slightly dated/barely-maintained library or a close-but-not-ready-for-primetime one).
What exactly do you mean by different signature? Are you just trying to do something like partial, or just replacing the annotations? Or do you want to dig into the guts so you can do something like replacing one of the embedded globals with a parameter that can be passed in without building a wrapper function? (I think I have code for that one on github that nobody should ever use…)
For a lot of "how do I do this without a wrapper" problems (like flipping arguments, or partialing from the right, etc.), there is a fun answer, but the real answer is "you don't, just write a wrapper".
 
Basically something like this:
@add_parameter('x')
def foo():
    print(x)

foo(5) # output: 5
Actually the case at hand is a bit simpler than that; the function doesn't have access to a non-existant parameter x like that. In my case, it's more about changing parameter values than adding new parameters
@kwargs_to_args
def foo(*args):
    print(*args)

foo(a=1) # output: 1
^ something like that
 
The body of the first one's code is going to get compiled to look up x as a global, before your decorator sees it. But you still don't have to modify the bytecode; just create a wrapper function with a custom copy of globals that inserts the x value there. Sure, there are major differences you can see if you reflect on the objects, but normal behavior will be the same as if you monkeyed with the bytecode object.
 
wim
hmm, who should get my +450 for bounty
the low rep guy who answered first, and correctly?
or the high rep guy who answered later but wrote a long detailed answer
 
7:29 PM
Definitely Seifert, 'cause he's the only one with sources
 
wim
Yeah, I think with the bug history and digging up that unit test he wins
 
I think he should get it because of the lengthy explanation (complete) he gave.
 
Alright, dinner time. Taking a temporary break from thinking about functions and code objects and closures and globals
 
For that kwargs_to_args, what
rule is it supposed to be applying?
 
wim
The "Another Reason ?" part is kinda bogus
but the rest is gold
 
7:33 PM
@abarnert basically it takes the kwargs and calls the function with *kwargs.values() instead
 
In random order?
 
doesn't matter, it's just an example anyway :P
 
wim
LOL @ the docstring of CodeType
 
Anyway, whatever the answer is, what part of it is not trivial to do with a wrapper function?
 
wim
@abarnert Right. This is total XY problem.
 
7:35 PM
The problem with the wrapper function is that it shows up in tracebacks, and I don't like that. In my case, I have to create and compile the wrapper function dynamically, so whenever an exception is thrown you get these ugly "In file <string>, line 2" stack frames included in the traceback
 
wim
if you're trying to do jacked up stuff you should have a jacked up traceback
feature not a bug :P
 
Okay, let me rephrase: I'm just curious how to do it :P
 
If I get a TypeError about the wrong number of parameters, I wouldn't be very happy with a traceback that hides the way the parameters are getting shuffled around…
For "curious about how to do it", go download byteplay or bytecode and start playing with the examples. Some of them are better motivated, some are equally silly toy examples but at least they have working code. There are also blog posts by me, Victor Stinner, and a few other people on fun things to do with byteplay, but it might be better to experiment on your own first, and then see what others have done.
 
This is what I get for trying to explain the reason behind it :/ Next time I'll just say "I'm curious" from the start.
 
You do want to eventually learn how to build up the params to pass to CodeType, and everything all the way down from there except maybe how to build an lnotab from scratch (that's just horrible), but having a helper that does most of the stuff you don't care about means you can learn that stuff later and start playing now.
 
7:41 PM
That module looks ancient. Does it even work with python 3?
 
@davidism the links to the example code in your tutorial seem to be broken?
 
Oh, there's a fork for python 3.
 
The original one does not work with 3.x, or even 2.6. I believe the best fork for 3.5 is serprex's. I don't know if there's a 3.6 version.
 
serprex links to github.com/vstinner/bytecode in his readme
 
Yes, that's the bytecode I was mentioning that's newer but maybe not quite ready for prime time.
 
7:43 PM
cbg friends
 
Victor researched all of the aborted "redesign byteplay from scratch" projects (including mine) before starting it, and he actually finished the redesign instead of getting lazy.
The one part he hadn't finished designing last time I checked was the part to let you write "bytecode assembly"; he wanted to rewrite my cpyasm frontend to use the guts of ZR's byteasm, but decided to punt on that until post-1.0.
 
wim
anyone have real-world example of Obsoletes-Dist metadata?
 
That moment when you lose 15 rep cause OP decides to unaccept your answer to accept a 0 upvote answer... funny thing is the question was 2 years ago :\
 
wim
Is the 0 upvote answer better than yours?
sometimes superior answers appear later because of language developments, and sit there on 0 votes, and could do with an accept mark...
 
Reached 200 answers. I'm having a rest now...
 
wim
7:56 PM
@Aran-Fey can't argue with that! :D
 
@wim I don't think so? and the answer that got accepted was a few minutes after mine... two years ago lol... and OP accepted mine after both was posted so yeah.... :D who knows
 
00:00 - 20:0020:00 - 00:00

« first day (2727 days earlier)      last day (2236 days later) »