« first day (3630 days earlier)      last day (1301 days later) » 

12:00 AM
Something simpler than np.stack([df[column].cat.codes.values for column in df.select_dtypes('category')], -1)?
 
 
3 hours later…
3:03 AM
cbg, I want to be able to create and delete files in a remote ubuntu server using python, I have looked into paramiko (many answers suggested this) and running linux commands for this, any other alternatives?
is there a library that can work something like open('file_name',mode='w',server='0.0.0.0') ?
so I can handle them as file-like objects
 
We use a package called spur which is a wrapper around paramiko, and it supports this kind of remote file access.
 
this one? github.com/mwilliamson/spur.py if it is then thanks, I will see how I can make this work for me
 
Yes, that's the one.
 
 
5 hours later…
8:32 AM
For jupyter notebook, I always find the .ipynb_checkpoints really confusing since they appear on almost every .ipynb file
Sometimes I move the .ipynb file around leaving the .ipynb_checkpoints folder behind is it good practice to move both the folder and the file together all the time? Or is it safe to delete the .ipynb_checkpoints folder
 
9:08 AM
I delete the checkpoints folder regularly
When I'm moving around files, that is
 
9:19 AM
@Sijmen thanks looks like it only updates everytime you manually save so it's not too important
 
 
4 hours later…
1:14 PM
cbg guys
 
 
1 hour later…
2:30 PM
Python... Is good.
 
2:43 PM
That moment when you are in a video conference and there are audible police sirens closing in on the speaker...
@Kevin As in "Life... Is good." or "Mac'n'Cheese... Is good."?
 
Virtuous, tasty, and emotionally fulfilling
 
I was told snakes taste like chicken. Does that match your experience?
 
It tastes like the color of a television tuned to a dead channel. An acquired taste, admittedly
 
3:09 PM
It's been two weeks of reorg headaches at the office, and the only real change to my routine is that I don't have to fill out the yearly Ω-TPS mega-report anymore. Totally worth it.
 
cbg folks
 
The report required my mother's maiden name, a measurement of the total number of semicolons in .cs files on my hard drive, a five paragraph essay on the Teapot Dome scandal, and a sprig of wolfsbane plucked from the highest hill in New Jersey during a new moon, so I'm pleased that it's no longer my responsibility
 
really?! they actually asked about LoC?
 
No, just semicolons. I think they're afraid we're going to run out.
I think the Visual Studio Enterprise license has a clause about that. Don't want any overage fees.
 
3:33 PM
HI
How can I use this django json path pathlib Path module instance of os json_file = open (os.path.join (settings.BASE_DIR, 'sep_app/json/table.json'))
 
I don't understand the question. You have what appears to be valid code. Is it not doing what you want?
 
django 3.1.1 recommended to use pathlib instance of os module, how can I use pathlib here?
json_file = open (os.path.join (settings.BASE_DIR, 'sep_app/json/table.json'))
 
Oh, ok, I understand the question now. Let me pull up the pathlib documentation...
Probably something like json_file = open(pathlib.Path(settings.BASE_DIR) / "sep_app" / "json" / "table.json")
 
thanks, this one working json_file = open (Path(settings.BASE_DIR, 'sep_app/json/table.json'))
 
According to the docs, just replacing os.path.join with pathlib.Path should work.
Kevin'd again :/
 
3:44 PM
That works too. I wish the pathlib docs, or perhaps an appendix to PEP 8, would give some guidance about the preferred style for Path construction.
There's like three ways to do it, which is two more than I usually like
I think this isn't the first time this sentiment has been uttered in here this month
 
You mean what Aran was asking lately?
 
Ah, so it was Aran. Yes.
 
yesterday, by Aran-Fey
Poll: path / 'foo' / 'bar' or path / 'foo/bar'?
Or do you mean something else?
 
That's the one :-)
 
suggestion: add an import hook that understands p-strings to automatically create Path objects.
pf-strings support interpolation with non-literal paths
 
3:48 PM
time to edit that interpreter code, Miyagi
 
If I were writing code for myself, I'd probably go with the approach NIKHIL chose, but I didn't propose it initially because putting slashes in the string literal part of the path felt a little Windows-centric
 
