Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import not working properly
#5
ok...for example foo.py
class Foo():
   def __init__(self):
       print('foo')
When I import it into bar.py with import foo
I get a NameError that my class is undefined

[inline]
me@me-ubuntu:~/Documents/py/cs$ python3 bar0.py
Traceback (most recent call last):
File "bar0.py", line 5, in <module>
x=Foo()
NameError: name 'Foo' is not defined
me@me-ubuntu:~/Documents/py/cs$
[/inline]

when I use from foo import *
I get the expected print out of 'foo'

I find this very odd...
Reply


Messages In This Thread
import not working properly - by mepyyeti - Jan-18-2018, 05:24 AM
RE: import not working properly - by metulburr - Jan-18-2018, 05:30 AM
RE: import not working properly - by mepyyeti - Jan-18-2018, 06:36 AM
RE: import not working properly - by metulburr - Jan-18-2018, 06:39 AM
RE: import not working properly - by mepyyeti - Jan-18-2018, 06:57 AM
RE: import not working properly - by metulburr - Jan-18-2018, 07:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel isnt working properly after python function is started IchNar 2 330 May-01-2024, 06:43 PM
Last Post: IchNar
  File Handling not working properly TheLummen 8 854 Feb-17-2024, 07:47 PM
Last Post: TheLummen
  Pathlib import not working chriswrcg 9 3,834 May-29-2022, 07:37 PM
Last Post: snippsat
  fpdf orientation not working properly KatMac 1 3,389 May-02-2021, 10:47 AM
Last Post: Pedroski55
Lightbulb Jupyter is not working properly brunolelli 3 3,033 Apr-23-2021, 03:22 AM
Last Post: Larz60+
  Properly import from sub/parent folders? oclmedyb 2 2,096 Dec-14-2020, 12:22 AM
Last Post: snippsat
  How to keep a loop containing a web import working in python executable? coder1384 3 2,914 Feb-22-2020, 06:49 PM
Last Post: snippsat
  file.write not working properly mnh001 11 4,565 Nov-09-2019, 10:20 PM
Last Post: mnh001
  hatching not working properly with matplotlib Staph 3 3,082 Jul-28-2019, 07:17 AM
Last Post: ThomasL
  import logging not working segerhult 3 13,294 Feb-07-2019, 05:31 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020