#๐Ÿ”’ Circular import

22 messages ยท Page 1 of 1 (latest)

green hemlockBOT
#

@tribal phoenix

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tribal phoenix
#

help me with this circular import plz

rugged ridge
#

Circular imports are, by definition, waiting on other scripts to finish importing by other scripts, etc.

#

You just need to rearrange your imports so that they don't try to import each other

#

Another way would be to just put similar scripts into 1 script. So there's no circular import at all

tribal phoenix
#

i try to put the import line in the function but when i do the function get repeated

rugged ridge
#

I don't understand what that looks like

#

Can you paste the code here or in a pastebin service please?

green hemlockBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

tribal phoenix
#

def display_outcomes(outcomes):
"""
Displays the calculated outcomes in a clear and formatted way.
"""
# Printing outcomes to the console

print(f'''

data file selected is {outcomes[14]}
*************************** ''')
output_format = f'''
The total number of vehicles recorded for this date is {outcomes[0]}
The total number of trucks recorded for this date is {outcomes[1]}
The total number of electric vehicles for this date is {outcomes[2]}
The total number of two-wheeled vehicles for this date is {outcomes[3]}
The total number of Busses leaving Elm Avenue/Rabbit Road heading North is {outcomes[4]}
The total number of Vehicles through both junctions not turning left or right is {outcomes[5]}
The percentage of total vehicles recorded that are trucks for this date is {outcomes[6]}%
the average number of Bikes per hour for this date is {outcomes[7]}

The total number of Vehicles recorded as over the speed limit for this date is {outcomes[8]}
The total number of vehicles recorded through Elm Avenue/Rabbit Road junction is {outcomes[9]}
The total number of vehicles recorded through Hanley Highway/Westway junction is {outcomes[10]}
{outcomes[11]}% of vehicles recorded through Elm Avenue/Rabbit Road are scooters.

The highest number of vehicles in an hour on Hanley Highway/Westway is {outcomes[12][0]}
The most vehicles through Hanley Highway/Westway were recorded between {outcomes[12][1]}:00 and {(outcomes[12][1]) + 1}:00
The number of hours of rain for this date is {outcomes[13]} '''
print(output_format) # i tried to import the python file here
h_module = HistogramApp(outcomes[15], outcomes[14][12:20])
h_module.run()
save_results_to_file(outcomes, output_format)

green hemlockBOT
#

Hey @tribal phoenix!

It looks like you are trying to paste code into this channel.

You seem to be using the wrong symbols to indicate where the code block should start. The correct symbols would be ```, not '''.

Here is an example of how it should look:
```
Hello, world!
```

This will result in the following:

Hello, world!```
You can **edit your original message** to correct your code block.
tribal phoenix
rugged ridge
tribal phoenix
rugged ridge
tribal phoenix
#

well lecturer told he need that task E in the other python file

rugged ridge
#

ok then

#

You have only one choice

#

Remove the imports in the other file

tribal phoenix
#

ok thank you ill try

green hemlockBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.