use prf-strings for windows...
 
using slashes outside of the literal is not windows-centric, of course, because / is an operator and \ isn't so there's really no choice
 
am I weird for still liking os.path.join(*"path/to/file".split('/'))
perhaps that's an artifact of solo-coding for too long?
 
@AndrasDeak that's what the voices in my head keep telling me...
 
3:58 PM
Superfluous argument unpacking is an early warning sign of Telecommuting Madness. You need other coders to yell at you so you remain grounded in reality.
You use too many semicolons! Or not enough! One of those!
 
@inspectorG4dget That does seem weird, yes. Do you really need to convert slashes to OS-specific path separators? Because if you don't, just write "path/to/file" without all that other stuff
 
@Aran-Fey it's for the OS compatibility reasons
 
Well, if you're letting python handle the path, regular slashes will work just fine on any OS. So unless you're passing that path to another application, you're wasting your time
 
oh right! that's a fair point
 
I wonder if that behavior is documented anywhere.
If not, it might just be an implementation detail of CPython, which means I can make KPython do the opposite
In KPython, open("foo/bar.txt") will look in the current working directory for a file whose name is "foo/bar.txt"
 
4:09 PM
good question
 
well, I intend to be a python pirate for long enough for this to never become an issue. Anyone got a broom... and a rug?
(explanation: "python pirate" => CPython)
 
KPython costs $100 per user license so if you use any other distribution you're effectively pirating from me
I'm losing millions of hypothetical sales per year!
 
4:31 PM
hahahaha
 
Just think of me eating a single pea for dinner in my ramshackle apartment, lit by the guttering flame of a stub of a candle
 
you have outreferenced me, sir
 
The stereotypical image of cartoonishly abject poverty has no single origin, although while composing the message I was thinking of both A Christmas Carol's Tiny Tim, and also this image:
 
4:48 PM
ahh. Add a dimly lit screen and strewn research papers and you've described the grad students of my era :P
 
5:02 PM
Hello
pixmap = QPixmap(r"C:\Users\Χρήστος\Desktop\1234.png")
        self.player_list_image_label.setPixmap(pixmap)
        self.player_list_image_label.setScaledContents(True)
Works ok!
But if i replace 1234.png with a jpg image, the image didn't displayed... :(
 
@ChrisP educated guess: that function/class doesn't support jpeg images. Have you looked at the documentation?
 
No (sorry).

So, what method should i use?
I want to display an image inside a frame and at the bottom of the frame i want the image title.
 
I don't know
 
@ChrisP Even if I knew I wouldn't want to help you, because the last time you asked for help here you gave confusing information and refused to clarify and follow up when people tried to help you.
Together with your history and Kevin's link I'm sure you just gave a wrong file path.
 
5:07 PM
I also suspect that it's a bad file path. If you can demonstrate otherwise with an MCVE, I could give a second opinion.
 
MCVE, i.e. Chris P's kryptonite
 
I'll meet you halfway and provide my own png and jpg files, assuming the problem is replicable for any kind of png and jpg.
 
There is displayed that supports many kinds of image formats.
 
We're on the same page, literally :-)
 
But it's on c++
 
5:10 PM
True. But PyQt runs C++ qt under the hood
So odds are pretty good that they support the same kinds of images
... Unless PyQt is a major version or two behind Qt? It's not inconceivable I suppose.
This random tutorial I googled claims that PyQt supports jp(e?)gs
 
That tutorial doesn't work. (I changed "image.jpeg" to "image.jpg")
Same, with both links.
Doesn't open jpg images
 
Delightful, I can use the tutorial's code as an MCVE and see if it works on my machine.
Installing PyQt5, please hold...
 
@ChrisP Is the image actually jpg? I mean not just the extension but the image itself? Funnily this is Windows we are talking here.
 
self.im = QPixmap(r"C:\Users\Χρήστος\Desktop\Papinhio player\project\disket box\images\ΑΓΙΑ ΚΥΡΙΑΚΗ.jpg")
I will upload the image to check it
 
