jrbrearley
(John Brearley)
January 14, 2021, 8:37pm
1
The create topic editor allows drag/drop of graphics images. Why not allow drag/drop of .py & .txt script files?
Having user copy/paste text, then manually indent each line by 4 spaces is rather annoying.
You don’t have to manually indent each line by hand.
If you are using the fancy editor, you can use the “format as code”
button which I believe looks like this: </>
Otherwise you can begin and end your code blocks with three backticks,
like this:
```
code goes here
```
Note that the backticks have to be on their own lines.
SiqingYu
(Ssuching Yu)
January 15, 2021, 6:40am
3
I’m a bit surprised that the Markdown code block syntax is unknown to lots of Discourse users.
jeanas
(Jean Abou Samra)
January 15, 2021, 3:30pm
4
For a reason unknown to me, indentation is mangled in many posts even inside the code blocks, like in the following posts:
The following is the code. Because the input file is kindof big, I use pool.apply_async function from python multiprocessing module. I was just wondering, does this make sense?
if name == ‘main’:
pool = mp.Pool(mp.cpu_count()-1)
print(“cpu counts:” + str(mp.cpu_count()))
with open("./test.txt") as f:
nextLineByte = f.tell()
for line in iter(f.readline, ‘’):
pool.apply_async(processWrapper, args=(nextLineByte,), callback=logResult)
nextLineByte = f.tell()
pool.close()
pool.join()
def …
The forum says “(Attachment myrobot_sv1.py is missing)”. Maybe try to post inline? Use triple backticks like this:
```
Code goes here.
```
Hi. I have an input .txt file of size 2.7GB and a simple piece of code to process it as the following. Here, my goal is to create two different files based on this input file, with names inputSeqs.fasta and inputMeta.tsv. The thing is, it takes a rather long time to run.
with open("./ena_embl-covid19_20210107-0806.txt") as f:
line = f.readline()
while line != “”:
if line[:2] == “ID”:
strainNameIDLst.append(line[2:].strip()[:8])
elif line[:2] == “DT”:
samplingDateLst.append(line[2:].stri…
There are also cases where only part of the code is included in the block, or only part of the block is in fixed-width font, or a nested quote level appears for each level of indentation, e.g.:
I’m trying to create a program to help people with their time management, but I can’t figure out how to get it into tkinter.
I have 4 inputs that are put into if statements that determine if someone spends their time well or not.
# used to identify specific information given by the User
work = int(input('How many hours do you spend working each day?: '))
sleep = int(input('How many hours do you spend sleeping each day?: '))
outside = int(input('How many hours do you spend outside each day?…
Hi, the following is the code.
import time
from multiprocessing import Process
class Worker(Process):
def run(self):
print(f'In {self.name}')
time.sleep(2)
def main():
worker = Worker()
worker.start()
worker2 = Worker()
worker2.start()
worker.join()
worker2.join()
if name == ‘main’:
main()
with the following output:
In Worker-1
In Worker-2
[Finished in 2.109s]
I was confused. My question is, where do the names “Workr-1” and “Worker-2” come from? Many thanks.
I have not been able to work out how to convert a string to afloat. I’ve tried a.isdecimal() , a.isdigit() and a.isnumeric().
Hi, I need to know how to remove values to a python array
I have no idea why all this is happening. I’ve just activated mailing list mode for my account and will be trying to reply by email to something with a few tests to see if it is related to email (or maybe someone knows?).
At any rate, when a solution is found, it might be worth adding on the pinned post to tell users not to send screenshots but complete code examples, and how to format it correctly.
jrbrearley
(John Brearley)
January 15, 2021, 8:29pm
5
Thanks Steve. It looks like the backticks may not be documented anywhere in the mouse hover help. The </> icon inserts instructions:
indent preformatted text by 4 spaces
Other minor note: github.com forums allow drag/drop of graphics & .txt files.
So for .py, copy rename as .txt, then drop into post editor.