« first day (3756 days earlier)      last day (1175 days later) » 

3:50 AM
slightly off topic, but how do you guys work in a codebase where there are so much things that you dont control?
eg : input to python code is from a db which gets its input from some go script
is it ok for me to ask senior devs for the inputs I need or is it part of a dev to being able to mimc the workflow?
 
4:43 AM
laurel, why was that even star-ed?
 
5:17 AM
@python_user beats me
@python_user I've never worked at a company so your mileage may vary, but I'd expect that asking your superiors for help is not just fine but necessary if you're stuck and can't advance on your own
of course if you're not stuck, just uncomfortable with the tooling, it's harder to ask good questions
Good == constructive in this context
 
@python_user what do you mean by "how do you work in it"? I work in an environment with shit tons of code in different languages with data coming from a variety of places, so I think I have a good grasp on this type of workflow.
But I don't really know what your question is. Is it something like "how do you know your stuff works when it's hard to predict the input to your program" ?
 
@AndrasDeak exactly this, I just dont know what to ask
@alkasm this, I find it hard to grasp the existing db and the format in which they have the json etc
code base is severely under documented
 
Unit tests, types, and well-documented APIs are generally the key to integrating and interfacing with many systems, from my experience.
 
is it a good approach to just take a day or two and run individual components alone? eg : connect to db without using their main script, find how the format is?
then write a new script to connect to service 2, repeat that for all external services?
 
Well, that's a good way to figure out how it works but not data schema
schema for the db should be stored somewhere
 
5:26 AM
at least now I know db schema is something I can ask for, thanks
 
:)
For example of how I might parse your problem, I'd look at what are the data types that go inserts into the database? And then in general I'd test my code against all potential variations of that data type. For e.g. if a "customer" record with a name, address, blah blah was entered into the db, and I write some web service that takes in that record as a JSON, then I maybe want to test my service with all possible variations in input data
like, does my service work if the "name" field is blank? does it throw the right error? etc etc
So yeah I think finding the type (or schema) associated with data is really the most important bit here.
 
@alkasm I am going to try and find this, will help me a lot
@alkasm except Exception as err: is everywhere :D , line from actual code
 
lol
your code starting to look like the go code?
if err != nil
 
that might actually be true, part of the guys who wrote this also write go
and hence why I was asking about cameCase to snake_case converter a couple days back
 
haha. yea I'd probably just continue using the established convention..
until a new unconnected piece of code came 'round
 
5:31 AM
yeah that should do, but appreciate yours and Andras' suggestions
 
 
2 hours later…
7:41 AM
HI everyone I need a little help regarding pylint
I get this particular warning when I run pylint on a script called get_last_activity.py
get_last_activity.py:1:0: C0114: Missing module docstring (missing-module-docstring)
However I have my function defined like below:
def get_last_activity(dataframe):
    """
    Returns the bucket pertaining to the last activity observed for a list of user ids
    """
Any idea why its not getting recognized?
 
sounds like a module docstring is not the same thing as a function docstring
 
I have only that one function in the script, so will it still be different?@ParitoshSingh
 
 
1 hour later…
9:12 AM
Hi guys. Anyone online who is familiar with how sys.setdefaultencoding() works? I f'd up.
 
You're still using python 2?
 
Yeah, codebase upgrade to 3.X is planned for this spring.
Problem simplified: I'm running multiple (tens) of crawlers/spiders. For a reason I can't recall, I used "import sys, reload sys, sys.setdefaltencoding()" to tackle a problem, and pushed into github. All was fine, nothing broke. Later on, I worked on the same code, and for another reason I can't remember I removed the sys.setdefaultencoding-line. That broke 10-20 of other crawlers I've not touched in ages.
From what I see in testing, even removing all the 3 prementioned lines from the crawler that caused the problems, is not enough to fix rest of the broken ones. Does setdefaultencoding permanently change something elsewhere in Python files?
 
