Python Forum
define methods in another file
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
define methods in another file
#11
sort of.
C incude file tends to be class templates, structure typedefs, etc, but not usually code
an imported python file can include both code and data structures.
You'd be better off not trying to compare the two, it's sort of like comparing a lemon to
an orange, they're both citrus fruit, but quite different.
C and python are both programming languages but quite different.
Reply
#12
(Feb-23-2018, 11:07 PM)Python_n00b_06 Wrote: So basically "import" for Python is like "#include" for C/C++?
The general idea is similar similar,that want to use code written somewhere else in your program.
The underlying mechanism has several differences as C++ is a compiled language and Python is a interpreted language.

Example with #include <iostream> imports the methods related to input and output.
Python has these already build in,like eg print, write ect...
Python:
def foo():
	print("Hello world!")
C++:
#include <iostream>
using namespace std;

void foo(){
	cout << "hello world!" << endl;
}
Reply
#13
Back when i got into programming, i started by working on a security project. Just something to see how I fared. I didnt get too far tho as life came up educationally and personally. I finally got around to working on it again and just posted what I got working...albeit wrongly but to the same possible end. Here: https://python-forum.io/Thread-Security-...?pid=29623

I didnt want to copy what minuscule amount i had from there to this post. Any help and explaining on how i could fix; improve; etc etc would be helpful.
Reply
#14
deleted reply, thread is dead and useless
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Helps with reading csv file - 3 methods hhchenfx 4 3,274 May-13-2021, 04:15 AM
Last Post: buran
  Attibute Error: Two methods in a class, one I can reach, the other not (phantom file? GaryKuipers 4 3,154 Aug-28-2018, 02:32 PM
Last Post: GaryKuipers
  How to define a global file? dullboy 11 16,169 Oct-05-2016, 02:08 PM
Last Post: dullboy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020