« first day (3624 days earlier)      last day (1318 days later) » 

12:21 AM
So, anything new in the Python language?
 
 
5 hours later…
5:19 AM
Hey guys i have found a question which is the duplicate of another question, so can i post the questions link here?, because i cannot mark it as duplicate
 
5:46 AM
database question: sqlalchemy has something like db.create_all() that checks if table exists and if not then creates it. But I feel it'll always be a waste of a call after the first run. Is it smarter to just comment that out and tell the user to just import db and db.create_all() on first run?
I'm trying to work with postgresql but I doubt that adds anything
 
6:30 AM
hi
 
6:44 AM
@aadibajpai first run of what?
and hello, MHDaouas :)
@aadibajpai the reason that I ask is that you can use alembic as a separate tool to get the database up to date and it's a separate tool with its own CLI
 
can someone help me with this code where I m getting a syntax error as expected?I know I w'd get a syntax error but I don't know what the correct syntax w'd be
for i, j in zip([pressure_head, velocity_head], [45, 90])   error in this line
 
Add a : at the end?
 
use an IDE, please
 
oh god , I m making damn silly mistakes. I was using jupyter
thanks,
 
6:53 AM
Bernoulli weeps when you don't use an IDE
 
lol, true
 
cbg, anyone here used zeep library? is it maintained well compared to suds? or should I just stick with using requests as found in some SO answers?
 
hey, can I ask? if I know PHP (good, lets say like 5 years of experience), to what extend does it help me in knowing / learning Python (from the start); in % ?
maybe even 8 years of experience in PHP, lets say; and extend it to Python / Django as two separate things; what % there already?
 
I don't know PHP very well, but I think beyond loops and ifs there isn't a whole lot in common with python... maybe dicts I guess
 
ok, thanks a lot; so more like a different thing all together?
 
7:05 AM
@AndyRogers the language and syntax you need to learn from scratch, but the high-level concepts algos, data structures, MVC framework, etc. remain the same
 
so like 50% there?
 
kinda
 
thanks a lot!
good luck!
 
BTW there will definitely be some unlearning to do along with the learning
 
@roganjosh of the application, like if someone else wants to set it up they'll be creating the db just once
@roganjosh I've heard of alembic but I think it's mainly to update schema iirc
 
7:23 AM
Isn't that technically what create_all() does?
 
7:39 AM
45
Q: We found a [which] - may we burninate it?

EJoshuaS - Reinstate MonicaThe which tag is rather vaguely described as: The selection of a set of data from another set. This tag is very ambiguous, and could refer to several different technologies with equal validity. The vast majority of questions are about R, but there are also Python, JavaScript, and Unix questions...

haha that was fun :D
 
My ancestors figured all this out long ago. Throw it in some water; if it drowns, it wasn't a witch. If it floats, it's a witch; burninate it
 
there are comments.
"Test whether it floats or syncs. – andrewjames 9 hours ago"
 
Oh, I was kevin'd and they were up-market on the puns. I shall diminish and go into the West
 
@roganjosh and remain as mutton curry.
 
Ungoliant needs something better to munch on
 
 
1 hour later…
9:14 AM
Actually, scratch that. It's just unclear. They probably have a string type column
 
9:44 AM
@Praveen I think you can flag as a duplicate which would put the question in the close vote queue. But sure, you can link it here if it's python, but put something in the mesage other than the link so it doesn't onebox
 
10:03 AM
Where is using exec with locals useful? I can't understand why you'd want to do this
 
To dynamically create variables, of course.
 
I'm assuming that comment is tongue-in-cheek, but the exact pattern has come up again. I'm guessing it comes from another language?
 
It could also come from the same angle as the people asking whether there is a limit to how often type(type(...)) must be called on an arbitrary expression until the result is type.
There's a 25% chance that these questions lead to informed, useful wisdom, and a 90% chance that the OP will resort to name calling.
 
Eh, I can stir the pot on pretty much anything; I'm not too fussed about the specific question. I'm just curious that this "pattern" doesn't seem to come around by chance, so I'm wondering if there's a "if you need to frobnicate this bizbaz"-type reason for it being needed
 
@roganjosh Hm, I suspect using exec with locals is the XY to the XY to the XY to the XY of the OP.
@roganjosh Invite them to chat for Extended Questioning?
 
10:22 AM
I would, but I'm afraid I have an appointment to eat my own head so I'll have to pass
 
 
1 hour later…
11:30 AM
@roganjosh just a special case of variable variables
Yamming yam mobile firefox
 
:P I share the sentiment. I was very confused just then :P
 
People meeting a dynamic language eventually find eval and mistake its versatility for usefulness
 
It seems an awfully deep rabbit hole to be going down and researching along the way to get to the same conclusion each time
Or, maybe it's just the result of a random walk and I'm making a pattern out of it because other questions don't make it that far :)
 
12:01 PM
Mobile FF won't even load gmail for me now. What a piece of yam.
 
stackoverflow.com/q/63935126/4799172 needs clarity. If you can see the deleted answers; put it out of its misery, please
Thanks
 
1:01 PM
My boss: Yeaaaah, I'm going to have to go ahead and ask you to work all day Saturday, mmkaaay? That would be greeeaaat.
Me (to myself): But... but... I was told that I'd have this weekend off and I was going to attend the Room 6 hangout to meet people I've been chatting online with for years. I should burn this place down.
Me (to boss): Okay, and thank you.
 
I mean, you always have the option you thought of
 
I suppose. Lemme think about it...
 
1:39 PM
@smci reopened
morning cabbages, all!
shower thought (or just "thought", I don't really know what a shower thought is): I often pop into Room6 chat to find a *-pls tag, which I click on. But enough time has passed that it no longer requires action from me. The exercise ends up having wasted maybe 10sec of my time, which is pretty inconsequential in the grand scheme of things (or even the tall scheme of things)
But scaling this up, I wonder if it'd make sense to auto-remove/hide/retagAsDone such requests so that nobody needs to click on it anymore. Thoughts?
 
One potential issue I can see is that posts can't be edited after a certain (relatively short) amount of time.
 
Lol, you're suggesting they might make a new feature for chat? Give up. I try to follow up my cv-pls tags where possible to say that they have been completed, but there's no reasonable way to do it when there's on-going chat, and there never will be
 
I also kinda like looking at closed questions, mostly out of morbid curiosity, I guess.
 
how about a bot that regularly reposts *-pls messages? Nope! that'd get annoying AF real fast
how about a bot that moves *-pls posts to rotating knives after the action has been done? now it looks like we're hiding it. Also, Matt would no longer be able to follow up
 
@inspectorG4dget I am that bot
Did I pass the Turing test yet?
 
1:51 PM
@roganjosh and therein lies proof that the Turing Test has been passed
Great minds, Josh!
 
:P
 
@MattDMo aww mann! Any chance you could join in from work, assuming that not many other folks are going to be there?
 
I'm hoping to, and I may not even have to stay until noon. I'll be working outside, so I'll get Google Meet set up on my iPad...
@inspectorG4dget I actually read through The Rotating Knives periodically, for the same reason :)
 
curious: which city are you in? You mentioned noon - so I know were on the same timezone
 
Near Boston. I live up near the NH border with Mass, but I'll be working in Quincy Saturday.
 
1:57 PM
right on! Damn I wish I knew that when I was in Boston many months ago. Would have totally loved to grab a b33r
 
There's always next time. You're up in Canadia, eh?
 
The one thing I remember about Boston was not being able to find a bar. I had a 4 hour wait at the airport, so I headed into the city... I couldn't tell you how far I dragged my suitcase around looking for a bar
 
Strange, there are a bunch downtown, but I guess it depends where you ended up. We like our beer and sports here.
And by we I mean they. I like beer, but Boston sports are hit or miss for me.
 
I saw them re-enacting the tea-party and there were a few smarter-looking places there, and I stank from being on two flights so I didn't really wanna haul myself in there
 
And you probably would have paid $10+ for a Bud Light
(typical would be $4-$5 at a standard neighborhood joint)
 
2:04 PM
@MattDMo aye. Greetings from hockeyland. I'm in Ottawa (the capital city), which gives me the right to say that all other hockey teams are sens-less
 
good one :)
I've never been to Eastern Canada except for a very brief afternoon visit to Quebec, just because we were in the neighborhood and we could (pre-9/11). I've been to Banff in Alberta several times for conferences.
 
Banff is gorgeous (haven't actually been, myself). Quebec is lovely, especially if you go to Quebec City, etc. If you're ever up in Calgary in the summer, definitely try to check out the Stampede
 
I've only been there in winter, but it's still gorgeous then. We'd fly into Calgary then drive across the plain to Banff, with the mountains getting bigger and bigger in front of you. Around here, the biggest "mountains" are ~4000 ft, out there you get 8-10000+. Very nice...
 
I think I need to plan a ski trip there
 
2:25 PM
That would be a suicide trip for me - I haven't skied in nearly 20 years...
 
cbg, all, bugrit
 
@inspectorG4dget Thanks
 
@roganjosh the SOCVR people have a cv-pls manager userscript, just sayin
 
It can't overrule the 2 min edit rule, though?
My point there was that I'm not gonna write something like "^^^^^ closed, thanks". That's futile anyway because they'd already have clicked it
If there was a way to strikethrough posthumous tags, I'd use it religiously, though. But, lol, chat features
 
3:01 PM
@roganjosh ah, OK, I misread context then, sorry
not much point in following up with those posts I think
 
5 demerits to websites that disable copy-paste for "confirm your password:" fields. Typing passwords is Keepass' job, not mine.
I demand the right to shoot myself in the foot. I am an American, after all.
 
The right to foot arms?
 
I'm pretty sure their right mentions bears
 
And every other combination of appendages, yes
 
3:17 PM
@MattDMo Consider assertiveness training: "Normally I'd be happy to, but over three months ago I made a commitment to a high-level technical group I'm in* and I'm afraid it would be too disruptive to require a reorganisation of an international schedule."
* Fabricate or tell the truth according to taste, the latter sometimes being insufficiently likely to induce sympathy.
 
Yesterday I discovered tempfile.SpooledTemporaryFile and felt stupid for having implemented my own version of it, today I discover that passing such a file to zipfile.ZipFile makes it crash. Now I'm glad I've got a version that actually works
 
@roganjosh Take a cab and ask to go to the best bar within ten minutes.
@AndrasDeak The right to bare feet?
 
@holdenweb boooo. Way more interesting to just wander around.
Although, it helps if it takes less than an hour to find something eventful with people
 
Hi, i basically had a thought that you cant loop a number times and assign different variables to numbers inside the loop. And then this idea striked me, it works but is this safe to do so? Ive heard some posts say to be careful in using exec()
 
{relative} lives in Boston, I should ask them about hot spots tonight
 
3:31 PM
let = ['b', 'c', 'd', 'e']

for index, a in enumerate(let):
    exec(f'{a} = {index}')

print(e)
 
@CoolCloud Ah, the old "dynamic variables" trick. It's cute, but widely considered to be poor design
 
@Kevin Oh, is there anything new? updated?
 
99.9999999% of the time you're better off using a collection such as a list or dict
d = {}
for idx, a in enumerate(let):
    d[a] = idx
 
@Kevin Ha i see, but this wont assign the values on to variables right?
 
Right.
 
3:34 PM
The whole idea is that you usually don't want to dynamically assign values to variables
 
oh, any disadvantages ?
 
...speaking of which, you also usually don't want ZipFile.extractall to silently do nothing if the target directory doesn't exist, and yet here we are
 
For one thing, the variables all get written to the global namespace. You do not want the global namespace to get cluttered.
 
the dictionary method looks cool too, jus have to call the key at some time for the value, almost like a variable too
 
Or am I thinking of the globals().update approach, which is bad for the same reasons... hmm
 
3:36 PM
@holdenweb well, there's more there than I included. He's giving me tomorrow off, and most of the actual work I'll have to do will be between 6 and 8, so it's not a huge deal. It did make me think of Office Space, though
 
@Kevin oh, sorry im a beginner, do you mean the global scope? or is namespace something else?
 
Global scope, yeah
 
so without mentioning global here, it automatically becomes a global variable? woah
 
Only if you call exec in the global scope
 
Oops, I'm mistaken. the exec approach does write the variable to the correct scope, but those variables might be inaccessible later because the interpreter uses compile-time analysis to determine scope. For example:
def f():
    exec("a = 1")
    print(a)
f()

result:
Traceback (most recent call last):
  File "C:\Users\Kevin\Desktop\test.py", line 5, in <module>
    f()
  File "C:\Users\Kevin\Desktop\test.py", line 3, in f
    print(a)
NameError: name 'a' is not defined
The interpreter never saw an assignment statement inside f at compile time, so it assumed that print(a) must be referring to a variable in a scope higher than f's scope. But there is no such variable, hence the NameError.
 
3:38 PM
so there is no way to make it global?
 
I'm getting deja vu
 
@CoolCloud Hmm, unsure. I'm leaning towards "no" though.
 
6 hours ago, by roganjosh
Where is using exec with locals useful? I can't understand why you'd want to do this
 
@Kevin This error only comes when using it inside of a function right? Maybe we have to keep a reference or something.
 
Of course there is, that's what the other parameters of exec are there for
exec('a = 1', globals())
 
3:40 PM
@roganjosh Ha, I like that the accepted answer ultimately ends up with the value in a dict anyway.
 
@CoolCloud The main disadvantage (overlooking to possibility of random uncontraolled changes to the local namespace) is the necessity to use dynamically-generated code to access them, or resort to generally confusing tricks like getattr, often with absent-name detection logic.
With dicts in the language, why would anyone do that to themselves?
 
@CoolCloud You can avoid the nameError by putting a on the left hand side of an assignment statement inside f. But if you have to use an assignment statement anyway, suddenly there's no point in using exec to assign to it.
All of the workarounds you can propose for exec's flaws either end up making exec pointless, or end up putting the results in a dictionary, which you should have been doing in the first place
 
@Kevin It makes sense now, lol
@holdenweb Oh i see
 
I was wondering how to cache object creation in python. putting lru_cache over __init__ doesn't do anything (probably because at the point self already exists), and my grasp on __new__ is too weak to guess how I could/should use that to cache stuff.
I can do it with a classmethod-factory, but I don't like the pattern much
 
Since __init__ must return None, surely you are trying to cache side-effects? That's not going to work.
 
3:44 PM
When I say that you're better off using something else 99.9999999% of the time, I'm being sincere about the precision of that number. Most other questionable techniques only get like three nines.
 
Caching and __new__ don't go well together, because even if it returns a cached object, python will still call __init__ on it and reset any attributes it might have had
Any sort of caching mechanism should be implemented in the metaclass's __call__ instead
 
@holdenweb huh, didn't think about that.
 
__new__ isn't that hard to grasp if you don't get tricksy. I humbly offer github.com/holdenweb/hu/blob/master/src/hu/object_dict.py as a simple example.
 
class CachedMeta(type):
    @functools.lru_cache(None)
    def __call__(cls, *args, **kwargs):
        return super().__call__(*args, **kwargs)

class Cached(metaclass=CachedMeta):
 
@Aran-Fey But a factory class's __new__ need not return an instance of the factory class. When it doesn't, __init__ doesn't get called.
 
3:47 PM
nice
 
@holdenweb True, but returning instances of a different class from your __new__ can't exactly be called good design
 
@Aran-Fey just wanted to check up on the syntax of how to assign a different metaclass, so that's what it was
 
@Aran-Fey I'm not at all sure I agree with that. It seems very straight-laced for Python. Would it help if I called it a factory function?
I should clearly take another look at that repo with a view to radical redesign ...
I originally hacked it up as a demo for a client who was accessing JSON data structures using repeated string literal subscripts, to show how it improved readbility. I think they're still using it. It was really my testbed for poetry.
 
I have no problem with factory functions, only factory __new__s. If I go to a shoemaker and tell him to give me one of his creations, I wouldn't want or expect to get a scarf from him
 
@Aran-Fey clearly you have no sense of fashion
 
3:56 PM
I won't deny that (:
 
@Aran-Fey The longer I look at it, the more I like it. i.imgflip.com/4fb8tw.jpg
 
haha, use it wisely, young thief
 
4:14 PM
docs.python.org/3/reference/datamodel.html#object.__new__ says "The return value of __new__() should be the new object instance (usually an instance of cls)." which indicates that there are times when it won't be an instance of cls
Perhaps this is a very rare scenario but the devs must be of the opinion that it isn't always a shoot-yourself-in-the-foot move
Then again, by that same reasoning exec is also not always a SYITF move, so that's not high praise
 
How can I use Naive Bayes on Iris dataset? Should I just count a prediction for each feature, smth like: having [5.1, 3.5, 1.4, 0.2] as X vector count all 5.1 appearances in training examples where Y is the real answer (Iris-setosa)?
for example if 5.1 appears in two training examples then I should write P(5.1|Y) = 5.1 / (5.1 * 2) or what?
 
4:32 PM
@Aran-Fey I can only promise to try
 
4:52 PM
@inspectorG4dget No, I prefer to be able to see who asked for what to be -pls closed/deleted/reopened, when and why; even after the fact. And sometimes the related community discussion and logic of why/why not that request was good. As to not wasting time on already-completed requests, it doesn't take 10s, just do Ctrl-click on those links to open each in separate tab.
@entithat This is offtopic for Python room, also it sounds like homework. But anyway: the feature vector X has 4 components: sepal.length, sepal.width, petal.length, petal.width, or SL,SW,PL,PW or X1,X2,X3,X4 if you prefer for brevity. By "count all 5.1 appearances in training examples" I think you mean "all sepal.length==5.1 instances in training". So write your formula as e.g. P(SL==5.1 | Y) = .... And on the RHS, only use probabilities, don't use actual feature values like 5.1
 
So, it turns out the guy I was supposed to cover for on Saturday isn't going on vacation this week after all, so I don't have to work, which means I can rock the Room 6 Meet!
 
Do I need to return the 5 jerrycans of petrol? :P
 
@entithat: anyway it's offtopic to discuss here, there are tons of tutorials on iris dataset, please find one for NB and read through it.
@roganjosh You might be starting a diplomatic incident, sir
 
5:12 PM
is it possible when doing from something import this to import it multiple times so there are multiple instances?
 
@smci I don't know the reference, so I can't respond in kind. I'm really sorry :(
 
@roganjosh World War II? Hmm.
 
like maybe

from something import this as blah1
from something import this as blah2
etc
 
@smci sure, but who said it and I'd need a response in-context
 
@erotavlas You could, but why would you ever want to? (unless you intended to hack or monkeypatch one of those, or do something weird?)
 
5:15 PM
@erotavlas something seems broken here
 
@smci i want to keep the instances separate
 
I'm pretty sure blah1 and blah2 will be referentially identical in that case
 
@erotavlas instances? You'd get the same object.
 
@erotavlas but why? What happens if you just use the one import?
 
Instances of modules?
 
5:17 PM
Perhaps you could get separate instances if you cleared the modules cache in between imports... It's not exactly a best practice though
 
>>> from math import sin as math_sin, cos as math_cos
but don't do that
 
The best practice is to grab your ClueBat and visit the person that wrote the something module, and have a nice chat about good interfaces
 
Its spacy and I think its using some globals for the spacy object when loading a model
I wanted to load multiple models at the same time but its not possible unless I have spearate 'spacy' objects
 
I wonder if multiprocessing would be useful... Then you'd know for sure that the instances are separate
 
@erotavlas sounds like an XY problem
 
5:20 PM
which means making something like separate web services where each has its own import
 
multiprocessing is like separate web services without the web or services
 
Well it doesn't. What web service are you using?
 
i would use flask
 
Ok, and what do you consider to be a "web service" here? is that the server, or the instance you're using or what?
 
@MattDMo: what's your proposal "make a "canonical" comments page, possibly as a wiki" that you'll be discussing? Do you mean "standard, canned comments" e.g. "What is MCVE, in Python"?
 
5:26 PM
hold on verifying its not an xy problem as @AndrasDeak suggested
 
Yeah, something like "Questions asking us to **recommend or find a book, tool, software library, tutorial or other off-site resource** are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, [describe the problem](https://meta.stackoverflow.com/questions/254393) and what has been done so far to solve it. You *may* be able to get help on the [softwarerecs.se] Stack Exchange."
Preformatted, helpfully-worded snippets that can be cut and pasted with minimal modification, if needed.
I have a whole collection, but I've seen good ones from others, too. It's just a thought, but possibly useful.
 
Hmm, much to my surprise, importlib.reload doesn't always make new function objects
>>> import importlib
>>> import math
>>> sin1 = math.sin
>>> math = importlib.reload(math)
>>> sin2 = math.sin
>>> sin1 is sin2
True
 
perhaps sin's builtinness matters?
try with a third-party thing
 
I also suspect the builtinness
It's super doubleplus ultra cached
Hmm, same result for third-party thing colorama.init
 
@Kevin that's great, but could I have it in blue?
 
5:33 PM
Absolutely, we have colors for all tastes. I'm thinking something in a winter tone...
 
>>> import numpy
>>> orig_numpy = numpy
>>> importlib.reload(numpy)
<module 'numpy' from '/home/user/virtualenvs/py3.8_main/lib/python3.8/site-packages/numpy/__init__.py'>
>>> orig_numpy is numpy
True
>>> import sys
>>> del sys.modules['numpy']
>>> import numpy
>>> orig_numpy is numpy
False
 
tres mysterieux
 
importlib is weak :P
perhaps if you touch a file in the package it will actually reload it
 
docs.python.org/3/library/importlib.html#importlib.reload indicates that the module can tell if you're trying to reload it, and opt out if it thinks you're being too smart for your own good
The old "we have sin() at home" move
 
I'm surprised I can't find any relevant results for this... does anyone know how to limit download speed with requests? I'd rather not roll my own solution if I don't have to
I wish networks were smart enough to evenly distribute their bandwidth among all clients, but no, we can't have that in 2020
 
5:47 PM
Are you saying that your requests-using process is hogging all the Internet, and your other applications can't get any? Hmm
 
yeah
 
Oh, that's an interesting idea
30 day demo version though, that's unfortunate
 
stackoverflow.com/questions/17691231/… asks how to rate-limit requests, but sadly the answer isn't requests-specific
it assumes you have fine-grained control of the data stream
 
@erotavlas What would be a problem is loading the model on each request
 
5:58 PM
@roganjosh yeah that would slow down the response considerably :)
 
So you're at least not doing that?
 
@Kevin Yeah, I found that one. Not particularly useful, I really don't feel like touching any requests internals
I'd have thought there'd be loads of solutions for this. I'm puzzled
 
As someone who says that exact sentence at least once a week, I sympathize
 
@roganjosh no way
 
Subclass requests.Session and rate-limit the get/post/put methods (like 1/sec). Cheaper than $30.
 
6:01 PM
can a mimport be created in python? stands for multi process import
 
I think you can also throttle websites with firefox (developer edition?), perhaps selenium can be wired into it :P
 
@PaulMcG That won't work if I'm downloading a single large file though, right?
 
You can't add new syntax elements to the language, so from x mimport y is not possible
 
bummer
maybe python 4?
 
Dream big :-)
 
6:03 PM
time to fork EroScript
 
@erotavlas can we get some context on how you intend this model to work via flask first?
 
@AndrasDeak I don't think that word means what you think it means
 
( ͡° ͜ʖ ͡°)
 
@Aran-Fey No, but you might be able to stream the result using stream=True in your get call, and then rate-limit the calls to iter_content
 
@roganjosh its already working, I initialize a model when I run the flask app so the model is loaded before any request comes in, subsequent requests simply keep referencing the same model object
 
6:05 PM
@PaulMcG wut? I'm hip with lingo and I don't get it
 
When I saw "EroScript", a programming language was not the first thing to come to mind.
 
You can only fork EroScript if you subscribe to their OnlyFans
 
@erotavlas something is missing here, but I need to think about it
 
EroScript - the lovers script
 
Ero refers to pervs in anime
 
6:09 PM
oh lol
 
@PaulMcG I'd like to avoid that because you can apparently achieve much faster downloads if you simply read from response.raw instead. So if I have to, I'll create a file-like object that wraps around response.raw
 
@erotavlas So your model is bound to the route here
Now it is an XY problem because you just want to launch a second server?
 
if I did that it would be XY, but I don't want to, so I'm going to do this instead

dataPath = Path('data')
set_data_path(dataPath)
#modelPath = Path('model')

dirs = getSubDirs('models')
for i in dirs:
modelname = i.name
modelPath = Path(os.join('models', modelPath))

models[modelname] = spacy.load(modelPath, disable=[ "tagger"])
 
But that has nothing to do with the code you linked?
 
sorry I dont know how to do the ctrl K thing on a Mac :(
yes I'm going to replace the beginning part outside the route with that
so initialize multiple nlpmodel objects ina dictionary and change the route to accep the model name along with the text
 
6:19 PM
I'm actually getting quite twitchy behind the keyboard because this is exactly what I do day-to-day and that code block doesn't help
 
Be strong
 
help what? :)
help my cause? or providing an explanation?
 
Yes, they're mutually exclusive
 
sorry what's mutually exclusive?
 
I don't understand any of this model talk but I'm sending good vibes
send to five friends and your crush will come to your house and debug your app
 
6:27 PM
I'm calling it a day on my end, sorry
 
it's all good, I know what to do :)
 
I think I've confounded erotavlas with triple-nested XY problems a few times in the C# room, so turnabout is fair play
 
cbg :)
 
cbg
 
6:36 PM
@roganjosh Hey know its been a while, but have a quick question if you could, I was assigned task at work to make a simple app for our company, right now the idea is Learn Kotlin and develop it on Android. My question, could I not go the Kotlin route and just tap into my already known Python, brush up and accomplish same task?
 
The last time I checked (like three years ago), it wasn't very easy to integrate Python with Android
 
@vash_the_stampede Welcome back :) To the best of my knowledge, there isn't a python alternative. I spent a lot of time researching this and decided that kotlin would be my second language... I just never got round to it properly
 
Thank you guys so much, that was all, I miss you guys and python only had a short run in programming as a hobby, but you guys made it great, and I hope you guys have been doing the same for new future programmers <3
 
I'm trying
 
6:53 PM
if construction were like software development, doing a simple task like hammering a nail would take days to figure out. When you do finally get it to work, striking the nail causes a small fire and or hammer shatters into multiple pieces.
 
just spin up a second house
 
I've worked in construction, you'd be surprised how many things can go wrong just hammering a nail haha
 
The first nail takes two weeks, then every subsequent nail is 50 milliseconds
But only if it's exactly the same kind of nail hammered into exactly the same kind of wood at exactly the same angle
 
Lots of variables would have to remain constant, human effort and efficiency can be skewed just by personal emotional issues, focus lost, hits hand, sweat tired agitated, construction production quality varies so greatly from uncontrolable factors IMO... Now if they were robots ha diff story
 
focus lost / hits hand / mom's spaghetti
 
7:13 PM
@kevin a humonculus would do the trick now
 
Homonculi are hard to make because, as soulless vessels, you must first construct a smaller homonculus to pilot the bigger homonculus. But that one is soulless too, so...
 
Obv we need a Philosophers stone
 
7:29 PM
f'0.1212:.2f rounds to 0.12. Is there a specifier to force this to round up to 0.13?
 
@erotavlas My response was to the comment immediately above with the "or". I've re-read and you didn't mean what I thought you were asking
 
@erotavlas merriam-webster.com/dictionary/mutually%20exclusive this explains it better than I could
 
That was my initial reading, but actually, I think they were asking what I was referring to as mutually exclusive
 
>>> f'{math.ceil(100 * 0.1212)/100:.2f}'
'0.13'
:P
 
@roganjosh oh gotcya
 
7:34 PM
Text communication sucks :/
 
@AndrasDeak yah, that's what I'm looking at doing...in a more general way
was hoping fstrings just had a format specifier that just does it for me
 
I bet there are plenty of questions on SO about "round up n decimal digits"
@Code-Apprentice unlikely, as this is an arbitrary thing to do
 
I also don't think there's a format specifier for that
 
yah, most ppl just "round to nearest" but my clients aren't "most people"
 
Roundabout solution: use decimal to get the exact value string, then slice off the extra digits and increment the rightmost digit
Add handwaves here for carrying the one and not rounding 1.00000000 up to 1.01
 
7:37 PM
@kevin thats sort of what I was just thinking, some type of rounding set to correct placement then just add one to rightmost, if rounding everything up
 
Alternate algorithm...multiply to get your desired accuracy then use math.ceil, then divide again?
 
revolutionary ;)
it will be hard to get an automatic precision right, considering 0.1 + 0.2
good luck to whomever has to implement this specif... uh nevermind ;)
 
7:58 PM
@Code-Apprentice stackoverflow.com/a/61925057/10255652 Look at this answer, only thing I found not using ceil really that seems functional havent looked hard at it, but at a glance seems very similar to your request
 
oh that's interesting...what is this double negative black magic, though?
 
that's just ceil division using floor division
 
oh...because // instead of /
 
Floor dividing a negative number and then restoring the sign. Back in the day when the ceiling function hadn't been discovered yet.
 
I missed the // truncating the number.
wait...you can use // with floats? TIL
 
8:08 PM
division an be performed with any numeric dtypes I guess , in sql it is more like casting after division?
 
wut? :P
 
IDK about sql, but in most other languages / is overloaded for each numeric type.
 
@roganjosh ehh? did I say it incorrently?
 
They're talking about floor division in Python; In postgres (for example) it would be FLOOR() but I'm not sure about type casting
 
C-style language will cast operands before the division, but not the result after.
I doubt sql does any casting on the result.
 
8:14 PM
@anky question is whether I have the energy to test this. :P I suspect that the wrapper (psycopg2) or pandas has a bigger say in the type it's gonna return
It's pointless to test with sqlite3, which I'd prefer, because it doesn't care about types
 
