« first day (3034 days earlier)      last day (2138 days later) » 
01:00 - 20:0020:00 - 00:00

01:32
evening cabbage
01:58
cbg all
Anyone here decent with SQL? Trying to do something that I feel like might be possible with some sort of join, but not really sure.
 
4 hours later…
05:40
cbg
I remember reading a quote about how some programmers measure their productivity by lines of code: "Lines of code tell you as much about your program as ..." (can't seem to remember the rest, and I've forgotten the source). Anyone help me out?
 
1 hour later…
06:47
cbg
07:45
cbg
08:23
cbg
how does loc[[i]] even run?
is i some weird slicing type?
 
2 hours later…
10:33
@towc numpy arrays and relatives support sequences as indices. It's called advanced indexing.
So it's iloc that's non-trivial
10:55
huh
11:12
@poke how do you feel about a gitlab answer to this famous git question? Is there any general stance in about hosting-site-specific things?
cbg
I have a list of 10 common words extracted from nltk.FreqDist. Now, I want to get the bigrams for these words in a body of text. How would I do that?
I'm pretty sure there's a thing called nltk.bigrams, is that relevant? :P
Yes, I've been looking into that. But haven't found a way to get bigrams for common words
in my text
Eg. common words = ['phone', 'chat']
sorry, I don't actually know what ngrams are, I just thought this sounds like something that nltk should know out of the box
I take it you've thoroughly read the documentation?
I want to find the combinations of text that have these words.
Yes, I've been reading the docs but wanted to find a quicker way :D
11:22
OK
the choice to make .endswith accept tuples and strings, but not lists, also seems weird
anything you can think about there?
there's no defending that
welp
12:23
Any good source to learn about python pandas by the way?
maybe it's trying to encourage people to use generator comprehensions, and not use endswith as a data structure thing?
@towc I don't think so. If I had to guess it's a historical thing that stuck. There might be a lukewarm discussion on a python mailing list or the bug tracker...
if anything, lists were supposed to be the homogeneous containers (according to Guido in 2003), so it's lists that should work in that context, not tuples (of course both should work)
@sudoCoder have you seen the list of tutorials in the pandas docs?
@towc someone suggested tuples and it was done bugs.python.org/issue1491485
so the blame is shifted to tuple of exceptions and tuple of types in isinstance
yay
2
A: Why doesn't str.endswith allow the "suffix" parameter to be a list?

Martijn PietersThe API simply echoes isinstance() and except (Exception1, Exception2) syntax, which both only accept tuples as well. See the original feature request. There is no reason the code couldn't support arbitrary, non-string iterables (yielding strings). You could file a feature request in the Python...

Martijn seems to have reached the same conclusion
Sorry, misread your comment. I looked through the Python source history, and isinstance has only supported tuples for eons. I don't see a current reason not to support a list as well. I'd say it is historical. — Martijn Pieters ♦ Jan 27 '14 at 17:23
also an answer says that Guido was against having other iterables in startswith
@AndrasDeak that was before I read Guido's motivation.
12:30
ah, OK
> All in all I hope you will give up your push for this feature. It just
doesn't seem all that important, and you really just move the
inconsistency to a different place (special-casing strings instead of
tuples).
jpp
jpp
stackoverflow.com/questions/54534477/… unclear / too broad / no mcve / duplicate, take your pick - becoming a trend in :(
It's a positive-feedback loop, the more these get answered the more people are happy asking (or "non-asking") them.
to be fair theres nothing you can do to stop people from asking questions like those. more often than not, its more of a "first time on site/never saw other questions" kind of deal. I wouldn't say its a positive feedback loop.
jpp
jpp
@ParitoshSingh, The problem is they are encouraged if they see similar questions answered... yes, many of these are new, but if their first poor question is answered to their satisfaction, they can only be encouraged to the same next time.
The latter half of the sentence i agree with 100%
even though the former doesn't convince me
jpp
jpp
Yeh, nobody can prove they've seen other questions on SO, that's an arbitrary remark. But for a single user I think it's a fair assumption. (If X gives me successful result, keep doing X.)
12:45
aye, agreed
I got a weird problem. My local repo is somehow desynced from my github. When I try to git pull it tells me up to date, but github displays some files different than from what I have in my local repo. How can this be?
both github and me are on master
nvm nvm my b. Was looking at the wrong folder^^ same files one for cpu one for gpu
@ParitoshSingh anecdotal, but I've had askers tell me "but there are other similar questions upvoted here" when I told them their question was a bad fit
huh, interesting. that surprises me
of course it's always the effortless lazy ones, not the honest clueless
13:50
Today I am annoyed by regex-based solutions to the question "how do I specify custom indentation for my json dump?"
A week or two ago there was a "how do I replace blocks of newline with a single newline" question and one of the answers was a regex pattern. If it weren't for a link to regex101.com it wouldn't have even hinted at the pattern being a regular expression or whatever
re.sub(r',\s*"', ',\n"', s) works on the OP's sample input, sure... But bad things happen if the input contains a string that ends with a comma followed by a space
@AndrasDeak Troublesome when an answer doesn't have fully replicatable code. The other day I pointed out that an answer resulted in a NameError and the poster replied "oh, you need to replace i with j. But that's obvious, you should have been able to figure that out yourself"
wow, that's a terrible attitude for help-seeker
those are good motivators for silent downvotes and close votes
In fact I did figure that out myself within three seconds of reading the answer. I was just trying to give him an opportunity to absolve himself from my impending downvote. Spoilers: he did not absolve himself.
The answer was also conceptually wrong on top of that, but I digress
13:59
Oh, answer. Just downvotes then.
Now I'm thinking about robust ways to implement custom json formatting... What's a good way to check whether an object is a list of numbers? isinstance(obj, list) and all(isinstance(x, int) or isinstance(x, float) for x in obj) works, but it's hardly concise. Is there something in typing that could do this?
isinstance(x, (int, float))?
I'm holding out for, like, List[Number].isinstance(obj)
>>> isinstance([1,2,3], typing.List[int])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programming\Python 3.6\lib\typing.py", line 1161, in __instancecheck__
    return issubclass(instance.__class__, self)
  File "C:\Programming\Python 3.6\lib\typing.py", line 1147, in __subclasscheck__
    raise TypeError("Parameterized generics cannot be used with class "
TypeError: Parameterized generics cannot be used with class or instance checks
:-(
that's in line with "typing doesn't actually do anything useful"
I know, I just don't like it.
14:17
hello guys
@AndrasDeak isinstance(x, numbers.Number) for great ABC justice.
I need some help with python3 and printing in win32
@amcgregor thing.Thang
Is anyone up to the challenge?
I'll pass
14:19
If this is in reference to your most recent question, I'm looking at it now. I'll probably leave comments over there if I have anything.
if you have any experience with this
please share
thank you
Alas, George, I generate PDFs and punt printing to the users. :|
@Kevin yes it is about this question
@amcgregor I used to do this too but now I want them to choose between auto-printing and by hand pressing print later
but in windows it is a pain in the ass if you need to change margins, orientation etc.
@GeorgeSp Have you examined timgolden.me.uk/python/win32_how_do_i/print.html yet? community.spiceworks.com/topic/… uses a similar ShellExecute invocation, with answers pointing towards some Python packages like MSWinPrint.
14:25
yes I did, ShellExecute is not working in my system. the way I am currently trying to do it is by printing before I convert my image to pdf
This reminds me of a question I answered a long time ago, which went something like "how can I resize this image so that it is as large as possible while still fitting within a box of known size?". You can't do it just by looking at one dimension of the image and box. If you stretch the image so it's as tall as possible, it might become too wide; and vice versa. So you'd need something like
to now it came down to a margins and maximum size without change aspect ratio problem
MSWinPrint looks good, but very low level. You effectively issue GDI calls to a print surface. :/
y_ratio = box_height / img_height
x_ratio = box_width / img_width
final_ratio = min(x_ratio, y_ratio)
Sam
Sam
Cbg - do you guys have any hosting recommendations for a flask built backend?
14:28
@Kevin and what is box_height/width ? I mean what is it representing
In your case, the size of the paper not counting margins.
@Sam I'm biased by being a very satisfied customer, but I'm a fan of Heroku-alike services like Clever-Cloud.com w/ GitHub integration. (Deploy on push.) Flask apps enjoy minimum scaler sizes, thus minimum costs. Also popular and very Python-friendly is WebFaction, which I also used for quite some time before migrating to more cloud-y services.
Sam
Sam
@amcgregor hey - yeah I've seen Heroku is a popular choice
... But now I see that you're already doing that in your code, at ratios = [1.0 * printable_area[0] / bmp.size[0], 1.0 * printable_area[1] / bmp.size[1]] and scale = min(ratios). So I guess I'm not suggesting anything new.
Oh well.
I only know Heroku from ruby-on-rails things
14:30
@Sam Heroku- alike. ;) Clever-Cloud happen to have a DC just down the street from me here in Montréal, Canada, which is important for my clients. (HR departments of corporations.)
I notice that code isn't in the existing answer, though. Maybe there's some way to integrate it in there.
I'm being intentionally vague here because I don't know a dang thing about physical printers
a while back pythonanywhere.com was a thing, I don't know if that's applicable and what it's like
I never did any web stuff so I only see these things as a curiosity
y probably there is, I did not really get what he was doing because I do not know pywin32 in depth yet
Sam
Sam
@AndrasDeak They do offer a free version so maybe I'll try that.. I can always port
@Sam As a brief note, my main work codebase is currently consuming ~€4.80/day (large instances), my CMS apps pulling data from that main app ~€0.15/day each (pico), allowing each client site to independently scale as a consequence. Yay for microframeworks and < 256MB of RAM consumption. \o/
Sam
Sam
14:36
Are you using Clever Cloud?
@Sam Aye.
Sam
Sam
just chatting with their customer support team now.
@Sam They were also quite slick getting a custom MongoDB cluster set up locally for us. (Their shared MongoDB cluster is in France. Would have made things a touch too long-distance for me. ;)
Sam
Sam
Oh they dont have ElasticSearch
@Sam They allow arbitrary docker images (such as the official elasticsearch-docker one) to be utilized. So, they do, indirectly, support ElasticSearch.
Sam
Sam
14:43
The only thing I see wrong with them (only wrong for myself) is that they are a full platform rather than AWS (architecture) so it's probably better for learning purposes to get with something like AWS/Heroku?
Their container infrastructure appears to be Heroku-compatible, at least for the add-on API. AWS bare would be infinitely lower level than the application containers offered by CC. (I used to run my own infrastructure and sysop, but like e-mail services, my time was better spent higher-level away from the nitty gritty details of infrastructure.)
Key difference for me: my job is to solve client problems, not trying to convince machines to be stable and reliable. (← being a key contributing factor to my use of MacOS instead of Linux for personal and development machines. I'm not paying myself to sysop hardware that should Just Work™. ;)
cbg
was wondering why we dont have the option to flag for migration to codereview for Questions like these link
Try searching meta for "migrate code review".
It's pretty much for the reason that people think that questions like the one you linked are in good condition to be migrated.
I think code review chat has a bot that warns them about people recommending them in comments as well.
14:51
tl;dr "please don't dump your crap here, SO"
\o cbg
haha, that tl;dr is amusing
Yesterday I saw a question like "hey guys, what do you think of my code? I'm 14 btw". I think we should have a Stack Overflow Junior site that automatically receives any question where the OP tells us how old they are.
I cringe when I think of what questions I may have asked at 14
14 and perl
Around that time I probably would have been making posts like "I can't get OpenGL to render a triangle, can someone provide example code please?"
14:57
At 14, I had only seen a computer at a friends house.
then again we may have been much better at 14, had we access to SO
@AndrasDeak I once asked my math teacher in grade school if he could grade/verify a Newtonian physics proof (object launched at an angle of X, from a height of Y, how far/max speed/etc.) and he laughed, replying, "I also teach P.E." I wish I had SO back then.
Determining the correct magic incantations necessary to draw a triangle to the screen is legitimately difficult and I have much pity for 14!Kevin
I'd still close his post though.
@amcgregor ouch
14:59
Well all that ^^ has accomplished is me thinking of the triforce and Zelda theme music playing in my head
here the traditional coupling is workshop + computers
Related follow-up years later: high school maths teacher couldn't teach me matrix math when I started investigating 3D engine design and display projection. Schooling was very disheartening.
we didn't learn any matrix stuff in high school, then again my teacher probably knows how it works
I had assumed it was part of the university curriculum the teacher supposedly had been exposed to. ;)
PE teachers round here tend to moonlight only as health teachers. Because the adult that laughs when you get struck by a dodgeball is the most qualified individual to explain what a verguba is
15:02
Our PE teachers taught mathematics.
y'all live in weird countries
Sad reality
PE/math seems about as outlandish as PE/health I suppose
it's worse
PE might assume some knowledge about anatomy and stuff like that
how not to break your ankle is close to health
"helping my students win at dodgeball by teaching them to precompute the trajectory of the ball using a frictionless model" sounds less realistic
Physical Education is almost synonymous with health education
15:04
(and not just because friction is real)
One thing I wish they had introduced in grades 6-9: logarithms. Counting in a "times N" kind-of way is absolutely eye-opening.
I saw a license plate yesterday "logrthm" and considering my "pirr" license plate, I felt a bond
our PE teachers were basically bullies and discipline incharges...which was basically bullies.
Health was mostly oriented towards drug awareness and safe sex, so knowing how to avoid broken ankles hopefully wouldn't be a big part of the curriculum
A thirty second lecture on the dangers of silk sheets ought to suffice
The warning signs of: velour.
user4893937
15:14
guys so I messed a little with my /etc/profile and it seems like I made an error
user4893937
a syntax error
why are you messing with /etc/profile?
shouldn't you be messing with ~/.profile instead?
user4893937
install java
This is the Python room.
user4893937
15:15
and the profile seems to be a python file
No it's not.
sorry if dumb question, what is /etc/profile
user4893937
a linux file
@ParitoshSingh linux shell thing
user4893937
15:16
where should I be then?
java or somewhere on chat.SE perhaps
if its related to Java, there's a java room in stackoverflow chatrooms
I don't think this is really about java though
user4893937
its not a java file mate, nyways thanks
good luck
15:22
I'm trying to load sequential files but I want to not hardcode it:
`for i in range (0,5):
control_%s %(i)= np.loadtxt('/content/gdrive/My Drive/control_%s.txt'%(i))` This is obviously wrong but something like this should be possible right?
put them in a list or a dict, don't generate variable names on the fly
yes, but don't do it. the thing on the left, make it into a dictionary or a list.
but i need these files to be seperate
they will be
and they will be
lol
15:24
Oh, I'll look into it
one_of_your_files = list_of_files[i]
i almost want to say jinx but its always 1 or two words off
Also instead of range(0,5) use range(5). And instead of percent-formatting consider using str.format or f-strings.
15:37
@AndrasDeak I generally don’t like hoster-specific answers for Git questions, considering that it’s a decentralized VCS, so anything that uses a centralized service is already non-optimal. It’s okay if the question is clearly about (a) hoster, but I would avoid it for general Git questions.
thanks, that was my suspicion
The question is not really that good anyway considering all the “this is my take” answers..
But it does contain a few useful things
Yeah, I've taken a few tips from there. Lot of opinionated garbage, but the fundamentals for using something useful in native git is there
Hi guys
Anybody can help me with this question stackoverflow.com/questions/54537559/…
maybe you have good idea about that and help me out, thanks in advance . have a nice day
@AndrasDeak did you just down-vote question?
15:54
not yet but I can do that if you wish
if you want to help me please neglect it
@Mario welcome, please read our room rules: sopython.com/chatroom. In particular, don't post your recent questions in chat, and if you do, expect them to be voted on if someone wants to.
Hi okey
got it
 
1 hour later…
16:58
Getting line number of return statement is getting some negative attention, but it's actually kind of an interesting question, albeit one without much practical utility
Maybe you could do something with bdb.
coverage somehow does it
Hi Joran, thanks for your reply. My application allows users to enter business rules in Python and let them test them. As my application is not able to step through code, I want to find a way to get the returned line number so that I can highlight the corresponding line on the GUI editor — user2136168 22 secs ago
so I guess it is possible somehow
might indeed by a debugger XY problem
17:01
why would you want to do it?
At the heart of the execution phase is a Python trace function. This is a function that the Python interpreter invokes for each line executed in a program. Coverage.py implements a trace function that records each file and line number as it is executed.
it is interesting, but it's like asking "how do I find out how much of the self-closing door I opened before leaving"
there you go
17:03
huh, I thought there was only pdb
also, possibly an actually impossible problem, unless context is restricted, or the python interpreter is modified
ah, pdb makes use of bdb
now I'm curious what the difference is between bdb.set_trace() and pdb.set_trace(); for some reason I've only seen the latter
I expect the answer to be "nothing" or "the pdb shell you drop into has more features"
wim
wim
@MartijnPieters So, it was not a lot of work and I actually didn't need to touch the notebooks at all. github.com/mjpieters/adventofcode/pull/1/files I don't know how to write the entry-points in pipenv though - maybe pipenv just doesn't support entry-points?
@wim Pipenv does not manage package metadata.
@AndrasDeak My guess is that Bdb is an abstract-ish base class which doesn't do much at all when you call set_trace. Then pdb would have a concrete implementation of Bdb that actually does things.
17:13
Pipenv is there to manage dependencies for deployment or development, nothing more. It is a better pyenv / virtualenv / requirements.txt combo.
Put differently: Pipenv is great for managing applications. setup.py is there for libraries. See pipenv.readthedocs.io/en/latest/advanced/#pipfile-vs-setup-py
Evidence for my guess: I just tried bdb.Bdb().set_trace() and nothing happened.
Once a setup.py has been defined, add it to Pipenv with pipenv install -e .. Any dependencies specified in setup.py can be moved out of Pipenvs top-level list.
@Kevin thanks
@Kevin yes, Bdb is the base debugger implementation, Pdb the UI layer, so to speak.
I posted a Bdb-based answer, but I'm a little unsatisfied because it gives a not entirely intuitive answer if the function finishes executing without encountering an explicit return statement. For example, If I delete the final return from foo, then x.runcall(foo, 3) reports that elif(i==2): is the "return line"
I mean, that is the final line that executes, effectively, so... I don't know what answer I expect to get, but. Argh.
17:19
@Kevin note that bdb.Bdb().set_trace() does do something, but not in a interactive Python prompt with nothing to trace.
implicit returns in a string-returning function are the devil's playthings
Yeah.
@Kevin: ah, I see the question. Bdb is rather a lot of overkill!
is overkill not a given with that question?
Pudb is beautiful, Borland-esque overkill. >:P
Though every time debuggers pop up in any conversation anywhere, I keep thinking of that WSGI app remote step debugger, but can never remember the name. Nouns hate me.
17:26
pudb is awesome
i read that as pubg for a second and almost spilled my drink.
A ha! wdb!
@Kevin On the final line confusion, there's weirdness going on behind-the-scenes as to why that is. Without an explicit return, functions technically end with byte code to push a None and ret that, but the only actual source lines it could reference are the last line of the function, whatever that may be, even if it doesn't make sense.
we just need to hack the bytecode and change the None to something that raises, and then laugh at the confusing error message
@MartijnPieters Hmm, true. I think I'll play around with settrace and see how that treats me.
17:39
@AndrasDeak You joke, but I actually do have a problem involving mangling raised exception line numbers… (also storing them efficiently, though without love, that Q may have been auto-culled.)
At first glance, Bdb is a little more batteries-included, because I can easily trace exactly and only* the function call I'm interested in, and because it passes the frame as an argument to user_return
Neither of these being 100% essential, but they're nice to have out of the box
(*assuming I don't mind that the functions called by the traced function are also being traced)
Oh, I misread the settrace documentation. It also passes in the frame object.
So it's just runcall that's the killer feature
@Kevin: see my answer, where I use a context manager instead.
And I disable line-level tracing in Python 3.7, making it faster for larger functions.
Bdb is great, but there are several layers of dispatch in between the traced code and user_return(), and it won't disable line-tracing. So those dispatches fire for every single line executed.
Nice work. I was just wondering how this might be made context-managery.
 
1 hour later…
18:53
Hey guys, I am writing a Django app where I will serve files (PDF-files), around 2TB and a user will simply choose a file and download. I have a PostgreSQL DB where I store the pdf metadata, but now I need to store the file itself. I was wondering which service would fit best for me to store (cheap, fast). I was looking at AWS S3, but I am not sure if that's the best service that fits my needs. Any recommendation?
I use Digital Ocean because it is cheaper than AWS. And, of course, they offer the sort of block storage you are looking for.
Yeah, but their block storage per month is way too much for a 2TB of data that gets accessed.. a few times a week
Backblaze's B2 storage may be more cost-effective for your needs.
wim
wim
@MartijnPieters Yeah, I've heard this (in Kenneth's PyCon talk), but in practice the separation is not so clear cut. Python packages can be a mix of libraries and application (e.g. some public api/library but also some console script entry points), there is no clear line to delineate the two. Pipenv's story is not convincing, I much prefer poetry.
On S3, my own dataset would cost me ~half a million per month. B2: $122/mo for that dataset, if I were to cloud it.
19:00
@amcgregor yeah! I was just checking them out. 10 bucks a month sounds like a good deal
I wonder how fast is the retrivel, since there will be one retrievel on each pdf download
Is it bad to prefer poetry because it's a nice name?
thanks buddy!
wim
wim
@RobertGrant Yes
How can the price disparity be $499,878? We must be comparing apples to oranges.
19:05
@Dodge Drop 30 TiB into price calculators, be amazed. ;^P
I believe you, but how is it done for $122?
@wim feels good to get a serious answer to a joke question. Refreshing.
Storage Pods.
And staff dedicated to "shucking" drives. If external drives + enclosures are cheaper, they'll use 'em and extract the drives from them. During shortages, they've had to do that.
Wow that is really cool
wim
wim
Seems poetry has a greater scope than pipenv, so it's not exactly apples and oranges. Poetry has the lockfile also, but it does manage the packaging metadata and stuff aswell.
19:07
I've always wanted to build one of the pods myself, have never actually gotten the gumption to do it. XD Smacks of effort, man.
@Dodge also, they XOR everyone's data over the top of each other. They only actually have a single bit of storage.
@RobertGrant I like that idea, actually. Reminds me of my "reliable database servers with no permanent storage or moving parts, RTO/RPO of one minute" deployment strategy (after AWS ate our EBS volumes that one year… I stopped using EBS volumes!)
@RobertGrant it's also secure against attacks that way
19:24
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'dict'
if I had a dime everytime I made that mistake...
context?
I'm adding another nickel to the "SO post asking how to validate email addresses using a rule that will incorrectly filter out valid email addresses" jar
@ParitoshSingh ax.plot(xdata, ydata, label='foo' **plot_options)
aah i see
Sam
Sam
Any of you guys use Python Flask with AWS Elastic Beanstalk? I've just tried deploying my github code to my instance and I'm getting an error:
Your WSGIPath refers to a file that does not exist.
19:40
no experience with AWS beanstalk im afraid. but did you build a wsgi file that links to your flask app?
Sam
Sam
Nope. Not even sure I know what a wsgi file is
ah np. This should help you flask.pocoo.org/docs/1.0/deploying
ah, theres an aws beanstalk link there too
Sam
Sam
ahh thanks ill take a read
wsgi in particular, the tl;dr goes like this: flask ships with a server for development, and its nice and all for development, but ideally a server should be built for serving, and python flask/any server side script should be communicating to the server through a gateway.
the link or gateway can be done via wsgi among other options, and thus flask no longer is responsible as the server, it is managed by either apache, or some other dedicated server which is better at serving
(and better security, configurations and some other cool things)
@wim Pipenv doesn't claim there is a clear deliniation. You can use Pipenv for the application aspect, setup.py for the library aspect. The library underpinning an applicatioon.
wim
wim
19:55
@MartijnPieters but then you have duplication of information in both Pipfile and setup.py. ugly.
01:00 - 20:0020:00 - 00:00

« first day (3034 days earlier)      last day (2138 days later) »