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
DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

Mycroft Holmes posted:

I've run into a problem with my homework. I have to take the following list:

code:
[{'rank': 1, 'title': 'Pride and Prejudice', 'author': 'Jane Austen', 'year': 1813}, {'rank': 2, 'title': 'To Kill a Mockingbird', 'author': 'Harper Lee', 'year': 1960}, {'rank': 3, 'title': 'The Great Gatsby', 'author': 'F. Scott Fitzgerald', 'year': 1925}, {'rank': 4, 'title': 'One Hundred Years of Solitude', 'author': 'Gabriel Garcia Marquez', 'year': 1967}, {'rank': 5, 'title': 'In Cold Blood', 'author': 'Truman Capote', 'year': 1965}, {'rank': 6, 'title': 'Wide Sargasso Sea', 'author': 'Jean Rhys"', 'year': 1966}, {'rank': 7, 'title': 'Brave New World', 'author': 'Aldous Huxley', 'year': 1932}, {'rank': 8, 'title': 'I Capture The Castle', 'author': 'Dodie Smith', 'year': 1948}, {'rank': 9, 'title': 'Jane Eyre,', 'author': 'Charlotte Bronte', 'year': 1847}, {'rank': 10, 'title': 'Crime and Punishment', 'author': 'Fyodor Dostoevsky', 'year': 1866}]
and my instructions are:

I have no idea how to do this. I have spent 20 minutes trying to use .split to do it, before realizing it won't work. Any suggestions?

There are some *very* compact ways to do this in python that it sounds like you haven't met yet (and the question hint is suggesting you not use). As this is a homework question I'll just give a couple of hints for now.

To populate book_data you'll need to iterate over each entry the current list, transform it into the specified format, then append that transformed value to book_data

