« first day (3636 days earlier)      last day (1536 days later) » 
03:00 - 17:0017:00 - 00:00

03:37
Hey all, do we ask questions here or what?
04:11
someone can help me convert this code to python please
for (int i = 0; i < myArray.Length; i++){ if(myArray[i] < 1 || myArray[i]>5 ){ valido = false;
break;
}
How do i convert this code to python ?

Dim mayorSec As Integer = 1
Dim mayorSecAux As Integer = 1
Dim numeroMayorSec As Integer = 0
Dim numeroAux As Integer = 0
Dim i As Integer = 0
Do While (i < myArray.Length)
If (myArray(i) = numeroAux) Then
mayorSecAux = (mayorSecAux + 1)
Else
mayorSecAux = 0
End If

If (mayorSecAux > mayorSec) Then
mayorSec = mayorSecAux
numeroMayorSec = myArray(i)
End If

numeroAux = myArray(i)
i = (i + 1)
Loop

Console.WriteLine(("Longest: " _
+ (mayorSec + 1)))
Console.WriteLine(("Number: " + numeroMayorSec))
@EduardoHerrera Please use a code sharing service like dpaste or ppaste to share the code and also try to explain a bit what this code is doing as we may not be that good with Cpp (or C)
04:27
@ta_duke Yes, You can ask questions here, you can ask for opinions as well and of course the discussions but they all need to be related to Python.
Hmm. I do not understand C# there but based on what you wrote as a requirement, do you just need the frequency output of each number in an array, right?
do you want it without bultinins?
A quote from your second paste: """Write a program in CTM that prints the highest number of the array""", do you only need the maximum number or a histogram of all occurrences of numbers?
04:39
all occurrences of numbers
@EduardoHerrera Cool. Let me see
but i dont know how to write it in python
seq=[1,2,1,3,3,1,2,1,5,1]
for i in range(1,6):
	t='*'*seq.count(i)
	print(i,t)
there are better ways, if you want to import libraries
Yesp, it's the naive approach for problem solving, there are modules which make it easier (or harder in some cases ;p)
04:44
okay
if you have a code in c or whatver that is, can you just change the syntax?
@python_learner this solution is good but not enough
well I am sorry but that is all I can try
that works so I am not sure why that is not enough
@EduardoHerrera what does it miss though?
well i tried it in my test and display is not the result
result 1. *****
2 **
3 **
4
5 *
04:47
@Eduardo what's the test case(the value of myArray) you have?
myArray = [1,2,1,3,3,1,2,1,5,1]
well what do you expect it to display for this value of myArray?
I would also like to know, but pitifully the page I use test or the test does not demonstrate the expected result, I wrote it in visual basic.net and it worked perfect, now I am asked in python. I assumed it's just converting the vb.net to python.
arr = [1,2,1,3,3,1,2,1,5,1]

for i in range(1,6):
	t='*' * arr.count(i)
	print(str(i) + ': ' + str(t))
accepted
ty
it´s missing this one pastebin.pl/view/c5388e2d
04:56
@EduardoHerrera cool, that was just a difference of output format. The code by @python_learner was working totally fine.
@EduardoHerrera isn't that a different question?
yes
there is two differents question
how can i convert that for in syntax pythonisthic (new word)
you just need the highest value in the array in the second question, right?
05:00
arr = [1,2,1,3,3,1,2,1,5,1]

print(max(arr))
nono
i result one
it's fine the answer about @python_learner its okay
can you help me with another problem?
@EduardoHerrera that's what I did. You may have mistaken me there.
hmm okay
no its a different problem
@EduardoHerrera In your second problem, you have an array and you need to print the highest number in that array (not the number with highest number of occurrences), right??
cleaned
hmmm yes occurences
not
it should print the highest number of occurences
you should print the highest number of the array and if you repeat just print it once
05:09
@EduardoHerrera you're confusing me again. Do you mean the number which has highest number of occurrences, or the number which is greater than other values?
Okay only have to print the highest number of the array (that number can be repeated in the array, but it should only be printed only once)
arr = [1, 2, 3, 4, 5, 5, 6, 6, 6]

print(max(arr))
try this. it will output 6 on stdout.
Worked!
well thank you
it's to much 2/5
Cool :)
@EduardoHerrera umm. I don't know what that means :D
Okay i missed 3 problems
can you help me to solve ?
The test end
For example this one
05:26
you were taking a test :O ? Why would you take a python test without knowing it ?
greetings!
06:43
@EduardoHerrera that's been more than enough help from people here. Please do not use chat as a substitute to a tutorial
cbg, is there a ELI5 for thread(multithread) vs multiprocessing? some site that shows when to use what?
I want to write a script (no gui, so no blocking) that downloads images from a list of urls, I want to get the maximum network usage here, so thread or multiprocessing?
I think threading is the solution here but then I see mentions about GIL which I think is above my level as of now
if your bottleneck is the network, the answer is usually async actually
looking for a good article now, I know there are a few out there.
thanks I will look into async
07:01
this one doesn't look half bad as a primer
though someone else might find something better
if it helps me clear out the "when what is needed" part I would say it is helpful
07:27
@python_learner why just not dealing with concurrent.futures?
I did not know a module like that existed
Now you knew it :P
yeah :) so much when it comes to concurrency, I knew about the usual thread and multi processing, knew async by name
Just do not forget to maintain the same session while scraping :) that's will count as thread safe. where in the backend you maintain the same TCP connection which will prevent multiple TCP flags to establish & close while you are out of same session. that's will count as DDOS attack :P flood etc
you seem to know a lot about networks :O
I know DDOS but I didnt really know I would be doing them if I used concurrency in my code
scraping is looked down for some reason, I get that people abuse it but not all have API or free API
07:39
Scraping a website without prior authorization is count illegal within multiple countries
07:57
Hey guys random question, what is a decent sized full name field so as to not have to change the db varchar size at a later point
do you mean the max values to be stored within Varchar?
@αԋɱҽԃαмєяιcαη well I am needing to store full names within this app in a field however not quite sure what size is a reasonable limit for this type of field
08:18
@Kwsswart I don't think it's a requirement to set one if you're unsure
08:29
@roganjosh with qlalchemy it isnt a requirement when setting the models ? obviously am using flask-migrate so shouldnt be to difficult to change if needed just curious for production what would a decent limit be
came with comment field although may leave that to 255 and force them to make smaller comments ;/
No, SQLA should take an empty String() data type. I'll have to double check but I think that's an optional optimisation, at least in the case of Postgres. For SQLite I think it, as usual, will ignore the character limit. It's equally possible that some RBDMS will pick an arbitrary size
There can't be a decent generic limit - how would you cope if your db stored SO answers and then Aaron came along? :P
Then again, if you're storing a hash or a UUID or a name, you can make some either exact predictions or reasonable assumptions
Hmm well is it takes an empty db.String datatype then may leave that for comments, hwoever names surely 255 should work well considering english and spanish names I cant think there will be many with more than 255 characters
@roganjosh Not with names, I bet
100 chars would still be a better bound than no bound, but indeed, you can't know for sure
user13415013
Hello buddys
08:43
@roganjosh yeah whereas is it a better idea to leave something like a comment field without bounds?
Ugh, we have to deal with flags to shift the notifications?
Ah, all gone now :)
yeah that was some massive spam
@roganjosh you can click "I'm not sure" or whatever to ignore one flagged message at a time
there's valid/invalid/ignore
Yeah, they were just piling in faster than I could handle them while trying to concentrate on typing :P
you're welcome
08:49
:P
user13415013
;D
09:05
hi
please help
how i can do relative import
i am so confused
damn it is so hard
What exactly are you confused about?
The import system is a huge topic
i can not import .py file from the parent directory into my .py file
Imports do not work by directory.
Well, they kinda do
09:12
hello can i ask something fast in Django ?
@gharabat Show us how your project is organized, please
@gharabat do you get an error about the top of the package or something like that?
fast question does slug url with id is accepted by google ? i mean when i add website and pages to google search console for example example.com/url-1 ?
here is a screen shot,
i am trying to access pipliens.app from core.app

the error is :
Traceback (most recent call last):
File "core/app.py", line 6, in <module>
from pipliens.app import Pipeline
ModuleNotFoundError: No module named 'pipliens'
@Aran-Fey Kinda, as in “unless they do not”. Most of the issues I see with imports is because people think packages and directories are equivalent.
09:15
@gharabat that is not a relative import.
ooh, whats is it LOL
how i can do this import
that project layout also doesn't make any sense to me
relative import paths always start with a . (dot)
there really shouldn't be a billion random directories in the same folder as your venv
09:17
@Aran-Fey, how i can do better organization ?
@MisterMiyagi how i can import piplienes.app into core.app ?
project-name/
    .git/
    package_name/
        __init__.py
        module1/
        module2/
    tests/
    venv/
    README
PyCharm should already have set up the import search path to include all these folders. But the proper approach is to create a single, self-contained package.
I.e. What Aran just showed.
How do you run this code?
Yup. All the code goes inside package_name. (Except for tests.)
i really appreciate these valuable advices guys, thanks.

----

@MisterMiyagi i run it from command line
python3 core/app.py
Yeah, don’t do that.
use the -m switch
python3 -m core.app
09:22
anyone can answer my question please
ok i see,
i just googled it and the -m. stand for the module name
it seems a better way
thanks bro
@MisterMiyagi Why though? Does that even make a difference here?
Oh, never mind, I get it
Relative imports won't work inside core/app.py though
@KokHyvv are you asking whether site:example.com/url-1 works with google searches? Did you try?
@Aran-Fey yeah, proper package structure and an entry_points console_scripts seems like the best approach.
09:31
guys i have refactored the project as you advised and every thing is just working fine.

@MisterMiyagi, @Aran-Fey
@MisterMiyagi yes i asked about it
i don't try it yet because i want upload my new website soon so i asked before that
if it's wrong i want change it
to *
 
1 hour later…
10:48
Question to anybody familiat with flask-login and flak-session. I am currently trying to get users to login to the site and once they do have their permissions level set based on position which is saved to the same table as the user.
When using flask-login I can get them in easily, however can I access say user['position'] with flask login in order to set the permissions based on whether it is a manager, employee or admin? or is it better to save the position into a flask session-variable to access as needed?
or would it be better to use github.com/raddevon/flask-permissions
11:12
is is possible to load such data into JSON ? i tried to dumps and loads within JSON module.
this the source of the data after regex it within script tag.
Just replace \" with " and you have json
r'__INITIAL_STATE__=(.+?)</script>'
that's solved the case after loading it twice
12:10
morning cabbages, folks
12:47
cbg
13:01
Does someone know a package that scans a file for its mime type? The package shouldn't just scan the header of the file, it should scan the whole file thoroughly to ensure it hasn't been manipulated.
Yeah, no, there's no way something like that exists. Nobody in their right mind would create a program that can decode all image, video and audio formats, (un)compressed archives, office document files, and all the other file types that exist
Use one tool to detect the mime type, and then another tool to verify that the file is valid
Ok thank you. So you mean, I should for example use python-magic to detect the file, and if it's for example an image, use PIL to validate it?
yeah
ok thank you
On the topic of file types, I've encountered several .webp files recently and none of my usual image editing software* can open them
(*that is, MS Paint)
13:13
time to upgrade to gimp
I won't use a gui. I have to validate them programmatically
I begrudgingly use GIMP for the task. I'm not happy about it because it takes 90 seconds to boot.
O.o
It's not the fastest, but 90 seconds? o.O
@Aran-Fey Do you really think it's a good idea to validate the file by using packages like PIL? What if the file uses an exploit in PIL?
Uhh... so what are you planning to use instead? Is there any piece of software that you know to be free of exploits?
13:21
No but I thought you maybe know an alternative :D
nope
In the interest of accuracy I booted up my other laptop and timed it. I admit that 90 second was an exaggeration; it only took 88.30 seconds. I apologize for the deception
Of course, my laptop is at its slowest right after a fresh bootup, so that measurement is hardly representative of my usual experience. I'll time it again during lunch, as it should have cleared out all the crufty startup processes by then.
Hmm, okay, how do I say this... Does this laptop have a rotary knob on the front? Is it the kind of laptop where you put in a slice of bread and a few minutes later you open the lid and it has turned into toast?
When I pull the string it goes "the cow says moo"
I have so many questions
13:30
Maybe the real reason I've never gotten into machine learning or big data analysis is because my computer's clock rate is best measured in hertz
I timed it on my PC and it took 80 seconds, but that was literally the first time I started GIMP ever since reinstalling Windows last week
now it takes like... 7-8 seconds
14:02
@Kwsswart It's not a good setup to have the customer access stored in the same table as the customer data
Ideally you would want a many-to-many between the User table and the Permissions table
It can be quite convoluted to implement a decent and extensible access system. There is Flask-principal but I've never used it. Later on I can share an example from my dashboard if you want to try rolling your own
How not good of a setup are we talking here? "functional but very hard to customize/extend"? "glaring security hole"?
Certainly I'd implement fine-grained permissions for medium-to-large applications, but maybe for a little internal app, having just employee/manager/admin might suffice for v1.0
It's just not considered good database design anyway, if you're trying to follow correct database normalization. Even with a small app I may want to subdivide some permissions between two existing levels and give different people combinations of those new permissions; your app already becomes a mess and I wouldn't say it was an unreasonable thing you'd need to do
Does someone know how to change the header of an jpeg file? I want to change an image header to be considered as something else (like a .wav file or so)
You only have to figure out the approach once and then you just drop the ~100 lines of code into the project's auth.models.py and you instantly have a fully extensible system
14:22
Certainly, subdividing permissions is a reasonable requirement. But if your client doesn't give you that requirement, well...
I suspect we're both converging upon the same conclusion of "developers must use their best judgment to strike a good compromise between extensibility and YAGNI. History indicates that very very often, you are eventually going to need fine grained permissions, even if v1.0 doesn't require it"
many-to-many that ends up being one-to-one is virtually no overhead provided that you set up an index on the association table, so it's a do-once-and-forget-about-it even if you never end up using it
But yeah, storing it in a single table isn't "broken" off-the-bat :)
@Kevin the miracle of life: the birth of technical debt
14:41
Hmm, I think I just "picture of a bird"ed myself on a personal project I've been kicking around. I want to be able to crawl through an artist's twitter feed, stripping out any retweets and posts that have no images...
(easy API call, give me a couple hours)
... And also filter out any boring pictures of their housepets and animal crossing villages
(research team, five years)
If only they hashtagged their art diligently!
#forkevin
@Kevin would you like my super-awesome virtual zoom background as training data?
Animal Crossing screenshots could be easy to detect... just check if the saturation is off the charts
How hard could it possibly be to make a neural network that can definitively answer the question "is this art?"? Maybe I'll make the intern do it.
@inspectorG4dget Powerful. Evocative.
@Kevin it could just say "yes" all the time (with a random number generator to appraise the art) and may be contended as the one of the toughest art critics of all time
But seriously, a NN might be pretty good at distinguishing art from video game screenshots and photographs of cats. The majority of the artists I follow either work entirely in black and white, or draw their subjects over a featureless solid color background.
oh like that! yes. In fact, there are NNs that can learn a specific artist's style of art and render a picture in that style
styletransfer is amazing. AdultSwim uses it alot
14:54
The challenge here is that i can't be bothered to create an individual training set for each artist
just use google images? And a simple scrapper?
there's gotta be scrapable curated instagram channels
google might even have an api for that
Hmm, please elaborate. What should I be googling?
the name of your artist
14:56
I worry that if I google the artist, it will return both images of their art, and pictures of their cat. So I'll still have to do the manual work of categorizing them.
<artist_name> artwork
Ah, I see, offloading the work onto Google's own "artwork or cat?" AI ;-)
works good enough for the bigger ones I guess. The smaller ones won't have their art on google anyways I guess
And I love how incorrect the phrase on google is :D
@Kevin isn't that how work works? Offloading it to some other company :P Just kidding. But I guess it depends on your usecase, what you wanna do
But I read personal project, so I assume scraping google is fine
I have no moral problem with scraping google. My data is small, so it's very unlikely I'm going to trip a rate limit or anything
Gotta say, I kinda burned myself with git submodules. It seems like there are harder to use than just manually doing stuff
15:00
I wouldn't at all be surprised if there existed a curated collection of <artist name>'s artwork on a webpage or zip file
Especially if the other devs dont know either and are already doing their workflow without it
what's a git submodule?
@inspectorG4dget the confidence is strong :D
I might have a technical problem scraping google, because in my experience their HTML is obfuscated like they're trying to hide nuclear secrets
15:02
To be clear, I'm not talking about artists with Picasso level fame. I'm talking about artists with <1000 twitter followers.
I'm not going to find their gallery on the Louvre's website
@Kevin ooh! check their twitter accounts or their instagram pages. They probably self-promote a lot
I mean just try a few and see what google turns up. Will give you feel for it quickly
Now we've looped back around to the beginning :-) twitter is indeed what I'm trying to scrape and filter
Ok, I've tried google images on the first artist in my queue, who happens to share a name with a city in India. I get pictures of his artwork and pictures of the city in a 20-80 split.
Admittedly, most artists do not share a name with a city, so this is something of an outlier
15:06
oh?! I'm curious: what's the name of the artist/city?
Morbi, a municipality in Morbi district in the Indian state of Gujarat, and also the artist/writer of once-popular now-defunct webcomic Poppy O Possum
Actually in his specific case, scrolling through his timeline is aggravating not because of pictures of his cats, but because he retweets his old artwork about four times as often as he posts new artwork. So I don't necessarily need the cat detector for this one, just the retweet remover.
@roganjosh I am curious I am working on a item for the company I am at as a personal project and was thinking of using the flask-login current_user.position variable which will be set at registration to either manager, admin or teacher. And through this was thinking forcing redirects if their try access parts of the web app where you need to be a manager to use i.e. staff registration, student registration, class creation etc
@roganjosh Would be very curious to see I was thinking of using a similar system to the one used in the flask mega tutorial you guys recommended i look through a while back. As its simple to implement, however would like to see the way you suggest at some point.
@Kevin I've in fact never heard of this person nor the place. Cool bananas
Here's one possible reason you might want permissions that are more fine-grained than manager/admin/teacher: perhaps the manager of the Arts department should not have permission to create classes for the Science department.
Perhaps the manager of the Physical Education department is a good guy, but tends to destroy any computer system he touches, so he has no permissions, and his class creation duties etc are delegated to the Computer Science teacher.
15:24
@Kevin I get what you mean. Although it is an english adacemy so slightly less complex but the reasoning still stands, how would be best to set the permissions
why not use per-person permissions, possibly with defaults selected from roles?
in other words set up a separate table from the user information, possibly with literally just a link to the user table and a field for role?
A separate table keyed by user is a good start, certainly
I'd be inclined to have more than one field, though. Perhaps separate fields for "can register staff" and "can register students" and "can create classes"
Or something even more elaborate if you want to support "can create Arts classes, but not Science classes"
... That might need yet another table
@Kwsswart in a meeting for a bit, will send once I'm out
@roganjosh cheers man
@Kevin i get what you are saying maybe setting all to boolean fields so make it simple yes or nos for each permission
15:34
Basically yeah
@Kevin Cbg! In a past life, I worked in a project where permissions were structured like paths, so that Classes/create/* could create all classes, while Classes/create/Science could only create Science classes. It has been a while, and I think in retrospect I would probably put the create/read/update/etc. operations at the tail end of the path. But that was a pretty fully featured app, with many sub-domains and corresponding permissions.
long time cbg :)
I, too, am curious about what roganjosh's many-to-many design looks like. The simple design I have in mind uses a one-to-one table, and the complex design I have in mind is one or more one-to-many tables
@ParitoshSingh cbg :) I think I've seen you lurk. How are you?
Perhaps he's doing something with named roles, where each user can have many roles, and each role can belong to many users
15:47
Hey Andras. Im good! Got our festive season on the horizon, looking forward to it!
Even if perhaps this year we won't be able to meet many family members, but the break will be a welcome change :)
The benefit this has over hardcoding admin/manager/teacher into your model logic is that you can create new roles and modify the permissions of existing roles without having to change any of your code
@ParitoshSingh I hope you'll have a relaxing time :)
How about you all? how's things going?
@PaulMcG Hmm! IIRC my senior design project also used pathlike permissions. I don't know the fine details because I was more the JS man.
We got a nice grade so I can only assume that pathlike perms are good design 👍
@ParitoshSingh all's fine here, even if a bit insane :)
15:55
I have a higher proportion of insane-to-fine ratio than Andras, but I'm holding steady
"You merely adopted the madness. I was born in it, molded by it."
Ugh, coming back to a project after a few weeks/months after you decided you are too lazy to write unittests, because "it works" and now hating yourself.
Highly relatable
Also looking at code and being confused, because it can't even work at all like this. But being 100% that I manually tested this and it worked :D Oh Dante
I dug up an old project the other day that I'm 100% sure used to work, and it crashed instantaneously
15:58
@Hakaishin at least your thorough documentation and helpful comments will guide you
@Kevin Oh yes, that is very likely it. User <-> Role is many-to-many, and then the permissions are attached to Users and Roles alike (so that a user in Role "normie" can still be given special permission to "Blurb/Gornitz/frobnicate").
At least it was pretty easy to diagnose, as the error was ModuleNotFoundError: No module named 'urllib2'
I hate dredging up old code and finding it littered with Py2 "print" statements.
And some of us have a lot of old code...
@AndrasDeak hahaha, yes :D Well I could delete code, which is always my favorite part of coding :)
But it definetly doesn't help that the modules who have to interface with each other share 3 out of 4 letters and that they are just accronyms and totally meaningless. In the see of characters on the screen it's so easy to get them mixed up and I just did
That sounds fun to manage :P
16:07
yes, but the things already have between 2-4 words in them. And we didn't feel like writing out the whole thing.
I've been very happy with the refactoring/renaming capabilities in PyCharm, even changing names in comments and related .puml PlantUML diagram files.
on the bright side. That python package version numbers have to increase I always found annoying. Now I'm so happy to just see oh it's the newest version and not having to double check the sources :P
@Kevin thats what i was thinking a one to many table possibly from the user table to the permission table should be interesting
Style poll: d is a dict populated by json from a service I don't control. Should I do user_address = d["userAddress"], or userAddress = d["userAddress"]? PEP 8 says "be consistent with surrounding code", after all...
@PaulMcG yeah, they really got that one good
first
otherwise it will spread throughout. And this seems like a good point to make the conversion happen
16:12
@Kevin Well its a bit simpler of theres 3 main aspects in the company those that access and update class progress, those that search for details in the system, add classes, students and teachers and those that add students and use it simply to get details of students and classes
Hence why i was thinking using those 3 names to signify permissions
@Hakaishin Would love to find a good resource eto learn unit testing
ifyou have any...
not really sadly
@Kwsswart this isn't covered in the mega tutorial but the reasoning behind my setup is as Kevin suggested, but with one complication
@Kevin 100% user_address. JSON doesn't count as "surrounding code" because it's not code
For example, there were "unique" pages on my website such as a single page for stock levels. That's locked down based on a general permission. However, each department also had its own page which was a standard page just showing data specific to a department. In which case, I had another permission level, so it ended up being 3 tables
@Kevin Create a dataclass with var names in snake case, and then do obj = MyClass(**json.loads(config_json_with_ugly_java_like_names)). Then you can do obj.user_address.
16:17
I'm tempted to make a custom json deserializer that automatically underscore_cases all the keys
Use MyClass throughout your code to isolate from the vagaries of your not-in-your-control JSON input.
@Kwsswart this is a dpaste of the auth file for the dashboard. I did actually refactor it a bit to clean things up but I can't put my finger on that version right now
MyClass would nicely bundle all the troublesome camelCase into one conveniently ignorable section
@Kwsswart and this is an example implementation on a route
I think you'd need some code in post_init to do the actual name assignments, since MyClass's init will expect snake_case names, which you aren't getting.
16:22
Hmm true
I thought this was a no-brainer tbh. Create a pythonic interface for the API, and keep the camelCase stuff in there along with all the other API-specific stuff. What design decisions are there even to make here?
If you write your camel_to_snake JSON deserializer, then you don't need a dataclass, you could just use types.SimpleNamespace
@Aran-Fey Part of the problem is that I am conflating the camel-snake case issue with dict-namespace issue - my bad.
@Kevin don't let other people's mistakes leak into your own code
Create class method MyClass.from_json, and do the mapping there.
@Aran-Fey I guess I'm just once-bitten-twice-shy because one of my work projects uses ALLCAPS for table and column names, and the ORM uses PascalCase or camelCase for attribute names depending on accessibility level, and the front end uses snake_case for form element names...
16:26
@roganjosh will look at it in a bit just in a meeting it looks interesting
And sometimes the business logic needs to access all four of them in the same context and juggling them all has been a problem
I don't think this is uncommon, when you have front-end code in Javascript (typically camelCase'd), and back-end in Python.
Perhaps the lesson is not "strive for consistency between layers" but rather "encapsulate your code better"
That should make the decision easy then, right? snake_case all the way, no compromise
@Kwsswart No rush. One more piece to the puzzle, you can register a function in your app's __init__.py to allow for front-end validation too. Though if I was still working on that project I'd probably fix that function to not establish a new connection on every call. It went in years ago and I forgot to change it :P
16:30
If I went the no-compromise route, I might need to do _snake_case_with_leading_underscore in some places to avoid duplicate name declaration
Heh, I managed to pick some jinja for my example that didn't even use the function... but you get the idea :P
And the ORM may need to be tenderized with the ClueBat if I want it to map things to something other than PascalCase
Bad ORM! Bad!
@roganjosh - ok, so your many-to-many is User <-> Permission, where permissions are actual managed objects instead of just values like path strings. If you didn't make permissions actual objects, a User -> permission string table would probably suffice.
@Kevin For multiple duplicates, just keep adding more underscores to the front
@Kevin How would you end up with duplicate names? What kind of names are we even talking about? Instance attributes? Local variables? And how do you get duplicates?
16:33
user_address
_user_address
__user_address
...
@PaulMcG There's a good ~500 managed routes though, so I'm not sure I understand what you mean by "permission string"?
We were talking earlier about something like a path string to indicate object type and permitted operation.
@Aran-Fey For example, the ORM requires the User model to have the private attribute string _Address, and the public property string Address, which by default is a simple setter/getter on _Address
I know that recentish versions of C# let you magically declare private/public attribute/property pairs automatically, but I'm not sure the ORM allows that. It does some weird reflection stuff at runtime.
Student/update vs. Student/Humanities/update vs. Student/1729/update. The leading part is actually starting to look kind of REST-ish, and the tail end is the permitted operation.
I don't really get it. If the ORM requires a private attribute, then the _-prefix is fine. What would be different here if you were to compromise with variable names? Would you name the public one address and the private one Address?
16:39
What do you do if there is a JSON key or ORM attribute "_address"? I guess that is just discouraged.
In reality it's only a 5 min job to set up the base permission groups. Someone with Master access then can click a few buttons on the admin panel to configure new user with set departments and specific permissions. It perhaps is over-engineered but I start every project with this system anyway because I never want to preempt what I might need over project lifetime
Another case of Working Code beats Hypothetical Design
@Aran-Fey Oh, ok. I originally interpreted your advice to mean I should not be using the _-prefix.
Oh, I see. Nah, names starting with an underscore are still considered snake_case
03:00 - 17:0017:00 - 00:00

« first day (3636 days earlier)      last day (1536 days later) »