Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Feisty-Cadaver
Jun 1, 2000
The worms crawl in,
The worms crawl out.

pokeyman posted:

I’m sorry this is happening to you, but I’m not sorry I get to read about it here

Adbot
ADBOT LOVES YOU

Luigi Thirty
Apr 30, 2006

Emergency confection port.

not because of what you did but the inevitable legislative response

my C++ knowledge is about 15 years out of date. getters and setters are bad now and new/delete is considered harmful? my god

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


GNU Order posted:

Interesting choice but whatever helps. Personally I just get horny waiting for my builds to finish

not as horny as my autocorrect it seems!

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



whats the preferred documentation system for python?

there seem to be a bunch of standards for docstrings :|
https://realpython.com/documenting-python-code/#docstring-formats
https://realpython.com/documenting-python-code/#documentation-tools-and-resources

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

I thought you just wrote something and the dynamic nature of python would detect it as documentation and label it as such

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Boiled Water posted:

I thought you just wrote something and the dynamic nature of python would detect it as documentation and label it as such

lol


anyway seems sphinx is the go-to doc generator and pycharm supports a bunch of different formats so ill just blunder my way through it!

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ugh wtf is this poo poo, i hate path fuckery


/usr/local/bin/python3 "/Applications/PyCharm CE.app/Contents/helpers/rest_runners/sphinx_runner.py" -b html /Users/Krankenstyle/dev/MyProject/module /Users/Krankenstyle/dev/MyProject/docs
Fatal Python error: initfsencoding: unable to load the file system codec
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/encodings/__init__.py", line 31, in <module>
File "/Users/Krankenstyle/dev/MyProject/codecs.py", line 2, in <module>
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 26, in <module>
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/traceback.py", line 5, in <module>
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/linecache.py", line 11, in <module>
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tokenize.py", line 27, in <module>
ImportError: cannot import name 'open' from 'builtins' (unknown location)

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

AggressivelyStupid
Jan 9, 2012

documentation?? what is that, anyway, here's my six nested list comprehensions

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


floatman posted:

gently caress r.e. my previous story of using a logging library (monolog, PHP) to generate statefully held html to output back to page.

Today I found out that there was a monkey patched property being attached to the logger class, a property called "max_debug".
It was used something like this:

PHP code:
$this->logger->debug("Got html response!");
if ($this->logger->max_debug) {
     $this->logger->debug("Here is html body $body");
}
Putting aside the questionable sanity of having a logger collect html for output,
Basically everybody knows you can have various output levels for logger classes (i.e. warning, info, debug).
Instead of using info for info and debug for debug, this code uses debug for EVERYTHING and the monkey patched Boolean flag is there to represent a custom level lower than debug.

one of our guys does the same thing in his code except his max_debug equivalent is a define in one of his files somewhere
so logging level is controlled by something not in the file you are expecting and you have to edit code to change it

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Krankenstyle posted:

ugh wtf is this poo poo, i hate path fuckery

hmm it seems my internal module files are shadowing the system modules (codecs.py, string.py) but ONLY when i run in pycharm... i tried refactoring codecs.py to codec.py and it got further but failed at string.py

it works fine from the command line, what the hell ?!

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

floatman posted:

gently caress r.e. my previous story of using a logging library (monolog, PHP) to generate statefully held html to output back to page.

Today I found out that there was a monkey patched property being attached to the logger class, a property called "max_debug".
It was used something like this:

PHP code:
$this->logger->debug("Got html response!");
if ($this->logger->max_debug) {
     $this->logger->debug("Here is html body $body");
}
Putting aside the questionable sanity of having a logger collect html for output,
Basically everybody knows you can have various output levels for logger classes (i.e. warning, info, debug).
Instead of using info for info and debug for debug, this code uses debug for EVERYTHING and the monkey patched Boolean flag is there to represent a custom level lower than debug.

seeing "if (max_debug)" is giving me PTSD

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



lmao it was "add source roots to PYTHONPATH" in the run settings

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