Ok, PyQt is installed. I can verify that this code works perfectly for png, jpg, and jpeg files.
I notice that no error message is displayed if I pass a nonexistent filename to QPixMap. I'm surprised that I didn't even get a warning.
 
5:20 PM
@Kevin lol what?
 
Ok i tried, with the code that suggested.
I can see the png image but not the jpg image.
 
fun fact: you can't really wrap an async function with @functools.lru_cache, the way you normally would because the cached return value would be the anawaited coroutine, awaiting which changes the coroutine in-place
 
Is something wrong with the path?
 
which brings up an interesting question: any way to make lru_cache await the coroutine its target returns?
 
He's probably loading an image that is originally different extension but is saved as jpeg.
 
5:21 PM
Perhaps you could use os.path.exists(the_file_path_and_name) to manually verify that the filename is real
 
Windows just opens up the file that it shouldn't but python will not I suppose.
 
and apparently, this is the answer
 
Open the jpeg you are trying to load in Paint click save as then save as jpeg and then try
 
@AshwinPhadke I'm pretty sure Windows won't do that, but I guess I should test when I'm back at my PC
 
This is interesting... If I rename my image.png file to image.foobar, and change the filename in my script as well, then PyQt renders it just fine.
It must be determining the file type from the contents of the file, rather than its extension.
 
5:25 PM
@Kevin it's almost as if file extensions were arbitrary and silly :)
 
I think the file carries metadata
Actually, now I've tied myself up. Maybe Windows will open it with a different extension, provided that both are actual image formats
 
no sane software should rely on the file name alone
 
I know for sure that pngs and jpegs identify themselves in the first few bytes of themselves
 
@roganjosh I know that sounds silly but that happens only in Windows, no matter what extension you save an image file it wil still load it despite the image headers telling you it is a different file format
 
I try with "1.jpeg" in the Desktop directory (Windows).
The image didn't opened.
 
5:26 PM
This is only Windows specific issue
 
@ChrisP too bad, better luck next time
 
and even I was shocked when I discovered it
 
mmm, I have to test this now. Give me a few mins
 
That's why I told him TO ACTUALLY SAVE IT WITH DESIRED EXTENSION.
Windows becomes too user friendly but then again it is a general people OS so people shouldn't be troubled by this
 
@AshwinPhadke there's really no need to shout
 
5:28 PM
If by "no matter what extension you save an image file it wil still load it" you mean "windows will always determine the type of an image file despite its extension, no matter how you try to open it", that doesn't seem to be true for me. If I double click on image.foobar, then Windows asks me which program I want it to use.
If it was smart enough to know it was a png, then it would have opened it in paint or firefox without prompting.
 
@AndrasDeak heheh not shouting just highlighting, Is that what means on internet to write in capitals?
 
@AshwinPhadke no
reasonable discussion doesn't include capitals outside abbreviations
 
Or maybe you're saying "the windows build of PyQt can deduce file types, but not the linux build or osx build", which strikes me as odd although I have no evidence to disprove it
 
@Kevin .foobar is not a valid extension obviously, I am talking image extensions only.
 
@Kevin What I want to test is if you change the extension to another valid image extension
 
5:29 PM
Interesting. I will test that.
 
If i save as png with Ms paint it opens the image.
So may i convert the images?
 
So save an image with any valid image file
 
@roganjosh how will you see that it was opened differently?
Error from the reader?
 
@ChrisP obviously because now the image is actually a png
 
@ChrisP there might be international law forbidding coversion of your images
 
5:30 PM
You wouldn't, but Windows will determine what software to use to open a file based on its extension, so it's quite possible that it will still load the image because it's going to launch the same program
 
Ok, now that I rename the png image from "image.foobar" to "image.gif", when I double click on it the image opens in Windows Photo Viewer. Claim confirmed.
 
@AndrasDeak lol
 
You'd have to pull the file metadata
 
@Kevin Thank you
That's what I said , windows is too user friendly
 