@vash_the_stampede I had to bang out an Android app prototype for a contract job a few years ago and used Processing. It's really just Java but with a nice IDE and framework wrapper so you can focus on the app code and never write public static void main(String args[]) again.
 
@roganjosh IDK postgres , but i have used a floor division using a simple division then casting to int to get the floor. I dont remember the legacy (may be I am wrng too) but the reply was to whether you can use // with floats
@Code-Apprentice Overloaded is tuff to understand for me:)
@roganjosh most of my sql is either in spark or pandasql or sql server sometimes so it's fine..!! :)
 
8:33 PM
Okay now I understand what you guys meant
I guess
import pandas as pd
import pandasql as ps
d = [{'name': 'A', 'year': 2010},
 {'name': 'A', 'year': 2011},
 {'name': 'A', 'year': 2011},
 {'name': 'A', 'year': 2013},
 {'name': 'A', 'year': 2014},
 {'name': 'A', 'year': 2015},
 {'name': 'A', 'year': 2016},
 {'name': 'A', 'year': 2018},
 {'name': 'B', 'year': 2018},
 {'name': 'B', 'year': 2019}]
df = pd.DataFrame(d)
print(df)
print(ps.sqldf("""select *,(row_number() over (order by (select 0))-1)/3 as new from df"""))
name  year
0    A  2010
1    A  2011
2    A  2011
3    A  2013
4    A  2014
5    A  2015
6    A  2016
7    A  2018
8    B  2018
9    B  2019
  name  year  new
0    A  2010    0
1    A  2011    0
2    A  2011    0
3    A  2013    1
4    A  2014    1
5    A  2015    1
6    A  2016    2
7    A  2018    2
8    B  2018    2
9    B  2019    3
tested this
we don't need casting here
 
Come on now; this should be hosted off-site
 
i got confused between different systems
sorry!!
@roganjosh okay sorry, was just trying to get to it. :)
 
Just discovered something weird... python on Windows doesn't require a slash after the drive letter, i.e. you can do os.stat('C:Users'). I kind of want to report it just because I'm curious what their "that's not a bug" excuse is for that
 
When two typos compensate: missing r in r'C:\Users' but also missing \ :P
 
@Aran-Fey That's a Windows/DOS thing, nothing to do with Python per se. Windows path with no slash after drive letter and colon - what does it point to?
 
8:48 PM
oof, if that's true that's even worse
 
"that's even worse" - Microsoft^TM
 
Weird, I could've sworn os.listdir('C:') returned the contents of the C: drive, but it does actually return the contents of the cwd
Still, everyone search your code for things like os.listdir('C:') or Path('C:') and add that trailing slash
 
Is this the equivalent of os.path.join('/something', '/another/something') except the other way around?
 
kind of, sort of, maybe
At least I know the difference between Path.drive and Path.anchor now. And if I'm lucky, I'll still remember it in 5 minutes
 
That behavior only lists the cwd if you are on that same device. I just tried on my E: and F: drives. If I cd to E:\temp and os.listdir("E:"), I get the contents of E:\temp. But os.listdir("F:") gives the contents of F:\ (even though there is an F:\temp also).
 
8:59 PM
@anky Here I just mean that / does different things for different types of input. For example, floats or ints behave differently when you divide them with /.
 
That would explain why I thought os.listdir('C:') returned the real contents of my C: drive
Welp, spent 4 hours downloading a zip file, then python couldn't extract it and deleted the tempfile that contained the downloaded zip. Awesome.
 
And I get that same behavior at the console prompt too. dir E: gives the contents of E:\temp, and dir F: gives the contents of F:\.
 
I can't wait for the world to finally stop using buying Microsoft programs already
 
9:19 PM
@erotavlas The Ctrl-K thing on a Mac is ctrl-K
 
@Code-Apprentice I get it now, thanks for clarifying :)
rbrb bdw :)
 
9:43 PM
@Aran-Fey I don't see what this has to do with MS?
 
Nothing, that was my own fault
 
Or why you'd need to unzip with python. Everyone should be using 7zip... by law :P
 
unzipping automatically beats un7zipping manually :P
...except when it doesn't work
 
You kevin'd me :P
 
9:56 PM
@roganjosh I've discovered xz (as in .tar.xz). Gives 5-10% the size of .tar.gz in my use cases
 
<hand waves> silly OS. I'm talking about the OS: Windows
 
my bad :P
 
I actually have a mac being couriered to me as we speak. Can't wait....
 

« first day (3624 days earlier)      last day (1318 days later) »