On 11/01/17 02:53, kay Cee wrote:
> Is there a proper way to import a class from a module? If so, please tell.
The most common way is probably:
>>> from mymodule import Myclass
>>> myobject = Myclass()
but its just as good to do
>>> import mymodule
>>> myobject = mymodule.Myclass()
--
Al
Is there a proper way to import a class from a module? If so, please tell.
Thank You,
Unee0x
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
2011/5/30 Marilyn Davis :
> If we are coding via a vote, I'd be with Alan.
>
> If Timo adds non-parser modules, and they get through his glob filter,
> then surely his code will break with a nice error statement and that would
> remind him of his convention.
Sure. From my point of view, I prefer a
Timo wrote:
Hello all,
I have a question about how this is done the best way.
In my project I have a folder with multiple file parsers, like this:
- src
-- main.py
-- parsers
--- __init__.py
--- parser1.py
--- parser2.py
This gives you a stand-alone module called "main.py", and a sepa
If we are coding via a vote, I'd be with Alan.
If Timo adds non-parser modules, and they get through his glob filter,
then surely his code will break with a nice error statement and that would
remind him of his convention.
Or maybe it would just give a verbose report and go on to the next file.
"Alexandre Conrad" wrote
Why not use the os functions to read the file names
dynamically and build the list that way? Provided
the files use a standard naming scheme you don't
need to change the init code.
I wouldn't do that. If Timo adds non-parser modules in that
directory
(say some util
2011/5/30 Alexandre Conrad :
> selected_parser = "parser1"
> parser = parsers[selected_parser]
> parser = Parser()
> ...
I meant to have a capital P on the second line of course:
selected_parser = "parser1"
Parser = parsers[selected_parser]
parser = Parser()
or just (less readable though):
pars
2011/5/30 Alan Gauld :
> But this means having to maintain the list in init.py.
> Why not use the os functions to read the file names
> dynamically and build the list that way? Provided
> the files use a standard naming scheme you don't
> need to change the init code.
I wouldn't do that. If Timo a
2011/5/30 Timo :
> When the user clicks a button, I want to show all available parsers and use
> the choosen one when the user clicks "ok".
> Is it ok to place the following code in the __init__.py?
> from parser1 import Parser1
> from parser2 import Parser2
> def get_parsers():
> return [Parser
Timo wrote:
> Hello all,
>
> I have a question about how this is done the best way.
>
> In my project I have a folder with multiple file parsers, like this:
> - src
> -- main.py
> -- parsers
>--- __init__.py
>--- parser1.py
>--- parser2.py
>
> The parsers just contain a class wh
"Timo" wrote
When the user clicks a button, I want to show all available parsers
and use the choosen one when the user clicks "ok".
Is it ok to place the following code in the __init__.py?
from parser1 import Parser1
from parser2 import Parser2
def get_parsers():
return [Parser1(), Parser
Hello all,
I have a question about how this is done the best way.
In my project I have a folder with multiple file parsers, like this:
- src
-- main.py
-- parsers
--- __init__.py
--- parser1.py
--- parser2.py
The parsers just contain a class which do the work.
When the user clicks a bu
12 matches
Mail list logo