Hello. I was working on development related to .Net, and recently I had to deal with RP4.
I've been developing Python recently.
Because the direction of the data type or logic processing is somewhat different There's a lot of traffic.
Question 1) I received data from Rows data in DB as a list and registered the value in dictionary variable.
In this process, I want to process it later like the .Net below.
# Key Question 1: Put data in a global variable like a declared collection function (buffer) and call from another function to process conditional statements, data additions, modifications, and deletions.
# Key question 2: I want to use it like a DataInfo structure, but what form is it usually done in Python language?
# Key question 3: The results were obtained from the function of DB Select in the existing python and the data containing the results were
I need to add conditional statements, data, and delete in other functions, but is it not possible in Python in the first place?
<Global variable>
private dUserInfoBuffer As New Collection()
Private Sub ListAddFunc()
# Buffer to hold data queried by DB
Dim mResult As New Collection
Dim mDataInfo As New DataInfo
Dim mObject(10) As String
mResult = DB.SearchDataInfo()
For i = 0 To mResult
mDataInfo= mResult.Item(1)
mObject(0) = mDataInfo.Data1
mObject(1) = mDataInfo.Data2
mObject(2) = mDataInfo.Data3
list.items.Insert(mObject)
dDataInfoBuffer.Add(mDataInfo, mDataInfo.UserID)
Next
End Sub
#If you enter any information, it's the same as the contents of the buffer
Private Sub Input(ByVal vStr As String)
If (dDataInfoBuffer.Contains(vStr)) = True Then
Processing
Else
Return
End If
End Sub
I am studying by purchasing a textbook. I'm searching on the Internet and doing my work little by little by little by little Maybe it's because I can't find the keyword, but I keep getting a wall and I can't go over it.
I need your help~
python list dictionary
You need to change your mind. Python is not sufficient (compared to java, dot-net) although object orientation is supported. Coding like dot-net makes it difficult to gain the advantages of Python.
You don't have to declare a collection variable as a global variable, you can usually pass it over to the parameter using the built-in data type. You don't have to declare a class, so if it's simple, you can treat it as a function right away. Of course, you can put a list as a global variable and use it as a container, but...It's not a good idea. It is also important to make good use of the magic methods to work well on a class-by-class basis.
There are many ways to form structures. There is no structure like dotnet, but you can use class instead, and the recommended method is simply using namedtuple.
As you can see from the dbapi, it is usually returned as a list. Of course, using an om tool like sqlalchemy, which is often used, is the same as using an entity framework on a dotnet, so it would be the desired form. But it's going to be a lot of learning.
There are so many questions.I don't know if it's the answer you want.
© 2024 OneMinuteCode. All rights reserved.