To do the transformation you should look at either f-strings (if you've met them), or the .join() method.


Edit: okay, from your answers above sounds like we need to take a step back. Look at the first element of the list you've been given. What type of object is it? How would you get the title or author from that object?

DoctorTristan fucked around with this message at 19:52 on Feb 24, 2022

Adbot
ADBOT LOVES YOU

Mycroft Holmes
Mar 26, 2010

by Azathoth
okay, so so the data types are dictionaries. I think I know how to do this then.

ExcessBLarg!
Sep 1, 2001
What is the most concise way in this garbage language? I got this, but my head hurts:
Python code:
 [":".join([str(i) for i in d.values()]) for d in l]
Ruby code:
l.map {|d| d.values.join(":")}

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.
I'm using Python to tear through some data files, and un-gzipping them in Python is pretty slow. What's a sane pattern for quickly un-gzipping multiple large files to get them into a single Python process?

I've read http://www.dalkescientific.com/writings/diary/archive/2020/09/16/faster_gzip_reading_in_python.html, and it looks like one faster approach to ungzipping in Python is to use https://github.com/pycompression/xopen, which launches an external native gzip or pigz, directs its output to a pipe, and reads from the pipe in Python, both getting the better native performance and built-in multiprocessing because now the unzip is in a separate process.

Does anybody have sane ideas for how I could set this up to uncompress multiple files at once and get them all into Python in an organized way? I'm using to being able to do simultaneous multi-threading in Java or C# and can't figure out a Pythonic pattern here.

ploots
Mar 19, 2010

Twerk from Home posted:

I'm using Python to tear through some data files, and un-gzipping them in Python is pretty slow. What's a sane pattern for quickly un-gzipping multiple large files to get them into a single Python process?

I've read http://www.dalkescientific.com/writings/diary/archive/2020/09/16/faster_gzip_reading_in_python.html, and it looks like one faster approach to ungzipping in Python is to use https://github.com/pycompression/xopen, which launches an external native gzip or pigz, directs its output to a pipe, and reads from the pipe in Python, both getting the better native performance and built-in multiprocessing because now the unzip is in a separate process.

Does anybody have sane ideas for how I could set this up to uncompress multiple files at once and get them all into Python in an organized way? I'm using to being able to do simultaneous multi-threading in Java or C# and can't figure out a Pythonic pattern here.

Use multiprocessing's Pool to kick it off once per file, then wait for all the jobs in the pool to finish?

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.

Electoral Surgery posted:

Use multiprocessing's Pool to kick it off once per file, then wait for all the jobs in the pool to finish?

My understanding is that it'd be slow-ish to copy data back from a process, especially if it's potentially enormous. I'm assuming you're saying decompress each file in a separate process, then bring it all back to the master process. I need all of the data from all of the files in one python process to be able to re-assemble it. That's a good very basic improvement that I had missed though!

QuarkJets
Sep 8, 2008

This sounds like a problem I might try using asyncio to solve, assuming IO reading these files is substantial

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.
Reporting back to say that for my specific usage case, xopen is a huge winner: https://github.com/pycompression/xopen

Creates a new process to decompress each compressed file.
Uses the Intel gzip decompressor, the fastest in the land. Unless you have a non-Intel CPU.
Got a change to allow bigger pipes merged back into CPython to make their specific usage case even faster: https://github.com/python/cpython/pull/21921

This is absolutely perfect for having 5 60GB gzips open at once!

credburn
Jun 22, 2016
A tangled skein of bad opinions, the hottest takes, and the the world's most misinformed nonsense. Do not engage with me, it's useless, and better yet, put me on ignore.
Hey gang! I'm struggling through another bit of code and am hoping I could get some insight.

The assignment requires me to count the number of words in a string and print it out without using any imported modules. I'm supposed to get the values through loops and a dictionary, perhaps.

The string is
code:
'hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy'
And the output must look like:

code:
hello 1
cat 2
man 2
hey 2
dog 2
boy 2
Hello 1
woman 1
Cat 1
I worked through this yesterday and I almost had it. My problem was I ran into some string formatting issues and the whole thing became a little overly messy so I just started over. Now, embarrassingly, I can't even remember what I did to get the number frequencies!

The first thing I did was get a list of unique words. But after that, I'm a little lost. Without using count, what is the simplest approach to getting these values? A dictionary?

code:
contents = 'hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy'
words = contents.split(',')
unique = []
for i in words:
    if i not in unique:
        unique.append(i)
I gotta admit I'm struggling in this course. I flew through the first part, and the introduction to programming in general with such speed that my program mentor thought I had been doing this my whole life. Now I'm just hitting a wall :\

QuarkJets
Sep 8, 2008

Use a dictionary. If the word is not in the dictionary, add it, mapping to the value 1. If it is in the dictionary then just increment the value

Biffmotron
Jan 12, 2007

A dictionary is the right approach. Words as keys and the count as the corresponding value.

Break it down into the simplest steps.

You see a word.

Is it in the dictionary?

What do you do if it's in the dictionary?

What do you do if you haven't seen the word before?

12 rats tied together
Sep 7, 2006

another data structure you might find relevant to this assignment is the set

e: actually, this is quite wrong, but I'm leaving it up for your reference anyway. :)

credburn
Jun 22, 2016
A tangled skein of bad opinions, the hottest takes, and the the world's most misinformed nonsense. Do not engage with me, it's useless, and better yet, put me on ignore.

Biffmotron posted:

A dictionary is the right approach. Words as keys and the count as the corresponding value.

Break it down into the simplest steps.

You see a word.

Is it in the dictionary?

What do you do if it's in the dictionary?

What do you do if you haven't seen the word before?

I appreciate this. This is one of the problems I'm having most with this course; it's all online and through self-study and, um, autodidactism if that's a word; I try and translate the code into English the same way I translate Spanish grammar into English grammar before I fully comprehend it. And when I'm staring at just a bunch of words that I know mean something but don't automatically translate in a clear way, I get really lost. I suppose eventually I'll acclimate to the code better but in the meantime, yeah, I am staring at the code and I'm staring at the problem and they seem to be in two different languages and I can't bridge them.

Soanyway, here is my new code:

code:
words = contents.split(',')
mydict = {}
for word in words:
    if word not in mydict:
        mydict[word] = 1
    else:
        mydict[word] += 1
        
for i in mydict:
    print('{} {}'.format(i, mydict.get(i)))
Seems to work now! Thanks again, goons!

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
Don't forget f-strings! str.format() is out of date if not quite obsolete. I honestly prefer them because everything is inline.

credburn
Jun 22, 2016
A tangled skein of bad opinions, the hottest takes, and the the world's most misinformed nonsense. Do not engage with me, it's useless, and better yet, put me on ignore.
So the assignment actually included this bit about reading from a .csv file, and I ran into a problem that I solved in what I think is a pretty inelegant way:

code:
import csv
wordlist = open(input())
contents = wordlist.read()
wordlist.close()
contents = contents.replace('\n', '')
words = contents.split(',')
Where input is the .csv file.

The wordlist string always had a newline thing at the end.

code:
hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy\n
What would have been a better way to resolve it?

edit: f-strings!

credburn fucked around with this message at 00:23 on Feb 26, 2022

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED

ExcessBLarg! posted:

Python code:
 [":".join([str(i) for i in d.values()]) for d in l]

you dont need the [ ] in the inner comprehension at the very least

lazerwolf
Dec 22, 2009

Orange and Black

credburn posted:

So the assignment actually included this bit about reading from a .csv file, and I ran into a problem that I solved in what I think is a pretty inelegant way:

code:
import csv
wordlist = open(input())
contents = wordlist.read()
wordlist.close()
contents = contents.replace('\n', '')
words = contents.split(',')
Where input is the .csv file.

The wordlist string always had a newline thing at the end.

code:
hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy\n
What would have been a better way to resolve it?

edit: f-strings!

What you’re looking for is the
code:
strip()
method. Strip removes white space and new lines naturally. https://docs.python.org/3/library/stdtypes.html#str.strip

code:
words = contents.strip().split(“,”)
Also if you’re opening files you should use with open syntax. This will auto close the file when the with block is done.
Example
code:
with open(filepath) as f:
    lines = f.readlines()

lazerwolf fucked around with this message at 02:41 on Feb 26, 2022

QuarkJets
Sep 8, 2008

credburn posted:

I appreciate this. This is one of the problems I'm having most with this course; it's all online and through self-study and, um, autodidactism if that's a word; I try and translate the code into English the same way I translate Spanish grammar into English grammar before I fully comprehend it. And when I'm staring at just a bunch of words that I know mean something but don't automatically translate in a clear way, I get really lost. I suppose eventually I'll acclimate to the code better but in the meantime, yeah, I am staring at the code and I'm staring at the problem and they seem to be in two different languages and I can't bridge them.

Soanyway, here is my new code:

code:
words = contents.split(',')
mydict = {}
for word in words:
    if word not in mydict:
        mydict[word] = 1
    else:
        mydict[word] += 1
        
for i in mydict:
    print('{} {}'.format(i, mydict.get(i)))
Seems to work now! Thanks again, goons!

Tip: you can iterate over keys and values in a dict simultaneously!

Also yeah use f-strings they're great, you can basically directly insert variables into strings by just prefixing a string with the letter f:

Python code:
for dict_key, dict_value in mydict.items():
    print(f'{dict_key} {dict_value}')

credburn posted:

So the assignment actually included this bit about reading from a .csv file, and I ran into a problem that I solved in what I think is a pretty inelegant way:

code:
import csv
wordlist = open(input())
contents = wordlist.read()
wordlist.close()
contents = contents.replace('\n', '')
words = contents.split(',')
Where input is the .csv file.

The wordlist string always had a newline thing at the end.

code:
hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy\n
What would have been a better way to resolve it?

edit: f-strings!

You can use strip() to remove leading and trailing newline characters from a string, instead of using replace; replace works too but this is what strip is made for.

You can use open() as a context manager, this means that the file is closed even if an error occurs (making context managers extremely useful).
code:
with open(input()) as wordlist:
    contents = wordlist.read()
    # The file remains open until a new unindentation is reached
# The file is closed when this line is reached

Data Graham
Dec 28, 2009

📈📊🍪😋



Python, where telling a newbie to "use a dictionary" isn't a burn

Sleepy Robot
Mar 24, 2006
instant constitutional scholar, just add astonomist
https://www.youtube.com/watch?v=-AZUIL1rY3U

I'm trying to figure out a way to do python debugging using vimspector in neovim.

I watched the video above about setting up vimspector to do debugging, but he only shows how to do this using javascript testing library Jest. I got his version working for javascript just from copy and paste but I'm completely lost on what's actually going on in the code and how I would write something like the JestStrategy function but python instead. I'm guessing it has something to do with `cmd` but I've tried to log out its contents without much success.

I don't know how he's coming up with the `testName` if I can't see what's in cmd, I feel like this would get me a bit further along.

Sleepy Robot fucked around with this message at 00:04 on Feb 28, 2022

Zephirus
May 18, 2004

BRRRR......CHK

Sleepy Robot posted:

https://www.youtube.com/watch?v=-AZUIL1rY3U

I'm trying to figure out a way to do python debugging using vimspector in neovim.

I watched the video above about setting up vimspector to do debugging, but he only shows how to do this using javascript testing library Jest. I got his version working for javascript just from copy and paste but I'm completely lost on what's actually going on in the code and how I would write something like the JestStrategy function but python instead. I'm guessing it has something to do with `cmd` but I've tried to log out its contents without much success.

I don't know how he's coming up with the `testName` if I can't see what's in cmd, I feel like this would get me a bit further along.

He's doing unit testing with Jest, which is a javascript testing framework. This is nothing really to do with vimspector setup, he's just setting up macros and vim functions to call jest to debug unit tests in the second half of the video - he is all set up with vimspector itself by halfway through the video.

There are some guides for setting up vimspector for python on the vimspector site https://github.com/puremourning/vimspector#python which are relatively straightforward, at least as far as vim goes.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
So I can find guides about how to integrate Black into your coding and precommit hooks. But are there any packages out there that let you run Black on pre-commit and stage the formatted files? Or would I have to write something like that myself?

This totally exists on the JavaScript ecosystem so I'm sure there's got to be something out there

lazerwolf
Dec 22, 2009

Orange and Black

teen phone cutie posted:

So I can find guides about how to integrate Black into your coding and precommit hooks. But are there any packages out there that let you run Black on pre-commit and stage the formatted files? Or would I have to write something like that myself?

This totally exists on the JavaScript ecosystem so I'm sure there's got to be something out there

I use pre-commit to set up black flake8 and isort. Simple yaml file to set everything up.

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
On that topic, is there a way to exclude the venv from a pre-commit processing? I only want to process poo poo that I've written, I don't want to black every loving .py file in my ./env volder. I want to set up a pre-commit so I don't have to manually black everything but last time left a sour taste in my mouth.

After an hour sitting there waiting for black to get a quarter of the way through Python itself.

ploots
Mar 19, 2010
I have my editor set up to run black on write if the open file ends in .py.

QuarkJets
Sep 8, 2008

D34THROW posted:

On that topic, is there a way to exclude the venv from a pre-commit processing? I only want to process poo poo that I've written, I don't want to black every loving .py file in my ./env volder. I want to set up a pre-commit so I don't have to manually black everything but last time left a sour taste in my mouth.

After an hour sitting there waiting for black to get a quarter of the way through Python itself.

Your venv shouldn't be mingling with your project (e.g. You shouldn't have a ./env folder)

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
This is the first semi-successful venv I've used. It's (mistakenly, admittedly) set up so that the env top level folder is in the project parent folder, same as the main .py files. Next time I'd do it differently. I didn't realize until roughly last night that I did it a Bad Way.

Data Graham
Dec 28, 2009

📈📊🍪😋



Hrm. Putting the venv in the main project dir is bad? drat, PyCharm uses that as the default location for its integrated virtualenv behavior. Didn't know that was frowned-on.

QuarkJets
Sep 8, 2008

Data Graham posted:

Hrm. Putting the venv in the main project dir is bad? drat, PyCharm uses that as the default location for its integrated virtualenv behavior. Didn't know that was frowned-on.

Not bad per se, but you do run into problems like the OP is experiencing (having to spend time figuring out how to get linters and autoformatters to ignore your env directory when otherwise *.py would do). I tend to use conda environments, those are installed in a common location (somewhere adjacent to your conda/mamba executables)

Data Graham
Dec 28, 2009

📈📊🍪😋



Yeah I mean, I'm used to excluding it with a .gitignore and so on, but everywhere that I've seen that has black or coverage or other pre-commit stuff integrated also evidently has ways to exclude things. I'd think that would be a basic feature of any such tool, after all venv isn't the only thing you're going to want to exclude in the project dir.

lazerwolf
Dec 22, 2009

Orange and Black
In your pyproject.toml file add your venv folder to extend-exclude section


code:

[tool.black]
line-length = 120
include = '\.pyi?$'
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
/(
    \.git
  | VENV FOLDER HERE
  | .*__init__.py$
)/
'''

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
I have a class Order which acts as a container for multiple objects of class Opening. I want Order to be able to take multiple types of input, for instance, a CSV file, a tab-delimited text file, and direct manual input that is passed as a dict by the Flask app. At some point, I may also add an XML file input.

For each of these data type inputs, I want to perform a different __init__(), essentially. They will all contain the same basic data, but the structure will differ; the __init__() will also write to the same basic list-of-dicts, each dict of which will be passed to an Opening object in its constructor. The constructor then handles determining which kind of opening it is and processes it accordingly with the appropriate child class.

A sample of data, for instance. Here's a row from the CSV and a comparable row from the tab-delimited text format.
code:
1.00,AR7620A 48.X24.X.X. 1/2" FL W HC T3/16 CL OUTSIDE GLZ 1" RM/FB HC6L     ,1.00,EA,336.54,336.54

DWINDOW         AR762048.X24.X.X.,1/2" FL,W,HC,T     00000PGTIN  00001000004740000004740000336540
The reason I want to support multiple initialization methods is that this is a backend class for my Flask app, and I know there are multiple formats that we can pull the data from our vendors. I discovered this way back in my VBA days, trying to automate the calculation of materials for windows and doors.

I sort of understand multiple dispatch, but I'm having a hard time with the @classmethod decorator, or @singledispatchmethod. I suppose I could just take an any input and do an if-elif in the __init__() method? Is that the simplest way to do it?

Basically I want to achieve the following:
code:
if input_type = CSV then:
  process_the_csv_to_dict
elif input_type = TXT then:
  if correct_format then:
    process_the_txt_to_dict
elif input_type = list_of_dicts then:
  pass_that_to_Opening_constructor

D34THROW fucked around with this message at 19:04 on Mar 2, 2022

QuarkJets
Sep 8, 2008

Yes I think an if tree is a good approach, you can use dictionary dispatch if you want to be slick:

code:

processors = {"txt": txt_to_dict, 
    "csv": csv_to_dict, 
   ... } 
self.my_dict = processors[input_type](input_file)

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
If I'm interpreting that properly, that's storing a function as a dictionary value, then passing the input as an argument to the function called by accessing the dict key? :hawaaaafap: That is a loving awesome piece of programming and the easiest to syntactically parse for me, thank you!


EDIT: I can do it with a list too. If I pass the data type as an int via enum, then the data itself as an any type argument...processors[input_type](raw_data). Python never ceases to amaze. List comprehension blew my mind, this has me :psyboom:

D34THROW fucked around with this message at 20:19 on Mar 2, 2022

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
Documentation sure adds a lot of loving lines of code

Python code:
class Report(db.Model):
    """Material/labor/general report."""

    #: Surrogate primary key.
    id = db.Column(db.Integer(), primary_key=True)
    #: The report's timestamp.
    timestamp = db.Column(db.DateTime(), default=dt.datetime.now())
    #: A serialized representation of the report's header data. Can be
    #: loaded back into a report object with the report's `__dict__`
    #: function.
    header = db.Column(db.Text())
    #: A serialized representation of the report's data. Can be loaded
    #: back into a report object with the report's `__dict__` function.
    data = db.Column(db.Text())
    #: The user who created the report. Foreign key to :class:`User`.
    create_user = db.Column(db.Integer(), db.ForeignKey("user.id"))
    #: The type of report. Foreign key to :class:`ReportType`.
    rpt_type = db.Column(db.Integer(), db.ForeignKey("report_type.id"))
    #: The job for which the report is for. Foreign key to :class:`Job`.
    job = db.Column(db.Integer(), db.ForeignKey("job.id"))
vs
Python code:
class Report(db.Model):
    """Material/labor/general report."""

    id = db.Column(db.Integer(), primary_key=True)
    timestamp = db.Column(db.DateTime(), default=dt.datetime.now())
    header = db.Column(db.Text())
    data = db.Column(db.Text())
    create_user = db.Column(db.Integer(), db.ForeignKey("user.id"))
    type = db.Column(db.Integer(), db.ForeignKey("report_type.id"))
    job = db.Column(db.Integer(), db.ForeignKey("job.id"))
But hey, at least I restarted everything and did a proper pyproject.toml, .env, .pre-commit-config.yaml, and .flake8 so I've got my pre-commit hooks all set up nice and proper. Forces me to use PEP8 and I'm learning Sphinx autodocumentation as I go too!

QuarkJets
Sep 8, 2008

Yeah comments should actually be pretty uncommon imo, the names of functions and variables should make clear what is happening.

Also, don't use the names of builtins for variable names: id and type are verboten. The IDE you use should identify this

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug

QuarkJets posted:

Yeah comments should actually be pretty uncommon imo, the names of functions and variables should make clear what is happening.

Also, don't use the names of builtins for variable names: id and type are verboten. The IDE you use should identify this

In the hierarchy of best practices, over-commenting is still a lesser evil than a lot of other options though.

I do generally agree though with most of those being superfluous. timestamp is pretty clear (or created_time if you want to be more explicit), and I would only add comments on anything that's weird enough that you can't easily represent it with a nicely specific variable name.

Edit: Also, I think that function/method docstrings are way more useful in terms of documentation than individual variable comments.

Falcon2001 fucked around with this message at 23:25 on Mar 9, 2022

QuarkJets
Sep 8, 2008

Don't be afraid to use id as a suffix. user_id, report_type_id, job_id, etc. If it's actually an identifier, which most of those variables are, then label it as such. And if it's the primary key then primary_id or row_id are great labels

If I see "create_user" then I am going to assume that's a string containing a username or maybe even something else, not necessarily an integer that's actually a foreign key (you are using foreign keys to create relationships between tables, right?)

abelwingnut
Dec 23, 2002


i've always done the object first, then the descriptors.

so like, idCustomer, idTransaction, nameFirst, nameLast, etc.

helps me understand things a bit quicker in a glance

Adbot
ADBOT LOVES YOU

QuarkJets
Sep 8, 2008

abelwingnut posted:

i've always done the object first, then the descriptors.

so like, idCustomer, idTransaction, nameFirst, nameLast, etc.

helps me understand things a bit quicker in a glance

I like that too if I have a bunch of the same kind of thing (like several identifiers), but always snake_case for Python code

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