473,776 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

another docs problem - imp

Another Python docs problem...

I was trying to use imp.find_module ().
imp.find_module ("mymod", "./subdir") ImportError: No frozen submodule named ./subdir.mymod

subdir/mymod.py definately exists, has reasonable
permissions, etc.

After a lot of reading and re-reading the docs,
trying various things, I Googled on the error
message and lo, there was a message from
2002 by someone ranting about how hard
it was to do things in Python sometimes (no it
was not from me).

Turns out that you have to do imp.find_module ("mymod", ["./subdir"])


I saw not a hint of this in the docs. In fact
they seem to say that the first (unworking)
form *should* work. Bye bye about two
hours altogether...

I thought I would post this and hopefully help
someone else in the future (since I noticed
an unanswered posting here from Mar 2005
about the same problem.)

Jan 10 '06 #1
14 2298
[ru***@yahoo.com]
Another Python docs problem...

I was trying to use imp.find_module ().
[...]
I saw not a hint of this in the docs. In fact
they seem to say that the first (unworking)
form *should* work. Bye bye about two
hours altogether...

I thought I would post this and hopefully help
someone else in the future (since I noticed
an unanswered posting here from Mar 2005
about the same problem.)


Why not submit a bug report/patch for the documentation?
Documentation patches are fine in plain text (the maintainers will
take care of the necessary markup) and a submitted report will get
attended to, even it if takes a while - a post here is more-than-
likely to be missed by those that maintain the documentation. It
would take about the same amount of time as a post...

=Tony.Meyer
Jan 10 '06 #2

Tony Meyer wrote:
[ru***@yahoo.com]
Another Python docs problem...

I was trying to use imp.find_module ().
[...]
I saw not a hint of this in the docs. In fact
they seem to say that the first (unworking)
form *should* work. Bye bye about two
hours altogether...

I thought I would post this and hopefully help
someone else in the future (since I noticed
an unanswered posting here from Mar 2005
about the same problem.)
Why not submit a bug report/patch for the documentation?


I will.
Documentation patches are fine in plain text (the maintainers will
take care of the necessary markup) and a submitted report will get
attended to, even it if takes a while - a post here is more-than-
likely to be missed by those that maintain the documentation. It
I didn't post here for the maintainers' sake. The answer is
right in the text you quoted.
would take about the same amount of time as a post...


Jan 10 '06 #3
ru***@yahoo.com wrote:
Turns out that you have to do
imp.find_module ("mymod", ["./subdir"])


I saw not a hint of this in the docs. In fact
they seem to say that the first (unworking)
form *should* work.


from the find_module documentation:

find_module( name[, path])
Try to find the module _name_ on the search path _path_.
If _path_ is a list of directory names, each directory is
searched for files /.../. Invalid names in the list are
silently ignored (but all list items must be strings).
If _path_ is omitted or None, the list of directory names
given by _sys.path_ is searched /.../

it's not obvious how anyone can interpret the alternatives "a
list where all items are strings / omitted / None" as "not a hint
that a list is expected" and "a single string *should* work (i.e.
be treated as a pathname, rather than a sequence)".

</F>

Jan 10 '06 #4

"Fredrik Lundh" <fr*****@python ware.com> wrote:
ru***@yahoo.com wrote:
Turns out that you have to do
>> imp.find_module ("mymod", ["./subdir"])


I saw not a hint of this in the docs. In fact
they seem to say that the first (unworking)
form *should* work.


from the find_module documentation:

find_module( name[, path])

Try to find the module _name_ on the search path _path_.
If _path_ is a list of directory names, each directory is
searched for files /.../. Invalid names in the list are
silently ignored (but all list items must be strings).
If _path_ is omitted or None, the list of directory names
given by _sys.path_ is searched /.../

it's not obvious how anyone can interpret the alternatives "a
list where all items are strings / omitted / None" as "not a hint
that a list is expected" and "a single string *should* work (i.e.
be treated as a pathname, rather than a sequence)".


Well, I interpreted the if's as describing special cases
addtional to the first sentence. At least one other person
apperantly had the same problem recently.
http://groups.google.com/group/comp....57d0546?hl=en&
May I suggest that the problem is easily fixed simply
by removing the first "if".

Jan 11 '06 #5
ru***@yahoo.com wrote:
from the find_module documentation:

find_module( name[, path])

Try to find the module _name_ on the search path _path_.
If _path_ is a list of directory names, each directory is
searched for files /.../. Invalid names in the list are
silently ignored (but all list items must be strings).
If _path_ is omitted or None, the list of directory names
given by _sys.path_ is searched /.../

it's not obvious how anyone can interpret the alternatives "a
list where all items are strings / omitted / None" as "not a hint
that a list is expected" and "a single string *should* work (i.e.
be treated as a pathname, rather than a sequence)".
Well, I interpreted the if's as describing special cases
addtional to the first sentence.


The first sentence says that the _path_ argument is a search path.
It does not say that it can be a string; that's something you made
up all by yourself.
May I suggest that the problem is easily fixed simply
by removing the first "if".


Like

Try to find the module _name_ on the search path _path_.
_path_ is a list of directory names, each directory is searched
for files.

? So what happens when pupry reads this, and gets annoyed that he
always has to pass in a list ? It's probably better if you learn to read
technical documentation a bit more carefully.
.... and don't give me any "you're defending the status quo" crap in
response to this. There are lots of things to do in the library reference,
and a few of us are working on it (using different approaches), but
trust me, optimizing for a few

1 - I think I know how this works
2 - oh, it didn't work. let's check the documentation
3 - I think I've found a way to interpret the documentation as if
it allows me to do what I'm doing. it doesn't explicitly say that
I can do this, but it doesn't explicitly rule it out either, so I'm
probably right. I'll try again. maybe it works this time.
4 - (2 hours later) maybe I should try one of the alternatives that
is mentioned in the documentation. oh, it did work if I follow the
instructions. now I'm REALLY pissed, and am going to spend
another hour arguing about this on the internet.

practitioners, over the

1 - I think I know how this works
2 - oh, it didn't work. let's check the documentation.
3 - it says "can be a list" or "can be omitted". let's try one of
those. oh, it worked.

crowd is not on the list.

This reminds me of the old story when the local bus company made it
possible to pay with special "bus cards", which works like this:

1 - enter the bus
2 - put your card in the card reader slot
3 - if the card reader beeps annoyingly and flashes red, talk to
the driver. otherwise, get your card and get seated.

and some local rurpy's wrote long letters to the editor arguing that it
was a disgrace that the bus company didn't publish more information
in advance; maybe an illustrative folder sent to everyone in the area
would have been a nice idea, or some television spots showing how
to put the card in the reader? The reply from the bus company was
a gem:

"it's really very simple, and you only have to learn this once"

It may have taken you two hours, but now you know that strings are
sequences too, and that you cannot treat a number of if-sentences or
can be-sentences in a piece of text as "what I originally thought *plus*
what it says."

The latter is likely to save your many hours in your continued career as
a professional (no matter what your profession really is).

</F>

Jan 11 '06 #6
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** *************** @python.org...
ru***@yahoo.com wrote:
from the find_module documentation:

find_module( name[, path])

Try to find the module _name_ on the search path _path_.
If _path_ is a list of directory names, each directory is
searched for files /.../. Invalid names in the list are
silently ignored (but all list items must be strings).
If _path_ is omitted or None, the list of directory names
given by _sys.path_ is searched /.../

it's not obvious how anyone can interpret the alternatives "a
list where all items are strings / omitted / None" as "not a hint
that a list is expected" and "a single string *should* work (i.e.
be treated as a pathname, rather than a sequence)".
Well, I interpreted the if's as describing special cases
addtional to the first sentence.


The first sentence says that the _path_ argument is a search path.
It does not say that it can be a string; that's something you made
up all by yourself.


Correct it does not say it's a string. But your implication that
one can therefore conclude that it is not a string is silly.From unittest:
assert_( expr[, msg])
failUnless( expr[, msg])
Signal a test failure if expr is false; the explanation for the error
will be msg if given, otherwise it will be None. I should conclude that msg is not a string because
it doesn't say it is a string?
May I suggest that the problem is easily fixed simply
by removing the first "if".


Like

Try to find the module _name_ on the search path _path_.
_path_ is a list of directory names, each directory is searched
for files.

? So what happens when pupry reads this, and gets annoyed that he
always has to pass in a list ? It's probably better if you learn to read
technical documentation a bit more carefully.


Reading more carefully is always useful. But that does
not remove the obligation of the writer to write clearly and
unambiguously. Why would pupry think s/he always has
to pass in a list when the syntax description clearly shows
the arument is optional, and the following "if" sentence states
it is optional? But perhaps you are right; perhaps something
like "_path_is a optional list of..." would be clearer.
... and don't give me any "you're defending the status quo" crap in
response to this. There are lots of things to do in the library reference,
and a few of us are working on it (using different approaches), but
trust me, optimizing for a few
"optimize": to make as perfect, effective, or functional as possible.
(Merriam Webster New Collegiate)

