« first day (3868 days earlier)      last day (1073 days later) » 
00:00 - 20:0020:00 - 22:00

12:57 AM
cbg
 
1:08 AM
cbg
One of my pet peeves from time to time is when I in fact gave a detailed correct answer, the questioner downvotes my answer even though I have answered exactly what their bolded statement requested
 
how do you know it is the OP?
 
I think most new people just downvote just because there is an error that they don't want to figure out themselves
 
new people cant vote most of the time, even the upvote needs like 25 rep to register, downvote is probably 100 or 125 min, so its probably someone who knows the site at least some what
 
1:23 AM
@python_user 15*
 
thanks for correcting me, I find the "your upvote is registered but not counted" message a yamming lie
 
@python_user I do not know where it gets registered. But it does not get counted. Not sure if the OP passes 15 it would get counted automatically, either
 
it does not show up, once a 10 rep OP said they accepted and upvoted my answer, so I wanted them reps and voted the OP to 20, I got nothing, just +15 for the answer :/
 
@python_user That's sad :p
 
so lesson here is to upvote (if at all the question at least shows some input and expected output) then answer, so when they upvote you get rep :p
but I stopped doing this, new OP's dont show up, they probably check the answers logged out, so I eventually end up deleting them
 
1:43 AM
@python_user I do this when I'm desperate for upvotes :p
@python_user Cold move
 
@python_user deleted my answer, immediately watch my reputation +2 and OP's reputation +1
Anyway, whatever, the question was actually something that nagged me for a long time in sqlalchemy, and that I am in a pretty decent mood today so I still helped that OP. Hopefully they can see the light.
 
2:02 AM
I'm not sure why the 1000 rep privilege is at 1000... it's not that good
(it's to see the count of upvotes and downvotes each)
 
@metatoaster that makes sense, OP downvoting without a reason is a cheap move
 
2:17 AM
@python_user they did give a reason: can you do this <code example> instead?
which was not what they asked, though I suspect English might not be their primary language so there's that too
 
But that shouldn't be worthy of a downvote
 
2:42 AM
Yeah, some people don't quite know the etiquette for that. Even more annoying is when my 8+ year old question on a rather niche framework got a downvote for some reason without explanation, but whatever lol
 
 
3 hours later…
6:07 AM
so I just discovered that there are two symbols in sympy that I would like to import, but with different names ie `I` and `E`, which i would _really_ like to call `i` and `e`. it seams like I can't just do `from sympy import E,I as e,i`. But I can do:


```
from sympy import I as i
from sympy import E as e
```


is there a better way to do this?
 
6:21 AM
You could just import them as is (i.e. from sympy import E, I) and then create the assignment using tuple unpacking like e, i = E, I. Really though, "better" is very subjective.
 
hm, yours is the only option i don't like honestly
i think aliasing should be done with the imports directly, so it's stated upfront
(no offense intended)
 
as I said, "better" is very subjective.
 
that i agree with.
 
I generally very much dislike the import .. as .. syntax overall, unless in the exact case where I need to rebind standard constants
 
@AndrewMicallef also consider from simpy import I as i, E as e
 
6:26 AM
Yeah that's probably better, though again I generally would break them up into multiple lines in any case, like
from sympy import (
    I as i,
    E as e,
)
Keep things less cluttered. But again, "better" is subjective.
 
6:52 AM
cbg
 
TIL (and it's still early) that Substance over form has a very defined meeting. I was preparing a new attack and remembered the phrase "form over substance" which I was going to use to basically say "Yeah it looks good, but it has yam all use in the practical sense". Now I'm confused how my potential phrase came to be.
 
Isn't the phrase "style over substance"?
 
Not least because "over" suggests taking priority. But even that isn't really reflected in the original phrase
@MisterMiyagi and there we go. <scurries back under a rock> Thanks :)
 
Well, now I'm definitely going to drop "form over substance" in a few talks just to see who flinches. ;)
I expect most people won't notice.
 
7:18 AM
Hey Anyone here .. I want to know what are some of the advance and interesting topics in python ??
 
7:28 AM
@metatoaster Thanks, I didn't know I could do this.
 
@AbdulRehman Depends on what broader topics you are interested in.
 
7:59 AM
Am interested in internal Python Working and AI / ML
 
8:56 AM
Python sure has a reach on AI ML, most students nowadays seem to have a project on that
and there is always a AI ML Job Description for most companies, so that is a good choice from a job perspective
 
@roganjosh form over function?
@python_user it's just mostly a lie. These fake upvotes can be queried with SEDE I think, and affect something... maybe "hot" question status
 
Yeah, it seems I've mentally mashed two phrases together in my tiredness
 
It was 8 AM. Have you considered sleeping at night? :P
 
@AbdulRehman I like to recommend "Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow" by Aurélien Géron, mostly because it has lots of practical examples.
 
@roganjosh You need more sleep bro
 
9:11 AM
What is this "sleep"?
3
 
@roganjosh Was about to ask that. Haven't got that lot in a while
 
9:30 AM
cbg
 
hi
how can i add a value to every element of a list of lists?
having a list of elements you would do like this map(lambda x:x+1, [1,2,3])
but for a list of lists ?
 
two loops and a +=
 
Loop through the list?
 
you can't do without a loop?
 
You can, but it would be horrible
 
9:32 AM
ok thanks
 
@CătălinaSîrbu Something like this?
>>> a = [[1,2,3],[9,8,7]]
>>> for idx,i in enumerate(a):
...     a[idx] = list(map(lambda x: x+1, i))
...
>>> a
[[2, 3, 4], [10, 9, 8]]
 
yes
thanks
perfect
 
If you do not want to use loops, then try using numpy and back conversion to list
 
its perfectly fine with loops
 
Just if your bored try this :P
 
9:44 AM
but I was modifying the copy
 
>>> a = [[1,2,3],[9,8,7]]
>>> ar = np.array(a)
>>> list(map(list,map(lambda x: x+1, ar)))
[[2, 3, 4], [10, 9, 8]]
 
not the object itself
 
@CătălinaSîrbu Ah, I see
 
@CătălinaSîrbu if you're wanting a copy, why not: [[col + 1 for col in row] for row in a] ?
(it's still a loop - but don't see how that's an actual problem...)
 
I didn't wanted a copy, I just wanted to modify the object itself and I wasn't
for little_list in big list:
    map(lambda x: x+1, little_list)
 
9:54 AM
for row in a:
    for i in range(len(row)):
        row[i] += 1
 
lists are mutable so...
 
When your only tool is a map... every problem becomes difficult
 
@Aran-Fey Does this refer to both my examples using map? :p
 
No. Your code isn't pretty, but at least it works. What I'm saying is that this problem has a simple solution (like I said... two loops and a +=), but for some reason a map became involved and that made it difficult
 
@Aran-Fey Ah, yes
 
10:04 AM
stackoverflow.com/questions/67595038/… wants someone to debug their build
 
@Arne Done :)
 
thx =)
 
10:29 AM
@CoolCloud if you have a numpy array you can just do ar + 1
 
@python_user Oh that was simple
 
I dont fully understand numpy's data model but sometimes it works as I would expect :/
here is a recursive solution for that
def sum2d(seq):
    add_one = lambda seq:[] if not seq else [seq[0] + 1] + add_one(seq[1:])
    return [] if not seq else [add_one(seq[0])] + sum2d(seq[1:])

sum2d([[1,2,3],[9,8,7]])
Jon's list comp is the ideal way though :D
 
This example from official matplotlib site is not working on my pc - matplotlib.org/stable/gallery/mplot3d/…
The error says- wrong projection '3d'
What is the problem?
 
this may sound trivial, but did you copy paste that exactly?
 
I downloaded the file
So, no chance for copy paste errors
 
10:44 AM
download? I just used the copy icon in the code block and I can see a graph
 
