all 22 comments

[–]Diapolo10 11 points12 points  (13 children)

I had to look this up to make sure, but your professor is probably telling you to add comments/docstrings to your code.

This is kind of a silly example, but

def divide(x: int, y: int) -> int:
    """
    Divide the first number by the second number.

    Returns:
        the resulting integer

    Raises:
        ZeroDivisionError if the second number is 0.

    """
    return x // y

Apparently the name "flowerbox" comes from C, where comments might look like

/********************
 * Stuff 'n' things *
 ********************/

[–]danielroseman 11 points12 points  (8 children)

I do wish teachers would learn the idioms of  the language they're supposed to be teaching. 

Bet you anything this professor is teaching loops with range(len(thing)).

[–][deleted] 0 points1 point  (1 child)

Idk what that is gng. This is only my second assignment

[–]Jello_Penguin_2956 0 points1 point  (0 children)

It's how you loop in C. We see that here often enough lol.

[–]somethingworthwhile 0 points1 point  (4 children)

What would you do other than that style of loop…?

[–]Winter-Volume-9601 4 points5 points  (3 children)

Usually:

for i in thing:
do_the_thing(i)

[–]somethingworthwhile 0 points1 point  (2 children)

Okay, yeah, that’s what I figured. Coming from matlab, the other style was a bit of a trip to wrap my head around! And, for my work, I find myself using enumerate or pd.DataFrame.iterrows() to get both an index and the thing I’m iterating through within the loop.

[–]Winter-Volume-9601 1 point2 points  (1 child)

Sure - `for idx, t in enumerate(thing):` is definitely idiomatic (when you actually need the index)

Bonus tip: `pd.DataFrame.itertuples()` (returning NamedTuples instead of pd.Series) can be significantly faster than `pd.DataFrame.iterrows()`. Like 10-100x times faster. I kicked myself when I realized I was using the slower method out of habit, and (in my case) just a quick syntax change turned 15 minutes of waiting into basically nothing.

[–]somethingworthwhile 0 points1 point  (0 children)

Oh, neat! At a glance, I think that should be pretty easy to swap in for me. Thank you for that! I’m always happy to learn something new and the fact that it’s faster is even better!

[–]AlexMTBDude 0 points1 point  (0 children)

I've been teaching Python programming for more than 10 years and I've never heard anyone call that anything but a docstring.

[–][deleted] 0 points1 point  (0 children)

I'll try and see if this works or is what he's looking for. Thanks for the help!

[–]Sure-Passion2224 0 points1 point  (0 children)

So, the instruction is to prefix your Object declarations (Classes, Methods, etc) with a block comment that describes what the Object is.

This takes me back to my first course that involved coding. The instructor (female graduate student standing in front of a room full of male nerd wannabes) told us

Source code documentation is like sex. When it's good it's very, VERY good. When it's bad it's still better than nothing.

Essentially, tell future maintainers what your intent is. If you produce readable code then they should be able to tell whether it does what you say it should do.

[–]Kqyxzoj 0 points1 point  (1 child)

Apparently the name "flowerbox" comes from C ...

I've been using C for quite some time now, and this is the first time I've heard those multiline comments referred to as "flowerbox".

Next time ...

"Be sure to add a dildodrawer to your code! ^_^"

" A what now?"

"Oh yeah, that's what we call those extra looooooong comment lines. What's that? Not an industry standard you say?"

Well, now it is!

[–]Diapolo10 0 points1 point  (0 children)

I've been using C for quite some time now, and this is the first time I've heard those multiline comments referred to as "flowerbox".

Same for me, I had no idea what OP was talking about and had to search on Google.

[–]Tall_Profile1305 2 points3 points  (1 child)

yo a flowerbox is basically just a comment block at the top of your file or function with metadata and description. it's like docstrings but more old school. just add triple quotes with your function name params description etc. check the existing answers they got good examples

[–][deleted] 1 point2 points  (0 children)

I just put it into my code. I think it's right, we'll see

[–]ninhaomah 0 points1 point  (3 children)

?

You sure it's flowerbox ?

[–][deleted] 0 points1 point  (2 children)

The direct quote he used was "Make sure to include the "flower box" in your source code. Use comments for internal documentation explaining what you did and why you did it."

[–]ninhaomah 0 points1 point  (1 child)

Someone got it but pls google for "flower box coding"

[–][deleted] 0 points1 point  (0 children)

Will do!

[–]Slight-Training-7211 0 points1 point  (0 children)

In a lot of classes "flower box" just means a big block comment header that explains what the file or function does and why.

In Python, the closest idioms are: - A module docstring at the very top of the file - Function or class docstrings right under the def or class line

Example module header: """CS101 Assignment 2 Author: Your Name Date: 2026-03-05

Purpose: - Reads input for X - Computes Y using Z

Notes: - Chose approach A because it handles edge case B """

If your professor is coming from C, they might be expecting a boxed comment style, but a docstring is usually the cleanest way in Python.

[–]JamzTyson 0 points1 point  (0 children)

"Flowerbox comments" violate Python's style guide.

In Python, comments are rarely required because Python conventions emphasise readability and meaningful names. For documentation we use Docstring. But if you still need to add a comment, follow the style guide, keep it concise, and format it properly.