Regarding import statement in pox controller












0















I am reading the source code of pox controller. There is an import statement in one module called l3_editing.py which is modified based l3_learning.py.



The import statement is:



from pox.lib.recoco import Timer


Because I do not know Timer, I just along with the source tree to find this struct. But I cannot find this struct Timer, which really make me confused. It should be in pox/lib/recoco.py, but there is no module named recoco.py under lib package.



Items below pox/lib:



pox/lib



Items below pox/lib/recoco:



pox/lib/recoco










share|improve this question

























  • Look at the contents of the pox/lib/recoco/__init__.py file.

    – martineau
    Nov 15 '18 at 10:11
















0















I am reading the source code of pox controller. There is an import statement in one module called l3_editing.py which is modified based l3_learning.py.



The import statement is:



from pox.lib.recoco import Timer


Because I do not know Timer, I just along with the source tree to find this struct. But I cannot find this struct Timer, which really make me confused. It should be in pox/lib/recoco.py, but there is no module named recoco.py under lib package.



Items below pox/lib:



pox/lib



Items below pox/lib/recoco:



pox/lib/recoco










share|improve this question

























  • Look at the contents of the pox/lib/recoco/__init__.py file.

    – martineau
    Nov 15 '18 at 10:11














0












0








0








I am reading the source code of pox controller. There is an import statement in one module called l3_editing.py which is modified based l3_learning.py.



The import statement is:



from pox.lib.recoco import Timer


Because I do not know Timer, I just along with the source tree to find this struct. But I cannot find this struct Timer, which really make me confused. It should be in pox/lib/recoco.py, but there is no module named recoco.py under lib package.



Items below pox/lib:



pox/lib



Items below pox/lib/recoco:



pox/lib/recoco










share|improve this question
















I am reading the source code of pox controller. There is an import statement in one module called l3_editing.py which is modified based l3_learning.py.



The import statement is:



from pox.lib.recoco import Timer


Because I do not know Timer, I just along with the source tree to find this struct. But I cannot find this struct Timer, which really make me confused. It should be in pox/lib/recoco.py, but there is no module named recoco.py under lib package.



Items below pox/lib:



pox/lib



Items below pox/lib/recoco:



pox/lib/recoco







python import controller sdn pox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 10:06









martineau

68.5k1090183




68.5k1090183










asked Nov 15 '18 at 9:37









MelvinMelvin

287




287













  • Look at the contents of the pox/lib/recoco/__init__.py file.

    – martineau
    Nov 15 '18 at 10:11



















  • Look at the contents of the pox/lib/recoco/__init__.py file.

    – martineau
    Nov 15 '18 at 10:11

















Look at the contents of the pox/lib/recoco/__init__.py file.

– martineau
Nov 15 '18 at 10:11





Look at the contents of the pox/lib/recoco/__init__.py file.

– martineau
Nov 15 '18 at 10:11












1 Answer
1






active

oldest

votes


















2














The lib directory is a python package. It contains an __init__.py file. When you import a package this will cause any __init__.py file to be executed. So what's in there?



Just one line:



from recoco import *


Great we are getting closer! Lets look in recoco.py:



...
class Timer (Task):
"""
A simple timer.
...


There you have it!






share|improve this answer





















  • 1





    thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

    – Melvin
    Nov 15 '18 at 10:23











  • sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

    – Melvin
    Nov 15 '18 at 10:45











  • @Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

    – Rob Bricheno
    Nov 15 '18 at 11:48













  • @Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

    – Rob Bricheno
    Nov 15 '18 at 11:50











  • thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

    – Melvin
    Nov 15 '18 at 12:01













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316379%2fregarding-import-statement-in-pox-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














The lib directory is a python package. It contains an __init__.py file. When you import a package this will cause any __init__.py file to be executed. So what's in there?



Just one line:



from recoco import *


Great we are getting closer! Lets look in recoco.py:



...
class Timer (Task):
"""
A simple timer.
...


There you have it!






share|improve this answer





















  • 1





    thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

    – Melvin
    Nov 15 '18 at 10:23











  • sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

    – Melvin
    Nov 15 '18 at 10:45











  • @Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

    – Rob Bricheno
    Nov 15 '18 at 11:48













  • @Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

    – Rob Bricheno
    Nov 15 '18 at 11:50











  • thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

    – Melvin
    Nov 15 '18 at 12:01


















2














The lib directory is a python package. It contains an __init__.py file. When you import a package this will cause any __init__.py file to be executed. So what's in there?



Just one line:



from recoco import *


Great we are getting closer! Lets look in recoco.py:



...
class Timer (Task):
"""
A simple timer.
...


There you have it!






share|improve this answer





















  • 1





    thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

    – Melvin
    Nov 15 '18 at 10:23











  • sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

    – Melvin
    Nov 15 '18 at 10:45











  • @Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

    – Rob Bricheno
    Nov 15 '18 at 11:48













  • @Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

    – Rob Bricheno
    Nov 15 '18 at 11:50











  • thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

    – Melvin
    Nov 15 '18 at 12:01
















2












2








2







The lib directory is a python package. It contains an __init__.py file. When you import a package this will cause any __init__.py file to be executed. So what's in there?



Just one line:



from recoco import *


Great we are getting closer! Lets look in recoco.py:



...
class Timer (Task):
"""
A simple timer.
...


There you have it!






share|improve this answer















The lib directory is a python package. It contains an __init__.py file. When you import a package this will cause any __init__.py file to be executed. So what's in there?



Just one line:



from recoco import *


Great we are getting closer! Lets look in recoco.py:



...
class Timer (Task):
"""
A simple timer.
...


There you have it!







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 11:51

























answered Nov 15 '18 at 9:56









Rob BrichenoRob Bricheno

2,375318




2,375318








  • 1





    thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

    – Melvin
    Nov 15 '18 at 10:23











  • sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

    – Melvin
    Nov 15 '18 at 10:45











  • @Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

    – Rob Bricheno
    Nov 15 '18 at 11:48













  • @Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

    – Rob Bricheno
    Nov 15 '18 at 11:50











  • thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

    – Melvin
    Nov 15 '18 at 12:01
















  • 1





    thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

    – Melvin
    Nov 15 '18 at 10:23











  • sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

    – Melvin
    Nov 15 '18 at 10:45











  • @Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

    – Rob Bricheno
    Nov 15 '18 at 11:48













  • @Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

    – Rob Bricheno
    Nov 15 '18 at 11:50











  • thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

    – Melvin
    Nov 15 '18 at 12:01










1




1





thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

– Melvin
Nov 15 '18 at 10:23





thanks, I did not realize that the init.py will be executed. I thought that just is a tag to present that directory is a package.

– Melvin
Nov 15 '18 at 10:23













sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

– Melvin
Nov 15 '18 at 10:45





sorry, I can not agree with you after I have try a simple demo. You are right on some aspects. But could you explain what have still confused me: the statement "from pox.lib.recoco import Timer", it present that I want to import Timer, and Timer is in /pox/lib/recoco, so recoco must be a module which has a suffix .py and Timer must be in recoco.py. The recoco is the end of from keyword, so it won't be a package, because I have try it by a simple demo. And this truth is understandable, because the origin which we want to import from must be a module in the end or it will not be right.

– Melvin
Nov 15 '18 at 10:45













@Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

– Rob Bricheno
Nov 15 '18 at 11:48







@Melvin The recoco in your import statement is a package not a module. When we import pox.lib.recoco we are importing the directory pox/lib/recoco not the file pob/lib/recoco/recoco.py. Because a file called __init__.py is present in the package directory, when we import the package then that file is executed. You might enjoy this question stackoverflow.com/questions/7948494/…

– Rob Bricheno
Nov 15 '18 at 11:48















@Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

– Rob Bricheno
Nov 15 '18 at 11:50





@Melvin I will not accept your edit because the errors that you have in the example you gave me are caused by running under the Python 3 interpreter. Try your example using the Python 2.7 interpreter (which pox requires) and you will find it works. This behaviour changed from Python 2 to Python 3.

– Rob Bricheno
Nov 15 '18 at 11:50













thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

– Melvin
Nov 15 '18 at 12:01







thanks, I have retry it under python2.7, and it works fine. But I still think that the changes on import in python3 are more understandable. Thanks for your instruction, I have learn a lot from it, good bless to you.

– Melvin
Nov 15 '18 at 12:01






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316379%2fregarding-import-statement-in-pox-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python