@python_user But I am getting the error.
:(
 
in which case, copy paste your code into a pastebin or dpaste so others can check
 
Others can check the code at the link that I provided above
 
According to matplotlib.org/stable/api/… there is no "3d" projection available per default
 
Details - I downloaded the .ipynb file and ran it on jupyter notebook on windows 10.
 
10:51 AM
> fig.add_subplot(235) is the same as fig.add_subplot(2, 3, 5)
Wow, what were those devs smoking?
 
@Abhijeet.py my bad, I did not see there was a download link at the bottom, so ignore my comments, look into what Aran Fey suggested
 
11:38 AM
@Aran-Fey yes, that is a weird "feature"
 
@Aran-Fey that's from MATLAB
the "mat" in matplotlib, i.e. history
@Abhijeet.py from mpl_toolkits.mplot3d import Axes3D
Not sure why that example doesn't have that. I'll have to check a new version of mpl.
 
12:22 PM
What, you just import Axes3D and then never use it? O.o
 
That's less surprising than fig.add_subplot(235), to be honest.
 
12:49 PM
@Aran-Fey yes, it hooks into the add_subplot calls
3d plotting in matplotlib is a hack
 
Question, should people remove the python tag, but keep the python version tag in a post?
I just saw someone edit a question solely for the purpose of removing the python tag but keeping the version one
 
I don't see a problem with both the tags being there. Cuz answering such questions will give + pts in both the tags.
@12944qwerty It is based on opinion I suppose. Why have a python tag when there is a python 3.x tag already(their logic).
 
More reach
 
@12944qwerty No, the language tag should always be there.
It says so in the tag wiki AFAIK.
 
Hm, it does.... so then why did this user change that? (they have editing privileges)
 
@12944qwerty Submit another edit and add those tags in
 
morning cabbages, folks!
 
@12944qwerty Other people can be wrong, too.
 
cbg
 
cbg
ughhhh, I must have been colorblind. I thought green was red ;(
 
1:00 PM
..and red was green?
 
 
2 hours later…
2:46 PM
@Abhijeet.py OK, on matplotlib 3.4.2 the example works. Either upgrade your matplotlib, or use the import I wrote
@Aran-Fey likely reason why this ended up loaded by default ^
 
3:25 PM
hello everyone, can you help me to find a room where I can ask about deep learning with python??
 
@AbdelmalekMallek hello. I don't think there's a room for that on Stack Overflow chat.
 
@AndrasDeak Okey, no problem, I'm new here, and I'm learning deep learning, I tried to run a face antispoofing model in python , so I get some results and I want some help to understand them
any help please ?
 
3:40 PM
The answerer at stackoverflow.com/a/67580717/953482 gave a much more thorough answer than I could have, unfortunately
 
@Kevin stats.stackexchange.com/questions/524803/… this is the question that I'm looking for an answer
 
Let's see... yep, I don't understand any of it
 
it's just a test features comparaison between LBP and Haralick texture features, I want just to learn how to interpret the accuracy and the confusion matrix
 
@AbdelmalekMallek The use of features to predict classes is not deep learning. Deep learning uses little to no preprocessing or feature extraction. The accuracy is just that, the number of correct classifications in the validation run. The confusion matrix is a more detailed breakdown of predictions for each class. Explained fairly simply (I can understand it) here
If you take the following confusion matrix:
Train SVM with C=10
Accuracy: 0.8082670906200318
Confusion matrix:
 [[1591   79]
 [ 524  951]]
The accuracy comes from (1591+951)/(all)
The number of times the actual and predicted intersected over everything
 
3:59 PM
@desertnaut hello, can you help me here stats.stackexchange.com/questions/524803/…
@Dodge thank you I just became to unnderstand
 
@AbdelmalekMallek please don't ping random people
 
@AndrasDeak no I didn't pick randomly, this guy helped me in a previous question
 
@AbdelmalekMallek and they told you it's OK to ping in a chatroom they've never talked in yet?
When I said random I meant "unsolicited". It's rude.
 
@AndrasDeak why is it a problem for you ? and it's note rude , I just asked ok!
 
4:14 PM
I had a take-home test (suggested to be written in python) for a position and didn't get it, here's my repo: github.com/aeyalcinoglu/grover-challenge - I am curious what the correct solution was, any ideas?
 
@AbdelmalekMallek I'm a room owner here so people acting up is my problem. From our rules: "Don't ping (@username) users unsolicited. Use pings when they assist the flow of existing conversations."
So please follow the rules.
 
@aeyalcinoglu What do they mean when they say "Application should conform [with] streaming mentality."?
 
@Dodge Exactly :)
 
It's probably a known paradigm, guess I'll google
 
@aeyalcinoglu did they say they didn't like your work, or just that they rejected you?
 
4:22 PM
@AndrasDeak I guess it's both.
 
@aeyalcinoglu you guess?
 
@aeyalcinoglu you should write back to them for any constructive feedback. Even emailing the specific people you might have interviewed with. You'll probably get no reply but it's worth a shot.
 
Agree 100% and most interviewers are happy to provide feedback
 
I actually got a feedback after asking for it
 
What did they say?
 
4:30 PM
Not gonna force it out, if you do not want to say it. It is fine
 
in their repo they have mentioned they aren't supposed to share the feedback
 
That seems a bit shady
 
I guess if they use the same assessment for a couple other people, and if the feedback is public it just opens up to copying code
 
@aeyalcinoglu Some general commentary: As mentioned before, one could do this much more lightweight (esp. without dependencies, without async) – this may or may not be what they wanted. There are some code-quality red-flags that you might want to look into as well:
 
so if feedback is not known, it makes it a bit difficult to know if the code one is copying is correct or not, just my guess
 
4:44 PM
Hey there, somebody that knows Django Framework here?
 
If two people produce the same code it doesn't mean much. Syntax is perfectly copied by definition. Variable names might be unique. Finding the best program structure would be common to both and that's expected.
 
reminds of the time in my first year of CS where we swapped for loop with while loops to get away :D
 
@aeyalcinoglu [cont] Use docstrings liberally; if anyone but your or even just future you looks at it, document it. Don't use bare relative paths, use __file__ to anchor them to your script. Don't join paths via +, use os.path or pathlib. Don't put anything stateful in global scope unless you have to; that's open files, csv writes, and such. Be mindful of how your types work – don't copy then append to a list, use old_list + [new_item] to create a new one.
 
@MisterMiyagi Do you have any idea what the "Application should conform [with] streaming mentality." refers to in that challenge?
 
does Numpy have modular power? I can do pow(base, power, modulus) but I can't seem to do the same thing in Numpy without creating it myself. I'm about to write a Numba function but thought I'd ask before I do.
 
4:51 PM
@MisterMiyagi Thank you very much!
 
@aeyalcinoglu [final cont] Don't use global; whenever you have a global, it's most likely a good opportunity to show your grasp on class. Stick to the language – don't use os.system('kill -9 {}'.format(os.getpid())), directly use os.kill or even better sys.exit().
@Dodge I assume it means "use generators/iterators", but honestly it could mean anything. I'd go with the former, on the assumption that anyone who means something else is mentally streaming.
 
Got it, thanks
 
test_1_output_file_name is a red flag IMO, 99.9999% of the time you should not have variable names with digits in them.
 
5:09 PM
@Hathick hello, no. Please don't ask for help here with fresh questions on the main site as per our rules.
You have answers, try to discuss with them first. If in two days you don't have a satisfactory answer you're welcome to ask here too.
 
@Kevin I see, alright, thanks for the feedback!
 
... And replacing the name with test_one_output_file_name isn't much of an improvement ;-)
 
@AndrasDeak I understand, thank you.
 
@Hathick thank you too :)
 
