Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup for loop example + bump stated Python version #290

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

evantypanski
Copy link
Contributor

@evantypanski evantypanski commented Jan 8, 2025

Gets that example to compile run. Also bumps the stated Python version to 3.9 (after #285)

Copy link
Member

@bbannier bbannier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🚀

While you are at it, would you mind fixing the formatting of this code? zeek-format outputs

diff --git a/script-reference/statements.rst b/script-reference/statements.rst
index 4e6575c..4c73afd 100644
--- a/script-reference/statements.rst
+++ b/script-reference/statements.rst
@@ -718,29 +718,29 @@ Example:
 .. code-block:: zeek
 
     local myset = set(80/tcp, 81/tcp);
-    local mytable = table([10.0.0.1, 80/tcp]="s1", [10.0.0.2, 81/tcp]="s2");
+    local mytable = table([ 10.0.0.1, 80/tcp ] = "s1", [ 10.0.0.2, 81/tcp ] = "s2");
     local myvector = vector("zero", "one", "two");
 
     for ( p in myset )
         print p;
 
-    for ( [ip,p], val in mytable )
+    for ( [ip, p], val in mytable )
         {
-        if (val == "done")
+        if ( val == "done" )
             break;
-        if (val == "skip")
+        if ( val == "skip" )
             next;
-        print ip,p;
+        print ip, p;
         }
 
     for ( _, val in mytable )
         print val;
 
-    for ( [ip,_], _ in mytable )
+    for ( [ip, _], _ in mytable )
         print ip;
 
     for ( i, val in myvector )
-        print i,val;
+        print i, val;
 
     for ( _, val in myvector )
         print val;

Missing quote around `one` and `i` was coming from the previous for
loops' scopes which meant it was an ip address.
@evantypanski evantypanski force-pushed the topic/etyp/cleanup-example branch from 0303563 to d0d38cc Compare January 9, 2025 12:57
@evantypanski evantypanski requested a review from bbannier January 9, 2025 12:58
@bbannier bbannier merged commit 2625284 into master Jan 9, 2025
11 checks passed
@bbannier bbannier deleted the topic/etyp/cleanup-example branch January 9, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants