Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7820753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:25:08+00:00 2026-06-02T07:25:08+00:00

from os import listdir modo= [name.split(.py)[0] for name in listdir(scripts) if name.endswith(.py)] modules =

  • 0
from os import listdir
modo= [name.split(".py")[0] for name in listdir("scripts") if name.endswith(".py")]
modules = {}
for modu in modo:
    modules[modu] = __import__(modu)
test_samp.function("test") 

Hello!
If, say “test_samp.py” exists in the scripts directory, why does
this not allow me to run test_samp.function(“test”)?
It returns:

Unhandled exception in thread started by <function function at 0x8e39204>
Traceback (most recent call last):
  File "test_this.py", line 6, in function
    test_samp.function("test")  
NameError: global name 'test_samp' is not defined
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:25:09+00:00Added an answer on June 2, 2026 at 7:25 am

    Your are not defining test_samp you are defining modules['test_samp']. Plus if it’s in scripts you need to import scripts.test_samp

    in yor case use a package.Add an empty (or not) __init__.py (with 2 underscores). and use import scripts. Access your function with scripts.test_samp.function("test"). And you could use reload(scripts) to reload all of the package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After changing the import as a from-import i'm running into this error: from datetime
i need to create a object Image from import javax.microedition.lcdui.Image; using a file .png
OK, so I know that from-import is exactly the same as import , except
from Tkinter import * app = Tk() text_field = Entry(app) text_field.pack() app.mainloop() I want
Models from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, ForeignKey from sqlalchemy import Integer
Something like this: from Tkinter import * root = Tk() but = Button(root, text
Say I write this: from subprocessing import Popen, STDOUT, PIPE p = Popen([myproc], stderr=STDOUT,
I created a subclass from UIView #import <UIKit/UIKit.h> @interface MeeSelectDropDownView : UIView { UILabel
for this code: import sys import gevent from gevent import monkey monkey.patch_all() import requests
Following is my code: import zipfile from zipfile import ZipFile def extract(zipFilename, dm_extraction_dir) :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.