I've spent 5 minutes trying to figure out what that function does and still have no clue :|
 
The crawlers I work with tend to gather strings with scandic letters (ä, ö, å) etc, that Python 2 really hates. Using sys.setdefaultencoding did fix my problem at that time.
 
9:30 AM
Can you post a piece of code that doesn't work without the setdefaultencoding? Plus the error it throws?
 
seeing how sys.setdefaultencoding is related to unicode handling, I would recommend to take this as an opportunity to port your code to Py3 now. It is probably no more work than fixing the Py2 code.
 
Yeah, I will surely port the code to Py3 in the coming weeks. I tried it a year ago or so with the help of the py2to3 script, but something in the background libraries (I got the crawlers + library to parse whatever comes through them) broke without giving me any real indicators what the problem was. Once I get a fresh workstation this week and get it set up, I'll port the code, whatever it takes.
We are talking ~150 different crawlers alone + everything else that works its wonders in the background. I jumped in to the project at about 100 crawlers, and been alone on it ever since. So working with legacy basicly.
Aran, I'm trying to figure out what's the difference between the crawlers that work with the setdefaultencoding gone and with the ones that don't.
The error itself: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 10: ordinal not in range(128)
u2013 is that weird "bolded" dash line
 
I need some context around the error though
 
9:48 AM
I might just figured it out. I had the line:
"hours = [i.decode('utf-8').strip().replace(u'\u2013', '-') for i in hours]"
That caused the above error.
In the start of the crawler code, I already use:
# -*- coding: utf-8 -*-
This is all product of few months less "educated" me trying to just work my way through the encodings, without ultimately having an idea what I'm doing.
Now that the sys.setdefaultencoding is gone from the one crawler that exploded everything, I just need to skim through the one's that have equally useless decodings.
 
The only problem I see there is the use of '-' instead of u'-', but no clue why python is trying to encode your unicode as ascii...
 
So what I did above to fix the error, was simply remove the .decode('utf-8')
It's prolly because of Python 2. Python 3 is years ahead with the encoding. And I'm also working on Windows, that adds to the problem I've learnt.
 
I really really doubt that removing a decode call is the correct solution. AFAIK, unicode doesn't even have a decode method, and you almost certainly want i to be unicode rather than str
 
having i.decode or i.encode there both cause the UnicodeDecodeError/UnicodeEncodeError, respectively.
 
Erm, the error message doesn't really make sense with that code. Do you get the UnicodeEncodeError error when importing or when running the code?
 
9:57 AM
So what is i? What's its value and where is it coming from?
 
Note that the message says "'ascii' codec" – your code has specified utf-8 though.
 
Hours is a list of strings, that is gathered from a company website. The strings are representing opening hours of the company's store. What I'm attempting to achieve with the above code is to parse the strings to a form that the library understands. Depending on the site, the string encodings vary (from my experience).
And the errors happen when I run the code.
I'm using Scrapy as a framework
 
Strings being str or unicode? And if they're str... why aren't they unicode yet?
 
Unicode
Just checked.
 
Huh, so unicode.decode actually exists? That's dumb
Where the heck is the documentation for unicode anyway. The docs are so terrible sometimes...
 
10:02 AM
Yeah, so it seems. I'm as dumb, but being alone on the project I've just kinda rushed through, tossing encode and decode here and there until it works, lol
Really starting to look forward for the py3 jump. You guys have any tips for me concerning the upgrade to Py3? Is py2to3 recommendable?docs.python.org/3/library/2to3.html
 
I've tried 2to3 once and never again
 
Never again, as in it sucked and did not work?
 
yup
 
10:47 AM
best way to port is probably the classic "port by hand"
but it's also the most time consuming i imagine
 
Thats true, unfortunately.
 
11:08 AM
i'd say give 2to3 a try and see how it goes. if it starts looking ugly from the get go abandon it
no harm in trying in any case
docs.python.org/3/howto/pyporting.html might prove a useful read
if you have the time, you really might save yourself a lot of pain and suffering by writing even some basic "test" cases
Ofcourse when it comes to testing, "do as i say, not as i do". cough
 