"few" has nothing to do with it.
If this required a huge amount of work, your resistance
would be understandable. Since the wording changes
are petty minor your flamage over this is puzzling.
1 - I think I know how this works Wrong, I had no idea how it worked and read the docs
first. 2 - oh, it didn't work. let's check the documentation Yes, read it a second time, didn't see the alternate interpretation. 3 - I think I've found a way to interpret the documentation as if
it allows me to do what I'm doing. it doesn't explicitly say that
I can do this, but it doesn't explicitly rule it out either, so I'm
probably right. I'll try again. maybe it works this time. Nope. It was "hmm, seems to clearly state that it
takes a path argument." Since I was dealing with a
single directory, and (this stuff dealing with imports
and all) had just before been thinking about sys.path
solutions, I was primed to accept that the argument
was a string and assumed I must be doing something
wrong." <later> "Is there any source? Nope
must be C." <later> "How about google". Oh here
is someone with same problem, Damn, no answer.
Ohh here is some one else, different problem but
he tried both find_module(.., "xxx") and (..,"[xxx]")
and the latter didn't generate the error message. 4 - (2 hours later) maybe I should try one of the alternatives that
is mentioned in the documentation. oh, it did work if I follow the
instructions. now I'm REALLY pissed, and am going to spend
another hour arguing about this on the internet. No. As I said, I did not see your way of interpreting the
documentation until you posted. And I had no plans
to argue about it. I posted for the reasons I gave,
and made a suggestion about how the documention
could be improved.
Well, in your attempt at mind reading you at least
got one out of four.
practitioners, over the
1 - I think I know how this works
2 - oh, it didn't work. let's check the documentation.
3 - it says "can be a list" or "can be omitted". let's try one of
those. oh, it worked.


How about
1 - read some clear unambiguous documentation.
2 - write the code and it works as described.

My grandfather used to own a hardware store.
He frequently said he took every customer
complaint very seriously. "For every customer
who complains, there are a 100 that just take their
business elsewhere."
I wonder how many people had a problem with
this and lost time. Not as extreme as my case,
maybe just rereading it a few times. And of course
this particular piece of documentation is not an
isolated instance. If you are happy with the status
quo, if it is "good enough" fine. I am not.

....snipped long anacdote about busses...

Jan 13 '06 #7
ru***@yahoo.com wrote:
The first sentence says that the _path_ argument is a search path.
It does not say that it can be a string; that's something you made
up all by yourself.


Correct it does not say it's a string. But your implication that
one can therefore conclude that it is not a string is silly.
From unittest:
assert_( expr[, msg])
failUnless( expr[, msg])
Signal a test failure if expr is false; the explanation for the error
will be msg if given, otherwise it will be None.


I should conclude that msg is not a string because
it doesn't say it is a string?


nice logic, there.

</F>

Jan 13 '06 #8
ru***@yahoo.com wrote:
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** *************** @python.org...
ru***@yahoo.c om wrote:

from the find_module documentation:

find_module( name[, path])
[...]
Reading more carefully is always useful. But that does
not remove the obligation of the writer to write clearly and
unambiguously. Why would pupry think s/he always has
to pass in a list when the syntax description clearly shows
the arument is optional, and the following "if" sentence states
it is optional? But perhaps you are right; perhaps something
like "_path_is a optional list of..." would be clearer.
Well, perhaps if you'd read the intro to the documentation (more
carefully), or if you were more used to reading programming manuals,
you'd quickly have recognised

[, path]

as meaning precisely that the path argument is optional.
... and don't give me any "you're defending the status quo" crap in
response to this. There are lots of things to do in the library reference,
and a few of us are working on it (using different approaches), but
trust me, optimizing for a few

"optimize": to make as perfect, effective, or functional as possible.
(Merriam Webster New Collegiate)

Reliance on dictionary definitions is often the sign of rigid thinking.
If you can't produce your own definition and defend it you'd probably be
better of not quoting a definition in the first place.
"few" has nothing to do with it.
So you think the docs should be changed if just *one* person can't
understand them. Or maybe *two*? or *ten*?
If this required a huge amount of work, your resistance
would be understandable. Since the wording changes
are petty minor your flamage over this is puzzling.
As is your insistence on debating the point rather than submitting a
change request via sourceforge.
1 - I think I know how this works
Wrong, I had no idea how it worked and read the docs
first.
2 - oh, it didn't work. let's check the documentation


Yes, read it a second time, didn't see the alternate interpretation.
3 - I think I've found a way to interpret the documentation as if
it allows me to do what I'm doing. it doesn't explicitly say that
I can do this, but it doesn't explicitly rule it out either, so I'm
probably right. I'll try again. maybe it works this time.


Nope. It was "hmm, seems to clearly state that it
takes a path argument." Since I was dealing with a
single directory, and (this stuff dealing with imports
and all) had just before been thinking about sys.path
solutions, I was primed to accept that the argument
was a string and assumed I must be doing something
wrong." <later> "Is there any source? Nope
must be C." <later> "How about google". Oh here
is someone with same problem, Damn, no answer.
Ohh here is some one else, different problem but
he tried both find_module(.., "xxx") and (..,"[xxx]")
and the latter didn't generate the error message.
4 - (2 hours later) maybe I should try one of the alternatives that
is mentioned in the documentation. oh, it did work if I follow the
instructions. now I'm REALLY pissed, and am going to spend
another hour arguing about this on the internet.


No. As I said, I did not see your way of interpreting the
documentation until you posted. And I had no plans
to argue about it. I posted for the reasons I gave,
and made a suggestion about how the documention
could be improved.
Well, in your attempt at mind reading you at least
got one out of four.

practitioners , over the
1 - I think I know how this works
2 - oh, it didn't work. let's check the documentation.
3 - it says "can be a list" or "can be omitted". let's try one of
those. oh, it worked.

How about
1 - read some clear unambiguous documentation.
2 - write the code and it works as described.

Excellent. So now you only have to fix the docs and that's what everyone
will do from now on.
My grandfather used to own a hardware store.
He frequently said he took every customer
complaint very seriously. "For every customer
who complains, there are a 100 that just take their
business elsewhere."
I wonder how many people had a problem with
this and lost time. Not as extreme as my case,
maybe just rereading it a few times. And of course
this particular piece of documentation is not an
isolated instance. If you are happy with the status
quo, if it is "good enough" fine. I am not.

...snipped long anacdote about busses...

Clearly. So get your sleeves rolled up and provide a fix. Then you too
will get your name in the Python documentation contributors' list.

I agree that things that are difficult to understand could usefully be
fixed. Since this is the open source world I'm unsure as to why you feel
somebody else should fix it. It's also fairly obvious since you failed
to find other complaints about this issue in your Google search that it
isn't a frequent cause of complaint.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 13 '06 #9
Steve Holden wrote:
Clearly. So get your sleeves rolled up and provide a fix. Then you too
will get your name in the Python documentation contributors' list.


Is there such a list? I have contributed many doc patches and if such
glory is mine I would like to know it!

Kent
Jan 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1565
by: Bjørn T Johansen | last post by:
I need to introduce an extra field in a table that has one field as primary key. The "problem" is that this new field should be combined with the existing pk to create a new combined pk for the table, how to I change the table? Using the Alternate command? How? Or do I need to create a new table and copy everything to the new table? Cheers, BTJ
11
16961
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got the following frame structure at the top level: FRAMESET CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"> <html><head><title>Server List</title></head> <frameset frameborder="1" border="1" framespacing="1" rows="10%,89%">
8
2306
by: Eric_Dexter | last post by:
I was looking for a simple way to load a simple python program from another python program. I tried os.system(cabel) The file name is cabel.py a csound instrument editor.. The error I am getting is
2
2973
by: KraftDiner | last post by:
I have a class that is defined in a file called MyClass.py How do I use that class in another python script.. import MyClass ? (Does it need to be in a specific location?)
17
2721
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
3
12091
by: yinglcs | last post by:
Hi, i have 2 python files in *different directory* , how can I import python functions from 1 python file to another? i get this error: import task ImportError: No module named task/ Thank you.
2
1937
by: Carnell, James E | last post by:
I am thinking about purchasing a book, but wanted to make sure I could get through the code that implements what the book is about (Artificial Intelligence a Modern Approach). Anyway, I'm not a very good programmer and OOP is still sinking in, so please don't answer my questions like I really know anything. MY QUESTION: What is a slot? In class Object below the __init__ has a slot. Note: The slot makes use of a data object called...
2
1446
by: patrick.waldo | last post by:
Hi all, Fairly new Python guy here. I am having a lot of trouble trying to figure this out. I have some data on some regulations in Excel and I need to basically add up the total regulations for each country--a statistical analysis thing that I'll copy to another Excel file. Writing with pyExcelerator has been easier than reading with xlrd for me...So that's what I did first, but now I'd like to learn how to crunch some data.
11
7125
by: mjahabarsadiq | last post by:
Hi I have created a web application. I am using ant to build the war and deploy in tomcat. The war file is deployed under "TOMCATE_HOME/work/standalone/localhost/onlineres.war". I have my source files in "D:\Sadiq\Projects\Onlineres". The folder structure is as follows. 1) D:\Sadiq\Projects\Onlineres: This folder is having the context.xml, web.xml, build.xml and build.properties files.
0
10287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9922
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8951
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7469
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6721
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5492
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4030
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2859
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.