Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing a module
#9
(Nov-05-2016, 06:14 PM)Barrowman Wrote: I think your code should be more like this:
#!/usr/bin/env python

def main():
    inp = raw_input("Enter a value between 0 and 1: ")
    x = float(inp)
    for i in range(10):
        x = 3.9 * x * (1 - x )
        print x
        
main() 
Could you tell me how you put the second "main()" so it's in line with "def main():" ? I think that's the solution. When I press <Enter> after I type "print(x)", it lowers the cursor directly beneath it. The <Tab> doesn't help me either.

By the way, the code isn't mine; it's from Zelle's book.

(Nov-05-2016, 06:18 PM)nilamo Wrote: First, start by removing that terrible function "eval".  It's dripping with pure "evil".  Then get rid of the call to main() within main(), there's no reason for nonsense like that.

Does it at least run?  What's the filename, and what's the script you're using to import it?

Yes, it runs. The filename is "chaos.py". I import it with "import", thought Zelle mentions other methods, and they don't work either.
Reply


Messages In This Thread
Importing a module - by SrirachaSauceLover - Nov-05-2016, 03:20 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 03:37 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 03:53 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 03:59 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 04:30 PM
RE: Importing a module - by Larz60+ - Nov-05-2016, 04:29 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 06:14 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 06:51 PM
RE: Importing a module - by nilamo - Nov-05-2016, 06:18 PM
RE: Importing a module - by metulburr - Nov-05-2016, 07:13 PM
RE: Importing a module - by snippsat - Nov-05-2016, 07:49 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 08:39 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 09:17 PM
RE: Importing a module - by Barrowman - Nov-06-2016, 10:20 AM
RE: Importing a module - by snippsat - Nov-05-2016, 09:22 PM
RE: Importing a module - by Larz60+ - Nov-05-2016, 10:20 PM
RE: Importing a module - by SrirachaSauceLover - Nov-06-2016, 08:10 AM
RE: Importing a module - by nilamo - Nov-07-2016, 04:21 PM
RE: Importing a module - by metulburr - Nov-06-2016, 08:15 AM
RE: Importing a module - by SrirachaSauceLover - Nov-08-2016, 11:23 AM
RE: Importing a module - by snippsat - Nov-08-2016, 03:05 PM
RE: Importing a module - by ngltm - Jun-13-2018, 02:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  importing variables from module 8376459 1 392 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  no module named 'docx' when importing docx MaartenRo 1 1,326 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  My code displays too much output when importing class from a module lil_e 4 1,329 Oct-22-2022, 12:56 AM
Last Post: Larz60+
  Importing module in jupyter Noteboook ajitnayak1987 0 1,817 Jun-04-2021, 12:26 PM
Last Post: ajitnayak1987
  ERROR: importing desired module mbgamer28 0 1,751 Apr-05-2021, 07:46 PM
Last Post: mbgamer28
  importing module - not working jdhamblett 3 3,173 Jun-22-2020, 07:33 PM
Last Post: jdhamblett
  importing same python library in multiple custom module escape_freedom13 6 4,029 May-10-2020, 07:01 PM
Last Post: escape_freedom13
  Importing module from a package results in import error goghvv 2 2,523 Mar-27-2020, 07:13 PM
Last Post: goghvv
  Please help: problem installing/importing langdetect module in Jupyter Notebook ledgreve 3 7,572 Dec-30-2019, 08:17 AM
Last Post: LeanbridgeTech
  Problem with importing and using collections module pythomdummy 3 6,019 Nov-14-2019, 08:48 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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