@Kevin What would you suggest as a replacement?
 
5:16 PM
Simplest alternative would be lists, e.g.
output_file_names = ["test_1.csv", "test_2.csv", "test_3.csv"]
subtask_file_names = ["infants_with_more_than_14_rings.csv","males_heavy_and_short.csv", "shell_humidity.csv"]
output_file_names = [os.path.join(dest_dict_name, filename) for filename in subtask_file_names]
... Although I wonder if the first and third variables are really necessary to begin with, since you can derive their values at the point where you need them
#in other words, no point doing this:
for i in range(3):
    with open(sub_task_file_names[i]) as infile:
        data = frobnicate(infile.read())
    with open(output_file_names[i], "w") as outfile:
        outfile.write(data)


#... When it's easy enough to form the output filename inline:
for i in range(3):
    with open(sub_task_file_names[i]) as infile:
        data = frobnicate(infile.read())
    with open(f"test_{i}.csv", "w") as outfile:
        outfile.write(data)
 
@Kevin enumerate(subtask_file_names)?
 
You caught me :-) Yes, enumerate is almost always preferable to iterating over the indices of a collection using range.
It would also be possible to write the first code block without any indices at all, by using zip, but all other things being equal I'd prefer the approach that only depends on one list
 
yup
 
5:40 PM
I am looking to edit templates with python. For example I have a psd(photoshop) file for now and it has text layers and I want to be able to edit it with python. Does not seem to be possible. But is there any alternative to create a template with python?
 