There is a couple test cases in the legacy library that I've not really touched, as it has worked 99,9% of the time. Might need to utilize them if need be.
Luckily the main problems I'm about to face in the port are about encoding/decoding etc. Crawlers are quite simple. What I am also scared of is a "f'load" of backend libraries, middlewares, requirements that I need to figure out
Oh well, at least I get to tell my boss I'm not sitting around doing nothing for the upcoming weeks or so.
 
I wish I was ^ this guy
I have to tell something to my boss and I have nothing
 
Dude, that's me most of the year
 
@python_user what do you mean you have nothing? Like nothing done or nothing to do?
 
^Nice try boss (jk)
 
11:22 AM
nothing done :D, still figuring out how things work, apparently that is not an update I can tell more than once
 
Instead of saying I'm figuring out how to do foo, say I'm working on foo. Figuring out how to do it is part of working on things. But it sounds much better to management to say I work on, than I'm figuring out :P
 
^Underrated tip
 
I might use that later today
 
Sometimes this then leads into follow up questions of what in foo you are working and then you can dive deeper and sometimes if the person has enough time and interest they can even help you and be your rubber ducky ;)
 
I need all the help I can get so this might actually work out
 
11:29 AM
btw what was the reverse mcve joke about? Also the mcve parking lot joke would make for an amazing visual sketch :P
 
I guess some user asked a Q and roganjosh ended up with an MCVE for the user
 
Yeah, the OP posted a wall of code in their question and while trying to explain the problem to them, roganjosh ended up having to write a small snippet to demonstrate what's happening
 
haha wow
 
12:24 PM
morning everyone
 
cbg
 
hhh currently working on something and its extremely slow
 
@Sect0r you should make it faster if you can, optimization is cool and fun
 
thats what im trying to do
 
I also have lots of old tools like 20 years old and I am trying to fix almost everything xd
 
12:31 PM
haha
 
It actually teaches me from the hard way that why we all should learn the design patterns
 
do you wanna see the code?
Hi daniel
 
Hello
 
how are you?
@Alper Do you wanna see the code?
 
You know you are in a bad neighborhood if the chat is full of screenshots :D
 
12:38 PM
@Sect0r Yea, but I cant guarantee you anything
 
Hello all. I have a json file that contains an array of json objects.
I would like to ask, is it possible, via python, to append a json object to that
json file, without loading first the whole file content on python and appending
the new object and then writing the whole array back to the file?
 
You just want it to add to the end of the file as a json?
 
let's say json file contains: [{"name":"john","age":10}, {"name":"micheal","age":12}]

I would like to add to that array {"name":"chris","age":20}

so now in the file there should be : [{"name":"john","age":10}, {"name":"micheal","age":12}, {"name":"chris","age":20}
]
 
json might not be the best choice for on-disk formats; The trouble it has with appending data is a good example of why this might be. Specifically, json objects have a syntax that means the whole object must be read and parsed in order to understand any part of it. coming from: stackoverflow.com/questions/12994442/…
 
```for i in range(len(cmpdata)):
if cmpdata[i] in imgpalette: rpts+=1

for j in range(len(imgpalette)):
f cmpdata[i] == imgpalette[j]: clr=str(imgpalette[j])

cmpimgdata.append(clr + ' ' + str(rpts))```
 
12:43 PM
I see. I might go with CSV then. Thank you :)
 
a
 
@Sect0r please see our code formatting guide to chat and practice in the sandbox if necessary
 
@Alper one could always treat each line of the file as an element of the array and then parse each line individually
 
@AndrasDeak thanks
 
(but yeah... if the columns are always the same, CSV is probably better as you can have the header once with the names rather than it redundant in each of the objects - or depending what one's doing - perhaps even sqlite3 which'll make it easy to select/update/delete/insert etc... without worrying about hand-holding the physical file)
 
12:54 PM
for i in range(len(cmpdata)):
    	if cmpdata[i] in imgpalette:
    		rpts+=1
 	        cmpimgdata.append(str(cmpdata[i]) + ' ' + str(rpts))
@Sect0r does this work for you?
 
@John have a look at dataset.readthedocs.io/en/latest - it's very easy to use and flexible
 
@Alper Yeah, i still need a faster way to search through the lists tho..
ill go search online a bit
 
If you put your code more clearly, there can be
 
@JonClements it indeed seems easy to use. Well I already started with csv now but I will surely keep that in mind
 
@Alper I'll give you the full code in a bit, my mom is calling me
 
1:43 PM
it's a bit broken right now.. im working on that
 
@wim Thanks for mentioning this @wim
 
2:27 PM
aaaa i dont know how to fix this dumb function
 
imgpalette = list(dict.fromkeys(cmpdata))
1. that seems like a more expensive way of doing list(set(cmpdata)), 2. you should leave it as a set and then cmpdata[i] in imgpalette would be fast, 3. In the above code there's no way that cmpdata[i] not in imgpalette, right? Or am I misreading something?
 
oh
You are correct for 3
1 and 2 also..
i just tend to write code without thinking much and it turns into a mess
 
Pro-tip: think when you write code :P
 
yeah, i'll do that from now on
hmm, i still dont know why my smooth() function wont work..
 
is async any good? Any rants or compliments? I think of getting into it, any caveats?
 
3:00 PM
Anyone come accross an issue where you return an int from a function (the len of a list) and it comes out as a tuple outside the function?
 
not unless you specify something like return len(seq),
 
            TotExceps = len(list(reader)) - 1 #Minus one becuase of the header

    return TotExceps

type(TotExceps)
<class 'tuple'>
Even this doesn't fix it:

        ListExceps = list(reader)
        TotExceps = len(ListExceps) - 1 #Minus one becuase of the header

    return TotExceps

type(TotExceps)
<class 'tuple'>
 
with what you have shown it is not possible for me to figure out what's wrong
 
The full function that returns a tuple when I think it should return an int is:
def AppendCSV(File, Data):
    import csv
    with open(File, 'a', newline='') as csvfile: #Opens CSV file for writing
        writer = csv.writer(csvfile) #Creates writer object

        for line in Data:
            writer.writerow(line)

    with open(File, newline='') as f:
        reader = csv.reader(f)
        ListExceps = list(reader)
        TotExceps = len(ListExceps) - 1 #Minus one becuase of the header
        # TotExceps = len(list(reader)) - 1 #Minus one becuase of the header

    return TotExceps
 
@JamesMcIntyre No, that can't return a tuple. The mistake must be on the caller side. No MCVE.
 
3:15 PM
this returns an int
@JamesMcIntyre type(TotExceps) how did you get this TotExceps?
 
@AndrasDeak what mistake could there be on the caller side to make this function return a tuple?
@python_user I'm doing the type(TotExceps) on the main pythong file (rather than the functions file) where the function has been called
 
how do you call the function?
TotExceps = AppendCSV(...), this can also lead to a tuple
 
Ok... I'm not sure how it happened but the function call was chagned in the main.

Thanks for pionting out where the problem was
 
@JamesMcIntyre you tell me ^ :P
 
somhow the function name got removed from the main so instead of saying TotExceps = AppendCSV(FileName2, Excep) - it got changed to: TotExceps = (FileName2, Excep)
 
3:24 PM
I see
 
for future use, dont use PascalCase for variable and function names in python
unless its your internal coding standard for some reason
 
Ahh so ThisIsCalledPascalCase? Why not use it? It is usually my standared yes
 
yes it is, you can read up PEP8 when you have time, that explain this among others
 
they mean PEP 8, the official style guide
unless there are other considerations, the official recommendation is to use snake_case for most names and PascalCase (or whatever you call it ) for classes
 
3:54 PM
I think I just find that using the underscore all the time is a pain for touch typing and pascal case is clear to me.

It's a good point though and if I start writing classes at some point then I might need to do somthing like this to distinguish
 
I need a bit of help,
i've been poking at this function for like 2 hours now and i haven't been able to figure out what's wrong with it, any help?
def smooth(val, lval, thrshold):
    if(lval>val):
        if((lval-val)>thrshold):return val
        else:return lval
    elif(val>lval):
        if((val-lval)>thrshold):return val
        else:return lval
TypeError: '>' not supported between instances of 'NoneType' and 'int'
 
You really have to do something about your habit of writing ifs and elses and all that other stuff on a single line
 
i cant stop
and i dont know why
 
It sounds like the error isn't in the function, it's a matter of what arguments you're passing into the function
But the function is missing a branch that's executed when val == lval
 
i dont think im passing anything incorrectly?
uh, wait
here's the source
https://bpa.st/J7YHO
line 46 thru 48
 
4:10 PM
Yeah, the missing branch is most likely causing it
 
I'll add that, give me a moment
 
Ah I have issues with Popen every time. First I really dont get why shell=False is the default and not true, but then still I can't find the programs which I can find in a terminal normally. I feel like Popen should by default behave exactly like a normal terminal
I get ros2 not found error and I know I had this in the past, but I can't find the place and I can't remember how I fixed it
 
@Sect0r You clearly suffer from the whitespace-eating nanovirus. twistedmatrix.com/trac/wiki/TwistedMatrixLaboratories - I'd recommend you consult a doctor immediately ;-)
 
I don't think you can reasonably expect python to behave like a terminal. Some shells have a concept of being an "interactive" or "login" or whatever shell, so python would have to check "what's your shell? If it's bash, run it with -l and -i. If it's zsh, ..."
 
@Hakaishin I've re-written many bash scripts to subprocess precisely because Python does not suffer from the asinine automatic expansion/evaluation/escape mess of shells.
 
4:20 PM
$ echo What?!
What?!
$ echo How dare you!!
echo How dare youecho What?!
How dare youecho What?!
 
^ Someone somewhere out there relies on that to set up their analysis environment...
 
I've always vaguely assumed that shell=False is a security thing
 
@Kevin it is
@AndrasDeak yeah that's kinda annoying, I guess you have to 'How dare you!!'
tbf !! is quite handy
 
Although I wonder how much security it really provides. Obviously it keeps the bad guys from rming your entire hard drive, but I'd be surprised if they couldn't wreak havoc with the ability to run arbitrary executables
 
but still how do I get my ros2 command in a subprocess Popen :P
I use shell=True and get /bin/sh ros2: not found
but in the terminal it is found
 
4:27 PM
(I'm assuming rm is not an executable, but come to think of it, I don't know)
 
@Kevin usually the user only provides arguments, not executables. shell=false protects against Bobby Tables attacks.
 
Hmm, makes sense.
 
@Hakaishin is it also found in a no-login shell?
and is it an actual command or an alias?
is /bin/sh pointing to bash?
 
@MisterMiyagi how do i get a no login shell? I would assume no since my bashrc sources the dir where it is
it's a command not an alias
 
@Hakaishin via ssh, systemd, bash -someflagidontremember, ...
come to think of it, plain bash some command might be no login...
 
4:33 PM
In any case, I can see why the devs made shell=False the default. Given the choice between "annoy developers because their popen call fails the first time they write it from memory" and "Make clueless newbies vulnerable to arbitrary code execution attacks", the former is an easier pill to swallow
 
@holdenweb Will do!
 
so /bin/sh ros2 doesn't work neither does bash ros2.
@Kevin lol fair
 
@Hakaishin does bash -l ros2 work?
 
no
 
