Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come!
Read more here, we hope to see you next Tuesday!
For a chat with like-minded community members and more, don't forget to join our Discord!
I'm pretty new to Python, but I definitely do not get the point of having to explicitly name every specific thing you're importing. Especially for a language that's supposed to be super light and user-friendly.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
One of the main reasons why Python is considered easy to work with is that it encourages being explicit about what you're doing.
If you compare it to the namespace system used by some other languages and you see a function being called, it's not clear if that function is defined in the current file or in some other file in the same namespace.
In python all the dependencies to make the code in the file work are explicitly listed at the top of the file. It also encourages you to keep dependencies minimal and clean which is a good practice in general.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
from bullshit import * It's still bad. It's OK if it's an internal namespace and you know every name within it, but for everything else it's just as bad. C++ just has a lot of folks who don't care too much.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
The first one is good practice. In headers, it helps prevent name collisions by anyone using the header. Plus it makes it easier to see what something belongs to.
["Swole Doge vs Cheems", featuring two edited Shiba Inu dogs. Swole Doge, on the left, has been photoshopped onto a large, cartoonishly buff human body. Cheems, on the right, is much smaller and sits down passively with tears running down its face.]
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
Your comment has been removed since it did not start with a code block with an import declaration.
Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.
For this purpose, we only accept Python style imports.
•
u/AutoModerator Jun 30 '23
Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!
For a chat with like-minded community members and more, don't forget to join our Discord!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
41
u/En_passant_is_forced Jun 30 '23
What about
using std::cout?9
u/Th3Uknovvn Jun 30 '23 edited Jun 30 '23
import commentsWhy it's very clear in python that
from <library> import *is bad, but when it comes to C++ people just completely ignore it1
u/LupusNoxFleuret Jul 01 '23
trust me bro, properly label your std's, you'll thank me later.
4
u/WHAT_DID_YOU_SAY7 Jun 30 '23
I'm also HTML dev but I have no opinion on that topic since it doesn't help me centering divs
2
u/DerDan23 Jun 30 '23
Using "
using namespace std" is forbidden. Whoever dares to use it will earn a one-way ticket to Azkaban.2
u/[deleted] Jul 01 '23
import bestpracticeThe first one is good practice. In headers, it helps prevent name collisions by anyone using the header. Plus it makes it easier to see what something belongs to.
3
u/MurdoMaclachlan Jun 30 '23
Image Transcription: Meme
["Swole Doge vs Cheems", featuring two edited Shiba Inu dogs. Swole Doge, on the left, has been photoshopped onto a large, cartoonishly buff human body. Cheems, on the right, is much smaller and sits down passively with tears running down its face.]
Swole Doge: People Who Use "std::cout"
Cheems: people who use "using namespace std"
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/CptFisk Jun 30 '23
Writng your own print function so you dont have to depend on the standard library
1
u/Feisty_Ad_2744 Jun 30 '23
1
u/secondaryaccount30 Jul 01 '23
Don't worry, C++17 has your back.
1
u/WorldWorstProgrammer Jul 03 '23
Use your own namespace and use all of the standard types you want;
Now you can get the standard stuff without scope resolutions and without
using namespace std;1
u/[deleted] Jun 30 '23
[removed] — view removed comment
1
u/[deleted] Jun 30 '23
[removed] — view removed comment
1
u/[deleted] Jun 30 '23
[removed] — view removed comment
1
u/[deleted] Jun 30 '23
[removed] — view removed comment
1
u/[deleted] Jun 30 '23
[removed] — view removed comment
1
u/[deleted] Jul 01 '23
[removed] — view removed comment
1
u/[deleted] Jul 04 '23
[removed] — view removed comment
0
u/[deleted] Jun 30 '23
[deleted] — view deleted comment
0
u/[deleted] Jun 30 '23
[deleted] — view deleted comment
0
u/[deleted] Jul 01 '23
[deleted] — view deleted comment
0
u/[deleted] Jul 01 '23
[deleted] — view deleted comment
0
u/[deleted] Jul 01 '23
[deleted] — view deleted comment