Then if i save as the png image as jpg the python program still doesn't open it.
*Sorry (doesn't open the image)
 
5:32 PM
See here
As you can see, I've adapted well to my Mac
 
It is a feature if you ask any windows developer because as a normal user why would you bother the normal user with tons of file extensions if it is just going to be an image, this is silly but it is what windows does.
@ChrisP That cannot happen unless you have corrupted the image, try opening a different actual jpeg
unsplash.com/photos/F-rvSJl6qI0 Use this but it's a jpg
 
Ok i will try.
 
Half-serious solution: rewrite the application in Tkinter. If the problem goes away, it was caused by PyQt. If the problem persists, it's a problem with your file path or dev environment or OS.
 
No, with the unsplash image i still can't displayed. (Excuse me for my English)
 
5:37 PM
I will try with ubuntu
 
@ChrisP Use Kevin's solution
 
I will tell the exibition results on ~15 minutes.
 
Trying a different computer is also an acceptable diagnostic step
 
Well, my father's computer is broken.
 
Switching to the other OS of your dual-boot computer is also an acceptable diagnostic step
 
5:40 PM
Use Linux
that doesn't mean I oppose Windows, it is great at what it does.
 
Or, find out if you can see what format the file was originally as I suggested. "Use a different computer" doesn't seem a particularly practical way to fix the problem, it's only going to help with diagnostics
Actually, I think I've lost track of what we're actually solving :P It starts with "tutorial broken" and then becomes a discussion. Kevin verified that it isn't actually broken
 
just another day in no MCVE land
 
When I'm debugging I like to test a crazy theory like "the OS can't read jpegs" in between more sane options, just to mix things up a little
 
In ubuntu 20.04 i cannot open 'Αγία Κυριακή.jpg' but i can open another image with extension jpeg.
 
5:46 PM
There are only so many ways you can double-check a file path before you go mad
 
@Kevin I am currently debugging a file path issue and probably going mad
 
@ChrisP Hmm, maybe it's a unicode issue? What if you rename the file so it has only ASCII characters, for example holysunday.jpg?
 
Ok HollySunday.jpg opened well!!!
So how can i fix it?
I mean i have images with greek letters in filename.
 
On my (Windows) machine, QPixmap("./Αγία Κυριακή.jpg") works. So it's probably not PyQt's fault that it doesn't work for you
The next culprit is your text editor or IDE. If it's using the wrong encoding, the filename in your Python program might not match the filename in the file system.
 
I didn't try "./Αγία Κυριακή.jpg", i tried r"Αγία Κυριακή.jpg", so give me a minute please.
 
5:51 PM
Use english file names. Also remember a program will have problems if there is a space between file name you will have to explicitly mention space.
 
r"Αγία Κυριακή.jpg" also works for me. They should resolve to the same path.
Try to locate the encoding setting in your editor. Setting it to UTF-8 may help.
 
r"./Αγία Κυριακή.jpg" works
but in Windows i give an absolute path
(C:\Users\....)
Ok r"/home/chris/Desktop/Αγία Κυριακή.jpg" works.
So what's the problem?
 
I think at this point we have no idea
It feels like we've done a few laps round the block and, at least in my case, don't understand the problem properly
 
I've looped back around to "path or file does not exist"
 
@ChrisP You can remove r and just replace all \ with \\ and it will work, I said earlier this is windws file handling you have to use it the way it wants it.
I don't even know what the original problem is now
 
5:58 PM
I agree that non-raw path strings work in windows if you use "\\", but if you're implying that you have to do that instead of using raw strings, I disagree
 
@Kevin What I meant was his methods of path handling were not Windows compatible, he can use wither r or \\ but cannot simple expect to use \ and make it work
 
Also note that i have python3.8 in windows and python3.6 in ubuntu
 
I... Mostly agree that a non-raw string like "C:\Users\whatever" won't work in Windows. It frequently fails if any of the backslashes can be interepreted as an escape sequence. But sometimes by coincidence none of them can, and the path will resolve correctly.
 
@Kevin Yes it does work sometimes, but why take a chance :-p
 
Certainly it's good practice to use raw strings or proper escaping even if you're sure the path will resolve correctly. May as well get in the habit.
In any case if you go back to the start of the conversation, Chris was originally using raw strings, so he probably knows about the escape sequence problem already.
 
6:06 PM
print(os.path.isfile("C:/Users/1.jpeg")) returns True
 
If nothing else we know that QPixMap("C:\Users\whatever\image.png") won't exhibit the "empty qt window" behavior Chris has been seeing, because it will crash at compile time with SyntaxError: [...] truncated \UXXXXXXXX escape
 
invalid escapes might also become an error eventually bugs.python.org/issue32912
 
:prayer emoji:
@ChrisP Very interesting. That makes a bad path much less likely.
 
What is the meaning of: inadequate extension?
1
Q: Pyqt5 Why does my image load as a PNG but not a JPG?

JaitniumI'm using QPixmap to display an jpg image but it doesn't display. I converted the jpg image into a png and that works but I'd like to know the reason for it. pixmap = QtGui.QPixmap("information.jpg") self.infoLabel.setPixmap(pixmap) self.infoLabel.resize(100, 100) Loading as a jpg looks like t...

Bye guys, i go for walk.
:)
 
Perhaps "inaccurate extension" would be a better way of describing it.
Interesting that the poster there is claiming that PyQt can't deduce the type of an image file unless it has a matching extension. Exactly the opposite is what i observe on my machine. Could QT be making use of Windows' stupid "open files even if the file format doesn't match the extension" feature?
I'm curious how it behaves in Linux/osx.
Going by Linux's philosophy of "extensions are dumb and don't mean anything", I would expect the same thing to happen
 
6:17 PM
@Kevin There is no such feature. Windows is responsible for choosing which program will be used to open the file (which it does based on the file extension), and most (read: all) image viewers completely ignore the file extension. Windows has no clue whether the file format matches the extension or not. Only your image viewer knows that.
 
code style question: I have long list of attribute names that I'll want to parse out of an object. For readability, I did this:
my_list = ['a',
           'b',
          ]
 
Linux behaves exactly the same way. OS chooses the program, and the program opens the file. And I've yet to see an image viewer that informs the user about a mismatched file extension
 
I vaguely recall writing a tkinter app that refused to render an image unless its name had a matching extension. It may have been a nightmare.
@Aran-Fey Makes sense. So is the answerer of that question just flat-out wrong?
 
a problem that came up in prod is that we sometimes forgot the trailing , in each line (super easy to miss in the code review), which caused the strings to concatenate.
so I turned it into a listcomp:
 
It wouldn't be the first time an OP accepted an incorrect solution
 
6:21 PM
my_list = [line.strip() for line in
           '''a
              b'''.splitlines()
          ]
should that .splitlines() be on a separate line?
 
@inspectorG4dget ugh, I would say the answer is running black on the codebase
 
@Kevin Not necessarily. It's perfectly possible for Qt to require a matching file extension. It would be very unusual, but not impossible
 
Ok, I think we're on the same page now. My brain was running orthogonal to yours for a minute there.
@inspectorG4dget I use a pattern much like that from time to time. I put the split on the same line as the ending triple quotes.
 
much thanks
 
I don't think PEP 8 has a strong opinion on the placement of method calls in line continuations other than "be consistent"
 
6:28 PM
@inspectorG4dget ew
Way to ruin a literal
 
@AndrasDeak I don't quite disagree, but I'm also inclined to try something like this:
 
@inspectorG4dget Try this:
>>> """\
... a
... b
... c""".split()
['a', 'b', 'c']
>>>
 
my_list = [line.strip() for line in
           '''a
              b'''
               .splitlines()
          ]
 
When I use a triple quoted string to create a list of strings, I almost always do so at the global scope. That way, I don't need to muck around with multiple strip calls, because dangit beaten by holdenweb
 
@AndrasDeak not quite sure I understand what you mean
 
6:30 PM
Or alternatively include an extra newline if you don't want the method call on the last line.
 
I do use one strip call because I can't be bothered to put the "\" on the first line so I need to get rid of the newline some other way
 
@Kevin Did I just kevin Kevin?
 
Indeed so
That means your polaroid goes in the Eternal Hall Of Champions
 
