« first day (3447 days earlier)      last day (1501 days later) » 
00:00 - 21:0021:00 - 00:00

12:04 AM
@αԋɱҽԃαмєяιcαη instead of complaining start using your votes
 
@AndrasDeak Hola Bola. asking to know if there's something between lines which i didn't get :P
 
sometimes a cigar is just a cigar
 
but with Andras is just different :p ahah
 
Mar 11 at 14:27, by Andras Deak
@CeliusStingher please don't link bad questions for the sake of finger pointing. Actionable requests (cv-pls, delv-pls) are fine.
all in the spirit of that ^
 
@PaulMcG cbg, how y'all doing down there?
@PaulMcG What about One Proxy to Find Them?
 
 
6 hours later…
6:10 AM
cbg guys o/
 
 
1 hour later…
8:00 AM
^ gone. i will say, the question wasn't really a dupe per se, so much so as the OP was taking answers from one question, and then asking the next question for the immediate next problem without any thought into solving issues for themselves. I'll admit, i don't really know the correct procedure in such a case
 
8:28 AM
cbg guys
 
link no repro/solved
cbg
 
@shad0w_wa1k3r How are you ?
 
closed ty
 
cbg
@ParitoshSingh the user has an interesting bio
 
8:43 AM
heh, interesting :P
 
:)
 
9:02 AM
@superv doing good. How are you?
 
@shad0w_wa1k3r Not bad. Hope the corona siatuation isn't that bad overthere?
 
WTH today with me :( 1 2 And now 3
 
@superv It's not that bad, non-essential travel & entertainment places are restricted (work commute is allowed). Although, hate to say it, but getting bored working from home.
 
9:28 AM
mad world cbg all
 
@shad0w_wa1k3r It's hard sometimes. I can manage it on weekdays but not been able to go out on weekends is not desirable..lol
@JonClements fresh cbg ..:)
 
10:09 AM
CBG all!
 
@JonClements :D
 
I've been looking around for a quick hack to write python dict to text file as plain text..
the catch is I don't want quotes around the key or values..
d = {"path": "9/INCOMING/"}
but I need to write to file which looks like
{path: 9/INCOMING/}
 
json.loads ?
 
str(your_dict).replace('"', '')?
 
with open(k +".json", 'w') as f:
json.dump(v, f, indent=4)
i've tried f.write(json.dump(...)) as well... it still shows up
@Aran-Fey Doesn't work
Ooh! close one @Aran-Fey
I had to replace it twice .replace('
.replace('"', "").replace("'","")
Thanks. I could live with that.
 
10:24 AM
with open(my_file, "w") as f:
    f.write("{")
    for key, val in my_dict.items():
        f.write(key)
        f.write(":")
        f.write(val)
    f.write("}")
Safer because your dictionary values may have " that might get replaced.
And you can always indent as you like.
(assuming values are only strings, if they are themselves iterables, you need to handle a lot more)
 
cbg-ning
 
cbg
 
cbg
 
Thank you!
 
10:33 AM
@ParitoshSingh downvote, mostly :(
 
@d-coder you're welcome. I forgot the commas by the way.
 
Fun fact: found someone who has a working bot today: stackoverflow.com/users/11518920/jamesbot
 
11:12 AM
plenty of working bots on SO
 
dealing with string looks like a bunch of comma-separated JSON objects , trying to loads it but still couldn't figure a way to.
 
"comma-separated JSON objects" is not valid JSON
if that's really the case then it's missing an enclosing pair of '[' ']'
In fact json.loads(f'[{data}]') works. But this is a good sign that someone broke something badly, and this is just a crappy workaround. Convince the source to take a step back and fix the actual data.
for instance you now have to wonder whether strings are encoded properly etc.
 
@AndrasDeak Thanks a lot for the clarification. that's very new to me json.loads(f'[{data}]')
 
11:28 AM
it's just an f-string, the alternative is '[' + data + ']' (which is also fine, since data is already a string)
 
@AndrasDeak you know that my real data is actually including [] but i just left it because i thought that's will not make sense to take the enclosing pair of '[' ']'
you've correct a big point for me just now :P thanks a trillion
 
@αԋɱҽԃαмєяιcαη anytime
 
11:52 AM
Why do you make me do it myself tho ?
 
@domocar1 Are you serious?
So you're asking "why are you making me write my own code rather than writing it for me?"?
 
So you won't write it ?
 
@domocar1 I see you're catching on
 
I was just asking for help. I could study python afterwards.
 
11:57 AM
@αԋɱҽԃαмєяιcαη you really should start teaching askers rather than spoon-feeding them with a block of code.
It's no surprise that your askers keep asking multiple questions all the time. You're teaching them to cargo cult
@domocar1 please do.
 
@AndrasDeak You know. sometimes i explain all. sometimes not. it's all depending on the OP. if you have checked my previous answer for the OP which open a question multiple times, i've explained every single line. and even asked him about his target but he kept confirming that he know all.
 
@domocar1 I kicked you because we "don't have time to waste it" helping a needy person cheat on their exam.
 
for the current question. the OP didn't shared what he want to extract exactly. i got tired from explaining that requests package couldn't render JS on the fly.
 
@αԋɱҽԃαмєяιcαη I only saw a few of your answers on a previous serial asker and I only saw blocks of code. I'm glad to hear that's not always the case.
 
@AndrasDeak you never cheated on exam ?
 
12:01 PM
@αԋɱҽԃαмєяιcαη when that happens you don't write an answer. You vote to close as unclear, or a duplicate.
@domocar1 nope.
 
@AndrasDeak poor guys sitting next you if they needed help
 
@domocar1 yup.
 
@domocar1 I used arcane magic called studying
 
TIL: arcane
 
12:11 PM
@αԋɱҽԃαмєяιcαη It looks to me to be jsonlines which is used for some technologies like bigquery
 
@αԋɱҽԃαмєяιcαη that's not a close reason
 
is it allowed on SO to go step by step with a code ?
i usually see this issue but idk what shall i do with it ?
 
@αԋɱҽԃαмєяιcαη unless you find a close reason that fits, yes
2 hours ago, by Andras Deak
@ParitoshSingh downvote, mostly :(
 
in your opinion, that question can be flagged ?
 
12:19 PM
I don't have time to check nor domain knowledge
 
well, sometimes these are duplicates (to the old question) or too broad (failing to make it clear what more information is needed).
 
@MisterMiyagi thank you
 
FWIW, IMO most scraping questions are very poor and deserve no more attention than a downvote. They're the modern day equivalent of "how to regex this?".
 
As far as I know, asking a series of questions that are obviously just a way to get SO to do your project for you is not, by itself, against the rules.
99% of the time this is not a problem because if the person is too lazy to do their own work, they're too lazy to write a good question, so you can find another reason to downvote and close the posts
 
how would you guys store images (like in a sql database)?
 
12:23 PM
In the 1% of cases where the question meets community standards, I just grumble and close the tab
 
@Permian you don't. You store it somewhere else & store the location of that somewhere in the database.
 
ok
so do you store the location(url?) of an image in the db?
 
what do you store the images in?
 
I think in the dustier corners of my db, we've got an image column or two. They use the BLOB type, IIRC
 
12:24 PM
lets say i have the image location in an sql database
 
Do you also store a hash/checksum?
 
ooh that's a good shout
 
I don't know, but if I had to guess, probably not
 
if you are not working with a Python related framework, the question is off-topic here. But if you are, then there are helpers / built-in functionality that helps with image storage (it manages where it's stored as well as the database part of it)
 
181
Q: Storing images in SQL Server?

markoI have made a small demo site and on it I am storing images within a image column on the sql server. A few questions I have are... Is this a bad idea? Will it affect performance on my site when it grows? The alternative would be to store the image on disc and only store the reference to the ...

 
12:26 PM
@Permian check
 
Hey this looks useful
 
wonder which leetcode problem needs images in a database :P
 
nice find Kevin, interesting answer on that as well. Didn't expect the tradeoff threshold to be as high as 256KB
 
@AndrasDeak none and dont knock me!
@Kevin thanks
@αԋɱҽԃαмєяιcαη and you
 
12:41 PM
@Permian Consider storing all metadata, not just the location. A good minimum are what tools such as rsync use, namely location, size, age and checksum. If your use-case requires other meta-data, such as users, permissions or xattrs, store them as well.
 
12:52 PM
Don't reinvent the wheel, please use a standard library / tool.
 
1:14 PM
I'm a little surprised that sorting images in the file system is the conventional solution. If you had asked me an hour ago to give my opinion without looking anything up, I would have guessed that you should avoid putting file paths in your db, since it might increase the surface area of attack for malicious users
 
Metadata DB + Data Filesystems is basically how the LHC Grid works.
 
Maybe the bad guy will alter the path to ../../../../whatever.png and see what error message is returned, in order to probe your directory layout. Maybe the bad guy will alter the path to whatever.png; rm -rf in the hopes that you're interpolating the file names into a shell command without sanitizing it first
Both of these are easily enough defended against, of course, but my point is, it's still a nonzero amount of work to defend against, compared to the theoretically zero amount of work if you had used a blob
 
Basic SQL good practice would make that impossible?
 
Hmm, please elaborate
 
The way we do it, the user just has access to logical file names (basically URLs) and cannot access the physical data directly. Everything that hits the real world are UUIDs.
 
1:23 PM
The defenses I have in mind, I'm not sure I would categorize as SQL good practice specifically
 
I thought that we basically insinuated the same thing at the same time. Wouldn't parameterized queries prevent actually trying to execute that path? Worst case would be that the server would have an internal error if it tried to read the altered path subsequently? And I'm not sure how the user is given a route to interact with the image path in the first place?
 
@Kevin A merry band of mighty dwarven warriors?
 
I'll give more details about my imagined scenario. You have a web form that lets users upload images to your server. The server then passes the image through imagemagick.exe to apply cool filters to it, and returns the result to the user.
The bad guy clicks "browse", and chooses an ordinary image file. In the "filename" field, he enters "../../../../whatever.png" He clicks "upload".
Using best-practice paramterized SQL, you dutifully record in your db that user badguy1 saved a file with the name "../../../../whatever.png" at 9:30 AM. You then save the file to "C:/programming/Python/projects/cool_filter_site/" + user_filename.
 
Ok, but in that case, "../../../../whatever.png" is a path on the bad guy's system. If it's a path to an image on the user's computer, the server just receives the image
 
what you generally do is store that as the "uploader said it was named", but give it a random name physically on your fs
 
1:31 PM
Problem: the file is now saved at C:/whatever.png
 
so for instance... you could upload to imgur saying it's whatever, but it's going to save it as 6N8tY.jpg or whatever it wants
 
Nor would imgur care about the local path you gave it when navigating to them image on your system, surely?
 
@JonClements Excellent idea, and that's roughly what I had in mind as a countermeasure. But I don't consider that a SQL good practice
Because you should be doing that regardless of whether SQL is involved. If anything, it's a file system good practice
 
I don't browsers ever send a path anyway in the actual filename in the content-disposition header
 
"Kevin, did you really spend an entire page of chat in order to challenge the semantics of a single word choice in an informal conversation?", asks the hypothetical reader. Yes, yes I did.
 
1:35 PM
I didn't think so either, I'm setting up a test case now
 
@JonClements For an ordinary file-upload prompt? I think you're right. I'm supposing a pretty shoddily-written nonstandard form here
But "write good HTML forms" is also not a SQL best practice :-P
 
so you'd have to not use a browser and create your own payload for it
and most systems aren't going to care about the filename even if you pass it one - it's just a hint...
 
@Kevin Doesn't that all fall under "don't trust users", which is an SQL best practice?
 
like when you save as... and download as a file... the browser will use the filename= given to suggest the initial name and will suggest your default download path/last used path, but nothing stopping you as a client changing the name and/or path... the server won't know/care either
 
In this contrived web app, there is both an "upload" button and a freestyle "filename" textbox, because user images are stored for 30 days, and we want the user to be able to upload the same base image more than once and apply different filters to it, and save it under different names on the server, and keep them from overwriting one another
 
1:39 PM
meh... that'd just be stupid... you'd save it named whatever you want (probably just save it as the image look up primary key)... and then when they request some hacky path name, you just return the data from the correct file you've saved -
 
But then, a freestyle "filename" textbox would still be a path on the client's side, so if they put something wonky in there, SQL projection would stop it ever doing something wonky to your own query and they just broke their own user experience?
 
On the web filenames don't even really matter. It matters more serverside (to decide what to do with the file). Otherwise pages will just keep getting downloaded... I've not really picked up the transcript very far, but relative file paths are always preferred.
 
@roganjosh I agree that in my contrived example, the bad guy has no way to do something wonky to the sql query. The database is 100% safe. Nonetheless, they have successfully saved an image to C:/whatever.png.
Good thing they didn't overwrite c:/windows/system32/wincorlib.dll, that would be pretty bad
 
Mm, I think I see what you're saying but it seems to be contrived enough that such a developer would have some glaring other mistakes along the way. Maybe not SQL related, then, but basic understanding of not trusting users full stop. I imagine their app is broken in plenty of other ways :)
 
@Kevin your hypothetical example runs with admin/root privileges, of course?
 
1:50 PM
@Kevin except unless it's a completely irresponsible system - they haven't.... the server has saved it as 12345 under /some_system/files_storage/clients
 
@MisterMiyagi Yep, and with antivirus turned off because all the red flags were giving the sysadmins a headache
 
Why do you call that "hypothetical"? Let's be real here, folks...
 
Even without root, the bad guy could probably have some fun by overwriting ../bin/cool_filter_site_main.py with his own custom server code
<marquee>this page has been hacked by Badguy1</marquee> plus an embedded youtube window playing a rickroll, plus a javascript bitcoin miner
 
"Memory ineffective. To add more, often RDBMS’s are RAM driven"
arent all computer programs ram driven?
 
I think "RAM driven" in this context means that the database stores its tables in process memory rather than saving it anywhere in the file system
 
2:00 PM
strange
 
Hmm, but looking at that sentence in its original context, I'm not completely sure that's what it's saying there
 
@Kevin lol!!!!
 
The model it's proposing sounds more like "the data is in the RAM before it is saved to the file system"... Which is pretty much how anything is saved to the file system
 
@Kevin well... WAL are very much a thing
 
Maybe it's saying that the data has to be duplicated in RAM while the db converts the raw data into a form suitable for insertion? Compare to directly saving the raw data to a file, which ostensibly requires no duplication
@JonClements Good example.
 
2:09 PM
I think it's possibly saying something along the lines of "Imagine if you had a query such as `SELECT image FROM user_uploads WHERE user_id = ? ORDER BY datetime DESC LIMIT 1;". In which case, you've had to store all of the image BLOBs in memory during the whole query execution, only to ditch them after the sorting and return only 1 image"
 
I'm going to chalk this up to "RAM driven" meaning "uses more RAM than you might otherwise expect"
 
If you instead stored only the file paths, you don't physically have the image data in RAM
 
algorithm recommendation; offtopic, migrate to DataScience.SE stackoverflow.com/questions/60831843/…
 
@smci I'd guess that's too poop to migrate
 
@AndrasDeak Ok, then CV as 'needs focus'. Either way, it needs to be closed here, and I wanted to point the OP to DataScience.SE
 
2:16 PM
Semi-related problem. Suppose my database contains many tables, designed by many developers, which are written to and read from by many projects that I've never touched. Should I just assume that every string I take from the database is untrustworthy? Or is there some idiomatic way to mark some columns as "never touched by an end-user" and others as "possibly touched by an end user"?
I could probably make an educated guess just from the column name. user_name probably contains user input. user_country is a more tenuous bet. It might have been sanitized already to ensure that it's a two letter ISO-compliant country code... Or maybe it hasn't been.
 
@AndrasDeak -1 It's still valid and relevant to all of us to compare Python to non-Python web frameworks. (Now if they start asking JS-specific questions, that's off-topic)
 
I can't accept "just trust that all user input is sanitized before being inserted", because santization is context-sensitive. For example, maybe user_name has been sanitized to ensure it contains no javascript, but it never occurred to the original dev to check for XML bombs.
 
@Kevin Suppose there exists such an idiomatic means. Suppose you find it. Do your fellow developers know it as well?
 
In my imagined perfect world, yes they do. It's in the standards and practices document that everyone has read and tries to uphold to the best of their ability.
If the standard is "always end an unsafe column name with _UNSAFE", then I trust my imagined perfect coworkers to do so
 
@Kevin Interesting. Does your database engine have a concept of per-table role permissions? (unlikely) And is each table only written to by a single user, or how could you even get a list of all users who had written to it?
 
2:24 PM
FWIW, I'd also like to know if there was a general convention for this. I can't seem to find one and I've not encountered it mentioned before
 
@MisterMiyagi Yes, sadly. These days I downvote and close 99% of them [scraping questions]. 1% are useful or improveable, I try to comment/upvote/edit-improve/retag/retitle them. The Prayer of St Francis, if you will.
 
My gut tells me "putting 'UNSAFE' at the end of the column name is overkill. Check the comments for the column, and/or the documentation for the table/schema, to see if it is explicitly mentioned as being safe or unsafe. In the absence of explicit information, assume it's unsafe."
 
@roganjosh For efficiency, to prevent sanitzing every single read-access, presumably you have an unsafe and a safe db or table, users can only write to the unsafe one, and some role with higher permissions sanitizes them and copies them to the safe db/table.
 
@smci Well, I've just been browsing around postgres admin panel and in the same window that you could set access privileges are security labels but I can't work out what, exactly, they are for
 
@smci Let's see... Yes, the engine has per-table user permissions. I don't think it has automatic logging of all users that modify a table, but we have implemented custom history logging for some particularly sensitive tables.
 
2:33 PM
Since this question remains unhandled, I'm guessing that they're not widely used even if they could be used to label a particular column "user_changeable", or whatever flags you wanted
 
I know all the tables under my project's purview can only be written to by a single user, but I can't make any promises about all the other tables.
"classify all users as either safe or unsafe. If a user is unsafe, all tables they have write access to are also unsafe. All other tables are safe" is an attractive design... A bit hard to impose upon a legacy db, though
Or at least it would be in my specific janky setup, where I can't easily find a list of all users across all projects and their table permissions
Maybe that is easy for sane setups where the dev/qa/prod environments match each other very closely
 
2:52 PM
@roganjosh SQL Server (and presumably Oracle) support per-table permissions.
 
So does Postgres. I was just looking to see whether there was something more fine-grained
 
Apparently Oracle provides per row permissions, but I think you need to buy their expensive enterprisey package.
 
It suggests that table_name.column_name can be used as a basis for a security label, but I can't work out whether this is just metadata or actually enforces something
 
I don't think it's sensible to flag fields as "safe" in the way discussed here. There is some application out there that mishandles your data, no matter how it's sanitized.
Your data may be safe for regex, or Python, or JS, or bash, but someone, somewhere, out there will feed it to PERL.
 
Hmm, true. Even if a column is guaranteed to never be touched by a bad guy, maybe it contains "rm -rf" for perfectly legitimate and sensible reasons, and woe to any who would send it to a shell
 
2:55 PM
the kid might just be called Bobby Tables
 
Ahh there we go... just got the nice text from the government...
 
In the specific case of my user_country scenario, I wonder if there are any environments that could be pwned with only two characters of unsanitized user input
Points for this exercise are awarded on the plausibility of the environment actually being in a real tech stack. Making a two character Pyth program that segfaults is worth less than a two character bash fork bomb
 
well, we have some systems that grind to a halt if you repeatedly execute ls in the right place, so....
 
@Kevin which reminds me:
in CHATLAB and Talktave, Mar 11 at 13:36, by flawr
@LuisMendo regarding language design: "Every syntax error is an opportunity to pack in more functionality."
it might be very hard to write that pyth program :)
 
If there are 65,000 syntactically valid Pyth programs of length 2, then surely one of them will delete system 32 and set the cpu on fire
 
3:06 PM
@Kevin [citation needed]
 
I'm pretty sure I've seen a golfing esolang where every single unicode character is a valid instruction. That gives us considerably more room to play around
 
import os
os.self_destruct(True)
I think it works on all platforms too =)
 
@bad_coder please don't advertise fresh questions on main here. Even if it's not yours.
 
@MisterMiyagi I could brute force it and run every program in a virtualenv, but I'm not sure I could trust the virtual environment to properly simulate bursting into flames upon reaching a critical cpu temp
IME very few computer emulators simulate the thermodynamics of their hardware. Alas.
 
3:26 PM
Also it would be hard to distinguish between a program that loops forever, and a program that sleeps for 24 hours and then deletes system32 and bursts into flames
The Halting Problem is impossible in the general case, but maybe it's tractable if you limit it to programs of length 2...?
A hypothetical Tiny Program Haltingness Detector would not fall afoul of the usual impossibility proof of the Halting Problem, which relies on feeding the source code of the haltingness detector to itself. the T.P.H.D. I propose would have source code substantially longer than two characters, so you wouldn't be able to run it on itself anyway
 
@AndrasDeak Sorry I wasn't aware of that rule. Won't happen again. Thanks for the heads up.
 
@bad_coder it's alright, thanks :)
if OP is still struggling in a day you're welcome to ask again here
 
@AndrasDeak I appreciate your solicitude. I will keep these indications in mind henceforth.
 
I'm curious if any research has been done on this. is it possible to create an "N-size Halting Oracle" that can always determine whether a program of size N or less halts?
An N-size halting oracle would be less powerful than a conventional generalized halting oracle, which is allowed to accept an unlimited amount of input
I'm inclined to say that no, even this less powerful category of halting oracle is impossible. If you have an algorithmic way to create N-size halting oracles, then that algorithm is equivalent to a generalized halting oracle, which we already know can't exist
But perhaps I'm handwaving away too much by assuming that you can algorithmically generate N-size halting oracles for arbitrary Ns. Maybe an N-size halting oracle exists for every N, but no algorithm exists to generate them, and you have to use squishy human ingenuity every time.
 
3:44 PM
When you account for squishy human ingenuity in theorems things get weird. I think that's how the axiom of choice happened...
 
As a materialist, I don't think human brains are more powerful than a Turing machine, so I'm really just kicking the can down the road
I'm not sure if/how you could formalize the concept of "a sequence of numbers that can't be generated by any algorithm, but you can write an algorithm that takes a number and returns either 'that is not in the sequence' or 'that is element number X of the sequence'"
 
4:10 PM
Or would such an algorithm be equivalent to a halting Oracle... This is cooking my noodle
 
Help!
5
A: How to unistall python3.5 and re-install python3.7

Lê Tư ThànhThis answer follow this link You need to download python 3.7 first (example: You download to /usr/src/). Click here to download Then install prerequisites: sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqli...

I installed py37 but I am unable to pip install without using sudo or --user
 
219
Q: How to install python modules without root access?

RishiI'm taking some university classes and have been given an 'instructional account', which is a school account I can ssh into to do work. I want to run my computationally intensive Numpy, matplotlib, scipy code on that machine, but I cannot install these modules because I am not a system administra...

Jan 19 at 11:47, by shad0w_wa1k3r
I would quite prefer using sopython.com/chatroom instead of tinyurl.com/s2plygp as our Room Rules URL (room description text on desktop website). It is only 2 characters extra (does not cause an extra line of text), directly shows our domain & does not even show up on the mobile page (so not affected).
Code formatting guide URL can stay as is since it's actual URL is way too long & it's not as important as the chatroom page.
@AndrasDeak any update on this?
 
room topic changed to Python: Room rules: sopython.com/chatroom Code formatting guide: tinyurl.com/urnzp7k [no-covid-talk-pls] [python] [python-2.x] [python-3.x]
 
4:25 PM
Thanks :)
 
At least two people have suggested this, which is close enough to a majority vote I guess ;-)
100% of all the people that have an opinion on the matter are in agreement
Hmm, I finally unlocked the shop in Animal Crossing, but it opens at 8:00 AM, which is when I clock into work... This is a problem
I can't make optimal use of my 7:00-8:00 Me Time if I can't sell my day's catch of fish and bugs and cool rocks
Playing with my nintendo under my desk is against my moral code, and so is moving the nintendo's system clock back by an hour
I could move my work hours forward by one, but then it conflicts with my 4:00-5:00 Me Time, when I play Minecraft
 
4:40 PM
@Kevin Consider what an n-size program means. If we are talking source code, then there is some arbitrary interpretation of this code. E.g. a size 10 code interpreted by Python and Ruby are different things. In this manner, even a 1 bit program can mean literally anything.
 
@shad0w_wa1k3r I'm informed it's already been taken care of. (sorry :P)
 
@Kevin I retro-concur
 
@MisterMiyagi Right. The typical formulation of the proof of the Halting Problem doesn't even involve a "language", really. It's all just algebra. There isn't much of a coherent concept of "size" in that specific context
But perhaps you could create an isomorphism between that and actual cells & tape turing machines, which perhaps do have a coherent concept of size
Although taking into consideration the fact that classical turing machines have an infinite amount of cells and tape, makes it a little harder to formalize a description of one into a single finite number
 
