Status Usama
About
-
Posted Questions
No Question(s) posted yet!
Posted Answers
Answer
please refer to my website for more blog posts related to salesforcehttps://www.cringycode.com/
let’s say that we have 2 LWC components namely databindingParent and databindingChild. So now we want to send data from databindingParent to databindingChild and display the passed data.
databindingChild.html
Let’s straight away jump to line 4. here I'm printing the value in item variable using “{item}”
databindingChild.js
So I declare a variable and named it “item” and added @api property to it, because I want this variable(item) to be publicly accessible.
The Lightning Web Components programming model has three decorators that add functionality to property or function.
@api,@track,@wire. For now, let's talk about @api and @track.
we can also use @track but the basic difference between @api and @track is, @api is a public rendering property whereas @track is private property. Tracked properties are also called private reactive properties.
But both @api and @track have rendering property.
Here I want to send data from one component to another so I need a public property that can hold the data that is sent from another component.
databindingParent.html
In line no 5 we are making a call to “databindingchild” component and passing a value(var1) for the public property “item” .so now let’s see what “var1" variable contains.
databindingParent.js
In the above js file, we’ve declared a public property named var1.
we’ve written a function changefn() which is called when a change occurs to the input text.
In line 5 we are getting the value from the input text and then storing it in the var1 variable.
Here is the output of the above component databindingparent.
Answer is posted for the following question.
Answer
def build_index(filename, sort_col):
index = []
f = open(filename)
while True:
offset = f.tell()
line = f.readline()
if not line:
break
length = len(line)
col = line.split('\t')[sort_col].strip()
index.append((col, offset, length))
f.close()
index.sort()
return index
def print_sorted(filename, col_sort):
index = build_index(filename, col_sort)
f = open(filename)
for col, offset, length in index:
f.seek(offset)
print f.read(length).rstrip('\n')
if __name__ == '__main__':
filename = 'somefile.txt'
sort_col = 2
print_sorted(filename, sort_col)
Source: w3schools
Answer is posted for the following question.
How to how to sort large files in python (Python Programing Language)