How does “Import *” work exactly? Why does Vscode sometimes complains and sometimes not. /u/wnluk Python Education

I’m relatively new to python. I mean, I used it sometimes over the years whenever I needed anything small, but I never bothered to really learn it, never taken it seriously.
Now I wanted to learn networking, it sounds interesting, so I wanted to learn scapy.
I figured I’ll ask ChatGPT for a jumping-off point, and then I go from there. So I import:
from scapy.all import ICMP,IP,sr1
But then I think I can instead just write:
from scapy.all import *
And Vscode starts complaining.
What’s curious, it complains about ICMP() and IP(), but not sr1().
I get something like “IP is not defined”
What is happening? Shouldn’t “import *” import everything?
GPT tells me that “import *” is against the best practice, and I get that, but just because I shouldn’t doesn’t mean I’m not allowed to. Does it?

submitted by /u/wnluk
[link] [comments]

​r/learnpython I’m relatively new to python. I mean, I used it sometimes over the years whenever I needed anything small, but I never bothered to really learn it, never taken it seriously. Now I wanted to learn networking, it sounds interesting, so I wanted to learn scapy. I figured I’ll ask ChatGPT for a jumping-off point, and then I go from there. So I import: from scapy.all import ICMP,IP,sr1 But then I think I can instead just write: from scapy.all import * And Vscode starts complaining. What’s curious, it complains about ICMP() and IP(), but not sr1(). I get something like “IP is not defined” What is happening? Shouldn’t “import *” import everything? GPT tells me that “import *” is against the best practice, and I get that, but just because I shouldn’t doesn’t mean I’m not allowed to. Does it? submitted by /u/wnluk [link] [comments] 

I’m relatively new to python. I mean, I used it sometimes over the years whenever I needed anything small, but I never bothered to really learn it, never taken it seriously.
Now I wanted to learn networking, it sounds interesting, so I wanted to learn scapy.
I figured I’ll ask ChatGPT for a jumping-off point, and then I go from there. So I import:
from scapy.all import ICMP,IP,sr1
But then I think I can instead just write:
from scapy.all import *
And Vscode starts complaining.
What’s curious, it complains about ICMP() and IP(), but not sr1().
I get something like “IP is not defined”
What is happening? Shouldn’t “import *” import everything?
GPT tells me that “import *” is against the best practice, and I get that, but just because I shouldn’t doesn’t mean I’m not allowed to. Does it?

submitted by /u/wnluk
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *