473,396 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Importing User-defined Modules

I need to import modules with user-defined file extensions that differ from '.py', and also (if possible) redirect the bytecode
output of the file to a file of a user-defined extension.
I've already read PEP 302 (http://www.python.org/peps/pep-0302.html), but I didn't fully understand it. Would someone [who
understands it] please be able to give me a synopsis of it, along with a few explanatory examples, or some other alternatives, if
any?
Jul 24 '05 #1
3 2151
Am Sun, 24 Jul 2005 13:12:04 -0400 schrieb Walter Brunswick:
I need to import modules with user-defined file extensions that differ from '.py', and also (if possible) redirect the bytecode
output of the file to a file of a user-defined extension.
I've already read PEP 302 (http://www.python.org/peps/pep-0302.html), but I didn't fully understand it. Would someone [who
understands it] please be able to give me a synopsis of it, along with a few explanatory examples, or some other alternatives, if
any?


You could do it like this:

Copy the file to directory which is in sys.path. Give the file
the extension ".py". Import it with __import__
(http://docs.python.org/lib/built-in-funcs.html#l2h-6)

Copy the bytecode somewhere.

HTH,
Thomas

--
Thomas Güttler, http://www.thomas-guettler.de/
Jul 25 '05 #2
Walter Brunswick <walterbrunsw...@sympatico.ca> wrote:
I need to import modules with user-defined file extensions
that differ from '.py', and also (if possible) redirect the
bytecode output of the file to a file of a user-defined
extension.


You shouldn't really need a PEP for that; you can take control of the
compile and import processes manually. See the py_compile and imp
modules.

--
Andrew Clover
mailto:an*@doxdesk.com
http://www.doxdesk.com/

Jul 25 '05 #3
Thomas Guettler, your solution was very impractical besides being ignorant of my problem. Thanks for trying nonetheless.

Andrew Clover, that is exactly what I was looking for. A few examples would have been nice, but I think I can manage from here.
Thanks you.
Jul 26 '05 #4

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

Similar topics

0
by: Michael | last post by:
I apologize if this might be a beginner question, which is clear to the experts. But I could not find a clear answer yet. I have extracted a schema / user with the exp utility. I want to import...
4
by: Little PussyCat | last post by:
Hello, I nee to write something that will transfer excel data into an SQL Server table. I have for another database application I wrote have it importing Excel spreadsheet data using cell by...
2
by: Mr. Bungle | last post by:
When importing excel from access I am fully aware that one can import directly into a table. Can you get as specific via code or something to import data from an excel sheet to a FORM (Not Table)...
3
by: Mark | last post by:
All, As you can see below, I have had problems with inquisitive souls looking at data they shouldn't be. I though disabling the ability to create new databases using my workgroup would stop this...
2
by: Sara | last post by:
Hi - I've been reading the posts for a solution to my query, and realize that I should ask an "approch" question as well. We receive our production data from a third party, so my uers import...
5
by: dixie | last post by:
If I sent a user an empty database container - dB with no tables and I needed them to import their tables into it and one of their tables was a hidden table with the prefix Usys, is there any way...
4
by: Roy | last post by:
Could someone point me in the right direction here? The current method of importing new data into our db goes something like this: 1.) txt files received via email 2.) employees clean data and...
2
by: dawg1998 | last post by:
I am setting up a new web application with ASP.NET 2.0 and I was wanting to utilize the 2.0 Membership and Profiles system. However, I am having a lot of trouble importing a table of user info into...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
2
by: lrheeza | last post by:
Hello everyone, I am a newbie at MS Access and I need help!!! I am importing an excel file using Import functionality in MS Access, all the fields are required but there are instances in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.