hello,
my program has become a bit large,
and now I want to split the files over several subdirectories.
So in the example shown below, I just moved the files f1.py and f2.py to
a deeper subdirectory.
basedirectory\
mainfile.py
file1.py
file2.py
subdir1\
__init__.py
f1.py
f2.py
Now I don't want (even can't) change my program,
to change imports from
from f1 import something
into
from subdir1.f1 import something
simply because f1.py and f2.py are python files dropped by users
and I do not know on forehand what will be dropped.
I looked into the description of __init__.py,
in the hope I could make f1.py and f2.py available as if they were in
the basedirectory,
but i couldn't find a way.
Is there a way to make f1.py and f2.py available as if they were located
in the base directory,
without knowing their names (so in general all py-files in the subdir1) ??
thanks,
Stef Mientki 4 2182
stef mientki wrote:
hello,
my program has become a bit large,
and now I want to split the files over several subdirectories.
So in the example shown below, I just moved the files f1.py and f2.py to
a deeper subdirectory.
basedirectory\
mainfile.py
file1.py
file2.py
subdir1\
__init__.py
f1.py
f2.py
Now I don't want (even can't) change my program,
to change imports from
from f1 import something
into
from subdir1.f1 import something
simply because f1.py and f2.py are python files dropped by users
and I do not know on forehand what will be dropped.
I looked into the description of __init__.py,
in the hope I could make f1.py and f2.py available as if they were in
the basedirectory,
but i couldn't find a way.
Is there a way to make f1.py and f2.py available as if they were located
in the base directory,
without knowing their names (so in general all py-files in the subdir1) ??
thanks,
Stef Mientki
Put basedirectory\s ubdir in the PYTHONPATH environment variable or
os.path.append( r'basedirectory \subdir1')
in the body of your program.
-Larry
Larry Bates wrote:
stef mientki wrote:
>hello,
my program has become a bit large, and now I want to split the files over several subdirectories. So in the example shown below, I just moved the files f1.py and f2.py to a deeper subdirectory.
basedirector y\ mainfile.py file1.py file2.py subdir1\ __init__.py f1.py f2.py
Now I don't want (even can't) change my program, to change imports from from f1 import something into from subdir1.f1 import something simply because f1.py and f2.py are python files dropped by users and I do not know on forehand what will be dropped.
I looked into the description of __init__.py, in the hope I could make f1.py and f2.py available as if they were in the basedirectory, but i couldn't find a way.
Is there a way to make f1.py and f2.py available as if they were located in the base directory, without knowing their names (so in general all py-files in the subdir1) ??
thanks, Stef Mientki
Put basedirectory\s ubdir in the PYTHONPATH environment variable or
os.path.append( r'basedirectory \subdir1')
in the body of your program.
thanks Larry,
after a bit of fiddling, I think "os." must be "sys."
and basedirectory shouldn't be in.
so it becomes
sys.path.append ( r'subdir1' )
But what the .. is that "r" in front of the appended path ?
cheers,
Stef Mientki
-Larry
r" indicates a 'regular expression' string, normally
called a raw string. It means that \ characters are
treated using the regex syntax rather than the c syntax.
In the regex syntax, \ characters are escape characters
only at the end of the string, which allows you to
easily use Windows directory notation as long as you
don't need to end a path with a \
sys.path.append ("c:\\code\\new code")
sys.path.append (r"c:\code\newc ode")
The os.path module contains additional path handling methods.
[david]
stef mientki wrote:
Larry Bates wrote:
>stef mientki wrote:
>>hello,
my program has become a bit large, and now I want to split the files over several subdirectories. So in the example shown below, I just moved the files f1.py and f2.py to a deeper subdirectory.
basedirectory \ mainfile.py file1.py file2.py subdir1\ __init__.py f1.py f2.py
Now I don't want (even can't) change my program, to change imports from from f1 import something into from subdir1.f1 import something simply because f1.py and f2.py are python files dropped by users and I do not know on forehand what will be dropped.
I looked into the description of __init__.py, in the hope I could make f1.py and f2.py available as if they were in the basedirectory, but i couldn't find a way.
Is there a way to make f1.py and f2.py available as if they were located in the base directory, without knowing their names (so in general all py-files in the subdir1) ??
thanks, Stef Mientki
Put basedirectory\s ubdir in the PYTHONPATH environment variable or
os.path.append (r'basedirector y\subdir1')
in the body of your program.
thanks Larry,
after a bit of fiddling, I think "os." must be "sys."
and basedirectory shouldn't be in.
so it becomes
sys.path.append ( r'subdir1' )
But what the .. is that "r" in front of the appended path ?
cheers,
Stef Mientki
>-Larry
[david] wrote:
r" indicates a 'regular expression' string, normally
called a raw string. It means that \ characters are
treated using the regex syntax rather than the c syntax.
This is an incredibly creative answer , if not fastidiously
correct. Raw strings simply disable the special effects of
backslash (\) within the string (except that it cannot be
the final character of a quoted string even if it a raw string
for technical lexer (tokenizer) simplicity reasons). The regex
syntax is used on the resulting string constant if (and only if)
the string is passed to the regular expression functions as a
regex pattern parameter.
-Scott David Daniels Sc***********@A cm.Org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Josef Sachs |
last post by:
Is Andrew Kuchling's regex-to-re HOWTO available anywhere?
I've found the following (dead) links on various Web pages:
http://py-howto.sourceforge.net/regex-to-re/regex-to-re.html
http://starship.skyport.net/crew/amk/regex/regex-to-re.html
http://www.python.org/doc/howto/regex-to-re/
http://www.amk.ca/python/howto/regex-to-re/
Thanks in advance.
|
by: DraguVaso |
last post by:
Hi,
In my application I receive a Byte Stream (Dim bytFile() As Byte) which
contains a jpeg-picture, which I want to display in a picturebox.
I want to display it directly from the bytfile() without first writing it to
a file and than reading it. Does anybody knows how to do this?
|
by: Vlady |
last post by:
Hello. I recently built an ASP.NET "financial" application. I got to the
point where I have a HTML template (a contract) which needs to be filled with
various data from the database. I put a "generate contract" button on my ASPX
page, but I totally lack ideas of how to put the data in the correct places
in the html file. I was recommended (actually "do like this" from my boss) to
enclose the variable name like this {variable_name} in the...
|
by: Rich |
last post by:
Greetings,
Just starting out with .net. I have a vb.net app where I
connect to an Access mdb. I use a connection component
from the tool box (conn1), a data adapter component from
the toolbox (da1) and create a typed dataset (ds1) and
populate a grid on a form (grd1). This all works fine and
I can see data from the Access mdb in the grid. But now I
want to add a record to the mdb.
|
by: Peter |
last post by:
Hi, how can I do this (I don't really want to do this but what I do
want the same function name but have different return types and the
compiler keeps saying "public function .... they differ only by return
types")?
Public Function test() As Integer
Return 1
End Function
Public Function test() As Single
| |
by: Frank |
last post by:
Hi,
I have an vb6 app that I want to port to .net. I tried the wizard but it
doesn't convert it all. In my app I have a form with a datagrid on it. If a
user doubleclicks on a row a form is shown (modal) with details (and some
more info) about the selected row. Under vb6 it's quite easy to select
another row, through code, in de datagrid without closing the detailform. How
can this be done in .net?
Thanks,
Frank
|
by: Brian Henry |
last post by:
Here is another virtual mode example for the .NET 2.0 framework while
working with the list view. Since you can not access the items collection of
the list view you need to do sorting another way... here is my code on how I
did it to help anyone starting out get an idea of how to use virtual mode in
..NET 2.0
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
|
by: shonend |
last post by:
I am trying to extract the pattern like this :
"SUB: some text LOT: one-word"
Described, "SUB" and "LOT" are key words; I want those words,
everything in between and one word following the "LOT:". Source text
may contain multiple "SUB: ... LOT:" blocks.
For example this is my source text:
|
by: AMDRIT |
last post by:
Hello Every,
Today I am exploring async operations. In my scenario, I have a windows
form with a webbrowser control. The exercise reads a starting webpage and
populates a Queue with additional urls. From there I process each URL in
queue until the queue is empty. The problems that I am encountering are:
1. The browser appears to fire the DocumentCompleted and the Navigated
event more than once for the same url.
2. I often...
|
by: fnoppie |
last post by:
Hi,
I am near to desperation as I have a million things to get a solution
for my problem. I have to post a multipart message to a url that
consists of a xml file and an binary file (pdf). Seperately the
posting words fine but when I want to create one multipart message
with both then things go wrong.
The binary file is converted and of datatype byte()
The xml file is just a string.
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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();...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |