« first day (3556 days earlier)      last day (1375 days later) » 

12:12 AM
@roganjosh sure....sure. That's close enough at least :)
It fits that simple model concept at least. If you want to know more I have several papers from some symposiums and a few journals I could point you too ;) :)
 
 
1 hour later…
1:32 AM
@Arne whoops, I missed that message amidst all the protesting, sorry :P I first read the books (maybe twice), liked them a lot, then I saw the movies, they were meh, and then I came across mentions of inconsistencies (and some of these have been cropping up in image macros), and then I read the books again (in English) which helped me remember the differences. So I guess it's the former, I don't have any of this written up.
There's probably a few more I've come across and a lot more I'm unaware of, but these are the most egregious ones which keep me awake at night make me rant whenever the movies come up :D
 
1:45 AM
awesome solution to my problem @MisterMiyagi, 900 lines of code vs 5 :P
I couldn't understand your solution, though, @Kevin, even though I now know understand how lambdas, recursive functions and defaultdict work, more or less. How exactly is a line like `d[1][2][3] = 4` calling the recursive function? Also, if there was another value registered before like let's say `d[1][5] = 3`, wouldn't your function 'override' it? (erase)
why is backtick not working?
 
2:21 AM
@PedroSpinola d[1][2][3] = 4 is effectively syntactic sugar for d.__getitem__(1).__getitem__(2).__setitem__(3, 4). The __getitem__ method of defaultdict will check whether the key exists in the dict already, and if not, call the lambda* you passed to its constructor and set that as the value instead. Since the function deepdict itself returns a defaultdict, you can chain __getitem__ calls as deeply as you want
(*or any other kind of callable, for example an ordinary function)
I'm not sure I consider this recursion, in the classic sense. I don't think the call stack ever contains two function calls with the same id at any point.
d[1][5] = 3 wouldn't override the value at d[1][2][3] because d[1] will only assign a new value if 1 does not already exist in d. But 1 does exist, so the old value remains
Backticks don't work in multiline messages by the way. I wish they did.
 
3:23 AM
I see @Kevin, I'm getting there and appreciate your patience and detail!
Got 2 questions. Is this:
deepdict = lambda: defaultdict(deepdict)
d = deepdict()
the same as this?:
d = lambda deepdict: defaultdict(deepdict)
second: in the case of d[1][2][3] = 4 it first executes
d.__getitem__(1), right?
or is it from __setitem__(3,4) and backwards?
also I don't get why those <funtion <lambda>> stuff appear when printing d
nice to know about the method thing, I understand python a lil better now! :)
 
@PedroSpinola it'll have to find key 1 inside d (or return the default), then look for the key 2 inside 1's value, then look for 3 inside 2's value, as far as I understand.
 
 
3 hours later…
6:15 AM
@PedroSpinola 1) No, d = lambda deepdict: defaultdict(deepdict) is equivalent to d = defaultdict. 2) d[1][2][3] = 4 runs d.__getitem__(1).__getitem(2)__.__setitem__(3, 4). 3) d is a defaultdict, and when you print a defaultdict it displays the function it uses to create its default values
 
 
3 hours later…
9:20 AM
^ I use json.dumps and json.loads to fix that :/ is that how people do that?
 
I just avoid creating nested defaultdicts in the first place
 
laurel, I had to use it once but I couldnt wrap my head around the syntax until I asked a friend
@app.route('/browser/<path:urlFilePath>') I started flask and came across a syntax like that in an SO answer, can anyone tell me what it is called so I can google?
the : between path and urlFilePath, I am aware that text within <> is passed as parameter but what is the colon for and what is it called?
 
that table has the info I needed, thanks :) guess I will have to change my tutorial site
 
9:52 AM
@python_learner tutorials are nice to start going with a language or library, but they can be wrong or missing key details. When in doubt go for the docs.
And for the record I googled something, first flask doc hit was the API reference, found the first link to route(), found the "for more information refer to URL route registrations" link.
 
that is a good suggestion for further reference, I need to spend more time to familiarize with flask jargon then
 
10:09 AM
@python_learner people tend to refer to them as "dynamic URLs" even though that term doesn't appear in the docs linked
 
Dynamic Url makes more sense to me, guess flask devs must have missed out :p
 
10:48 AM
why are most cv-pls questions numpy or pandas?
I dont use either but there a lot of tutorials out there
 
