« first day (3890 days earlier)      last day (1065 days later) » 

3:53 AM
@fra-san Here is a public version of an older specification in which it's §4.1.2.3 "Representations with reduced precision". For this case in particular, you preprocess the lower bound with s/(-01)*// and you get exactly the desired result for these cases, including for entries with only month precision. "2015" is a year, "2015-04" is a month, "20" is a century (n.b. the 21st)
If you want fuzzy matching, like "2015-02-01—2015-11-30" probably includes "2015", you need another approach, but for these cases select * where date >= (CASE WHEN $lower GLOB '*-01' THEN replace($lower, '-01', '') ELSE $lower END) and date < 2015-12-31 works for any interval that is guaranteed to include the actual date on the low end and possibly includes it on the high end
 
 
5 hours later…
8:39 AM
@MichaelHomer Thank you for the link.
Sounds like a reasonable approach, yes.
 
 
3 hours later…
12:00 PM
@jesse_b that hat look like it came straight out of a game :D (this is cool)
@JeffSchaller /dev/null or /dev/zero? ;) I mean you could go with /dev/random but...
@Kusalananda It kinda depend. If it look like a single simple command, behind the hood, it could use more instructions or more resources than another [alternative here]. Because single simple command = trivial doesn't necesarily mean it's as "single" as it seems (eg: python command but it call tons of external command, etc)
 
@NordineLotfi ... but it's already filled with /dev/random :)
 
@JeffSchaller Nice. call me when you become a singularity
er, maybe phone won't exist by then, nvm
 
> a point at which a function takes an infinite value, especially in space-time when matter is infinitely dense, as at the center of a black hole.
"infinitely dense" isn't far off
 
@JeffSchaller I don't know, I can still jump high enough so I don't think you're dense enough yet ;)
maybe use /dev/urandom too just to be extra sure
also, I'm trying to convert a bash script to a ash version/sh version: is there any guide or doc that could help doing that?
looked around but I only see bash documentation...
 
@NordineLotfi my instincts would be to try shellcheck (copy/paste the script, change the sh-bang); and/or a VM/container where you can safely execute it. "null out" the external commands in some sort of safe way, etc.
 
12:10 PM
@JeffSchaller oh, the shell check idea is a good one; will try it thanks :D. I did thought of doing the VM thing since I have a sandbox/playground for that on qemu but given this might be doing parallel job, it might use too much Cpu, so prefer to do that natively if possible
 
I already found some trick to make this bash script faster; you or other here might already know that one or find it interesting:
@StephenKitt Thanks, didn't thought of rechecking there :D (guess i missed that)
 
@NordineLotfi that's what I meant about "nulling out" external commands -- have the CPU-intensive program turn out to be a "sleep 1" or something innocuous
 
@JeffSchaller oh, you mean so it can be easily debugged? that's a good idea yeah
 
@NordineLotfi Debian also has a checkbashisms script in the devscripts package
 
12:12 PM
@NordineLotfi just so you can focus on the shell aspects instead of the external aspects
 
I guess I could use the trick I picked up recently and use $SECONDS as sleep argument
@StephenKitt didn't know, Nice
@JeffSchaller yeah, i see what you mean :)
 
How big is the script, @NordineLotfi? If it isn't hundreds of lines, it should be easy to spot the bashishms.
 
@terdon it's like less than 20 lines. I guess it should be easy as you said, yeah.
right now I noticed process substitution doesn't work under sh/ash
(eg: <())
 
@NordineLotfi yup, you have to use a FIFO instead
 
@StephenKitt so, do I use some unknown trick or is mkfifo the only solution? :D
 
12:17 PM
@NordineLotfi it’s described in the link I gave above
 
@StephenKitt gotcha. Last thing i noticed: the link you gave me is about dash right? is it the same syntax as ash/sh? (like 100% same?)
just want to make sure
 
@NordineLotfi you can just post it in here if you want. Or, even better, ask a question on the site where we can give you a translation to a portable version.
 
@NordineLotfi it’s supposed to implement a POSIX sh, it’s the Linux port of ash
 
For example, usually you can replace while read i; do ...; done < <(command) with command | while read i; do ... done.
 
