Okay did some more editing https://pastebin.com/LtkFsDXQ no matter what direction I input I get the same output "Play again soon You are in the Foyer Enter your move:"
@SurpriseDog Depends on where you want to go. I'd take pure numpy if number crunching is your focus, and pandas if general data processing is what you're after. But there isn't really a clear-cut line between the two.
well when running the code it came back withpython3: can't open file '/var/snap/amazon-ssm-agent/4799/clone_repo.py': [Errno 2] No such file or directory within the errors the actual directory refered in script was os.path.join(os.getcwd(), 'clone_repo.py)
Kinda depends on your overall architecture. I don't know enough details.
You could pass the absolute path to the file as an argument, which is what it sounds like you're doing. Or, you could add the containing folder to the system path, if you control the server.
> Solution works perfectly (and every time) when the Python file program (or CLI) is executed from the same directory where you are located and want to get the exact absolute path.
To be completely honest, though, I am a bit uncomfortable with the deletion (by anyone, not just mods) of answers like this. Even if wrong, they can be valuable because they contain a common mistake/misunderstanding.
Note that it is at least coherent. Therefore, not crap. Although it might be wrong.
Not deletion by mods. Deletion by community? Heck yes.
> os.path.dirname returns upper directory from current one. It lets us change to an upper level without passing any file argument and without knowing absolute path.
@AndrasDeak It's unfortunate that it's positively scored, but that's y'all's fault (collectively, the Python community). The value it holds, independent of score, is that people looking for answers can see it, recognize it, then see the comments and understand why it's wrong.
Of course there's a chance that heat detector picked up the comment and it was deemed unconstructive. In any case we're better off with my edit, even though it hardly changes the rate at which that pile of work gathers upvotes.
Perhaps the situation is that people looking for answers to that questions are confused to begin with, so they are inequipped (more so than usual) to tell that an answer is useless.
All the complex, "that's not possible" answers and then there is this one - literally one line without importing a single thing. Thank you for sharing this, good sir! — ArturNov 5 '20 at 16:59
I love this.
I cannot tell you how many times a day I see this kind of thing
My takeaway was that he thinks there's enough knowledge and there's too much crap, and he'd like to help with the latter. It was nice, I think I voted for him.
> For anyone who has ever wondered: "deceze" stands for my initials, D. C. Z.; it's not a misspelling of "decease". You can call me David. You may have seen me around, I've been here a while. I've been here so long that a lot of the time I answer questions by closing them as duplicates of answers I've written before, or of answers I've seen a million times already. I love seeing and contributing new content, but quite honestly a lot of things here just need categorising, sorting and moderation by now, since the existing library of content is already so well established.
Or worse, depending on whether I want to be tangented into space. If Python continues to lend me its power, I'll probably survive, with a fun story to tell. So I'll go with "want"
I've hit memory errors in the past, writing my own neural network. It hit the MemoryError when computing the gradient (which was an exponent of a float). infinite loop appending to a list seems like it might also work
My first approach would be to hunt down whoever is emitting that output, and convince them to use something more standard, like json. My second approach would use re.findall.
import re
s = '[* TO 0.99][1 TO 1.49][1.5 TO 1.99][2 TO 2.49][2.5 TO 2.99][3 TO 3.49][3.5 TO 3.99][4 TO *]'
pattern = re.compile(r"""
\[ #literal left square bracket
( #capture only the interior of the bracket pair, not the brackets themselves
[^\]] #any character other than right square bracket
* #any number times including zero
) #end of capture group
\] #literal right square bracket
""", re.VERBOSE)
seq = re.findall(pattern, s)
Considering how long it took me to compose this
Most of it was spent hunting down a particular behavior I didn't expect... On a completely unrelated note, guess the output of this code:
import re
s = "fooQbar"
pattern = re.compile(r"""
[ #character set
^Q #anything other than the letter Q
] #end of character set
+
""", re.VERBOSE)
seq = re.findall(pattern, s)
print(seq)
If I understand it correctly myself, it assumes "#character set" is part of the character set. Then, since "^" is no longer the first character in the set, it's interpreted as a literal caret rather than a complement flag
I think the main problem there is figuring out which module such a function should be implemented in. You can't put it in itertools because it doesn't return an iterator. So where would it go?
ahh... I think pandas does that. itertools.groupby's sequential behavior is a frequent gotcha and definitely gotch'd me when I first started. I simply accepted it for how it was. I suppose the argument can me made for memory usage and itertools ties very hard to to be O(1) memory where possible. That's also why I'd just sort the list before a groupby
I suppose it could go in collections, but it would be a bit of a semantic stretch
Thanks for answering, I kind of agree with both of you is true that it doesn't have a module to put it. And I guess we could have a Grouper collection in addition to Counter
Python Intermediate. Before we had only a basic and advanced course... After a few years it was realized something is missing xD
A little bit of everything, project setup, virtualenv, dbs, web, http, apis, logging, exceptions, debugging, some tidbits of python that somebody felt had to be mentioned like arg, kwargs and random stuff I find useful/interesting or important that people know
interesting. If you had said "intro to programming/python", I would have pointed you to my slides from when I taught that. But they may not be relevant to your course. If you'd still like them, I can send you access to the gDrive folder
yeah, I definitely didn't cover any of that in my course
quite a practical course, which is nice. Feels a bit like a craftsman workshop less a theoretical lecture
Oh actually that would be really cool, I would love to improve my basics course, although I think it's already the best of the 3. The advanced is my bane and I will be muling over that in a few weeks. The thing is in the advanced the paths of what you can teach split so crazy, nlp is totally different than vision than reinforcement even though it's all machin learning. Don't get me started on all the different advanced topics there are in python itself like generators, meta classes and whatnot
I want to agree with that. I think a good approach would be to make it a seminar course: here are a few IDEs and frameworks and things like metaclasses that are advanced python. Now go prep a presentation on something sufficiently advanced (run it past me in office hours) that really like and present it to the class
@AndrasDeak xD It's the most graspable I feel like. The majority of people is from the humanities or some less technical research fields like geography/biology/law
it's not just that. It also addresses the breadth problem you mentioned - you'd have to trim down the content and you'd likely stick with what you know. This way, you get to scratch some blind spots as well. Depending on class size, you might even be able to add your own "relevant reading" list on top of your students' presentations
oh gosh! if this is for technical folk who don't necessarily start to salivate at the sight of python, I can't recommend Streamlit enough as a tool to "just get something off the ground right now"
@AndrasDeak because they get baited by buzzwords :D But yeah I often wonder why phds are sitting in the advanced course. I feel like if you are managing do get into a phd and stay there for longer than a year, you should be able to learn everything I present at about similar speed on your own. Nothing beats just reading the docs and SO. Come to think of it, maybe the socializing in the course is a substantial factor why people do these courses
Yeah it's from every possible direction. I had a 60 year old lady who never programmed asking me that she wants to program in colors. It took me until the 3rd course day of talking in the breaks until I understood what she meant :D
@AndrasDeak Hahaha, I just had that experience in a pub yesterday. It was a bit loud and I thought I wasn't understood acoustically when explaining something from work. I was like: "Yeah I teach Python on Sat. ???? Confused looks. Repeat louder: PYTHON. ????. Realizes problem. Teaching programming :D
I'd say I'm good at it, but only face to face. Online I'd say I'm worse than average at it. It's really two different skillsets. Because bodylanguage and facial expression can show you so much what step was not understood. It's like having a live debugging session running
@AndrasDeak Lectures with hundreds of people or smaller practical stuff?