I'm not sure I understand the connection between "edit the text layer in an image file" and "create a template". Is "template" the same thing as "psd file"?
 
Well in this context, yes.
What I mean is I have a file that is editable inside photoshop and that file would have like placeholders, so with python it would be nice if I could just edit the placeholders with whatever I want dynamically, but not possible. So I was wondering if it was possible to create such templates with placeholders to edit dynamically on the go(not psd, any other library).
 
The PSD file format appears to be documented here, so in principle you could read/edit/create psd files using this information
 
@Kevin Using python?
 
Sure. Python is perfectly capable of reading and writing arbitrary bytes to/from files. I myself wrote 30% of a Flash .swf file reader last month.
 
5:48 PM
Oh I see, Ill give it a look then
Right now with python, I use tkinter and place() and then put the placeholder texts wherever necessary, but since those are pixels, they distort on different screens
 
Maybe consider using an XCF file instead if photoshop can read those
 
@Aran-Fey Nothing built in, though I suppose there are converters
 
I'm interpreting the broader goal as "I have several programs that produce files of various types -- images, rich text, spreadsheets, etc. I want to be able to use those programs to create a nicely styled output, but which doesn't have any specific data yet. For instance, maybe my rich text will just say '[ESSAY TITLE] by [AUTHOR NAME]'. Once I have saved these files, can I use Python to fill in my placeholders?"
(brb)
 
@Kevin Well that is one way to put things :P
 
And the answer is, "it depends on the file format". Some formats, such as .txt or .csv, are as simple as outfile.write(infile.read().replace("[AUTHOR_NAME]", "Cool Cloud")).
 
5:54 PM
@Kevin Hmmmm when it comes to images, it is much of a bummer. Okay I guess I can use Canvas and then use Canvas coordinates, I think they wont be distorted on different resolution
 
Others are a little more difficult. I can think of a few Steam games whose save format I reverse-engineered. They were effectively just zipped .xml files. It would be possible to alter strings in those with a zip library and and xml library and like two lines of actual code.
To use an example fresh in my memory, .SWF would be more difficult still. On top of being zipped, most structures in the file statically define their lengths in their first field. Trying to change the size of any of the structure's other fields, without updating that length value, and the length value of all the parent and sibling structures of that structure, would make the file unreadable to the real software
 
Dare I ask how changing the resolution distorts anything? As far as I know, tkinter lets you set the position and size of every widget in pixels
SVG files are super easy to edit by the way, since they're xml
 
@Aran-Fey Well not distort per se, but appear a little displaced. github.com/nihaalnz/patient-hsptl-app/blob/master/Image/… In this image if I want to place text at x=10 and y=20 which is on the header, but in some other resolution it would be little displaced from the header.
 
SVG is a good example of an image file that you probably could edit the text structure of. It basically comes down to, is it a raster format or a vector format? raster formats such as BMP, PNG and JPG store only pixels, and have no native understanding of what "text" is. SVG, and almost certainly PSD, are vector formats. They know what text is and store it in a way that makes it easy for editing software to change it later.
 
Woah, calling PSD a vector format? That's... technically correct, I suppose
 
6:07 PM
I'm just guessing honestly :-) If you can't draw a line between (0,0) and (0,0.000000000000000001), then it's arguably not a vector format. But for our purposes we're more interested in the rich semantic metadata that vector formats usually have, compared to raster formats
Skimming through the Adobe document I linked above, I see a "type tool object setting" structure, with a Text data field. Very promising.
 
Every image editor worth its salt has text layers... which are certainly not raster data... and therefore, even if 99% of layers are raster images, PSD files are technically vector graphics
 
Close enough for our purposes :-D
 
Hmmmm Ill give it a try then
 
Ok, now that my rant is complete, I'm thinking more about the XY Problem... If the question is "how do I draw text in the correct position on this ID card?", I'd probably skip everything I just said and use Pillow
I'm not sure where tkinter comes into play here
 
In other news, implementing + writing tests for my set-like class with a key function has drained me of all my motivation to code anything for a week. I think I'm just gonna publish the module without the set class...
 
6:15 PM
Relatable, my geometry GUI project has stalled now that I've finished all the fun geometry bits and have only painful GUI bits left
 
@Aran-Fey "set like class with a key function" sounds like a dictionary
 
@Kevin Oh and Pillow would use x,y related to the image? Because if I want to write a text at 10,10 and it has to appear at a line, if it gets displaced then it would be elsewhere
 
Sets support too yam many operators, and every one of them requires 3 methods... __op__, __rop__, and __iop__. And then there's two variants of most operations, one that returns a new set, and one that modifies it in-place... I thought I might as well implement a set in addition to my dict (which was the original objective of the module), but I severely misjudged the amount of effort that goes into a set class
 
Pillow doesn't understand x and y in any context other than related to the image, so yes.
 
@Kevin Kay then, ill just try it and reach back to you soon(prolly days, really frustrated with exams)
 
6:21 PM
Ok, no hurry
 
@Dodge It's a set that lets you customize how values are hashed. Each value is passed into the key function, and the return value from that is used for hashing and comparisons. For example, if your key function is len, then "x" and "y" and [3] are all equivalent as far as the set is concerned
 
Ah, interesting
Membership testing based on object properties?
I can't instantly derive the use case for that Aran-Fey
 
the end goal is to rid Aran-Fey of the remaining little bits of his sanity
 
meh... sanity is over-rated anyway :p
 
6:39 PM
@JonClements hey puppy! was just thinking about you. How's life?
 
same old... should I be worried you're thinking about me? :p
 
lol! only if good friends are a cause for concer- oh yams!
I forget - are you in London?
 
Can anyone explain this piece of code from REST framework for Django to me? The whole Django community and their tutorials are just copy pasting this piece of code without any elaboration whatsoever
    def update(self, instance, validated_data):
        instance.email = validated_data.get('email', instance.email)
        instance.content = validated_data.get('content', instance.content)
        instance.created = validated_data.get('created', instance.created)
        return instance
What is instance, what is validated_data, why does it have a get method, what is the get method, where does it come from? Why do we need to pass instance.field to the get method?
 
looks like you take an object called instance and overwrite its email, content, and created attributes with what's in validated_data (which appears to be a dict), if it has the data. If validated_data doesn't have this information, don't overwrite the attribute
 
Why do I need to pass in instance.whatever?
to the validated_data.get method?
 
6:49 PM
@Silidrone those are defaults
 
oh so if get returns nothing, it uses that?
 
validated_default is probably a dict (only you can know for sure), and then .get gets the value with key 'email'.
@Silidrone yes, exactly
 
Hi. I'm new in this chat room. Can anyone guide me how do we comment or chat here?
 
and the instance, is the instance passed in to the Serializer? I think this update method is overridden here, does the Serializer internally call this method with the instance the serialzer has been assigned with when first created?
 
I just earned my chat priviledge.
 
6:52 PM
if it's ModelSerializer i guess it would be the Model instance
 
@ShreyanAvigyan You can type your message here into the chat box, that simple :)
@ShreyanAvigyan But make sure to read Our Rules first
 
Ok. But can we ask questions anytime here?
 
@ShreyanAvigyan Read the rules, it explains it
 
@AndrasDeak I mean I'm new to this but it's all Django REST framework thing, this method is just overriden inside the Serializer class, the parameters are passed in internally, the function doesnt get called directly by me
 
@ShreyanAvigyan welcome. You can see the rules that Cool Cloud linked.
 
6:53 PM
Ok.
 
@Silidrone you already know more about this than I do, but at least you're the one with the code :P
 
Thanks for guiding and instruction.
 