alright, so: can i avoid putting sphinx's index.rst inside my module? it looks ugly and id rather it was in docs/ next to conf.py...

code:
MyProject/MyModule/__init__.py
MyProject/MyModule/foo.py
MyProject/MyModule/bar.py
MyProject/docs/conf.py	# sphinx config file
MyProject/???/index.rst	# sphinx master file
it works if i hae it at MyProject/MyModule/index.rst but if i put it anywhere else i get this:

code:
$ venv/bin/sphinx-build -b html -c docs/ CorrectOCR docs
Running Sphinx v1.8.5
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed

Sphinx error:
master file /Users/Krankenstyle/dev/MyProject/MyModule/index.rst not found
configuring it in docs.py as master_doc = '../docs/index' doesnt work

cinci zoo sniper
Mar 15, 2013




Krankenstyle posted:

lol


anyway seems sphinx is the go-to doc generator and pycharm supports a bunch of different formats so ill just blunder my way through it!

yeah, sphynx on readthedocs is modus operandi for people who document their poo poo

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

yeah, sphynx on readthedocs is modus operandi for people who document their poo poo

cool. you know anything about my previous post about index.rst? do people normally just cram it in the module because ew ew ew

cinci zoo sniper
Mar 15, 2013




Krankenstyle posted:

cool. you know anything about my previous post about index.rst? do people normally just cram it in the module because ew ew ew

no, people usually sphinx-quickstart and setup a root path for the documentation in ~/docs or ~/doc ("docs" or "doc" input value respectively). i haven't ever tried moving it, let me check separately

cinci zoo sniper
Mar 15, 2013




honestly? not a single clue why you cant have it in MyProject/docs/ as described. i'd just regenerate sphinx at this point :v:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



yea i thought it was supposed to go in docs/ but sphinx complains if its not in my module :confused:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

honestly? not a single clue why you cant have it in MyProject/docs/ as described. i'd just regenerate sphinx at this point :v:

lol gonna try rebuilding :shrug:

cinci zoo sniper
Mar 15, 2013




oh, one way to probably work around this is to do sys.path.append or sys.path.insert within conf.py, e.g. sys.path.insert(0, os.path.abspath('..'))

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ohhh thanks!!

cinci zoo sniper
Mar 15, 2013




okay so then the sys.path part considering your project structure was equal to MyProject/MyModule/, as that is where __init__.py is

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

okay so then the sys.path part considering your project structure was equal to MyProject/MyModule/, as that is where __init__.py is

got it to work with sys.path.insert(0, os.path.abspath('..'))

and then in index.rst a bunch of
code:
.. automodule:: MyModule
   :members:

.. automodule:: MyModule.foo
   :members:

.. automodule:: MyModule.bar
   :members:
and using the makefile that sphinx generated for me with "make html" (or "make coverage html" which adds a txt file with whats missing docs still)

whew, that was the hard part. now to actually write the documentation... :sweatdrop:

Scionix
Oct 17, 2009

hoog emm xDDD

TheFluff posted:


blocking is always loving pointless, but the idea was good. listening to music harms concentration and i have no idea why everyone insists on doing it while coding.

if my boss enforced a no listening to music/podcast policy while working I would quit on the spot lol

Soricidus
Oct 21, 2010
freedom-hating statist shill
why would python want to standardise on a single docstring format? TIMTOWTDI is in the zen now, right?

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


argh anyone know if you can set a pubxml publish profile to "delete all files prior to publish except for a specific file"? you can set them to exclude from copy but I can't find any documentation on the delete sections or any actual documentation just fragments or "this feature is deprecated" pages

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Soricidus posted:

why would python want to standardise on a single docstring format? TIMTOWTDI is in the zen now, right?

thats perl

python seems to be more like "idk just do whatever, who knows it might work??"

e: or "just defer everything to runtime, gently caress you"

Soricidus
Oct 21, 2010
freedom-hating statist shill

:thejoke:

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Luigi Thirty posted:

getters and setters are bad now

C++ doesn't have those, are you referring to making member variables public?

Luigi Thirty posted:

and new/delete is considered harmful?

they always were harmful, the difference is that we have realistic alternatives now

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


hackbunny posted:

C++ doesn't have those, are you referring to making member variables public?

kinda :thejoke: but is there any reason besides cargo culting to implement trivial (i.e. not factories and such) getters and setters even in say Java? I suppose if you use an interface type in the signature

e: i've seen python getters and setters used for runtime evaluation shenanigans, but that's not really a good argument in favour

Private Speech fucked around with this message at 01:42 on Mar 12, 2019

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
They give you the option of adding logic later on without needing to refactor callers.

floatman
Mar 17, 2009

duz posted:

one of our guys does the same thing in his code except his max_debug equivalent is a define in one of his files somewhere
so logging level is controlled by something not in the file you are expecting and you have to edit code to change it
Lmao do we work with the same guy?
1. There is a massive PHP file which contains nothing but global string definitions
2. The definition names are things like MANUAL_PREFIX ( which are strings which contain a period at the end e.g. "DERPPREFIX.") and definitions like OPERATION_SUFFIX
3. To initialise a monolog logger, you need to provide a channel name. This guy initialises loggers using a concatenated pair of prefix and suffix definitions e.g new logger(MANUAL_PREFIX . OPERATION_SUFFIX);
4. At points in the code, the class that calls the logger will retrieve the logger name.
5. It then does a string split based on period (.) To return a array of strings with a count of 2.
6. It then checks if strings[0] == SOME_PREFIX
7. If the strings match, the class, which contains application logic, will alter behavioral based on the name of the current logger its using.

So over here, logging level and application logic are controlled by something not in the file you are expecting and you have to edit code to change it.

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Jabor posted:

They give you the option of adding logic later on without needing to refactor callers.

I guess it makes sense, particularly when java doesn't let you override member access with a function

looking around a lot of people don't like it though, including the isocpp comittee itself, arguing that a) you are breaking encapsulation by exposing members marked private, and b) if you add logic you might want to refactor the callers anyway, since the class could now behave differently than the callers expect (e.g. you fire off an event on modifying some value, but a caller uses it for an algorithm which calls it thousands of times per millisecond)

e: here's a summary of stroustrups/isocpp conclusions on the topic

isocpp posted:

C.131 Avoid trivial getters and setters

To summarize,
Notes
Before applying this rule check if Rule Rc-struct applies.
Next, consider if you should have the getter/setter at all. There is a purist argument in object oriented programming that classes should do things not provide data. While C++ is not a pure object oriented language purist argument is worth considering.
The key to this rule is whether the semantics of the getter/setter are trivial. A getter/setter is trivial if the following conditions apply

The implementation of the getter is a simple return of value

The implementation of the setter is a simple assignment

If either of the above fail to apply in the future you would not be able to use a tool to change to using getter/setter functions.

Not being able to use a tool this means that you have provide binary compatibility guarantees, along with PIMPL implementing trivial getters/setters in a .cpp is good "just in case" protection. Sometimes it means that are political issues in your organization around change. This should not be used an excuse to not have a tool available to do these refactors as needed.

Enforcement
Flag multiple get and set member functions that simply access a member without additional semantics. Make sure violators know how to use refactoring tools to add these if they need non-trivial implementation latter.

Private Speech fucked around with this message at 06:06 on Mar 12, 2019

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



floatman posted:

Lmao do we work with the same guy?
1. There is a massive PHP file which contains nothing but global string definitions
2. The definition names are things like MANUAL_PREFIX ( which are strings which contain a period at the end e.g. "DERPPREFIX.") and definitions like OPERATION_SUFFIX
3. To initialise a monolog logger, you need to provide a channel name. This guy initialises loggers using a concatenated pair of prefix and suffix definitions e.g new logger(MANUAL_PREFIX . OPERATION_SUFFIX);
4. At points in the code, the class that calls the logger will retrieve the logger name.
5. It then does a string split based on period (.) To return a array of strings with a count of 2.
6. It then checks if strings[0] == SOME_PREFIX
7. If the strings match, the class, which contains application logic, will alter behavioral based on the name of the current logger its using.

