« first day (4072 days earlier)      last day (859 days later) » 

12:01 AM
Cbg, I was going through my math class of truth table and was wondering if there was any equivalent to "if p then q" in python. TBH I am not clear what "if then" means, so I was wondering if I would be able to understand this concept with something inside python already, like I was able to understand "and"(p and q) and "or"(p or q) relating to python faster.
 
I don't understand what's happened. My phone has switched to mobile view but I've been using the browser and pretending to be on a PC for over a year
 
@CoolCloud Nope, there's no builtin operator for that. It's functionally equivalent to (not p) or q though
That's a really bad example of if-then in that image, wow
 
quality education
@Aran-Fey Oh nice
So I assume there would be nothing built in for if and only if too?
 
Here's a better example: "If it rains, then the ground is wet." There are 3 possible scenarios:
1) It's raining, and the ground is wet (because of the rain)
2) It's not raining, and the ground is wet (because of a flood or whatever)
3) It's not raining, and the ground is not wet (duh)
The only state that is impossible is "It's raining, but the ground is not wet".
 
@roganjosh "that's my secret, Cap. I'm always on mobile" meta.stackexchange.com/questions/372049/…
 
12:09 AM
@CoolCloud Is that even a logical operator?
 
Well...
 
That's just p == q
 
Wow lol
@Aran-Fey Ah this makes it MUCH more clear
 
@AndrasDeak thank god I'm not losing my mind. I've got it back as it was but I swore I didn't touch anything to change it in the first place
 
@Aran-Fey Anyway thanks, this makes it much easier to understand :)
 
12:21 AM
@roganjosh you shouldn't be able to get it back
 
Bite me, SO
I feel like I need some 80s music to accompany me riding a Harley. Or, I'm not really breaking any new rules that they intended for chat.
 
Girls just wanna have fun...
The bubblegum poppiest song I can think of, fortunately from the eighties
 
I can roll with that
 
Hello :D
 
 
6 hours later…
6:23 AM
p = {1, 2}
q = {1, 2, 3}
print(q < p)
@CoolCloud This is probably the closest equivalent in python code, but it is because of the mathematical equivalence between set operations and boolean operations.
 
 
3 hours later…
9:03 AM
cbg
docs.djangoproject.com/fr/1.8/_modules/django/db is it correct that close_old_connections is not part of the public api, because it is not in __all__? Could it be an oversight and forgotten to be added? What is the definite source of when something is part of the public api or not? If I search for the function on django I don't find it, only using google I get to that page
 
9:38 AM
cbg-ning
quick question: Let's say you are using python with sqlite and you are tasked to retrieve the first line where you have the minimum values of something
in SQL, it would be something like that SELECT restaurant_name,MIN(restaurant_seat) FROM restautant GROUP BY restaurant_seat LIMIT 1. I was thinking of embedding it in the python query. But thinking about it (and because it is my first foray with db using pythion), I was wondering if there is another way to do that ...
 
us an orm
whats the context?
 
@Hakaishin No, it is not an ORM. There is no specific context, right now, just an exercise I was asked to do.
 
@AndyK then it depends what the excercises whants to teach you
 
@Hakaishin No idea but thinking about it, the embedded SQL seems to be a honest one
 
 
1 hour later…
10:55 AM
Fixing all these warnings the one that is left the most is too broad exception clause. And I gotta give it to Java the throws idea is nice. I would love to know what all possible things my functions can throw to be able to catch them
Also SE is so useful, I read this yesterday: money.stackexchange.com/questions/146723/… And was hit by it today. I gotta say without having have read that scam post, I might have engaged a bit. Now it was an easy block
 
11:37 AM
I have a list of bytes, how to convert it to json? i used json.dumps(bytes_list), but python shows error
 
What do you expect the result to be? JSON cannot represent bytes directly.
 
11:49 AM
You have a list of bytes? That's unusual O.o
 
the story is this, I have an app script endpoint which receives a post data and saves in a folder. but to send the data in python I need to read the file bytes as a string and the encode it, but this solution is not working, as I have received no files at the endpoint
the dart solution is like that, I read the file as bytes and then b64 encode it and send a post request, thats it, it works
so I was thinking maybe I should make a byte list instead of a string and then I make it json, and then I encode it and send via post request
 
I... don't get the description. Is the "post data" bytes or string? "read the file bytes as a string and the encode" would imply reading bytes, converting to string, and then converting to bytes again – is that what you actually want to do? Your description implies that you store received data in files, so "I have received no files at the endpoint" means there is no data – what do you want to send, then?
Python's base64 works with bytes data, so "read the file as bytes and then b64 encode it and send a post request" should work just the same in Python I guess.
 
12:06 PM
I don't follow it either. What is the endpoint you've constructed?
 
in my python script I am reading a <text.txt> file and putting in a list of bytes like this [b'H', b'E', b'L', b'L', b'O']
 
What's the point of the list? Why not just b'HELLO'?
 
12:21 PM
But I'm asking about the API code you have. I don't understand why you've programmed something to take a list of bytes
 
Anyway, sending a file as JSON or as base64 are both bad ideas. HTTP has support for files built in. Use that mechanism.
 
to address the elephant in the room, bytes are already a sequence of ints. you've essentially created a frankenstein monster instead of just simply sending bytes
also, i suspect you should have been able to get the strings to work just fine as well
 
<considers adding a strict "no elephants" policy to our rules>
How did you get on with your solver, Aran?
 
I finished refactoring it just an hour ago. Discovered a design issue that I'm now pondering, so refactoring will likely continue soon...
I have code that produces a solution for your problem, it's just not pretty
 
I expected it on my desk by 9am to start playing! :P
Ooo, that sounds cool! What's the ballpark run time?
Also, that's pretty fast going to get an MVP in that space of time
 
12:35 PM
Can't say, haven't tested it on a large dataset yet. I'm just playing around with 2 machines and 3 products
This MVP has been in development for weeks :D
 
Not on my problem, though. I'm guessing the refactoring is around generalising for different problem domains?
I've got a meeting in an hour with a steel manufacturer and I think it's going to push the limits on what we can solve in reasonable time. That'll be two pretty gnarly and totally different problems on our plate - one where we have a combinatorial problem but with 3 steps in series, where each sub product can then go on to become 15 sub-products. Very much like that game that you and Kevin were talking about
 
That too, but mostly it's about thinking up a design that's useful for both laymen and experts. Currently, I have a low-level API based on multiple inheritance with abstract base classes, and a high-level function that takes 2 dozen (optional) arguments and dynamically constructs a suitable solver for you
 
I already have a name for my production scheduling library, so that's at least 80% of the work done. The last 20% is just being hand-waved at the moment
 
Hahaha, good work
 
1:05 PM
@roganjosh 15% is registering it on PyPI. Hurry up!
 
Alas, this will be internal :/
At some point it would be cool if I could get at least some portion of my libraries released as open source. There's actually a chance of that with the company because they want to encourage contribution to open source, but at the moment it's just not going to happen
 
me again, what is the possible cause of key error in dataframe while in fact when I print the columns. it is already there. even if I store the column names inside an array and passed it as an index. it generates key error also. i cannot find the right keyword to google this
the closest i get to googling this is finding an answer regarding whitespace delimiters problem, while mine using ExcelFile which didn't even have it
 
It should not be possible to take a list of columns, cycle it back into the query without modification and get a KeyError. You're going to need an example
 
As a rule of thumb, if you get a KeyError that's because the key is not present. Python rarely throws errors just because it feels like it.
 
"rarely"? :p
 
1:16 PM
Whitespace delimiters don't really make sense here. That will affect you with the . accessor notation, but it's quite possible that you have leading/trailing whitespace even with single-word column names. Also, I don't understand the point about ExcelFile
 
Hi
hope everyone's doing well
 
'ello 'ello
 
I'm here looking for a suggestion on how to solve a regression issue. Is anyone here familiarized with the problem? I have different straight lines with the same (approx.) slope and different ns
here you can see a picture of: stackoverflow.com/questions/70283688/…
do you think there's a package for that?
 
function doPost(e) {
  var myJSON = JSON.parse(e.postData.contents);
  var blob = Utilities.newBlob(Utilities.base64DecodeWebSafe(myJSON.file),myJSON.contentType,myJSON.fileName);
  var body = blob.getDataAsString();
  MailApp.sendEmail("xxxx@gmail.com", "this is a test subject", body);
}
this is the end point i was talking about
 
@JonClements It helps me pretend I don't make any real errors. :P
 
1:21 PM
the code is self explanatory. it takes the data sent to it, and makes it a email body.
when I am using the dart solution it works like a charm.
void sendEmail(file) async {
  List<int> fileBytes = File(file).readAsBytesSync();
  print(fileBytes);
  var encodedBytes = base64.encode(fileBytes);
  print(encodedBytes);

  var daten = {
    'fileName': 'wendeux',
    'contentType': 'text/plain',
    'file': encodedBytes
  };

  var dio = Dio();
  var response = await dio.post(
      'https://script.google.com/macros/s/<google-id>/exec',
      data: daten);
  print(response.data.toString());
}
I want to replicate the dart code in python
 
If it's a plain text file, just read it as a string instead of bytes
 
def sendEmail(file):
    with open(file, "rb") as f:
        contents = f.read()

    encodedBytes = base64.b64encode(contents) # b64encode takes a string argument
    # print(f'{encodedBytes = }')
    data = {
        'fileName': 'wendeux',
        'contentType': 'text/plain',
        'file': encodedBytes
    }
    response = requests.post('https://script.google.com/macros/s/<>google/exec', data)
    print(response.text)
    print("email sent successfully")
 
'file': encodedBytes.decode()
people_who_were_bitten_by_b64encode_returning_bytes += 1
 
"# b64encode takes a string argument" *doesn't. But that doesn't matter much, since contents isn't a string.
 
1:38 PM
yuck, camelCase
 
Hey
 
should use this:
sample_string_bytes = sample_string.encode("ascii")
base64.b64encode(sample_string_bytes)
 
Im trying to learn python, does anybody know any good resources or learning websites that I could use?
 
@discoMonkey What is sample_string? How is this related to the problem?
 
@ColorWolf1 You might want to start at the official Python tutorial.
 
1:43 PM
Oh I didn't know there was an official Python tutorial, thanks
 
@Aran-Fey I wanted to point out the line where I have encoded the bytes, should I encode the string to ascii before b64encode ??
 
What is "the string"? You don't have a string
 
i could have read the text file as string instead of just binary
 
If you read the file as string, you should skip the base64-encoding. That serves no purpose then
 
I just realized there's no perl room
 
1:57 PM
Lame joke alert: That's because StackOverflow is optimized for sand, not perls
 
Im using the python tutorial, but when I try to use numbers like they do my thing doesn't return anything.
Im on https://docs.python.org/3/tutorial/introduction.html
 
Are you writing your code in a file or in the python terminal?
If in doubt, send a screenshot
 
Im writing it on a website right now, mostly because im on a school computer and they don't allow us to download things like the python compiler.
codingrooms.com
 
@Aran-Fey Of course this only applies for new python learners :P
 
2:14 PM
@ColorWolf1 You can launch a REPL/Shell directly on python.org. There's a part showing a shell with a yellow >_ in the upper right corner; click the >_ button.
It's a pythonanywhere.com shell, I think.
 
Alr Ill look at it
Oh wow it works
The numbers work now lol, thx
 
cbg
 
what's worse then c++ you ask? CMake....
 
2:41 PM
Hi everyone, I have a pandas dataframe in which one column is a date column and the other is a timezone based column (in the form of difference from GMT i.e. either ahead or behind ). Is there any way I can vectorize the operation of creating a new adjusted date column based on the timezone? pastebin.com/H7c8tncq
 
People still ask questions in the chat instead of as a regular question on the site? rip
 
You can concat the strings before passing to to_datetime. Note that string operations aren't really vectorised
@12944qwerty rip?
 
We've practically been getting bombarded with questions lately
 
they should simply increase the rep limit again
 
what is the limit currently
 
2:45 PM
20
 
that seems lower than i remember what
 
@roganjosh can you show one example?
 
it was 100
 
@RaphX not really any different to this
I don't think rep as a barrier is either effective or going to fix the problem. I'm becoming more stringent about asking for MCVEs and not giving handouts. No regular should feel the need to pick up poor questions, so I will support requests for more info when I'm about. I don't think it would be healthy for the room to have higher arbitrary standards
 
3:04 PM
I dont think the rep barrier does very much for the chat
 
Yeah, earning 20 rep is easier than finding out that chat exists
 
I didn't even know chat existed until I had a conversating with someone in a comment section, where it then told me that we should move to chat. It took me another 2 hours to find where chat was lol.
*conversation
 
@ColorWolf1 having a barrier probably does a lot because you can't just set a bot up from scratch - you have to at least do something "useful" (though rep can be easily won)
 
Yeah I guess it does prevent bot spam
But who would set up a bot for stack overflow? And if they would, they would be one odd human being.
 
My sweet summer child
It'd be fine if there was only one of these odd people :P
 
3:08 PM
Hahaha
 
@ColorWolf1 Maybe you should check out this room
 
What is that
It looks like a bot log or something
So they do make bots for stack overflow
 
It basically is. But I think it's important here to make the distinction that those bots are helping the site
 
Yeah
But imagine the bots on like.. Youtube or something infiltrating Stack-Overflow
 
True, I should have pointed that out
 
3:12 PM
Those spam bots
 
People put a lot of effort into those bots
 
Dang, thats alot of coding, at least they aren't spam bots
 
3:37 PM
Your friend's ideas don't align with what's useful with the Python room.
 
3:49 PM
I am sorry
 
 
2 hours later…
5:56 PM
Wow, using the new cool mobile interface for the very first time!
Cabbage, all
 
cbg
what new cool mobile interface?
(or you presumably mean the one that seriously breaks the desktop one :p)
 
6:20 PM
18 hours ago, by Andras Deak
@roganjosh "that's my secret, Cap. I'm always on mobile" https://meta.stackexchange.com/questions/372049/new-responsive-activity-page
Still riding my Harley with "Girls just wanna have fun" playing. It's a long scene, but really drives the message home
 
6:38 PM
Wow, my IDE looks a whole lot less colorful now that I made my first commit for this project. All the files went from a nice green to a boring grey
 
6:49 PM
Hi all, hope you are doing great!
Haven't been here in a while now...
I've got a small question non related to python but SO in general. How (if even possible) can I decline someone's edit in my answer?
 
@CeliusStingher if you're the owner of the answer - you just go to review and click reject
did you have something specific in mind?
 
7:10 PM
@Aran-Fey You need VSCode. Then the only grey things are untracked files. I think it's one of their key selling points :P
 
Thanks for the answer @JonClements I am referring to this specific answer stackoverflow.com/questions/70294885/…
 
Shopping around for an IDE; "I really like this model, but do you have it in red?"
 
Depends on your theme I guess. With cobalt2 my files are all grey, just... a lighter shade than untracked files
 
In which another contributor edited my answer with code text for the name of columns and text should not be code
 
@CeliusStingher looks like a good edit to me... they corrected a typo and put links to the relevant documentation - what am I missing?
 
7:18 PM
I got a comment a few days ago by someone (can't remember the name) stating that code text like this should be used only for code and not to highlight stuff (for example column names as the contributor did)
 
ahh... okay... yeah... there wasn't a real need to code block the column names... but it wasn't harming anything... and sometimes code blocking column names actually makes things more readable... I don't think there's a hard and fast rule for it
assume good faith for edits unless they're blatantly crap - as the owner of the post you can always do as you've done now and gone down the middle accepting some changes but putting some back
 
Appreciate it, I don't remember if the comment came from a moderator or not... Perhaps I took more seriously than a suggestion from their part!
 
7:44 PM
@CeliusStingher there's no comments on your answer (deleted or not) and no moderator was involved anywhere in that Q as far as I can see
 
I wrote a web scraping script in AWS Lambda using python but I cannot figure out how to change WebGL Vendor/Renderer. Everything works under my local IDE but not on Lambda. For more details, see here: stackoverflow.com/questions/70265306/…
 
Nono, it was on an answer some time ago @JonClements
 
I waited 2 days per room rules and researched all I could... nothing
 
@CeliusStingher ?
 
@roganjosh Sneak peek at my current code. Would appreciate feedback if you have any. I hope I've added enough comments
 
7:50 PM
Oh sweet. I'm really curious about your approach here so it might take me a little while to get back to you
 
Sure, no problem
 
I think I'm missing the meat of the solver? The action will be in wayfinder won't it?
If you want feedback on the interface, I think you've done a good job of abstracting the problem. _compute_possible_moves is what I think will explode on big problems (if I understand the interface correctly)
 
Sort of? Some of it is in there, yes. Nothing terribly interesting though. The search algorithm is just a depth-first-search per default, so the only optimization it does internally is that it assigns work to those machines with limited capabilities first. You can see how it starts by letting Machine3 produce a bunch of Product D
It's actually fine if _compute_possible_moves returns a billion results; child states are created lazily on demand. So with a DFS, it will only create 1 child state
The next optimization I have in mind is to check how many different machines can create a product (for example Product D can only be created by machine 3), and start by producing those. Still figuring out how to generalize that
 
8:06 PM
With the heuristic approach, I can pre-generate the machine swaps, then ensure that each machine only swaps to a product it can make. That can be done easily enough with dicts. It takes a single function call to np.random.randint() to give me the machine ids... after that I'm stuck with a loopy solution to draw from their product dicts
It's still quicker (last I checked) to generate the machine swaps in a single batch of 10,000, even if I terminate early, than it is to select a machine index at random on each loop
Bit wasteful on memory, but meh
 
Memory's cheap
 
@JonClements You said:
@CeliusStingher there's no comments on your answer (deleted or not) and no moderator was involved anywhere in that Q as far as I can see
And I replied that the comment with regards to not using code block for column names was in another answer of mine, some time ago which I couldn't find. It wasn't in the answer I shared
 

« first day (4072 days earlier)      last day (859 days later) »