Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so yes - package is in python's directory (probably somewhere in /usr , yes i use linux). file (python script) where variable'd be setted will be xyz.py in home directory (probably ~/ ). how can i make it so package will get variable contents and name to pass for inside functions?

What I have tried:

package (example, take its name as xyz.py in environment variable)

global x
file = open(x , "r")
extension = file.suffix
if extension == '.textmd':

    Bold = re.search('<bold>(.*)<bold;>', file).group(1)
    Italic = re.search('<italic>(.*)<italic;>', file).group(1)
    Underline = re.search('<underline>(.*)<underline;>', file).group(1)
    Crossout = re.search('<crossout>(.*)<crossout;>', file).group(1)

    # ... blah blah blah the rest of code

else:
    raise Error("invalid file !!!")


file im working in :

import xyz

global x
x = "testing.file"
print(Italic)


yes i know this example contains some other things but generally variables cant match.
Posted
Updated 18-Feb-22 9:07am
v2

1 solution

Your code samples above are not clear.

Basically, you can't pass parameters to a package. A package is just a wrapper around a set of functions, which you can call after the package has been imported. You can pass parameter values to the functions, but they must be the correct type as the function requires. The documentation for each function explains in details.
 
Share this answer
 
Comments
hacknorris-dev 18-Feb-22 14:10pm    
so if i make everything a function i can make user to pass link or path to a file? will then variables work in same state as now or also to modify?
hacknorris-dev 18-Feb-22 15:08pm    
anyways - probly edited so you'll understand it more...
Richard MacCutchan 19-Feb-22 4:26am    
Sorry, no. I still have no idea what your actual question is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900