question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to simply iterate column values?

See original GitHub issue

Hi Ilya,

I wonder if there is a simple way to iterate specific columns of a table as an alternative to the following implementation (based on pysnmp v4.4.4)?

    @property
    def _notification_targets(self):
        snmpNotifyEntry, = self.instrum.getMibBuilder().importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyEntry')

        varBinds = initialVarBinds = (
            (snmpNotifyEntry.name + (1,), None),
        )

        while varBinds:
            varBinds = self.instrum.readNextVars(varBinds)
            name, val = varBinds[0]
            if exval.endOfMibView.isSameTypeWith(val):
                break
            if name[:len(initialVarBinds[0][0])] != initialVarBinds[0][0]:
                break

            yield str(val)

A simpler and faster method would be the following:

    @property
    def _notification_targets_not_public(self):
        snmpNotifyName, = self.instrum.getMibBuilder().importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyName')
        for oid, val in snmpNotifyName._vars.items():
            yield str(val.syntax)

However, a protected class member is accessed here.

I would appreciate comments or alternative recommendations.

Best regards, Andreas

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
etingofcommented, Jan 15, 2019

Sounds like if there was a getSubtrees() method/property alongside registerSubtrees(), that would solve this…

Meanwhile, could you walk snmpNotifyEntry subtree by calling snmpNotifyEntry.getNextNode(name) starting with name=snmpNotifyEntry.name?

0reactions
optimosfetcommented, Mar 21, 2019

Meanwhile…

Unfortunately, the use of the .syntax object/property is not appropriate because of the multi-phase procedure for creating/writing. For now, I will continue with the usual suspects .readGet()/.writeCommit().

Read more comments on GitHub >

github_iconTop Results From Across the Web

Iterating over rows and columns in Pandas DataFrame
In order to iterate over rows, we use iteritems() function this function iterates over each column as key, value pair with the label...
Read more >
Pandas Iterate Over Rows with Examples
Like any other data structure, Pandas DataFrame also has a way to iterate (loop through row by row) over rows and access columns/elements...
Read more >
Loop or Iterate over all or certain columns of a dataframe
Iterate over columns in dataframe using Column Names. Dataframe.columns returns a sequence of column names. We can iterate over these column names and...
Read more >
How to Iterate Over Columns in Pandas DataFrame - Statology
We can also use the following syntax to iterate over every column and print just the column names:.
Read more >
How to Iterate Over Rows in a Pandas DataFrame - Stack Abuse
In the for loop, i represents the index column (our DataFrame has indices from id001 to id006 ) and row contains the data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found