« first day (3779 days earlier)      last day (1170 days later) » 

3:20 AM
In here : pastebin.com/kEvxMSY9 1 is where I define a state , 2 is where I give locations of inside that 4x4 state and 3 is where I assign a color to it , however I keep getting error as in the below message, what am I doing wrong here?
<ipython-input-12-5fa17c0657c2> in reset(self)
     41     self.state[tuple(self.goal_pos)] = 0.5
     42     self.state[tuple(self.loose_comm_pos)] = 0.6
---> 43     self.state[tuple(self.loose_battery_pos)] = 0.4
     44     self.state[tuple(self.magnet_pos)] = 0.2
     45     observation = self.agent_pos

IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed
 
 
2 hours later…
4:53 AM
check the shape of tuple(self.loose_battery_pos) and then ask yourself if it makes sense or not
your code is complaining that it doesn't.
 
 
4 hours later…
8:31 AM
execfile doesn't work in python 3.9?
 
doesn't work since 3.0, I think. there are workarounds using plain exec though
 
>>> exec('threenames.py')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
NameError: name 'threenames' is not defined
but threenames.py does exist in the current directory
 
well, exec expects the code, not the filename
 
just pass the file's content to exec
decently sure that importlib has a function to just load a module from an arbitrary path as well.
 
execfile('file.py') doesn't have alternatives besides import and from statements?
 
8:36 AM
the alternative is to load the content and exec it...
 
also, importing is how you should be re-using code, so it's not so much an alternative as it's how it should have been done in the first place. execfile was a hack that got removed because "there should be one and only one way to do something"
steps off soapbox again
 
That's the one:
exec(open("./filename.py").read())
 
<takes Arne's soapboax> Isn't there an elephant in the room here? Should we be talking about exec on a file? I'm not sure why you'd need that
 
ducks and walks away, whistling
 
They need that because execfile doesn't work, duh
 
8:43 AM
@Arne why you said "execfile was a hack that got removed because "there should be one and only one way to do something""
 
because import is there to load code from files.
 
sounds like porting py2 to py3. I pity our poor guest enough for that as not to start a discussion
 
@MisterMiyagi that
@Arne no, just major confusion (I give it 95% chance)
 
2to3 should already translate execfile to an appropriate exec construct.
 
@EnthusiastiC that line is from the zen of python, which is often quoted when discussions move into "why should things be done like this?"
the question "how do I load code from a different file" is, in python, answered with "import it". As a consequence, execfile was superfluous and should be removed. Which it was.
 
8:48 AM
I see.
 
Were they basically equivalent @Arne?
It feels like a really clunky construct so presumably execfile had another intended purpose?
 
execfile lets you load code without having it properly searchable by python, i.e. sys.path
 
I'd call it "an import that messes up your namespace as a bonus"
 
Fancy
 
so it's not exactly the same. But most of the problems it solves are problems you should not have in the first place.
 
8:51 AM
but python 2.x has plenty of alternatives
as python gets updated it becomes narrowed.
Even loading modules,
For Python 2 use:

import imp

foo = imp.load_source('module.name', '/path/to/file.py')
foo.MyClass()

For Python 3.5+ use:

import importlib.util
spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py")
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
foo.MyClass()
 
I... don't think that's Python's fault
 
honestly, if you need to do that on a regular basis, then we should be talking about the why instead of the how.
 
In fact, I've never seen code like that so I can't imagine the circumstances that bring it about
 
who claims the fault
The community?
 
? Are you saying that you've lifted this approach from something on SO?
 
8:56 AM
@EnthusiastiC so what? 2.x is dead. Write good code, not code you could write 10 years ago.
 
Won't somebody please think of the <> operator?
 
@EnthusiastiC Importantly, consider this possibility: a room full of python experts in unanimous agreement might be on to something, and you need to listen.
 
@MisterMiyagi That's in the sequel to this discussion
It's still alive and well over there :P
 
@roganjosh I really didn't understand what you are trying to mean.
 
@MisterMiyagi I heard that c++20 added operator<=>. Would be a great addition to python.
__spaceship__ I mean
 
8:59 AM
@EnthusiastiC You've made an odd statement about whether this is the community's fault. I'm asking whether you're saying that because you've just cargo-culted some code you found on Stack Overflow. Otherwise, I don't know what you mean
 
I demand the turbofish! ::<>
 
@roganjosh it's my opinion
 
Then it cannot be the fault of the community
 
I'm not an expert and I'm just beginner
 
But this is the wrong terminology anyway. It's not a discussion of blame; I think we just want to fix this
 
9:01 AM
I noticed several changes
happens
to python as it get updated.
 
Yes, but in this case it looks like it was a good thing that this got removed because it's highlighted something that's... less than ideal. Why are you not importing the file, as has been asked?
 
In comparing versions I noticed handful statements are omitted that's not encouraging either.
 
but yeah, what's wrong with normal imports?
i have a sneaking suspicion people used this hack to bypass having to package and install packages properly
 
nothing. I'm following a book which uses 2.x version.
 
oh dear
 
9:04 AM
Zed sense is tingling
 
find the nearest dumpster and dump it there.
 
@ParitoshSingh Why?
 
So if you don't have a good enough justification for writing code this way, then here's the takeaway. this isnt how you should be importing modules
@EnthusiastiC because you'll end up learning practices that will make both your life harder and everyone else's who tries to use your code down the line. python 2 is dead
 
I'm about it's introduction.
 
@EnthusiastiC close it
 
9:06 AM
@EnthusiastiC Python2 is dead since last year. Says the guy still paid for maintaining Python2 code.
 
then it's the perfect time to ditch it, before you go too far down the rabbit hole, isnt it
 
@EnthusiastiC That book is either very old or very wrong, or both. You should NOT learn python 2 quirks. Learn proper python. Look for another book.
We mean it.
 
2007 book.
 
doesn't matter. it's like youve picked up a history book
 
In tech terms, that's a cave painting
 
9:07 AM
oh really?
 
oh even better
i can write a history book in 2020, and it would still not be correct for building spaceships, because it covers how to smelt copper or something and iron hasnt been discovered
python 2 is dead. don't use it if you dont have a reason to use it.
 
thanks for your advices.
 
@ParitoshSingh second part is redundant
 
cheers. if you want some resource recommendations theres some really great books out there
 
if you have a reason to use it, learn python 3 then change what is missing in 2.x
nobody should be reading python 2 books
 
9:11 AM
@ParitoshSingh could you name some of them?
 
i believe even we have a list somewhere. but one external resource is is pythondiscord.com/pages/resources and here's another sopython.com/wiki/Recommended_Reading
if i had to pick one, "automate the boring stuff" is an excellent book
 
I'll check that out.
 
@ParitoshSingh oh you meant use pythoff, rather than use the book. Sorry, context skewed my brain.
 
lol, i had to google pythoff
 
It's all about phyton these days anyway
 
9:15 AM
ah i found the correct sopython link: sopython.com/wiki/What_tutorial_should_I_read%3F
i was wondering why i was providing a link that was recommending lord of the rings, but to be fair, i cant complain!
 
How's tricks anyway, @ParitoshSingh? I haven't been around much recently but it seems you're becoming more regular in the room these days :)
 
@roganjosh hehe yeah, i find myself realizing that just pushing myself to finish work is a never ending and burnout inducing job, and surprisingly cuts my learning a lot.
So i've tried to make a conscious effort to push back on workload, and still engage in places with python purely for the sake of learning/enjoying and not purely locked in a work-related context
But really, i just miss you all ;)
 
#relate! I've got a couple of days off before my brain melts entirely :)
 
9:33 AM
Thanks for all the great help everyone, love this platform =D
 
Hello @FlorisFancypants. You've won the username-of-the-day award that I've just invented :)
 
9:51 AM
@AndrasDeak I just saw a Twitter post referring to --0-- as a "spaceship" operator, to do ceil division: --0-- 12 // 5 evaluates to 3. See this: bugs.python.org/issue43255#msg387248
 
hmmmm
Ah, because the 0 - makes the first minus parse as binary minus
 
What is <=> supposed to do? Always return True? a = 1; a <=> 2
Oh, I guess it looks like some kind of in-place swap, maybe? x <=> y? Probably clearer and less bug-prone than x ^= y; y ^= x; x ^= y
 
@PaulMcG it's a kind of comparison operator that somehow allows all the other comparison operators to be inferred. That's all I know.
 
Ooof
 
10:14 AM
That --0-- trick is a big performance win also, since it inlines the constants and avoids a function call:
>>> timeit.timeit("ceil(12/5)", "from math import ceil")
0.21978599999999915
>>> timeit.timeit("--0-- 12 // 5")
0.012343000000001325
 
10:28 AM
Huh. I think timeit will capture the import overhead only once too? After the first run, it would be cached, so that's a crazy speed increase
Surely that has the import overhead. Maybe I'm misremembering how imports are handled
 
isn't --0-- 12 // 5 evaluated at compile time? :P
dis.dis("--0-- 12 // 5")
  1           0 LOAD_CONST               0 (3)
              2 RETURN_VALUE
 
>>> dis.dis(lambda a, b: --0-- a // b)
  1           0 LOAD_CONST               1 (0)
              2 LOAD_FAST                0 (a)
              4 UNARY_NEGATIVE
              6 LOAD_FAST                1 (b)
              8 BINARY_FLOOR_DIVIDE
             10 BINARY_SUBTRACT
             12 RETURN_VALUE
>>> dis.dis(lambda a, b: --0-- 12 // 5)
  1           0 LOAD_CONST               1 (3)
              2 RETURN_VALUE
@roganjosh The second string arg to timeit is for setup steps that are not included in the timeit time
 
In which case, in the words of the auto-generated clickbait titles that seem to have died a death - "I have no choice but to be flabbergasted"
 
A better comparison:
>>> timeit.timeit("--0-- a // b", "a, b = 12, 5")
0.0993029999999635
 
still pretty neat
 
10:39 AM
Just use -(-12//5)...
 
But SPAAAAACEship, pew pew!
 
@AndrasDeak the ceilray operator -(-//)?
 
 
1 hour later…
11:55 AM
Hello everyone. When I try to pip3 install whatever, I get "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"

I've searched around but didn't find any solution yet. I was hoping if someone could point me to the right direction of solving my problem
I use ubuntu 20 and I have pyhton3.6
 
How did you install python 3.6?
 
I installed it as described here askubuntu.com/questions/1231543/…
 
what a trail of trash
@John OK, so obvious question: why are you not using python 3.8?
 
Because thje project I'm working was developed on a machine with python3.6 which I know works, so I wouldn't like to risk it with python3.8
 
12:01 PM
You don't want to risk using a version of python that's already available on your system?
 
Hey from a supplier I got 2 wheels one has static in the name and is 9 times bigger than the one which is not called static. Which one should I take? Usually when installing wheels I didn't encounter two versions like now
 
What exact "risk" do you think there is?
 
@Hakaishin the static one is likely statically linked, i.e. contains all dependencies.
 
@Hakaishin I'll take "what are shared libraries?" for $500, Alex stackoverflow.com/questions/2649334/…
 
How come I never encountered this distinction with other python packages? I installed many of them.
 
12:04 PM
Because project includes many python scripts with many many python libraries and I thought maybe some pakcages wouldn't work with python3.8
for example one of the packages requires python3.5 and above, which is not a problem in my case but it's still an example of incompatibility with python3 versions
 
@Hakaishin have you seen packages which said "aside from pip install you'll need to install <these libraries> through your package manager"?
@John do you think "must be over 3.5" and "must be less than 3.9" are equivalently likely constraints?
Anyway, you're free to use 3.6, after all it's you who'll have to work with it. I'm just surprised.
 
no of course not. The second one is much less likely
No, I'm open for advice
and thank you
I'm just expressing my concerns
 
Yeah, and I was asking for them. No worries.
 
@AndrasDeak actually no. Most pip install packages just work :)
But yeah the wheel is not built for my platform anyways. Gotta write more emails ¯_(ツ)_/¯
 
@Hakaishin so I suspect most of those might end up using shared libraries installed with the package manager
(I don't mean python3-... packages but lib... packages)
 
12:10 PM
@AndrasDeak @AndrasDeak Could you elaborate on this?
 
When you build python from source you use the same thing for a lot of optional (but important) packages
 
Sorry, I tried to reply on one of your messages
 
@John that was a response to the Q&A Miyagi linked, not aimed at you, sorry
 
the "what a trail of trash"
ok
 
@John you succeeded, you just don't have to add my name manually. It's put there automatically with the reply.
 
12:13 PM
yeah noticed that after
So I guess your suggestion is to use python3.8 since the chances of incompatibility with python3.6 are very low, right?
 
have a look at: semver.org
to my knowledge python follows semantic versioning maybe with small changes
 
user13727121
May i know if there's anyone using vscode here? do updates wipe out all your projects? I just lost everything when I updated my vscode, no warnings were given
 
@John In general, later Python versions are backwards compatible. You only get problems if libraries are compiled and not built for newer versions, or use some of the very few things that were deprecated.
Usually, you will find out very quickly if that is the case.
 
Alright, thank you :)
 
@CoreVisional Projects generally live on your filesystem. Updating VSCode should not delete them.
 
user13727121
12:21 PM
@MisterMiyagi that's what I thought. I googled about the issue and I was surprised this happened to a lot of people too. The updates wiped out their entire things. I've looked into my recycle bin, because vscode usually puts deleted files there but it wasn't there...
 
where were your "projects" kept before you uninstalled vscode?
 
user13727121
the same directory as the software
 
@John notable exceptions to what Miyagi said include modules that make heavy use of the C API (e.g. numpy usually has to fix a few things for a new python version) or libraries that work with python bytecode.
Most code is not like that
 
you placed your actual code files where vscode was installed? o.o that sounds like a..uh..bad idea
 
@AndrasDeak noted. Thanks
 
12:32 PM
I do not know whether vscode would delete your projects if you keep it inside it's install dir, but frankly i wouldn't blame vscode if it did.
 
user13727121
@ParitoshSingh The thing is, I've updated my vscode before and it kept all my works, but not this time.
 
okay. let's see. my first suggestion: go into full recovery mode. any backups? if not, perhaps try data recovery software if thats an option
my second suggestion: do not place your projects inside an application's install dir. that's just asking for trouble.
 
user13727121
@ParitoshSingh I'm not blaming, just curious, I saw that others get this, like a warning message before updating, where it'll discard their works and stuff. But all I get was the update button, nothing to warn me about :\
 
user13727121
@ParitoshSingh yes, im currently using Recuva, it's still scanning
 
well frankly i would be surprised if it did warn me. here's the thing. you placed your very important file do not touch into someone elses "house"
now if the house gets a demolish instruction, it's frankly unreasonable to expect them to check "oh did the other guy need this file that is in my house?" before the demolition crew gets to work.
more often than not, the only thing these type of softwares ask you about are your* "settings", and they aren't really doing a second check for specific files that have no reason to be there.
 
12:38 PM
pandas.pydata.org currently being mislabeled as 'Dangerous' by Google Safe Browsing "recently found harmful programs on pandas.pydata.org" and the big red warning screen. (Seems like a false positive; when I click on the justification link it's empty)
 
Google knows using pandas can be injurious to your health.
 
user13727121
Alright... Guess I've learned it the hard way. I've used IDEs like Pycharm and Intellij, did the same thing (keeping my projects where the IDE is installed), but it never just removes my entire work. Gonna move it elsewhere now
 
@smci I did get this in firefox today, I thought it was just me
 
 
2 hours later…
2:50 PM
What's the way out to install different python versions without any issues?
I want to install some modules that are incompatible with python 3.9.
 
@EnthusiastiC installing a separate distribution like conda, or building your own python from source and keeping it separate from the system one
 
I didn't find bimpy module in conda
 
There's probably a way to use pip directly even with a conda installation, but I don't know how that can be done safely.
 
execuse me I'll carry out later.
 
I have got away with using pip to install packages when I had conda as my python setup, I didnt face any issues
 
3:47 PM
Nov 14 '20 at 16:47, by roganjosh
Don't bother. Just use pip. If it breaks, you can yell at me in another chat room
I've now transitioned away from conda entirely, but I'll stand by that comment
 
 
1 hour later…
4:53 PM
@EnthusiastiC The normal way wojuld be to create a virtual environment based on the Python version you required.
[I declare it beer o'clock on Friday afternoon]
 
5:08 PM
@python_user There are obscure bugs that can bite you related to binary extension library compatibility across multiple platforms, but that's unlikely to trouble most people. Generally, it Just Works™.
@roganjosh Life is simpler without Conda, that's true.Ease of use is so important in a toolset.
 
 
2 hours later…
7:41 PM
Awesome!!! I see they aren't using pyparsing (breathes sigh of relief)
Wait!!! I take it back - github.com/nasa/fprime/blob/… (Sure hoping it isn't runtime code.)
Gah! They are using version 1.4.5, released in December 2006! :(
 
8:25 PM
@holdenweb but creating virtual env doesn't mean I can install modules for python 2 whereas I have python 3.9?
 
@EnthusiastiC How did we get from "not available in conda" to "different python version"? :'(
 
bimpy module not available in conda; unless it is private because i'm not a registered user. This module couldn't install using pip; using python 3.9.
 
What version of python did you get with conda?
 
Honestly I don't know how to deal with conda anyhow
 
Oh, sorry.
 
8:35 PM
I installed python latest version 3.9 and trying to run some codes that require modules
to be installed
 
6 hours ago, by EnthusiastiC
What's the way out to install different python versions without any issues?
I want to install some modules that are incompatible with python 3.9.
When you asked ^ that I thought you wanted to know how to install different python versions without any issues. My bad.
I think what you have to do is keep trying to install packages for 3.9 that aren't available for 3.9. That might eventually work, who knows.
 
I said that because I thought it was a compatibility issue
because
python -m pip install bimpy
tends to pop up some errors eventually.
I encountered this for e.g. "error: Microsoft Visual C++ 14.0 is required."
 
very cryptic
 
and others...
I don't want to post them if they are meaningless for you.
tell me, creating virtual env doesn't help either, right?
 
8:45 PM
this article applies to my issue right? djangocentral.com/…
 
Considering that I just told you that creating a virtual env doesn't help: absolutely.
 
but "different environments can have different versions of modules." not different versions of python?
What would you recommend as a solution to this problem?
 
I have a sense of deja vu
 
could you make it clear?
simple better than complex.
uninstalling python 3.9 then installing <=3.8
should solve this issue.
 

« first day (3779 days earlier)      last day (1170 days later) »