>>> def foo():
...     my_list = [line.strip() for line in
...            '''a
...               b'''.splitlines()
...           ]
...     return my_list
...
... def bar():
...     my_list = ['a',
...                'b',
...               ]
...     return my_list
@inspectorG4dget with ^that compare dis.dis(foo) and dis.dis(bar)
 
6:33 PM
If you have a code linter, there's a good chance it can warn you about potential accidental string concatenation, FWIW
 
@inspectorG4dget I don't follow
 
@holdenweb ahh, so it seems that I'd forgotten that split()'s default behavior is to split on all consecutive whitespace. So I thought I needed to splitlines() on '\n' and strip() on whitespace for each line. Yet again, I earn my Village Idiot title
 
I'm telling you what I meant by the literal thing
 
For example PyLint has --check-str-concat-over-line-jumps
 
Woah. I need to try get that running in VSCode
 
6:34 PM
Oh, would the split() approach work even for indented strings? It never occurred to me to try that.
 
@Kevin if each row is one word
 
@AndrasDeak I only meant that I was using your suggested cleaner method at first, which then caused a bunch of bugs; and that's why I needed to move to the dirtier method
@Kevin Yup!
In [308]: L = ['''a
     ...:         b
     ...:         c
     ...:      '''.split()]

In [309]: L
Out[309]: [['a', 'b', 'c']]
 
@inspectorG4dget I know, although reject "needed" to move to.
 
@AndrasDeak Ah, true. I guess that's why I usually end up doing split("\n") rather than using the zero argument form
 
@AndrasDeak I wouldn't know how to fix that problem, then. I just found out (thanks Kev) that I could use PyLint's --check-str-concat-over-line-jumps. But I'm still on the fence about that, because it imposes a requirement that the team use a linter, which (while probably prudent) is unenforceable by me
 
6:38 PM
In my case, I don't use triple-quote-and-split because I'm afraid of string concatenation. I use it because I'm too lazy to type more than six quote marks.
A linter will not help me. I need a minion to do my typing for me.
 
@inspectorG4dget you could just enforce people paying attention with code ;)
Or writing tests that catch this, maybe
Either way that "smart" listcomp looks like terrible bloat to me
 
Kevin's Amanuensis, quite the honour
 
I think I'm going to go with the triple quoted split for this, actually. That seems to be the cleanest way for me. Thanks all
 
"Jeeves, take a letter. 'To who it may concern: import myAppGui; if __name__ == "__main__": myAppGui().mainloop(). Regards, Kevin Q Kevinson, esq."
 
"You are cordially invited to provide an MCVE" :P
6
 
6:43 PM
Alternate proposal: put the string data in a text file, which your script read()s from
Once your app goes viral and you need to translate it into 39 languages, you'll need swappable i18n files anyway
 
@Kevin today I searched for an error and 95% of google hits were localization pages
 
I actually did consider that. But this is for getting attributes out of an object from an API. So language/translation is not in the scope, which makes this a bit of overkill. But there is another part of the codebase that'll benefit from this. I might try this out there
 
Haven't felt that denvercodery in years
 
There is a certain despair upon discovering that all of your google results contain only pages that aren't intended to be human readable
 
If you haven't made it to the 7th page of Google results, where you're translating from Chinese and hoping for the best, you haven't had a real problem
 
6:48 PM
I sense a story here. Do tell!
 
I would sooner fake my death and become a cabin hermit than go beyond page 1. It's the principle of the thing.
 
@inspectorG4dget actually, I forget. I'd have to un-deactivate (?) my facebook to find it, and the cost-benefit analysis suggests it's not worth it. I don't think it was particularly interesting, just very obscure
 
oh well
 
My problems tend to fall into two categories: 1) there's a solution on stackoverflow, and it's the first google hit; 2) there are two google results, and both are in Russian.
 
I could use "reactivate" there, but then "deactivated" is the actual facebook status, so I'm not sure it works
 
6:51 PM
I'll allow un-deactivate. Or just activate :P
 
Having seven pages of results usually means that I have not yet vivisected the problem down to its most essential components
 
now I'm wondering what you'd call it the third time you do that... "un-de-reactivate"?
 
Re-deactivate
 