10:59 AM
@python_learner they probably aren't
@python_learner the amount of available information doesn't correlate with the amount of off-topic or unclear questions asked
A large ratio of all new python questions are pandas. And I have an interest in numpy, so I'm more likely to look at those questions, and to have domain-specific information to decide if it's close-worthy.
 
I have only been looking at SO from an "askers" perspective guess I had it wrong
 
If available information stopped people from asking bad questions, the front page would look a lot different :)
well, not the front page, because that's a disgrace
 
If chat wasnt hidden I am sure new users (with enough rep) can ask such questions here
but it would end up like the python discord (reddit)
 
yeah, we don't want that
 
11:24 AM
I actually have both pandas and numpy tag hidden, and if I see one that clearly uses those but not tagged properly I tag them and go away. However there are rare instances where the question was actually well-formed and clear enough for an answer, those I do.
 
12:04 PM
Are there any iterators in the stdlib where two distinct iterators can compare equal? I'd need something like assert iter([]) == iter([])
Never mind, I'm just gonna rewrite the test
 
 
1 hour later…
1:23 PM
Hmmm how do I save object hirarchies? Like that an apple and a banana are a fruit, but also that they can be part of a fruit salad.
 
Are there fruits that can't be part of a fruit salad?
 
yes
why you think it would be easier if all would be part of a fruit salad?
 
Sure. If any instance of Fruit can go in a fruit salad, the problem solves itself.
The problem's too vague, though - depending on the circumstances, a FruitSaladMixin, a goes_in_fruit_salad attribute or even a global set containing all fruits that can go in a fruit salad could be appropriate solutions
 
haha, yes that is my problem right now. I kinda have an idea, but as you say there are multiple ways to realize that, but I'm not sure which is the easiest to do. I already did a simple prototype, but it's too simple. Well gotta think some more about it
 
2:17 PM
PSA: check your cast "reactions". I had 4 even though I cast 0 on purpose.
3
 
Weird. I have 0 but I did cast one as a joke to LinkBerest a few days back, then deleted. If anything, you'd expect my count to be spurious vs. someone who never cast any
 
@AndrasDeak I think that must be a figment of someone's imagination... such a thing would never exist, right? :p
 
@AndrasDeak is cast reactions up and downvotes?
 
sorry for the pings, this is the original announcement
 
yeah I found my way there
wtf is that, that sounds ridicolous and stupid compared to up and downvote. Looks like the community agrees with that post standing at -1k votes
 
2:24 PM
Hi, I 'm trying to use the python's python-docx module, read the xml through document._element.xml. However while assigning i.e., document._element.xml = #some string , I get the error AttributeError can't set attribute.
 
@Hakaishin yes. No need to flesh out that argument here anymore though. You can vote or comment on the answers on meta.
 
@AndrasDeak haha, then why remind us to check our reactions? Just now learned about it and it doesn't sound important
 
@Hakaishin because "I had 4 even though I cast 0 on purpose"
 
Can someone help me? I 'm trying to replace something in that xml string and save back the xml as docx file
 
@VisheshMangla have you read the corresponding documentation thoroughly?
 
2:26 PM
If you want to rewrite xml, use an xml writer, not a word document writer
 
I guess I did, I even saw its "dir". I got a few posts on SO but they read the table elements and use .text which is not valid here
@Aran-Fey that seems to be a good idea
 
do you have one word for pasta and gnochi? My addons list for both looks the same, but I have no clue what word to use to describe both
 
but I don't know how xml and word doc are related.
 
@Hakaishin it's spelled "gnocchi"
 
haha thanks, but I disagree
 
2:28 PM
I think gnocchi is a subset of pasta
 
will simple saving d = #some xml string as a .docx file make it a docx file?
 
But, hmm, maybe not...the way these thing are called in Hungarian makes this confusing
 
ah good idea, so I have Pasta: [normal, gnochi] perfect
 
@VisheshMangla probably not, I think the xml is compressed
 
in particular, we have the same word for "pasta", "dough" and "batter"
 
2:29 PM
but no I don't think so pasta is grain, gnochi is potato
 
so that actually makes the "use an xml writer" idea a dead end
 
yes, that y I 'm dependent on this module.
 
@Hakaishin please don't call it gnochi, if there's anybody other than you using the end result
 
@Aran-Fey I've been trying to figure this for the whole morning. So the default value being provided is a function, right? Which doesn't matter because default value is going to be overrided. But what is the base condition for the deepdict() to stop running recursively? I tried to debug @Kevin's function with pdb but I couldnt figure out how to get exact information on how is deepdict() being called when the last line is executed.
 
can you figure out something if I share the "dir" of this document._element.xml? It print's as xml.
 
2:30 PM
@VisheshMangla "you guess you did". Which part of the documentation did you read thoroughly? Do you have a link?
@VisheshMangla NO!
 
So why do you need to modify the xml in the first place? Can't you achieve the same result by using the high-level API, i.e. modifying the document?
 
Just to be clear this is the code:
from collections import defaultdict
deepdict = lambda: defaultdict(deepdict)
d = deepdict()
d[1][2]['3'] = 4
 
I don't think you can find this specific thing in the docx
 
@VisheshMangla Either documentation links, or a simple MCVE. Dumping random stuff you found lying around won't help.
 
@Aran-Fey well, it's a bit difficult to explain, but I 'm bound to follow this approach
ok
 
2:32 PM
@AndrasDeak huh, thanks for that. I will call it gnocchi
 
Jul 1 at 12:06, by Andras Deak
@VisheshMangla No. You have depleted your trial-and-error options. You will actually have to step back and spend a lot more time thinking about what to ask and how. If you don't have a proper, informative MCVE you're doing it wrong. If you say "sorry there was a typo" you're doing it wrong. If you say "google gives nonsense results" you're doing it wrong. You seem to be missing the basics of python, so learn it first. Finnish a good tutorial. This room is not a replacement for that.
 
I give you a MVCE code
 
If it's difficult to explain you haven't spent enough time with it before asking.
@Hakaishin for what it's worth the wiktionary calls it "pasta-like dumplings"
 
will it be ok to post code on dpaste? Is there a specific preference here?
 
@VisheshMangla it's fine, as long as it's an MCVE
 
2:34 PM
making a kind of food hierarchy is interesting and more challenging than I thought. And asking google things like pasta, gnochi commonalities, doesn't yield many useful results
 
emphasis on the M for Minimal and C for Complete
 
you can try using any .docx file
 
@Hakaishin that's because the few tens of thousands of years of gastronomy were not constructed with scientific rigor in mind.
@VisheshMangla I get it how it doesn't let you assign there. It's not clear what you're trying to change it. And as I said, you need to show me the docs you looked at.
@Hakaishin wikipedia says it's "a variety of pasta" so you're good
 
yeah, I just found the same :P
 
you probably have to add examples wherever possible to help clarify ambiguities
 
2:36 PM
well it's few SO answers from where I learned how to extract the xml. The docs don't contain any info on how to extract the xml.
 
pasta (e.g. spaghetti, fusilli, penne) vs Pasta (e.g. pasta, gnocchi, dumplings)
 
ugh, capitalization is a stupid mechanism for information transfer, I don't like it
too error prone
 
yeah, not end-user friendly at all
 
@VisheshMangla Apparently docx files are zip archives of xml files, so it shouldn't be very hard to go at it with an xml parser
 
I'm surprised how long it still survives in the german language. I think german should be much more like english. So many nice things we could incorporate. Like less pronouns, less gendered, less capitalization
less conjugations
 
2:40 PM
well if you perform "dir" on this private variable document._element.xml it gives <class 'docx.oxml.xmlchemy.XmlString'>
 
@VisheshMangla OK, you got me to look at the docs. You're using python-docx, right? There's no mention of the _element attribute on Document objects, which togeher with the leading underscore means that it's not documented and should not be used. You should find another way to access the xml.
the _element attribute doesn't even seem to be defined on the Document class, so it probably comes from the ElementProxy parent class, which I can't even find in the docs right now
 
I well if you see SO there are plenty of people asking questions on that
 
@PedroSpinola There is no exit condition. The whole point of the deepdict is that it can be arbitrarily nested.
Whenever you try to access a key that doesn't exist in the defaultdict, it calls its default_factory function to create a value for that key
 
Many of them dig up the xml to find cure of their problems
Unfortunately I 'm unable to find one setter which sets the xml attribute to some other string
 
>>> d = defaultdict(lambda: print('default factory called'))
>>> d[0]
default factory called
 
2:43 PM
@VisheshMangla because the library you are using doesn't seem to support that functionality. That means you're on your own, so either find a better library that does this, or you have to get your hands dirty digging into the machinery and implementation of docx files. Either way it's unlikely that people here will be able and willing to help with all that.
 
then it seems I 'm on my own. ok
 
@VisheshMangla right now I can't even see how your code works passing a single argument to Document when its source seems to accept two parameters
@VisheshMangla on your own with everyone else that tries to do this, but yes
 
oh thanks, I was not in the habit of reading source code
that's why I missed it
 
There's little else left if the docs are not forthcoming.
@VisheshMangla can you confirm that you were instantiating Document with a single argument?
 
2:47 PM
OK. Perhaps there's multiple implementations of Document in there
 
document = Document("DEMATTENDER FORM for LOF.docx") there's one arg here
 
they are trying to hide the xml part. Someone on #python on IRC said me this.
 
That's reasonable. It's probably less "trying to hide" and more "don't want to expose", because that might be an implementation detail for them (and the docx format in general)
 
hmm true
 
2:49 PM
The repository was last committed to more than a year ago, which is not a good sign (the project is dead or in stasis)
 
how can it be , I got to knew about this on #python.
 
This is the Document entry point you're using, but it won't be easy tracking down the object you get back. Good luck diving the source!
 
that too 2 months ago, and I remember saying that their docs page looks too old to whch they said they commited a few months before only
ok, but thanks for the source code advice
 
@VisheshMangla to answer that question, there can be many reasons. There might be no good other options, especially with a semi-proprietary format like docx. So even if the project starts to die people will stick around because there's nowhere else to go. Or they just hope development will come back, or the maintainers will pass on the project to somebody else. And a lot of people might not be aware of the project's fate, because they used it two years ago.
 
this is really a great project.
 
2:54 PM
haha, I can't decide if cake is a modifier of chocolate or the other way around :D
 
@Hakaishin other way around
sponge cake, fruit cake, cheese cake...
 
I once had to do a little work with docx files and the python-docx library... While the top-level help functions cover a lot of stuff, for some things I still had to resort to accessing the underlying lxml'd document...
 
yeah I got it the other way around too, the again chocolate icecream, chocolate bread
but yeah in general I agree with you. It's just not super clear cut
 
@Hakaishin modified icecream, modified bread...
I can imagine a lot of ambiguous cases but this is not one of them :P
 
I'm convinced :P
 
2:57 PM
@VisheshMangla your best bet is tracking down whatever object the _element is, and figuring out if its xml is mutable or can be modified in any other way
 
3:23 PM
I see @Aran-Fey! I still don't understand how exactly iteration is made in this particular case, but I suppose I'll have to learn bore about constructors, lambdas and methods like __get__ and how d[1][2][3] could be called exactly. I appreciate man! :)
I have implemented your code @MisterMiyagi and funny enough it's 27% slower now (1.1s > 1.4s). But I know literally nothing about performance in python and this is a very small dataset with a very crappy code overall lol. Just thought you might like to know, if it means anything :P
 
@PedroSpinola do you understand how a non-infinite defaultdict works?
 
4:07 PM
are instant noodles more pasta or more soup?
 
@Hakaishin yes
 
man ontology is hard. Also totally futile without a use case :D
 
4:24 PM
You might want to have the rest classified on twitter or reddit, though
 
do you mean by? Or what you mean by on? In the sense this is chat is not the right place :P?
 
Yes (the last one)
 
haha, will do
 
4:57 PM
@AndrasDeak there was a fair bit of noise. and reminds me to read the books again some time, I haven't done so since I saw the movies I think
There is more then enough time now, too
 
Do you read these stuff in the original English?
I always try to do that. Got stumped with Neverending Story :)
 
I loved the film to that... just not the scene with Artax and the swamp of despair :*(
 
@AndrasDeak Yeah, I used LotR to learn English.
.. isn't Neverending Story originally German?
 
@Arne yes
 
@Arne heck yeah
Hence my being stumped :D Ended up reading the Hungarian translation for once.
 
5:08 PM
ahh, now I get it
 
My German is mostly non-existent so there's no way I'd try reading anything in it.
My Russian used to be decent, and still Dostoevsky was too much :)
 
I'd assume Dostoewsky is harder than a children's story? :p
I wouldn't try learning German with Faust
On the topic of re-reading good stories to fill the void of boredom, I think I'll also re-read Bartimaeus. Yet another "children's book" that I remember quality-wise to be head and shoulders above a bunch of more mature novels.
 
Yeah, I didn't mention that I picked up a "Penguin books" kind of transcript with reduced vocabulary. It was still too much :D
Then again I did try this 5+ years after last learning the language. It probably would've went better afresh.
 
I could try to encourage you to learn German, but I hardly find myself consuming any German media lately. There is just so much in English, and learning languages is a lot of work.
I've started speaking English to my wife sometimes ._.
 
It's not for me :) I learned it for two or three years in elementary school. I didn't learn much and I forgot almost all of it. What's left is mostly enough to confuse my brain abroad into thinking that I should be able to understand what people and telling me and that I should try to answer in German (which is silly). I always have to make a conscious effort to tell people I don't speak German :D
Like when a waitress comes to take orders, and I'm the only guy who doesn't speak German. My brain trips for a moment before I respond in English
even though I couldn't respond in German beyond "ein Schnitzel, bitte" :D
 
5:23 PM
add "ein Bier, bitte" and you got survival covered ^^
You come to Germany regularly?
 
Yeah, I don't like beer so I avoid that subject for fear of being tarred and feathered :P
@Arne irregularly. Some conferences tend to be there.
 
@AndrasDeak visible shock
If you come to pycons or such, maybe we can share a tea =)
as soon as they start to be in-person again
 
@Arne physics conferences, otherwise sounds good :)
The last one I didn't go to in Regensburg got cancelled in March for the obvious reasons
 
6:07 PM
@AndrasDeak oh well, other than pycons it's just fintec stuff for me so the overlap is a bit slim. But I'll keep my eyes open.
 
6:20 PM
@Arne 1. I don't think I've been near your city but I'll let you know if I ever am :) 2, your rep is 7777 D:
 
 
2 hours later…
8:48 PM
(Wrt the ticked answer)Hi, I was looking at the stackoverflow.com/questions/22756344/…. I have successfully loaded the xml in a string and then using regex made some replacements. Only part left is how to overwrite it? Can someone refer me some docs? I looked at the dir attribute of docx and couldnt see the read method.
There seems a function stackoverflow.com/questions/22756344/… in the docs but I can't see the name of the file parameter rather it asks for achieve name
 
9:45 PM
Well, I found it out. Above problem solved.
Another thing is, is there any shorter(lesser lines of code) method to achieve this stackoverflow.com/questions/4653768/…?
I just need to overwrite one file of a zip.
 
9:59 PM
Not really @AndrasDeak, I have google around but I just can't grasp some stuff going on in this exact moment, because I lack the necessary fundamentals. It will come with experience. I learned a lot trying to understand this fully for now, though :)
I mean if you have any reading material to point out about non-infinite defdicts please share I'll be interested for sure.
 
10:25 PM
@PedroSpinola nothing beyond the official docs and examples
a defaultdict is a dict with one extra feature on top: if you try to access a key that isn't present, it uses a default value that is generated by calling a specific function (the function that was originally passed during defaultdict's construction). (When I say "function" I really mean "callable" but let's ignore that for now.)
 
One of the things I don't understand is how something like (without 'synthatic sugar') : d.get(1).get(2).set(3,4) would be "iterable", meaning it would "rotate" through the deepdict dictionary from start to finish, first trying to get(1), then get(2) and then return before set(3,4).
 
@PedroSpinola it doesn't do anything of the kind
d is a nested dict (with a bit on top because it's a defaultdict). d.get(1) gets the value in the dict for key 1. If that value is a dict, then .get(2) might work, assuming that this first-level-nested dict has a value for key 2. And so on.
 
That's what I got from pdb debug lol
 
This is nothing specific to defaultdicts: d = {1: {2: {3: 'asdf'}}}
 
I know, I wasn't even using it
what you say isn't almost the same as what I said?
(me with wrong words though)
 
10:54 PM
It was supposed to be the same thing, explained differently, because you started yours with "One of the things I don't understand"
 
I still don't understand though :P But this is on me, of course. Thanks anyhow :D
 
@PedroSpinola As I said, first try understanding regular defaultdicts, and nested regular dicts too.
 
I do understand those, I think. And I do understand that it does work, by providing default factory to keys if they are not found. This is why when d = deepdict() is executed, a default factory is then provided for it (seen it in pdb). This would be sufficient, but I was trying to understand the underlying theory on how it works exactly. And what I don't get is the recursive aspect and how exactly it handles the defaultdict being called upon "itself".
 
@PedroSpinola there's no recursive aspect. It's just a defaultdict. It's just that the default object it creates for a missing key is another defaultdict of the same kind. But not the same defaultdict object! Only cousins.
Added a formal request for the company to correct for this bug meta.stackoverflow.com/a/399303/5067311
 
11:13 PM
alright, I was using 'recursively' incorrectly it's just nested functions, not necessarily recursive. but there's still iteration, right, because that function is called as many times as there are keys present, and it will run first on key get(1), then 2, etc, right? This is what I don't get exactly on how it works. How does python "know" it should execute first get(1), than get(2), and stop before set(3,4) ?
 
@PedroSpinola as I said it goes step by step. There's no "nested functions". There are independent defaultdict objects. There's no "iteration" in the traditional sense. There's just lookup one after the other.
When you do d[1][2][3] you're saying "look up 1 on d whatever that is, then look up 2 on whatever that is, finally look up 3 on whatever that is". If any of these steps doesn't work (because the lookup fails on the given object), you get an error.
Defaultdicts, as you know, create a value when you look up missing keys. So when python evaluates d[1] it creates a new defaultdict for the key 1 if it was missing beforehand. Then it looks up 2 on this defaultdict. Since it's empty, the key will be missing, so again it will create a new defaultdict and assign it to key 2 of this inner defaultdict. And then 3 is looked up on this defaultdict, creating yet another defaultdict.
 
20 hours ago, by toonarmycaptain
@PedroSpinola it'll have to find key 1 inside d (or return the default), then look for the key 2 inside 1's value, then look for 3 inside 2's value, as far as I understand.
 
Ohh now I understand how they are independently calling the function, I was thinking it was all going as a "pack" and then evaluated! Alright, only question that remains is how python 'knows' it should go "step-by-step" into d[1][2][3] = 4 instead of just trying it to set(3,4) directly. This is default "behavior" for dicts "parsing" ?
 
@PedroSpinola what would it call set(3,4) on?
by the way dicts don't have a .set method, and neither do defaulticts
 
Simple as that
 
11:26 PM
@VisheshMangla You show a lot of missing fundamental knowledge on how Office saves files (docx, xslx, ppx, etc) and what you should/can do with the XML. You should look over the Microsoft documents on this if you wish to continue or you'll end up pulling out all your hair
 
@PedroSpinola It's not dict parsing per se, it's just parsing in general. The parser doesn't know whether d or d[1][2] are dicts. It can't do anything other than go from left to right.
 
alright, I get it now :D That was awesome. I appreciate man :)
About the .set method yes I just refer the original message when one of the fellas here explained the correct way it "worked" after "synthatic sugar" or something like that.
 
"syntactic" sugar. Something that relates to syntax.
@PedroSpinola Whoever mentioned a "set method" to you needs a slapping with a wet fish
 
No that was my flawed memory + imagination lol :P
 
21 hours ago, by Kevin
@PedroSpinola d[1][2][3] = 4 is effectively syntactic sugar for d.__getitem__(1).__getitem__(2).__setitem__(3, 4). The __getitem__ method of defaultdict will check whether the key exists in the dict already, and if not, call the lambda* you passed to its constructor and set that as the value instead. Since the function deepdict itself returns a defaultdict, you can chain __getitem__ calls as deeply as you want
that's very much not .set
 
11:29 PM
But doesn't matter for what I was trying to understand, and do now :D
 
it's tricky because dict.get exists (and is useful for getting default values from regular dicts)
 
yeah, I know
set or setitem doesn't, though?
I mean, as a dict method?
 
@VisheshMangla Start with how office actually opens files so you understand why people were confused by your question. If you need more detailed information check out the base .Net library (as python's docx uses the same dlls)
 
@PedroSpinola without duple underscores: no
__setitem__ does, as Kevin mentioned.
 
tbh I don't understand those variables with __ on python very well, today I understood the if __name__ = __main__ thing, but that's all. have you got any reading material for that?
 
11:31 PM
@PedroSpinola yes, these are various protocols in python. See the data model section of the docs. But hang tight, it's a bit complex :)
 
just a sneaky peak
:P
 
The idea is that using obj[...] = val on any object obj will call the object's __setitem__ method, and in any other context (that I can think of right now) obj[...] will call the __getitem__ method. It's possible that I'm forgetting about/ignoring important cases, I'm just trying to give a rough idea.
So you can support indexing in your custom class by implementing these methods
 
@JonClements I usually give up and just use Powershell - sometimes the shell is just the best option
 
11:53 PM
Yeah, I get it now. Somehow I thought the "from right from left" thing only applied from value -> var in soomething like var = value, but I see it's obvious it would be impossible to parse [3] = 4 before parsing [2], and [1] and d of course :D
 

« first day (3556 days earlier)      last day (1375 days later) »