@terdon right, that's true. I did want to do it but preferred to try and fix this myself :D (that's usually what I try to do so i can learn more)
@StephenKitt I see. Interesting
 
12:20 PM
Good for you! :)
 
one question I had concerning FIFO: I know it's technically a temp file, but say, if the input you send to a FIFO is bigger than your memory/local remaining disk space, would it buffer it per chunk like a pipe would, or?
essentially, I never used it much because I thought it would fill my remaining disk space/ram if the file was bigger than it...
 
@NordineLotfi not sure what you mean by “technically a temp file”; it’s a FIFO, and behaves like a pipe, writers are blocked when there are no readers
 
@StephenKitt I see. I meant technically a file because it has a inode, but I guess it was a misinterpretation on my part
guess I'll use that then
 
man fifo
> The kernel maintains exactly one pipe object for each FIFO special file that is opened by at least one process.
 
33
A: What happens when writing gigabytes of data to a pipe?

Chris Downtl;dr: at some point, yes will be blocked from writing if the data isn't being read on the other side. It will not be able to continue executing until either that data is read, or it receives a signal, so you typically don't need to worry about yes writing gigabytes and gigabytes of data. The im...

 
12:26 PM
and my comment above is inaccurate, it’s not “when there are no readers”, it’s when data isn’t being read fast enough
 
@Fabby is there a funeral or something? I was promised a $3 million payout!
 
@JeffSchaller that’s only for 300k+ users
 
This is tremendously exciting news for our employees, our customers, our community members, and for our shareholders
 
@StephenKitt argh, bitten by the fine print again
 
12:32 PM
I wonder how big Joel’s bank account is now
 
@StephenKitt I see. I never found a pipe doing that but I guess based on what you said and the post Jeff posted, it seems it can happen
 
@NordineLotfi see this answer for experiments you can conduct:
19
A: On-the-fly stream compression that doesn't spill over into hardware resources?

Stephen Kittdd reads and writes data one block at a time, and it only ever has one block outstanding. So valgrind dd if=/dev/zero status=progress of=/dev/null bs=1M shows that dd uses approximately 1MB of memory. You can play around with the block size, and drop valgrind, to see the effect on dd’s speed. ...

 
@StephenKitt Thanks, much appreciated :)
 
 
3 hours later…
3:06 PM
How do I track down the source of a Dockerfile "ADD" statement when it's a hash? ADD dir:9a635ed62e25...
 
@JeffSchaller I’ve never come across anything like that, and docs.docker.com/engine/reference/builder/#add doesn’t mention it
 
It successfully populates that /extra directory from somewhere; I just can't put 2 & 2 together.
 
@JeffSchaller right, that’s the layer description, not the Dockerfile
 
is it maybe a temporary (deleted) layer?
my container knowledge is ... contained :)
 
3:14 PM
ergh, right. So I need to put my hands on the actual Dockerfile, when all I have is the image. thanks!
 
3:25 PM
struck out. I guess you don't have to publish a Dockerfile for images on hub.docker.com
 
@JeffSchaller yup, you don’t
 
then I guess I went about as far as I could with askubuntu.com/a/1342462/619216; erm. Maybe I'll mention opening an Issue on the related github repo.
 
3:44 PM
woohoo, +2 on AU!
 
all because I saw meta.askubuntu.com/questions/19602/… and want to help review :/
 
I need to get up to 2k before I can help there ;-)
 
Ditto!
 
ah right I thought you were reviewing and came across that question in the review queue, but you’re answering to get up to 2k!
 
so little time, so many problems! :)
btw, the "dive" utility is neat -- very handy for inspecting docker image layers.
 
3:54 PM
@JeffSchaller yup, it’s very handy
 
