Augmented Assignment Python Swallows

On By In 1

I'm writing a lightweight class whose attributes are intended to be publicly accessible, and only sometimes overridden in specific instantiations. There's no provision in the Python language for creating docstrings for class attributes, or any sort of attributes, for that matter. What is the accepted way, should there be one, to document these attributes? Currently I'm doing this sort of thing:

This will result in the class's docstring containing the initial standard docstring section, as well as the lines added for each attribute via augmented assignment to .

Although this style doesn't seem to be expressly forbidden in the docstring style guidelines, it's also not mentioned as an option. The advantage here is that it provides a way to document attributes alongside their definitions, while still creating a presentable class docstring, and avoiding having to write comments that reiterate the information from the docstring. I'm still kind of annoyed that I have to actually write the attributes twice; I'm considering using the string representations of the values in the docstring to at least avoid duplication of the default values.

Is this a heinous breach of the ad hoc community conventions? Is it okay? Is there a better way? For example, it's possible to create a dictionary containing values and docstrings for the attributes and then add the contents to the class and docstring towards the end of the class declaration; this would alleviate the need to type the attribute names and values twice. edit: this last idea is, I think, not actually possible, at least not without dynamically building the entire class from data, which seems like a really bad idea unless there's some other reason to do that.

I'm pretty new to python and still working out the details of coding style, so unrelated critiques are also welcome.



A Burmese python's eyes were bigger than its stomach (literally) when it decided to attack and swallow a white-tailed deer whole.

The hungry 31-pound python took on a 35-pound white-tailed deer 111 percent its mass. It was a shocking sight, even in Florida, where the python is an invasive species. 

Officials stumbled upon the 11-foot female snake in Collier-Seminole State Park in Naples with a "large food bulge" back in April 2015, the Conservancy of Southwest Florida said in a blog post Thursday. The officials just released details of the finding, which will be published in the March 2018 issue of the peer-reviewed quarterly Herpetological Review.

It's believed to be the "largest predator to prey ratio" ever documented in the history of the Byrmese python species, the conservancy said.

Florida officials released photos of a 2015 case involving a python eating a deer as the case appears in a peer-reviewed Journal in March.  (Conservancy of Southwest Florida)

Wildlife experts say the snake's healthy appetite is problematic because it proves pythons may feed on white-tailed deer before they're old enough to mate, which could negatively impact the deer population, a primary prey for panthers and other large animals in the area.

“[It's] is another important piece of evidence for the negative impact invasive Burmese pythons are having on native wildlife across the Greater Everglades Ecosystem” Ian Bartoszek, a wildlife biologist for Conservancy of Southwest Florida, said in a statement. “Imagine the potential consequences to the state and federally protected Florida panther if Burmese pythons adversely affect the number of white-tailed deer."

Officials safely captured and relocated the snake, which painfully regurgitated the dead fawn in the grass. Shortly after, the python was humanely euthanized. Wildlife biologists then performed an autopsy on the snake and collected genetic samples.

"Biologists are accumulating valuable life history information on the behavior of Burmese pythons in Southwest Florida," the conservancy wrote. "This information is leading to the development of an effective python removal technique that combines both hunting and radio-telemetry tracking efforts to target and remove breeding female pythons and disrupt the egg-laying cycle."

A 2015 photo, which was just released this week, shows a Burmese python regurgitating a 35-pound white-tailed deer.  (Conservancy of Southwest Florida)

The Florida Wildlife Commission has been asking for the public's help to remove the snakes, encouraging them to "remove and kill pythons from private lands whenever possible."

The South Florida Water Management District even created a python elimination program in 2017 to protect the Everglades and eliminate the snakes from public lands. Approximately 158 pythons were eliminated during the program in roughly two months.

Wildlife officials would like to find a more effective way to eliminate the creatures, and they believe research is key.

Florida wildlife officials share a 2015 photo of an 11-foot Burmese python and the body of a white-tailed deer, the snake's prey.  (Conservancy of Southwest Florida)

“If we can continue to target breeding female pythons for removal the results are two-fold,” Conservancy of Southwest Florida President and CEO Rob Moher said in a blog post. “We are keeping the invasive snakes from multiplying and reducing the overall impact on our native wildlife populations.”

"Tens of thousands of invasive Burmese pythons are estimated to be present in the Everglades," the United States Geological Survey (USGS) says. Officials believe the snakes multiplied over the years, turning into an invasive species, after careless pet owners released the exotic animals in swamps.

It's believed to be the largest predator-prey ratio in the case of a Byrmese python ever documented, the conservancy added.

It's believed to be the largest predator-prey ratio in the case of a Byrmese python ever documented, the conservancy added.

It's believed to be the largest predator-prey ratio in the case of a Byrmese python ever documented, the conservancy added.

Newly-released photos show a Burmese python swallowing a young deer in April 2015.  (Conservancy of Southwest Florida)


Leave a Reply

Your email address will not be published. Required fields are marked *