otherwise, check in the shell where it actually gets the command from. So which ros2 and checking what extends the PATH to match.
 
4:35 PM
I tried which ros2 and then using the absolute path, that failed too
 
What kind of system is this?
Your own laptop or a managed hpc system or...?
 
with a weird: importlib.metadata.PackageNotFoundError: ros2cli
own pc, a pretty normal ubuntu 20.04
if you feel like trying ubuntu has prebuilt binaries, so sudo apt install ros2 and then trying subprocess.Popen("ros2 bag play") should do it
actually I might have said that wrong, ros has a bit more setup than that. Not much, but like around 5min maybe
 
erm, shouldn't that be subprocess.Popen(["ros2", "bag", "play"])?
 
not if shell=True
 
I doubt that ^
 
4:40 PM
but I also already tried both
 
I don't think Popen can raise a PackageNotFoundError on its own, so I suspect ros2 is executing, but something is wrong with its environment and it can't find one of its dependencies
Maybe the CWD is something it doesn't expect, or it's using the wrong Python, or something
 
yes pretty much
I get:
Traceback (most recent call last):
  File "/home/usr/ros2_foxy/install/ros2cli/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli', 'console_scripts', 'ros2')())
  File "/home/usr/ros2_foxy/install/ros2cli/bin/ros2", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.8/importlib/metadata.py", line 504, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
but that doesn't really help
 
Popen has a cwd argument, so you could fiddle with that if you think it's a likely point of failure
 
are you sure /usr/lib/python3.8 is the one for which ros2 was installed?
 
I tried cwd it doesnt help. I not sure which python ros2 is expecting
 
4:50 PM
have you confirmed that both the commands ros2 bag play and ros2 work properly when you run them in a regular terminal?
 
yes
 
Ok, I suspected as much, but wanted to be sure
 
hmmm, but I'm getting tired, I think tomorrow the problem will solve itself. Thanks for your help guys :) Have a nice evening
 
Sam
Why doesnt this work?
 
Don't want to go on a wild goose chase figuring out why Popen would mess with packages, only to discover that ros2 has a package problem unrelated to Popen
 
Sam
4:52 PM
        fileName = os.path.join(self.guildFolder(guildid), "settings.json")
        if(not self.settingsExist(guildid)):
            self.makeSettings(guildid)

        with open(fileName, "r") as settingsFile:
            settings = json.load(settingsFile.read())
        return settings


GuildID is a number and guildFolder returns `C:\Users\super\Desktop\Projects\# Discord Bots\Passing\Sam's Pet\modules\..\saves\guilds\786710203314733106\settings.json` here
It says:
Task exception was never retrieved
future: <Task finished coro=<handleMessage() done, defined at index.py:84> exception=AttributeError("'str' object has no attribute 'read'")>
Traceback (most recent call last):
  File "index.py", line 119, in handleMessage
    settings = modules.settings.getSettings(msg.guild.id)
  File "C:\Users\super\Desktop\Projects\# Discord Bots\Passing\Sam's Pet\modules\settings.py", line 26, in getSettings
    settings = json.load(settingsFile.read())
  File "C:\Users\super\Anaconda3\lib\json\__init__.py", line 293, in load
 
@Sam json.loads(...), or json.load(settingsFile).
load() expects a file handle, loads() expects a string
 
Sam
I see I see thank you :D
Task exception was never retrieved
future: <Task finished coro=<handleMessage() done, defined at index.py:83> exception=JSONDecodeError("Expecting ',' delimiter: line 3 column 45 (char 71)")>
Traceback (most recent call last):
  File "index.py", line 118, in handleMessage
    settings = modules.settings.getSettings(msg.guild.id)
  File "C:\Users\super\Desktop\Projects\# Discord Bots\Passing\Sam's Pet\modules\settings.py", line 25, in getSettings
    settings = json.loads(settingsFile.read())
  File "C:\Users\super\Anaconda3\lib\json\__init__.py", line 348, in loads