@JeffSchaller never thought of answering question on AU for some reason
feel too comfortable on Unix.SE
@JeffSchaller I recall finding this utility a year ago or so; it is pretty nice (although I'm more of a LXC/LXD user myself)
 
@NordineLotfi as a U&L native, I can't recommend splitting your time to yet another UNIX side. But if it's for altruistic reasons, I can't complain :)
 
yeah, for sure
 
@StephenKitt just after I sent my message recommending it, I searched the archives to see if you had already mentioned it!
 
too bad there isn't anything like that for LXC/LXD...
@StephenKitt is it from a review? I'm asking because +2 is usually either a review or when you accept an answer
not knowledgeable enough with the point system yet
 
3:58 PM
@NordineLotfi from a review, thanks to an edit on Jeff’s answer
 
@NordineLotfi it was a review that I fast-tracked ;)
 
I’ve never asked a question on SE ;-)
except on Meta
 
@StephenKitt yeah, I noticed (at least on Unix.SE, wasn't sure until you mentioned it for the rest)
@JeffSchaller Nice
 
so now I’m waiting for Jeff to answer lots of questions on AU, I’ll edit them all
 
4:01 PM
@StephenKitt riding coattails to the stars of LQP and suggested-edits
 
2. ...
3. Profit!
 
@StephenKitt I'm more used for 3. to be ... or ??? :P
or maybe I did it wrong all this time o-o
 
bash counts from zero, zsh counts from one, Stephen counts from 2?
 
@JeffSchaller no, 1. was riding coattails ;-)
 
we'll never succeed if we can't put our plan in order! :)
 
4:03 PM
so the original has ??? in step 3
 
@StephenKitt right, that explain why I always did .../??? for the 3
Thanks for the confirmation
btw, does anyone know any decent html2text utility? I noticed the C version doesn't work on certain character/html tags, Lynx/w3m/Links/etc doesn't work on certain html tags either (I did mail someone maintaining Lynx for confirmation too...)
 
there goes my suggestion for lynx -dump
 
so not sure what to do at this point -- I started working on an existing parser in python but thought I could just be lazy and use something already existing and in C
@JeffSchaller yeah, I tried that, even with other options I explored (eg: nomargins, etc)
it does work better than w3m based on the output, but it still miss some working html tags
 
So you've probably seen:
48
Q: Is there a simple Bash tool which can quickly render basic HTML?

STWFrom time to time I need to do a simple task where I output basic HTML into the console. I'd like to have it minimally rendered, to make it easier to read at a glance. Is there a utility which can handle basic HTML rendering in the shell (think of Lynx-style rendering--but not an actual browser)...

 
only solution I found that work 99% is html2text (the python version, which is different) but while this work and give the output I want...it's just too slow (eg: take 3min for a 2mb file while Lynx take like 20second for the same...)
@JeffSchaller will take a look to make sure, thanks :)
@JeffSchaller hmm, sadly already know/tried the option listed there :/ Thanks for linking me to it though
right now I got a working solution but would want something in C and/or faster hmm
I also thought of asking on SO but I'm kinda question banned there, and not sure if Python related stuff would be OK on Unix.SE
so I guess that leave me with either making a faster parser or posting a question about it on Unix.SE? yeah
 
4:30 PM
anyone knowledgeable in regex here? have these in a pipe:
grep -w "Id=\"${get_total1}\"" file | grep -oP '(?<=Body=").*?(?=")'
want to use only a single invocation of grep/or other tool to do this (eg: without pipe/more than one invocation) how could I go about it?
thought of using perl for this since it work better for this, but not sure of the exact syntax there either
 
@NordineLotfi We need to know what you are trying to find.
 
"I wanted to parse some HTML, so I thought I'd use regular expressions. Now I have two problems" :)
2
 
@terdon I'm trying to find a pattern starting with Id="exactnumberhere" and extract it from Body
@JeffSchaller right, but you saw what I mentioned earlier and how other right tools for the job miss some tags? :)
if you or anyone else know a better tool on Unix to do html to text, I'm open for any suggestion
 
@NordineLotfi So something like:
no wait, ${get_total1} is expanded, right?
I can't do this without seeing the input and expected output.
 
@terdon yes, it should contain a number (single digit)
@terdon ah, let me get an example input
 
4:35 PM
make sure the Body has some kind of DNA sequence, so terdon can recognize it :)
 
:P
 
something like this?:
@terdon (message was too long)
 
So you want the value of Body= but only for the specific ID, got it
Here you go:
$ grep -oP "Id=\"${get_total1}\".*Body=\"\K[^\"]+" file
&lt;p&gt;Are questions that belong to the category &quot;What Apps Should I Get?&quot; appropriate Android Enthusiasts? How about if they're asking for specific apps, such as &quot;What are good RSS aggregator apps that integrate with Google Reader and allow offline reading?&quot;&lt;/p&gt;&#xA;
or:
grep -oP 'Id="'"${get_total1}"'".*Body="\K[^"]+'
 
4:50 PM
@terdon Thanks a lot! work great :D
@JeffSchaller it didn't had DNA sequence, but at least it had two layer of html tags. I guess that's not too far off? :P
 
The \K is really cool. It's like the lookbehind you used, but simpler. It means: "ignore everything matched before this"
 
@terdon Nice. that's a cool new trick :o
 
$ echo "abcdefg" | grep -oP 'a.*\Kd.*'
defg
 
@terdon pretty neat, yeah
 
@NordineLotfi To avoid the "two problems" mentioned by @JeffSchaller, you may also have a look at specialized tools; e.g. xq, from github.com/kislyuk/yq
In this case, for instance:
xq -r '.[] | select(."@Id" == "'"$get_total1"'")."@Body" | @text' ./file
2
 
5:01 PM
@fra-san :O this is amazing, didn't know about xq...
@fra-san how can I do a similar command but make it so "'"$get_total1"'" is similar to [0-9]* ? (comparing what you could do using grep here since I'm more used to it)
 
@fra-san Better to properly import the variable's value so that it's JSON encodod if it needs to be: xq --arg t "$get_total" -r '.[] | select(."@Id" == $t)."@Body" | @text' file
@NordineLotfi xq -r '.[] | select(."@Id" | test("[0-9]*"))."@Body" | @text' file
 
@Kusalananda Seems this work fine if it's only single line per file, but have the error xq: Error running jq: ExpatError: junk after document element: line 2, column 2. if it's more than one line
here an example:
 
@NordineLotfi Well, a well-formed XML docemunt needs a single root node. Yours don't have that.
 
@Kusalananda there isn't one here yeah. So no yeah to parse it without a root node with xq?
 
Inserting a start node <root> as first line and terminating it with </root> on the last line sholud fix it.
 
5:13 PM
alright, will try this. Thanks :)
 
@NordineLotfi No XML parser would parse it the way it looks now.
 
gotcha
 
@NordineLotfi Also note that the number of lines doesn't matter. What matters is the document structure.
 
@Kusalananda yeah, I see what you mean. so I'm guessing it work fine without root nodes if it's just a single line? (since it did earlier) just curious
 
I have below issue in finding the binary, go version command fails:
~$
~$ cat /etc/paths.d/go
/usr/local/go/bin
~$
~$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/MYUSER/go/bin
~$
~$
~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/MYUSER/go/bin:/usr/local/go/bin
~$
~$ uname -a
Darwin XYXYXYXXYX 19.6.0 Darwin Kernel Version 19.6.0: Mon Apr 12 20:57:45 PDT 2021; root:xnu-6153.141.28.1~1/RELEASE_X86_64 x86_64
~$
~$ which go
/usr/local/go/bin/go
~$
~$
~$
~$ go version
-bash: /usr/local/bin/go: No such file or directory
~$
~$
 
5:18 PM
@NordineLotfi It worked before because it was a single node.
 
@Kusalananda I see :o
Seems that work fine for the earlier example, but if you use `1` as Id's value, it output the line under: https://termbin.com/h66x

using `grep -oP "Id=\"1\".*Body=\"\K[^\"]+"`
It works fine if I use `5` and only output a single line
 
5:33 PM
0
Q: How to update PATH on mac?

overexchangeBelow is the environment in Mac: ~$ ~$ cat /etc/paths.d/go /usr/local/go/bin ~$ ~$ cat /etc/paths /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Users/MYUSER/go/bin ~$ ~$ ~$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/MYUSER/go/bin:/usr/local/go/bin ~$ ~$ uname -a Darwin XYXYXYX...

 
Nvm, figured it all out :D. had to use this:
grep -oPw 'Id="numberhere".+\K(?<=Body=").*?(?=")'
Thanks again for the help! @terdon
 
@overexchange Did you recently move the executable without starting a new shell session. If you're using bash, do hash -r to reset the remembered location for the go executable. If you're using zsh, do rehash instead.
@NordineLotfi Don't use grep to parse XML. What if the Body attribute happened to come before the Id attribute (order is not important for XML attributes)? An what about decoding the encoded text?
 
5:49 PM
@NordineLotfi yay!
 
you're right. Here I know the Id part and the Body part will always be like this because this is from the stack dump data set (and from scanning most of it, it look like it always is formatted this way, especially after double-checking the schema...)

Now, for decoding the "double layered" html tags from the Body (actually only one layer, the rest is just normal html): I use html2text (python version) with a couple customization I did (still not working exactly well) but from what I seen and benchmark I did with `time, it _is_ faster than other tools I tried to use
 
(echo '<r>'; cat file; echo '</r>') | xq -r '.r.row[] | select(."@Id" == "5")."@Body"'
Or, with a variable id: (echo '<r>'; cat file; echo '</r>') | xq --arg id 5 -r '.r.row[] | select(."@Id" == $id)."@Body"'
 
@Kusalananda ok I admit, if this is faster than html2text and the aforementioned regex, I would use this without a second thought (here caring more about speed than anything else)
let me benchmark this real quick
 
Not parsing XML with regex is a bit of a mantra here. For two reasons: first, this SO post, and second because it is really not a good idea for arbitrary [XH]TML files.
 
HTML-matching regexen are actually an easter egg in chat (maybe just chat.SO)
 
5:59 PM
@terdon yeah I'm well aware :D I know this post since more than 2 year or so, but still: if your requirement is speed, your data deterministic, your need limited but specific, then regex, isn't too bad, unless there is a faster and better solution (emphasis on speed here)
Here I'm only using it as a stop gap, but as I mentioned earlier, if I find better and faster solution, I would use them as alternative without a second thought
 
Yeah, I mean don't tell anyone (I have a reputation to maintain) but I use regexes every single time I need to parse HTML.
4
But that isn't very often, nor is it for anything that needs to be robust or even repeatable. Just for one-off things.
 
@terdon great mind think alike ;)
 
when I see Tony the Pony I'll know you sent him
 
@terdon of course. This is a similar thing I have here: something I won't be doing all the time and only because I 1. Don't know a faster lang (eg: C) 2. didn't found faster alternative than the one I mentioned already
 
You can do it properly with regular expressions, mind you, but quite frankly I doubt you would have the knowledge for it. I know I sure as hell don't, anyway.
695
A: What to do Regular expression pattern doesn't match anywhere in string?

tchristOh Yes You Can Use Regexes to Parse HTML! For the task you are attempting, regexes are perfectly fine! It is true that most people underestimate the difficulty of parsing HTML with regular expressions and therefore do so poorly. But this is not some fundamental flaw related to computational theor...

But Tom does.
 
6:02 PM
@terdon that's pretty nice to know. Thanks :D
 
But, as you will see if you read that, the answer both demonstrates that it is possible to do it safely and robustly and clearly shows why you'd have to be a bit crazy to want to do it instead of using a parser.
 
@terdon I honestly don't have the knowledge either but I do know a project, off the top of my head that implement a very primitive html parser, and that use regex to do it (actually more than one, but this one is using sed and shell script)
 
plus it's perl
 
@NordineLotfi a "primitive" parser, sure. A full one? That's harder :)
@AndrasDeak Yes, that's the only good thing about it.
But, my little pythonista, I challenge you to find anything unclear or illegible in that Perl code! :P
 
@terdon I said primitive but...I guess you'll be the judge of that:
it's mostly sed + shell script
but yeah
@terdon I'll try but I won't bet too much on my python skills (not as good as bash if that say anything about me)
 
6:05 PM
@NordineLotfi Sorry, that was addressed to @AndrasDeak who was complaining about Perl.
 
@terdon oh, Alright. No worries :)
 
@NordineLotfi that will break on most HTML documents:
> Due to the line-by-line processing nature of Sed, I recommend always putting hard breaks (\n\n) between block-level elements (lists, paragraphs, etc). markdown.bash does a lot less implicit processing of elements separated by only one break (\n) than the Perl version does.
 
@terdon Indeed. That's why I didn't cite it in the "tools" I tried...mostly because it was very primitive
 
Damned impressive, regardless.
 
Indeed, very
 
6:07 PM
@terdon my ($name, $value) = @+{ qw< NAME VALUE > };
something's off with the syntax highlighting in that answer
 
@AndrasDeak OK, yes, that's a bit hard to understand. But far clearer than python's list comprehension or lamda stuff :P
 
@terdon syntax is only clear once you know what it means! More news at 6 :P
wow, "knews"
 
Apparently Lisp works well to parse HTML, but I've never tried it.
 
@AndrasDeak True. So go learn some Perl syntax! ;)
 
I did, actually
 
6:09 PM
@AndrasDeak lucky :P
 
@AndrasDeak Ah. In that case, I will have to back down because I do admit it is hard to defend perl syntax.
 
perl was my second programming language
 
I tried to pick up some perl books but they all seem harder to understand than the perl oneliner I find on Unix.SE
 
At least, however, it doesn't treat whitespace as significant!
 
@terdon yeah, that put me off of python for years, but I got used to it and started depending on it in days
 
6:13 PM
I use both these days. I still find the whitespace thing annoying though.
But joking apart, python is a great language. Nothing comes close to Perl for text parsing, but for anything else I would likely prefer python myself.
 
glad I'm not the only one who find the whitespace thing annoying
 
6:31 PM
@Kusalananda Yeah, right. Thanks! Downvoting myself here, there is no excuse for embedding expansions into a command string.
 
@fra-san cough I do it all the time...guess it's not a good idea because of specific reason(s)? (or is only relevant to xq)
 
@NordineLotfi Semantically significance whitespace in Python is a well-known misfeature.
 
on point as always
 
One of the unpleasant side-effects is that cutting and pasting code can mess it up.
Using something like Elpy helps.
It tries to prevent you from doing nonsense formatting.
 
ipython really helps. It lets you just paste!
Well, not everything, but you can copy code that's indented say 4 levels deep in your program, so it will have 16 leading spaces, and it will run it as though it had 0 leading spaces.
 
6:42 PM
It's not the pasting that's wrong, I bet. Random websites injecting whitespace.
I've never had any issue copying things to and from my terminal.
 
@AndrasDeak From a script to a regular python console for testing is the one that really annoyed me before I got ipython.
 
well yeah, the built-in REPL is not great
it's about as user-friendly as gdb
 
Say my code was part of a class or something, I couldn't just copy the relevant lines and run them, I had to first copy to another text file, then use sed or perl to remove the whitespace and then paste. But ipython handles it.
 
@FaheemMitha I see. Didn't know it was popularly disliked :)
 
you can also only copy at most one block of code
@NordineLotfi to be fair Faheem popularly dislikes many things so generalise his opinions with a grain of salt :P
 
6:45 PM
@AndrasDeak lol. that's fair
I dislike a couple stuff myself but I generally either keep it to myself or try to fix it before complaining (unless I need help in the fixing like I did today)
 
Eh, is there anyone who actually likes having significant whitespace? Other than Guido, I mean?
 
@terdon yeah, it's great
 
Really? Why?
 
braces and semicolons are a pain to type out :P
 
I mean I don't mind it but (unless there mixed tab and space made by someone else's project)
@terdon force of habit I bet
 
6:46 PM
@AndrasDeak No more than trying to figure out the right indentation. Considerably less, even.
 
and it forces a given style on the code, which makes it very readable if you're used to that
 
@AndrasDeak If I wasn't sure, I would say this sound like sarcasm
 
@terdon if you have such complex indentation then perhaps the code needs refactoring
and decent editors will auto-indent for you, so you only have to handle unindents
 
@FaheemMitha I didn't know about Elpy. Nice!
 
I'm not saying everyone should have significant whitespace. I'm just saying that not everyone hates it. Most python devs don't hate it, otherwise they wouldn't be python devs. We're not JS people to hate what we use.
 
6:48 PM
@NordineLotfi I wouldn't say popularly disliked. Opinions vary. But it's certainly commonly acknowledged as a problem.
 
@AndrasDeak I don't know; most editor I tried, except Pycharm, won't really auto indent all the time, unless I'm doing something wrong
 
@NordineLotfi you probably are
 
@FaheemMitha I see. Well, I'm just glad I'm not the only one thinking this is all
 
Along with that global lock thingy.
 
@AndrasDeak I guess. meh, "force me to learn the syntax" is what I'll go with :D
 
6:49 PM
@AndrasDeak I need to "figure it out" even when it's two deep. And sure, the editor can handle it, but that's the same with braces. And at least braces are clean, unambiguous and make it trivial to select code blocks.
 
I've never had issues selecting code blocks :P But perhaps my programming problems are different.
 
@AndrasDeak Editors can't autoindent Python code if it's semantically significant.
 
@FaheemMitha I heard GIL can be alleviated if you use the multiprocessor module or other one like ray etc
 
Unless they're AI and are watching you.
 
In any case I don't want to python fanboy here, I don't care what other people think about python. But claiming that everyone hates its syntax is just off the mark.
 
6:50 PM
@FaheemMitha Exactly what I think I wanted to say earlier (I think?)
 
@FaheemMitha thank you for your input
 
@FaheemMitha they do a pretty good job. To take a trivial example, if you start a new for loop, any decent editor will add a level of indentation when you hit enter or tab.
But yeah, as soon as it gets a little complicated, you need to be very careful not to break stuff.
 
@AndrasDeak I don't want to be pedantic here either, but didn't you said you didn't like the "whitespace" thing earlier, or did I misunderstand? :)
 
@terdon It's fine if it is simple, yes.
 
And I also have to sometimes add code to a web backend, and that doesn't handle indentation so this whole whitespace thing is just asking for bugs.
 
6:51 PM
41 mins ago, by Andras Deak
@terdon yeah, that put me off of python for years, but I got used to it and started depending on it in days
that's what I said
 
I see
 
But I've had more problems than I can remember cutting and pasting Python code.
 
@FaheemMitha me too
 
After starting to use Elpy it's a bit better.
 
the only editor where indentation was 99% perfect was probably Pycharm, and even then it was hit or miss sometimes
but now I use vim/emacs/geany/etc so yeah...
 
6:53 PM
I'm somewhat surprised to hear that because I also use vim and it autoindents just fine.
  autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
 
@NordineLotfi Geany? I also don't know Pycharm.
 
@AndrasDeak don't get me wrong; it does indent fine most of the time but as Faheem and terdon mentioned previously "once it get a little complicated" it sometimes doesn't indent the way you would think it should
 
Oh, Geany is an editor.
 
@NordineLotfi the only time it doesn't indent correctly is when you have a syntax error on an earlier line. Pay attention to that next time and see.
 
@NordineLotfi And it's a wonderful way to introduce bugs.
 
6:54 PM
@NordineLotfi Ah, but you see, for python people that isn't a limitation of the language, it means you're doing it wrong.
Which is my main issue with the language actually: it keeps wanting to offer just one way of doing things and forcing its opinions on me.
 
@terdon HA, I guess I'll just get used to it like Andras did then...
 
if vim stops indenting correctly you have to find the missing closing parenthesis
 
Now, I completely understand that this is just as much a feature as a bug, and does result in better code in many (most?) cases, but I still find it annoying sometimes.
 
@terdon that is 100% true
 
@NordineLotfi Well, avoid cutting and pasting. Use your editor's insert instead.
 
6:55 PM
and if you don't like that one way use something else
 
@AndrasDeak right, I guess this did happen on occasion so I'm now unsure if this was that or not, but I'll keep the advice in mind and see if it doesn't happen again, thanks :)
@FaheemMitha yeah, but thing is, this wasn't just happening when copy pasting
 
@NordineLotfi Well, it can also happen when refactoring.
 
@terdon this is exactly what I thought too
that's also why I didn't want to learn Python initially and wanted to go C/ASM full throttle
 
@AndrasDeak Yeah, it's the official python philosophy. And I do get it, it's just that sometimes I really don't want to learn The Python Way®, I just want a quick and dirty thing that works, analyzes my data and gives me the result.
 
there's always R for that
 
6:56 PM
shudders
 
but R syntax is just weirder than python
 
Common Lisp is the language that behaves best when moving it around. Because everything between parentheses is a semantically meaningful piece of syntax.
 
R I actually do dislike.
 
me too
it look like Perl but weirder, if that even mean anything
 
Couldn't be better for refactoring.
 
6:57 PM
What's your field, @NordineLotfi? What kind of thing do you do for a living?
 
@NordineLotfi Python is a good language. For basic use it's hard to beat.
 
@FaheemMitha Any language that allows dangling quotes is disqualified by default.
 
And library availability is second to none. Unfortunately, languages without libraries just aren't very useful unless you are doing very original green field development.
@terdon Huh?
 
@terdon well, I used to have an accountant position, but then preferred to do software engineer stuff...right now I'm mostly doing consulting in computer related field, and trying to aim for a job in the software engineer industry
 
@FaheemMitha You know, things like this:
    (add-to-list 'load-path "~/.emacs-lisp/")
@NordineLotfi Ah, so that's why you're full out learning everything you can get your hands on. Good for you!
 
7:00 PM
@terdon Thanks :)
 
@NordineLotfi (Late reply) Code injection.
 
@fra-san oh, so that's why it's frowned upon...
that make so much more sense now that i recall all the time it wasn't recommended
 
@terdon Not a problem, IMO.
 
@FaheemMitha It breaks my brain's parser.
 
Lisp has exceptionally clean and clear syntax. I wish other languages did.
@terdon Sorry to hear that. Sounds painful.
 
7:02 PM
@terdon I have to say I agree here too ;)
I tried to keep emacs as my sole editor, but given all the stuff I wanted to implement, and the sheer lack of understanding I had in Lisp...
you probably know where I'm going here, so I don't need to say it: I stopped using emacs
but I still like it, kinda
 
@NordineLotfi Common Lisp is worth learning, but unfortunately lack of libraries is a major issue.
 
especially the org-mode idea, it's pretty nice
@FaheemMitha indeed, that's what I noticed too when trying to learn it
Emacs-Lisp isn't the most documented thing, even with the huge doc for Emacs
 
It's a pity it is so little used. It's so much better then the competition.
 
heh. I can't leave it. I've tried a few other editors and IDEs, but the level of configuration I can get, and the fact that I've had my .emacs file for almost 20 years now make it very hard.
 
eg: there tons of undocumented stuff, so much so, many emacs user will tell you: "even after X year of using it, I'm still learning new things everyday about Emacs!"
 
7:04 PM
And debugging Common Lisp is a positive pleasure.
 
@FaheemMitha yeah, I liked the demo video where some were debugging in real time a 3D structure
it's pretty cool for AI stuff too
 
SWANK/SLIME is really super cool.
 
indeed, there a similar thing for other lang in vim though
 
@NordineLotfi It's good for lots of things. But like I said, lack of libraries.
 
7:05 PM
You can't write everything yourself from scratch.
Python is really good that way. Take Pandas, for example.
 
@terdon I feel the same. Sometimes, if it's say for corporate/license reason, I don't mind using a very specific syntax/method of doing something but otherwise, I'd prefer my own, or at least an emphasis on speed/specific result in mind
 
Yeah. Although, to be fair, chances are my own approach will not be as good. But at least it's mine and I understand it and its logic.
 
Exactly
plus, even if you learn your method isn't that good, you can always change it/improve it, because it's your method
that's what make it spark special
@FaheemMitha I wouldn't deny that. It's really good for basic stuff (thanks to the ginormous amount of existing libraries and code snippet)
 
8:09 PM
@overexchange Next time, let us know that you actually have an active question, don't just re-post your questions in chat.
@overexchange I'm also noting that you have an extremely poor record of accepting answers. If you want people to spend time helping you, it may benefit you to actually accept the most helpful answers.
5
 

« first day (3890 days earlier)      last day (1065 days later) »