how can i import files from current directory ?

45 views
Skip to first unread message

keshav bhide

unread,
Apr 16, 2015, 4:01:49 PM4/16/15
to rapyd...@googlegroups.com
If I would like to import some file in the current directory how to go about doing that. For example

main.pyj  has-> 
import ui
def main():
        ui.showHeader();

and ui.pyj is a file in the current directory.

Do I need to place ui.py in /usr/local/lib/node_modules/rapydscript/src/lib or can i make it work

thanks



Alexander Tsepkov

unread,
Apr 17, 2015, 9:35:06 AM4/17/15
to keshav bhide, RapydScript
The import mechanism currently assumes you import individual files. What you mentioned in original post should work fine from the same directory, in fact tests/import.pyj tests just that.

Alexander Tsepkov

unread,
Apr 18, 2015, 1:04:23 PM4/18/15
to keshav bhide, RapydScript
You can use --pythonic-imports flag instead, I personally prefer explicit module tag because sometimes I want to separate logic into separate files without separating them into separate modules. To me, file represents a boundary between logic, but not necessary a boundary between the group of similar logic.

On Sat, Apr 18, 2015 at 10:55 AM, keshav bhide <keshav.b...@gmail.com> wrote:
Thanks I didnt know I hade wrap my code inside a module tag. 

Alexander Tsepkov

unread,
Apr 18, 2015, 4:12:09 PM4/18/15
to keshav bhide, RapydScript

On Sat, Apr 18, 2015 at 4:05 PM, keshav bhide <keshav.b...@gmail.com> wrote:
Hi this new flag is not working for me. 

Alexander Tsepkov

unread,
Apr 18, 2015, 4:26:35 PM4/18/15
to keshav bhide, RapydScript
This was fixed in a recent patch: https://github.com/atsepkov/RapydScript/commit/4d2910feecd273d5c07b6ca87d70a2028a5f7aeb

Unfortunately, I forgot to rebuild the JavaScript files after applying the fix from the developer. If you use the github version, you can run ./build command from the main directory and the problem will fix itself, the npm version didn't have this fix pushed to it.

On Sat, Apr 18, 2015 at 4:15 PM, keshav bhide <keshav.b...@gmail.com> wrote:
Yeah I tried that, but it throws a type error. this is what I get 

usr/local/lib/node_modules/rapydscript/lib/output.js:1030
                    self.variables.forEach(function(arg, i) {
                                  ^
TypeError: Cannot read property 'forEach' of undefined
    at /usr/local/lib/node_modules/rapydscript/lib/output.js:1030:35
    at /usr/local/lib/node_modules/rapydscript/lib/output.js:221:19
    at OutputStream.with_indent (/usr/local/lib/node_modules/rapydscript/lib/output.js:198:16)
    at Object.with_block (/usr/local/lib/node_modules/rapydscript/lib/output.js:220:9)
    at /usr/local/lib/node_modules/rapydscript/lib/output.js:1029:24
    at /usr/local/lib/node_modules/rapydscript/lib/output.js:221:19
    at OutputStream.with_indent (/usr/local/lib/node_modules/rapydscript/lib/output.js:198:16)
    at Object.with_block (/usr/local/lib/node_modules/rapydscript/lib/output.js:220:9)
    at /usr/local/lib/node_modules/rapydscript/lib/output.js:1024:20
    at Object.with_parens (/usr/local/lib/node_modules/rapydscript/lib/output.js:230:15)
Reply all
Reply to author
Forward
0 new messages