Does this mean my JSON is wrongly formatted?
 
Ngl, error messages like that make me want to have static typing. A message like "json.load expects a file object, you moron" would've been a lot clearer
 
Sam
Yeah
This above is even weirder
I don't know where to look
 
@Sam yep
 
5:00 PM
JSONDecodeErrors do indeed indicate that the JSON is wrongly formatted
 
@Sam look at line 3 column 45 of your settingsFile.
 
I don't know if I've ever seen "Expecting , delimiter" before though. When does JSON have a mandatory comma?
 
Sam
Since when does JSON expect a comma here?
 
json doesn't support comments
 
Sam
Oh.
None at all?
 
5:02 PM
and please just use settings = json.load(settingsFile) instead of settings = json.loads(settingsFile.read())
@Sam none at all
 
Sam
Damn thats crazy
 
use YAML if you want comments
 
@Sam vanilla JSON doesn't. Some parsers tolerate it, but that's not JSON.
 
Sam
@MisterMiyagi I get headaches from yaml
I guess im moving the comments to the makeSettings method
 
Interesting, so the parser says "expecting comma" when you feed it a dict and give it a surprising token where the closing curly bracket would be
In a perfect world it would say "expecting comma or closing curly bracket" since both would be valid there
 
Sam
5:05 PM
I didnt do anything to my python parser (i think)
I only installed anaconda and some more things
But I dont think that changes anything
 
I'm talking about the JSON parser, to be clear
 
Sam
thats in JSON.py if im correct
 
@Sam I didn't say you did. Hence your JSON being invalid.
 
Sam
@Kevin I was talking about this
 
I just noted that you might think that comments are valid because some parsers in some languages accept comments in "JSON"
 
5:07 PM
I was talking about that too
 
@Sam ah, OK
Kevin's just musing I think, rather than suggesting that you broke the parser
 
Sam
it works!!!!!
end result: [01/27/21 18:07:31] [i] [786710203314733106][#admin-chat] Sam0072: now\nhttps://media.discordapp.net/attachments/786710203571372075/804034877342875658/wojakgrin.png
so what it does is:
you cant print images in text (at least, usefully print)
so I took the proxy_url of the images and appended them to msg.content
thats it lol
the json is because it loads the settings on every message for some reason
need to fix that next
nevermind - it loads the settings each time to see if autotranslate setting is still True
thanks for the help guys, appreciate it
 
I'm worried -- if it went from broken to working without you doing anything, it can go from working to broken just as easily
 
Sam
Yeah I removed the comments
 
Ok
<musing> I wonder how receptive the CPython devs would be to a patch for github.com/python/cpython/blob/…...
 
5:16 PM
I'm also concerned that the two lines at github.com/python/cpython/blob/… seem contradictory
when the object is closed there's no bail, it just ends parsing and returns the object if it can, at least from a glance
Adding "or '}'" into the error message seems fair game
 
Yeah the comment doesn't seem to precisely describe the behavior
Perhaps you could argue that "bailing" here can mean both "exit the loop" and "jump to the bail label" in which case both branches are bailing, but in different ways
 
Yeah, but that argument wouldn't get far ;)
 
One could argue many things if one is unconcerned with winning arguments
Perusing through the bugs page, I see the cpython devs have historically been open to improving json parsing messages. I was worried they might reject them because it would break compatibility for tests that check the message data of exception objects. But they more or less consider that a non-issue
Tests are made to be broken anyway ;-)
Now where did I put my detailed guide to submitting a patch... It's one one of the four computers I've used in the last decade, surely
 
5:34 PM
@MisterMiyagi
I am having a hard time trying your answer from https://stackoverflow.com/questions/65912706/pattern-matching-over-nested-union-types-in-python : because I can't manage to install `mypy` with a python3.10 installation...
 
Are you getting an error message?
I see that there's no 3.10 distribution for mypy on pypi... I wonder if you could force it to use the 3.9 one, just to see if it works.
 
3.10 is still in beta, right?
 
How could I do that?
I have tried to run `pip install mypy` in a docker container using python:3.10.0a4-slim-buster
Yes, it's still in beta.
 
We're up to "Python version 3.10.0 alpha 4" according to Cpython's repo
 
And the pip install mypy fails building the wheel for typed-ast
 
5:44 PM
@Kevin ah, not even beta
If you live on the cutting edge you get cut
6
 
I know that pip's requirements grammar lets you specify a python_version, but I don't know off the top of my head how to embed that into a one line command
If all else fails you could download the 3.9 .whl file from pypi.org/project/mypy/#files and pip install path_to_the_whl
 
@AndrasDeak Well, I don't.
I was just willing to try out an answer I was given on SO. But it does not seem to be doable in practice (at least not until mypy supports python3.10...).
 
Yeah not hugely practical I'm afraid
 
@Kevin ERROR: mypy-0.800-cp39-cp39-manylinux1_x86_64.whl is not a supported wheel on this platform.
 
Darn. Well, it was a long shot
 
5:49 PM
Well, I will stop considering this answer then ^^
Thanks for your help :)
 
Is there a way to read pivot table already created in an excel file in Python using pandas or by some other library?
I see pandas has pivot_table function, but it is used to create pivots in excel, not read existing pivots.
 
a pivot table should be "just a table" for all intents and purposes no? just read it?
 
If the pivot table is the only thing in the file, then perhaps pandas.read_excel would do it
oops beaten
 
ooh, kevind the kevin? ^.^
 
You are growing more powerful
If pandas can't parse your excel file, you could cut out the middleman and use openpyxl
 
6:05 PM
Thank you for responding guys.

I have an excel file containing dropdowns.
E.g. a dropdown containing employees names.
When I select an employee, I see all data for just that employee.

in the same way, I have 6-7 other dropdowns.
Any way to read excel in the same format and have it display in a browser?
Thanks.
and the excel file is generated from PowerBi... if this helps any.
 
6:35 PM
It's not going to turn it into html for you though, I doubt any library can do that out of the box
 
@Aran-Fey Alternatively, write considerate messages rather than leaving it to the system programmer of your dependency who knows nothing about your application.
@Kevin See above.
 
I am usually on the "knows nothing" end of these situations so I am happy to have the other guy write considerate messages for me
 
@Kevin Thank you.
 
6:54 PM
hi
 
To be clear, I don't think it's, like, a glaring oversight that the JsonDecodeError message isn't maximally descriptive. Inside the innermost branch that raises the error, the comma character is exactly and only what it expects to see. So, arguably, implementing my imagined patch would make it less technically correct
 
@Pamplemousse Sorry about that. MyPy has some compiled parts, it won't actually work with Python 3.10 any time soon; there is no need to run MyPy on 3.10 to check 3.10 code, though. The current master of mypy already has support for |-unions but the release does not.
 
7:16 PM
@Kevin rephrase to "Expecting ',' delimiter in this block of code"
 
 
4 hours later…
11:06 PM
Well this was fun. I dist-upgraded my debian to nudge a lot of "kept back" packages to be upgraded. In the process python 3 got bumped from 3.8 to 3.9. This implied that python3-distutils is now python3.9-distutils, and 3.8 got removed, breaking my 3.8 installation and 3.8 venv. I started a new one with 3.9, but llvmlite which is needed by numba needed an llvm installation, but the debian package for llvm was exactly the wrong version compared to what llvmlite needed.
So I installed an llvmlite one version older from source, and numba worked. And then I realized that another package I use is not available at all for 3.9... so I ended up building 3.8 locally and sticking with that until my dependencies bump themselves to 3.9...
it's not like I had plans for actual work tonight
 
11:27 PM
hi all,
Can I find someone who can deal with sentiment analysis in python
 

« first day (3756 days earlier)      last day (1175 days later) »