that'd be "to deactivate a second time", no
 
I thought that's what you meant
 
7:03 PM
I un-deactivated earlier today because I was told I needed a picture for my slack profile, then re-deactivated ASAP. I had 8 notifications and I had ended on a big argument when I first deactivated. It's painful to ignore the red notifications but I resisted... I passed the test
stackoverflow.com/q/64034288/4799172 needs more detail. The answer has invented a lot
 
nono... I meant "having deactivated, undo the deactivation (or activate); now do that activation for the third time, which would require a bunch of deactivations as well"
 
wut?
The status of the profile flip-flops between a binary state. There's no reason to try push the context of how many times that's happened into the language?
 
7:19 PM
1. sign up for facebook (primary activation)
2. deactivate
3. activate (first reactivation)
4. re-deactivate
5. un-re-deactivate (second reactivation)
6. de-un-re-deactivate
7. re-un-de-un-re-deactivate (third reactivation)
 
The first rule of English is "just have fun with it"
 
@roganjosh Kinda reminds me of chain email forwards whose subject line looked like "FW: FW: FW: FW: FW: FW: FW: FW: <the actual subject>"
 
s/<the actual subject>/READ THIS IMMEDIATELY!!!/
 
@inspectorG4dget I stand corrected. The context of how many times it's gone through the loop is relevant - it's been extra-vetted by lots of people so it must really be important
 
I imagine it'll be useful in detecting accounts of spies, but not beyond that
 
7:44 PM
Activate and deactivate your account at set intervals to send messages via very slow morse code
 
in C:\Users\Χρήστος\AppData\Local\Programs\Python\Python38\Lib\site-packages\pyqt5_tools\Qt\plugins\imageformats

has some dll's files (for example:qjpeg.dll).

May i copy those dlls?(where?)
 
You can still use messenger if you deactivate your account :P You can't if you delete the accpount. Fun-fact, you can't delete your account (well, pre-GDPR you couldn't, don't know about now)
@ChrisP Yes, you can copy files. I'm stopping this here because it's totally unclear what you're asking
 
Another job well done I guess
 
For the record I didn't have to move any dlls around or import them or anything in order to get jpegs to show up on my machine
 
8:16 PM
I have an API endpoint that returns an array. How can I serialize it so it's more like {metadata: {}, objects:[thearray]}
I do this in the serializer?
 
What do you mean by "array"? Is it JSON?
 
yeah so currently my endpoint returns [{a:1, b:2}]
I want something like {meta:{},objects:[{a:1, b:2}]}
 
Ok, that's a "list". Lots of other languages would call that an "array" but, in the context of Python, the word "array" implies numpy and that's not possible to serialize without some transformation
 
ah okay sorry. List then (I come from the dark caves of Java)
 
@qaispak that's 90% of what you want. You'll need to be a bit clearer on the problem you're facing. And no need to be sorry, I'm just pointing out what I think is an important distinction from other languages
 
8:20 PM
yeah thanks for that
So for this problem, I know I could possibly wrap it in what I want right before I return the data in my response but that doesn't seem correct to me
 
"correct" in what sense?
If you have a list and instead you want a dict with the list as a value, it's correct to do just that
 
You're going to need an MCVE and some context for me to be able to help you. I've guessed some of it, but I can't answer to "doesn't seem right" if I can't see what you've done. It seems right in-so-far-as I can imagine things, just like I can imagine dragons
 
Just to be clear what we're saying is API response -> JSON to python list -> python dict -> python dict to JSON if you want to pass that on as JSON for some reason
At least that's what I had in mind :P But I don't actually know web stuff.
 
@AndrasDeak , I feel like somehow Django should be adding those things but from the answers seems like I was wrong. I'll look back in my code again.
I just assumed the fact my return value doesn't have a meta and objects key meant I'm missing something obvious.
 
(can't help with the django part)
 
8:26 PM
Adding what "things"?
 
@roganjosh a meta{} key and an objects: that would refer to the object returned instead of the object just being returned.
 
That's sent my mental circuitry into a loop. I don't follow at all
 

« first day (3630 days earlier)      last day (1301 days later) »