Oh, I just took the code example from their documentation I still didn't write any code of my own until I'm sure I know how it works :D
class CommentSerializer(serializers.Serializer):
    email = serializers.EmailField()
    content = serializers.CharField(max_length=200)
    created = serializers.DateTimeField()

    def create(self, validated_data):
        return Comment(**validated_data)

    def update(self, instance, validated_data):
        instance.email = validated_data.get('email', instance.email)
        instance.content = validated_data.get('content', instance.content)
        instance.created = validated_data.get('created', instance.created)
It's actually like this, previously I just took out the methods, now you can see the class too
 
OK, that has **validated_data that only works with dicts and other mappings
Right at the top:
serializer.validated_data
# {'content': 'foo bar', 'email': 'leila@example.com', 'created': datetime.datetime(2012, 08, 22, 16, 20, 09, 822243)}
 
as far as I understood it's like the spread syntax in js, right?
 
6:57 PM
I don't know JS but probably? This is native python, not a django thing.
 
yeah, I mean it just puts all the properties of the object as parameters to the function?
 
yes
 
I don't get the instance part honestly, I mean they never mentioned how it gets passed in to these functions
the parameter instance
 
That seems critical, so it's probably mentioned elsewhere or earlier, somewhere where the method gets called.
Actually, it seems like that update should be a classmethod, and you'd call it on whatever you want to update
"update these three attributes of this object using this dict, and leave them unchanged if the dict doesn't contain them"
 
the usage is, you just call .save on the Serializer instance, and then it internally calls either create or update
 
7:00 PM
why that's specifically there in the API guide should be figured out from the API guide
 
@Dodge In my case, I'm going to store 2d matrices in it. They're not natively hashable because they're mutable, but I'm not mutating them and I want to filter out duplicates
 
yeah they are just very vague (in my opinion) but you're right, it is (sort of) mentioned, it's the instance created by the create method or if you explicitly pass one to the serializer
thanks for the help
 
No problem. Someone with actual django experience might be able to give you high-level help.
 
7:24 PM
I'm having a little bit issue with ctypes.CDLL. If I compile
I'm having a little bit issue with ctypes.CDLL. If I compile a dll I can't access its functions through ctypes.CDLL.
I'm using cl.exe from command line on Windows 10.
 
What's the error message?
 
AttributeError: no function named
 
And the code that threw that?
 
Wait. I'll give the simpler version here.
int testingfunc(PyObject* arg) {
	return 0;
}
This is just a simple function that doesn't do anything. It's a dummy function but the problem is AttributeError
The full code:-

#define PY_SSIZE_T_CLEAN
#include "Python.h"

int testingfunc(PyObject* arg) {
return 0;
}
 
7:47 PM
that code would raise a SyntaxError rather than an AttributeError.
 
I get a completely different error message when I try to access a nonexistent function from a dll, so I have no clue what you're doing
 
because it's not python
@Aran-Fey to be fair we only saw the pinky toe of the error message
 
This python extension module
 
@ShreyanAvigyan it would be helpful if you put together an actual MCVE that reproduces your surprising error.
 
7:48 PM
Ok. I'll post it as soon as it finishes compiling.
 
the dummy c extension, the command you used to compile it, and a dummy python snnippet that tries to import it and raises the error
@ShreyanAvigyan the M in MCVE stands for "minimal", so if it needs time compiling it's probably not the best to post here
 
No not at all. It'll take 1 minute
 
reproducing the issue with your testingfunc above should also help debugging efforts
 
Yes. I reproduced it before. I'm sure it'll also occur now
 
excellent :)
 
7:52 PM
Leo/Africa just came up (-:
 
Are you listening to a Leo playlist? :P
 
Nah, just sprinkled here and there
 
OK, then it's more news-worthy ;)
 
Compilation commands: cl /LD -Ipython_dir\Include examplemodule.c python_dir\libs\python39.lib

Python code throwing error:-
>>> import ctypes
>>> l = ctypes.CDLL(*dll path*)
>>> l.testingfunc
 
And that really throws "no function named"?
 
7:58 PM
Yes
AttributeError: function 'testingfunc' not found
 
:|
 
What did I tell you about the pinky toe of the error message? :P
 
00:00 - 20:0020:00 - 22:00

« first day (3868 days earlier)      last day (1073 days later) »