So over here, logging level and application logic are controlled by something not in the file you are expecting and you have to edit code to change it.

holy poo poo lmao

Arcsech
Aug 5, 2008

Private Speech posted:

I guess it makes sense, particularly when java doesn't let you override member access with a function

looking around a lot of people don't like it though, including the isocpp comittee itself, arguing that you a) are breaking encapsulation by exposing members marked private


this argument has always seemed like a bunch of fart huffing by smalltalk worshipers

quote:

and b) if you add logic you might want to refactor the callers anyway, since the class could now behave differently than the callers expect (e.g. you fire off an event on modifying some value, but a caller uses it for an algorithm which calls it thousands of times per millisecond)

e: here's a summary of stroustrups/isocpp conclusions on the topic

that would be a reasonable argument if java had a way to declare a variable as non-null and have that verified by the type checker

it does not

also I’m not particularly interested in soustrops, or the c++ committee’s, thoughts on what makes code understandable, I’ve seen to much of the c++ standard library for that

Luigi Thirty
Apr 30, 2006

Emergency confection port.

hackbunny posted:

C++ doesn't have those, are you referring to making member variables public?


they always were harmful, the difference is that we have realistic alternatives now

yeah it was dogmatic that you NEVER MAKE MEMBER VARIABLES PUBLIC because OOP ENCAPSULATION RAAAARGH

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Luigi Thirty posted:

yeah it was dogmatic that you NEVER MAKE MEMBER VARIABLES PUBLIC because OOP ENCAPSULATION RAAAARGH

it's an opinion that seems 100% correct to me except in the context of fascist-objectivist languages where everything-is-an-object. if you're in java or ruby or (i think) python where there is no way to express a simple immutable datatype, you're god damned right i'm going to have trivial getters and setters.

but in a good language where you can have simple data types with typed field access then i can't imagine why you would need trivial getters and setters in your actual objects.

ComradeCosmobot
Dec 4, 2004

USPOL July

DONT THREAD ON ME posted:

it's an opinion that seems 100% correct to me except in the context of fascist-objectivist languages where everything-is-an-object. if you're in java or ruby or (i think) python where there is no way to express a simple immutable datatype, you're god damned right i'm going to have trivial getters and setters.

but in a good language where you can have simple data types with typed field access then i can't imagine why you would need trivial getters and setters in your actual objects.

as long as you can transparently substitute an accessor for the typed field access, sure

if your language can't do that, you can be sure that your business requirements will suddenly change to require you to touch the new foo.last_updated field every time you change the value of foo.butt

but if, as you suggest, your types are immutable, then yea you might be okay

Luigi Thirty
Apr 30, 2006

Emergency confection port.

this is C++ for my mastodon client so

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

ComradeCosmobot posted:

as long as you can transparently substitute an accessor for the typed field access, sure

if your language can't do that, you can be sure that your business requirements will suddenly change to require you to touch the new foo.last_updated field every time you change the value of foo.butt

but if, as you suggest, your types are immutable, then yea you might be okay

yeah i mean there are a lot of ways to do encapsulation, it's not just objects. package, module, whatever. you can use these to control mutable field access.

more tangibly: say i have a package, intestines, that contains a struct, colon, that has a field, []poop. i can say that colon is a public type, but access to the field []poop is private to members of intestines. things defined in intestines are free to modify poop with an understanding of its important semantics, but other packages only see colon as a simple immutable data type with no fields. if they want to extract a []poop from a colon, they need to access it with the getPoop(colon) -> []poop method defined in intestine.

you can dress this up in a bunch of ways that are basically just object oriented programming as it is popularly defined.

DONT THREAD ON ME fucked around with this message at 07:10 on Mar 12, 2019

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply