473,662 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't I import this?

Hi list,

I can't understand this. The following import statement works fine:

from PythonCard.temp lates.dialogs import runOptionsDialo g

but this one fails:

from PythonCard.tool s.codeEditor.co deEditor import CodeEditor

I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.

What's going on? (Running Python2.5 under WinXP).

Regards,
Jun 27 '08 #1
8 1253
John Henry schrieb:
Hi list,

I can't understand this. The following import statement works fine:

from PythonCard.temp lates.dialogs import runOptionsDialo g

but this one fails:

from PythonCard.tool s.codeEditor.co deEditor import CodeEditor

I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.
How do these complaints *look* - we can't read your mind nor your
screen, as you might imagine....
What's going on? (Running Python2.5 under WinXP).
What do you think is more probable - pythons import-mechanism, the
foundation of nearly all libraries, is broken - or you make a mistake?

Diez
Jun 27 '08 #2
On May 13, 1:18 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
John Henry schrieb:
Hi list,
I can't understand this. The following import statement works fine:
from PythonCard.temp lates.dialogs import runOptionsDialo g
but this one fails:
from PythonCard.tool s.codeEditor.co deEditor import CodeEditor
I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.

How do these complaints *look* - we can't read your mind nor your
screen, as you might imagine....
What's going on? (Running Python2.5 under WinXP).

What do you think is more probable - pythons import-mechanism, the
foundation of nearly all libraries, is broken - or you make a mistake?

Diez
Thumper's dad always told him: If you don't have anything nice/useful/
garbage to say, then don't say noth'ng at all.

Next.
Jun 27 '08 #3
John Henry wrote:
Hi list,

I can't understand this. The following import statement works fine:

from PythonCard.temp lates.dialogs import runOptionsDialo g

but this one fails:

from PythonCard.tool s.codeEditor.co deEditor import CodeEditor
This kind of "dotted" name import only works for packages, and a
directory is considered a package only if it contains a file name
__init__.py. Looking around my installation of PythonCard (on Linux)
I see that most of those directories *do NOT* have a __init__.py, so
they are not packages and cannot be imported that way.
Of course this leaves unanswered the question of *how* you are supposed
to import that code. I've never used PythonCard so I can't help
further, but I suggest looking at the documentation and examples
supplied. And perhaps waiting for someone with experience with
PythonCard to answer.
Gary Herron

P.S. It is usually a waste of time to tell us that something fails
without telling us *how* it fails. (Cut and paste the error message
always, and the traceback usually.) If you don't, you will usually get
a request to supply that information, and then have wast3ed the time for
one full round of message to the group. Even in this case, I'm only
guessing how it failed for you.

I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.

What's going on? (Running Python2.5 under WinXP).

Regards,
--
http://mail.python.org/mailman/listinfo/python-list
Jun 27 '08 #4
Thumper's dad always told him: If you don't have anything nice/useful/
garbage to say, then don't say noth'ng at all.
You mean it's not useful to tell you
- to give more information on *what* acutally goes wrong?

- in the meantime, to look harder for your mistake, because it's
unlikely to be python's failure?
Can't help you then. Won't happen again.

Diez
Jun 27 '08 #5
On May 13, 1:49 pm, Gary Herron <gher...@island training.comwro te:
John Henry wrote:
Hi list,
I can't understand this. The following import statement works fine:
from PythonCard.temp lates.dialogs import runOptionsDialo g
but this one fails:
from PythonCard.tool s.codeEditor.co deEditor import CodeEditor

This kind of "dotted" name import only works for packages, and a
directory is considered a package only if it contains a file name
__init__.py. Looking around my installation of PythonCard (on Linux)
I see that most of those directories *do NOT* have a __init__.py, so
they are not packages and cannot be imported that way.

Of course this leaves unanswered the question of *how* you are supposed
to import that code. I've never used PythonCard so I can't help
further, but I suggest looking at the documentation and examples
supplied. And perhaps waiting for someone with experience with
PythonCard to answer.

Gary Herron

P.S. It is usually a waste of time to tell us that something fails
without telling us *how* it fails. (Cut and paste the error message
always, and the traceback usually.) If you don't, you will usually get
a request to supply that information, and then have wast3ed the time for
one full round of message to the group. Even in this case, I'm only
guessing how it failed for you.
I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.
What's going on? (Running Python2.5 under WinXP).
Regards,
--
http://mail.python.org/mailman/listinfo/python-list
Thank you very much. I didn't know about the __init__.py
requirement. Appreciate it.
Jun 27 '08 #6
John Henry wrote:
On May 13, 1:49 pm, Gary Herron <gher...@island training.comwro te:
>John Henry wrote:
>>Hi list,

I can't understand this. The following import statement works fine:

from PythonCard.temp lates.dialogs import runOptionsDialo g

but this one fails:

from PythonCard.tool s.codeEditor.co deEditor import CodeEditor
This kind of "dotted" name import only works for packages, and a
directory is considered a package only if it contains a file name
__init__.py. Looking around my installation of PythonCard (on Linux)
I see that most of those directories *do NOT* have a __init__.py, so
they are not packages and cannot be imported that way.

Of course this leaves unanswered the question of *how* you are supposed
to import that code. I've never used PythonCard so I can't help
further, but I suggest looking at the documentation and examples
supplied. And perhaps waiting for someone with experience with
PythonCard to answer.

Gary Herron

P.S. It is usually a waste of time to tell us that something fails
without telling us *how* it fails. (Cut and paste the error message
always, and the traceback usually.) If you don't, you will usually get
a request to supply that information, and then have wast3ed the time for
one full round of message to the group. Even in this case, I'm only
guessing how it failed for you.

>>I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.

What's going on? (Running Python2.5 under WinXP).

Regards,
--
http://mail.python.org/mailman/listinfo/python-list

Thank you very much. I didn't know about the __init__.py
requirement. Appreciate it.
Actually I should have added that there ways to import such things, and
PythonCard must be using some such method itself. You can manipulate
the sys.path variable, or directly call the import mechanism using the
builtin __import__, or use a suppled "imp" module. However, you
should not have to do any such thing to use PythonCard. It should do
them in for you.
Jun 27 '08 #7
John Henry <jo**********@h otmail.comwrite s:
On May 13, 1:18 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
John Henry schrieb:
the class CodeEditor all exists and yet idle keep complaining
that it can't import from PythonCard.tool s.
How do these complaints *look* - we can't read your mind nor your
screen, as you might imagine....

Thumper's dad always told him: If you don't have anything
nice/useful/ garbage to say, then don't say noth'ng at all.
Thanks for the aphorism. You're still no closer to actually getting a
useful answer, until you can provide the information Diez explained
that we need.

--
\ "I used to be a proofreader for a skywriting company." -- |
`\ Steven Wright |
_o__) |
Ben Finney
Jun 27 '08 #8
On May 13, 3:42 pm, Gary Herron <gher...@island training.comwro te:
John Henry wrote:
On May 13, 1:49 pm, Gary Herron <gher...@island training.comwro te:
John Henry wrote:
>Hi list,
>I can't understand this. The following import statement works fine:
> from PythonCard.temp lates.dialogs import runOptionsDialo g
>but this one fails:
> from PythonCard.tool s.codeEditor.co deEditor import CodeEditor
This kind of "dotted" name import only works for packages, and a
directory is considered a package only if it contains a file name
__init__.py. Looking around my installation of PythonCard (on Linux)
I see that most of those directories *do NOT* have a __init__.py, so
they are not packages and cannot be imported that way.
Of course this leaves unanswered the question of *how* you are supposed
to import that code. I've never used PythonCard so I can't help
further, but I suggest looking at the documentation and examples
supplied. And perhaps waiting for someone with experience with
PythonCard to answer.
Gary Herron
P.S. It is usually a waste of time to tell us that something fails
without telling us *how* it fails. (Cut and paste the error message
always, and the traceback usually.) If you don't, you will usually get
a request to supply that information, and then have wast3ed the time for
one full round of message to the group. Even in this case, I'm only
guessing how it failed for you.
>I've checked and rechecked to make sure that the spellings are proper
and that the tools, the codeEditor directory, and codeEditor.py, and
the class CodeEditor all exists and yet idle keep complaining that it
can't import from PythonCard.tool s.
>What's going on? (Running Python2.5 under WinXP).
>Regards,
--
http://mail.python.org/mailman/listinfo/python-list
Thank you very much. I didn't know about the __init__.py
requirement. Appreciate it.

Actually I should have added that there ways to import such things, and
PythonCard must be using some such method itself. You can manipulate
the sys.path variable, or directly call the import mechanism using the
builtin __import__, or use a suppled "imp" module. However, you
should not have to do any such thing to use PythonCard. It should do
them in for you.
I tried to call __import__ directly and didn't work neither.

What I was doing is to invoke their codeEditor directly into my
application. Their codeEditor was designed to be a stand alone
application and that's why it didn't include the file you cited.

I never quite understood what they were saying about __init__.py but
now I understand. Learn something new every day.

Thanks again.
Jun 27 '08 #9

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

Similar topics

10
4515
by: Gianni | last post by:
When I compile my class I get this strange message. The message is strange as that class is not abstract !!!! Please help! Gianni
2
8654
by: Dennis | last post by:
The setup: Windows XP Pro Python 2.3 GTK+ 2.2.1.2 and pyGTK 1.99.17 for Python 2.3 from http://www.pcpm.ucl.ac.be/~gustin/win32_ports/ I've downloaded and installed per the instructions the pyGTK and GTK+ for win32 from the above locations. Folowing the instructions, I import pygtk first, run pygtk.require('2.0') second and then import
12
2757
by: Richard Hanson | last post by:
Over the last few days, I reinstalled Win2kSP2 to a spare harddrive I had just swapped into my Fujitsu LifeBook P1120 (long story <wink>). Subsequently, I DL'ed the newest Python alpha (2.4a2), and when trying to install it, I immediately got this error: This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
7
20552
by: Ron Adam | last post by:
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win 32 _Ron
3
2003
by: kwatch | last post by:
What is the condition of module name which is available in 'from .. import ..' statement ? ---------------------------------------- import os print os.path # <module 'posixpath' from '/usr/local/ lib/python2.5/posixpath.pyc'> from posixpath import sep # (no errors) from os.path import sep # (no errors, wow!) path = os.path
1
3161
by: bruce628 | last post by:
I want to use SWT tab compnent and make it be multiline,but I fail.please see the class TabFolderExample. Can aneone help me? import java.awt.BorderLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JDialog;
5
1729
by: W. Watson | last post by:
Is there a single source that explains these statements? ------------------------------ from Tkinter import * from Numeric import * import Image import ImageChops import ImageTk import time import binascii import tkMessageBox
3
6112
by: notnorwegian | last post by:
import Tkinter from Tkinter import * i have a program where if i comment out either of those import- statements i get an error. i thought they meant the same thing and from was supposed to be just to imort just a specific function and the * imports everything in the module. but aparently the above statements have diffrent meaning and i cant
8
2672
lifeisgreat20009
by: lifeisgreat20009 | last post by:
What might be the possible cause ? I have created a website using struts framework, jsp In my transaction page the money is not getting transferred.. When I hit the submit button in my Transaction.jsp page , no transaction happens .. Only the url changes from http://localhost:8080/bankfinalproject/jsp/transaction.jsp to this
1
3673
by: hdivecha | last post by:
i have make a jtree program in java and if the node is circle then the circle can be shown in frame and i have to resize it with slider . plz help me i have done the tree program bt how to get selected node means its circle of any thing else i can't get it .. someone plz help me i have attached my program with this import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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...
1
6185
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
4179
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...
1
2762
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
2
1747
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.