@AndrasDeak thanks for the update :-p
 
5:00 PM
what is the correct way to iterate a lsit
 
for item in my_list:
 
@Kevin You could probably define size akin to "minimal number of instruction given Turing Machine / Lambda Calculus" but that has an entire storage room full of cans of worms attached.
@Permian iterating it
 
I suspect you are about to say "but that's what I'm doing, and my code is still broken". In the future, consider asking directly about your problem rather than stating a rhetorical question you already know the answer to
 
how bad is
for i in range(len(list_name)):
 
5:02 PM
@Kevin no its about code style
@MisterMiyagi why?
 
A) it hides the intend of iterating the list B) it's slower C) it's less generic D) it duplicates the list's preexisting iteration code
 
90% of the time, for item in my_list: is sufficient. In the remaining 9% of the time, for i, item in enumerate(my_list): is sufficient. In the remaining 1% of the time, for i in range(len(my_list)): might be appropriate, after all other designs have been rejected
 
@Kevin ok thanks guys
i did this in a faang interview
they didnt like it
 
5:21 PM
wow... this is a borked system... it uses || to delimit rows, and | to delimit columns... take a guess what whoever did it this way forgot about...
 
The fact that the row delimiter is basically using the column delimiter twice? funnily enough, can't even imagine a row delimiter for some reason
 
Can it handle strings with pipes inside them?
 
i always think of rows as just..like rows. but i guess newlines are usually the row* delimiters in csv files eh?
 
Basically yeah
 
@Kevin nope... nor blank columns
 
5:24 PM
just stick a "\0" in there, problem solved
 
boom. rowsted
which almost sounds like "row instead" mashed together
i'll show myself out the door now.
 
I too have suffered under an ad-hoc pipe based delimiter format. Except sometimes it used colons as a delimiter.
 
previously when I've worked with the charity commission's database... that was also intriguing:
There are 15 output files, each corresponding to a table in the extract. The files are BCP files (extension ‘.bcp’) which, due to embedded characters in the data, have the following delimiters:

@**@ for columns and

*@@* for rows.
 
:-I
 
petition to use unicode emojis as delimiters
 
5:34 PM
wtf... this is even more confusing... for a certain column - if there is no data... it will fill with 0... however, 0 is a perfectly valid value - so.... wow...
I hope whoever paid for the system to be built didn't pay too much for it :)
 
@JonClements empty columns?
 
@Code-Apprentice yup... bit late to the table - it's been mentioned above... but yes :)
 
yah, I been working. Just taking a break to catch up on chat
 
cool... how's work going?
 
good for the most part
my company has shifted to work from home. Had to take my setup from the office and find a place to set it up in my aparement
 
user10984358
5:46 PM
If there is a Wordpress or any CMS and I would like a page to have some content taken from my python script how do I do that? I thought about having a flask endpoint and making the CMS request that endpoint, is this possible? also I am sorry if this not python related and has to do with CMS
 
The Internet tells me that Wordpress has a plugin system that developers can use to extend the system's functionality. If you can't find anything ready-made, there's always that.
 
user10984358
the answer I saw on SO was this wordpress.stackexchange.com/questions/120259/… I guess my search terms were off
 
user10984358
I guess this has got more to do with CMS dont want to pollute the room any longer, thanks for that nudge though
 
6:07 PM
@TheNamesAlc Do you have an existing CMS site? If not, you might want to look into libraries that build a CMS on top of flask directly. Then you can do everything in python and not switch between php and python.
 
@Code-Apprentice @TheNamesAlc I'm keeping an eye on wagtail these days - although it's built on Django, it's a kind of CMS that's a Flask to Wordpress's Django (if that makes sense)
 
user10984358
I dont, I just wanted to try a CMS in this "downtime" so I was looking into options, Wordpress seemed popular, also came across Ghost
 
@TheNamesAlc that sounds like something good to learn. Wordpress is written in PHP, so I'd start with the basics before jumping into mixing Wordpress with python and flask. If you're goal is to integrate a CMS with flask, I'd look into a CMS that's written in python instead. I know there is a 3rd party CMS library on top of django. There might be something similar for flask.
 
user10984358
makes sense, I have a couple python scripts that generate some useful csv (to me), so my end goal is to have a CMS read data from these scripts that generate these csv and display, then I can proceed further, thats the plan so far
 
user10984358
I know I could do this with a full on flask approach but like I said, I wanted to see what's the whole thing with CMS, looking into wagtail now
 
6:32 PM
how can I search SO by questions asked by me and answered by a specific user?
 
user10984358
6:42 PM
probably regulars know better but I just did a google spree, api.stackexchange.com/docs/…
 
user10984358
gives answers by piRSquared so you can leverage the api to write a script that compares the response? pretty sure there is option on the GUI, I cant find it :/
 
wim
@AMC ugh, happens all the time. here's one from a few hours ago, out of 4 answers there are 3 reasonable and Pythonic then one is a horrific one-liner. you can guess which the OP accepts 😒
homework dump attracting flies stackoverflow.com/q/60836205/674039
 
7:19 PM
does someone know a dupe for printing str and dict[str] looks differently?
@wim ugh. Why do people love **{ so much?
It's like... cutting off your foot, shooting it, then re-attaching it.
 
wim
I don't know but it seems to be n00bs that love it (and lambdas)? It's counter-intuitive, you would think that beginners in particular would prefer the more simple and easy to understand style of code than pseudo-functional style stuff.
 
If they would be doing it right at least...
**{<pairs>} in a dict literal is exactly equivalent to <pairs>, just with a metric ton of cargo cult on top.
It's a wonder they didn't iterate the list by index...
 
user10984358
7:51 PM
@wim best of both worlds :p
 
user10984358
>>> t
[{'a': 11, 's': 21}, {'a': 12, 's': 22}, {'a': 13, 's': 23}, {'a': 14, 's': 24}]
>>> list(map(lambda x:x.__setitem__('s',str(x['s'])),t))
[None, None, None, None]
>>> t
[{'a': 11, 's': '21'}, {'a': 12, 's': '22'}, {'a': 13, 's': '23'}, {'a': 14, 's': '24'}]
 
user10984358
I wanted to sneak in ** but couldn't :/
 
fresh cbg everyone
 
@wim delvable
 
8:16 PM
hmp = dict( '(':')', '[':']', '{':'}')
it doesnt like that but python dictionary keys can be strings and the value can be anything
 
Colons don't belong in function args.
 
wim
you have to use literal not function call
i.e. {'(': ')', '[': ']', '{': '}'}
 
@PaulMcG why not?
@wim hmmm
 
same as list(1, 2, 3)
 
wim
this would probably look better though
pairs = "()", "[]", "{}"
hmp = dict(pairs)
 
8:19 PM
or this dict(['()', '{}', '[]'])
 
> I'm currently using numpy in python 3.8.2 64-bit for a clustering problem, on a machine with 1.9 TB RAM. When I try using np.zeros to create a 600,000 by 600,000 matrix of dtype=np.float32 it says
"Unable to allocate 1.31 TiB for an array with shape (600000, 600000) and data type float32"
:'(
 
ok thanks guys
 
@Permian Eh? It's not valid syntax
 
no, you know what, i don't care. i've determined that i'll be happy with my 8 gigs of ram.
... i can't do it Andras... D:
 
wim
whatever the successor to stackoverflow is, I'm thinking it might need to have some kind of verification stage to ensure that a question is on-topic before it can start accepting answers.
 
8:30 PM
i usually getting an issue with fstring while trying to skip quotation , like trying with '' ''' ''' """ """
something like
"{\"Command\":\"LOD\",\"Text\":\"-\",\"ClientState\":{\"value\":\"\",\"text\":\"\",\"enabled\":true,\"logEntries\":[]},\"Context\":{\"Text\":\"-\",\"NumberOfItems\":0},\"NumberOfItems\":0}"
i would like to fstring NumberOfItems value
so i can loop over with passing a value to it.
 
im not quite sure what the question/issue is, could you simplify a bit, and show how you're writing an f string as well?
 
f"""{\"Command\":\"LOD\",\"Text\":\"-\",\"ClientState\":{\"value\":\"\",\"text\":\"\",\"enabled\":true,\"logEntries\":[]},\"Context\":{\"Text\":\"-\",\"NumberOfItems\":{}},\"NumberOfItems\":{}}"""
will lead to SyntaxError
 
I'm getting deja vu?
Why is your JSON escaped like that?
 
ye that's kinda weird, that's completely unreadable and I'm sure there are better ways to do whatever you're tryaing to do
 
also, knee jerk reaction, why not just make the dicts correctly, and convert to jsons only at the end?
 
8:42 PM
but your error comes because you can't have \ in expresion statement
 
A sensible knee-jerk, though :) Seems to me that something has gone wrong earlier on in this process
 
If you are using triple double quotes, the internal backslashes are unnecessary
And what is the purpose of empty {} in an f-string?
 
@PaulMcG indeed going to pass a value to it.
i will revert back to correct the JSON from the start
 
+1
Don't create JSON with f-strings. Create a dict, and then use json.dumps to get the string.
Then issues like "I want to assign the value of NumberOfItems" become simple dict element assignments.
 
00:00 - 21:0021:00 - 00:00

« first day (3447 days earlier)      last day (1501 days later) »