« first day (4420 days earlier)      last day (538 days later) » 

4:15 AM
Hi, I am using import statement of Tensorflow on MacOS M1. When I run import tensorflow statement, it says "The kernel appears to have died. It will restart automatically."
Does anyone know how to run Tensorflow in MacOS M1?
I tried with conda environment as well, but it didn't work
 
 
1 hour later…
5:43 AM
0
Q: Extract nodes from json based on user input preserveing a portion of the higher level object as well

vineet singhneed to extract object from the given json based on the node chain passed by user and neglect those which are not in user input, then create a new json object my master json is : { "menustructure": [ { "node":"Admin", "path":"admin", "...

 
 
1 hour later…
6:52 AM
@roganjosh haha.. No I was not getting data in profile but then took a deep breath n just followed the basics for data flow n problem solved.
 
7:59 AM
And of course the yaml is still b0rked
 
@rowoc there is a reason I moved your question - we have room rules that ask for you to wait for 48 hours before bringing a question here. If you think that just posting the content will get you round this request, you're wrong
 
Why does your company insist on using YAML if they can't even write correct yaml files?
 
@Aran-Fey Hi I had reformatted the yaml , now can i post the question and solution what i tried ?
 
@rowoc did you not even read what roganjosh told you?
 
@PeterT sorry I didnt noticed
 
8:23 AM
@rowoc have you noticed now that this is the second time I've kicked you?
Third time will escalate it to a moderator. Read harder
 
dpaste.org/k2EmU how to add testing configurations in create_app()
 
You want to store the config outside of the app factory. Something along the lines of this
 
@roganjosh can't we add testing configurations in this current create_app()
?
 
You could, for example, create a Config class and pass it to the factory, which is what I did with my website
Whether or not it should be in a class or some other type of file is completely up to you. We're seeing what fun there can be with YAML formatting, though
 
Do I need to use os.path or I can directly write configurations like this " app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False" in config claskk
 
8:34 AM
I am quite fond of the composition aspect of having Config being a class, though. There's a few nice things you can do, but I couldn't tell you whether my usage is considered as abuse or just normal use :D
 
@roganjosh please you can share
 
@NaveenPandia No, you're setting the property directly there. The point is that you break it off into its own class
I did share. You're aware that the orange text are hyperlinks? I linked you to my repo
 
yes I'm exploring yor repo
 
The config class is here
It's not exactly how I would structure it in future because it's not installable as it is, but it's close enough to at least demo passing the config. You would just make another config class with your testing parameters and override the default for the application factory if you wanted to switch to testing
 
and if I have mysql as DB in path what should be used?
 
8:42 AM
Well, you'd need to set the correct connection string in your config object. You could have one config that points to SQLite and another that points to your production DB
 
Now I've created a secondary create_test_app() for testing and I will call this for testing.. What say about this approach?
 
That it's the wrong approach
I'm going to guess at your misunderstanding. The approach you're using is called a factory for a reason. You ask it for an app in a specific configuration and it gives it to you, all set up. The point of the factory is that you have one function that can give you apps in different states
The way that your factory builds different apps for you is that you pass it different Config objects. It's the same function, but the app it produces is fundamentally different
So, you should have just one create_app(config=Config()), but if you want it in your test state, you'd call it with create_app(config=TestConfig()) (or something similar)
 
ok now that's what I didn't got the first time.. now it's clear
I'll create config class
 
The secret sauce is this. Every attribute that your config class has (in CAPS, which might be surprising) will then get passed to the app
 
8:58 AM
@roganjosh have you created test folder ?
 
No, I don't have any testing set up for it. "Shame, shame, shame"
 
that's fine
 
9:10 AM
Why is the method "__new__" never called on a second parent class?

class Sub(First, Second):
 
Because you didn't write First.__new__ properly.
Dies First.__new__ ever invoke super().__new__?
 
I've not overrided the new method on "First"
But now I got another issue. "First" uses the "Second" __new__ method. Any idea why?

class Sub(First, Second):
 
I'm not sure what you are asking now.
Sub should use Second.__new__ and that should be exactly what you want.
First should never use Second.__new__ (Unless it's class First(Second): or similar).
 
Weird. I'll need to debug and see why this happens.
Thanks for the information.
:P
 
9:25 AM
You can also try giving an MRE.
There are probably some corner cases depending on which class defines __new__ and which class defines __init__ since Python can fill in defaults for one depending on the other.
 
10:08 AM
AFAIK, super works the same way with __new__ as it does with __init__, and the same guidelines and reasoning apply.
 
Cbg
 
10:59 AM
I'm having a hard time understanding the guarantees of async_generator.aclose. Specifically, the first two sentences confuse me:
> Returns an awaitable that when run will throw a GeneratorExit into the asynchronous generator function at the point where it was paused. If the asynchronous generator function then exits gracefully, is already closed, or raises GeneratorExit (by not catching the exception), then the returned awaitable will raise a StopIteration exception. […]
This seems to say that await agen.aclose() will raise StopIteration.
I'm not sure whether this is supposed to say just "agen.aclose() will raise StopIteration" with the implication being that await in await agen.aclose() will catch-and-discard that exception.
 
A monad is just a monoid in the category of endofunctors, what's the problem?
 
Something tells me that's the answer I deserve. ^^
 
Honestly, I could well be looking at C++ documentation with that comment. Jeez, the information density is something else
 
It's not what I was expecting, I can tell you that. Just wanted to find out whether await agen.aclose() is guaranteed to return None.
Since mypy is bugging me about that one... :/
 
11:23 AM
The only thing I'm relatively certain of is that nothing will happen if you don't await it
 
@MisterMiyagi related: bugs.python.org/issue34730
from that report, this might work: bugs.python.org/issue34730#msg325704 at least to ensure it get closed when it should (unless that's not what you want, in which case I probably misunderstood)
 
Ads
12:15 PM
hi im new to this page! was wondering if i can get guidance from someone who can share a code that i may be able to leverage on:

- Looking to set up a jupyter notebook to reply to emails sent out
- i am currently working off a mac OS
- the emails are sent through outlook

hope i can get some guidance here :)
 
using Jupyter for that seems kind of crazy; why is that a requirement?
 
12:34 PM
@tripleee def a crazy requirement
 
1:06 PM
@tripleee a lot of data scientist or people who prefer working with jupyter notebook basically use that for everything, and I really mean everything. Usually they end up moving that to a simple python script/module instead. Just look on some repos on gist.github and github with the jupyter notebook tag
I agree it's not really a needed requirements unless you want to test things out there
(in which cases, using ipython is fine too, unless you are working with images/etc which jupyter notebook support)
 
yeah, I'm not alien to using Jupyter if that's what you like, but it's probably better to keep it separate from the code requirements
sensible email responders would run in the background and poll your IMAP server periodically, or something like that
so basically no user interface at all, beyond log files
 
yeah, I wouldn't use that either for this, but if I saw someone trying to do that there, that wouldn't surprise me.
Instead of saying "set up jupyter notebook to..." they could also say "how to reply to emails using python" or something along the line. Then use that on jupyter if you really, really want that.
 
1:24 PM
I got it working now, however, when I subclass a built-in type like "str", the __new__ method on "B" is never executed.

class A(str, B):
Do you know the reason for that?
 
Subclassing builtins is asking for trouble, and adding multiple inheritance is like adding a gas station to a bonfire
 
@Aran-Fey Haha I see. I don't want to subclass from a built-in type, but.. trying to solve some things in the API before letting anyone else use it.
 
@tripleee Aaah.. so.. you know what? I'll let someone else that wants to subclass from str to solve it by themselves.
 
Creating a string subclass sounds like a questionable thing to do, but if you're really sure you want to do it, there's also collections.UserString
 
1:30 PM
I've implemented this sort of feature now, which I don't 100% like, but it's kind of neat when I got it working. We've got our own "Process" class now that automatically resolves to for example "WindowsProcess" or "LinuxProcess", depending on what platform you run the script.

(Based on how pathlib does it)

https://github.com/python/cpython/blob/3.11/Lib/pathlib.py#L868
@Aran-Fey Yeah, you're completely right. MyEnum(str, Enum) is kind of the only usage I can think of?
Using new as a factory method should be used carefully, as it introduces some magic. But well, it works fine now. :p
 
I don't think a string enum is a good idea. In general I don't like enums with values very much. All I care about in an enum is that MyEnum.FOO != MyEnum.BAR
 
2:15 PM
am trying to read an xlsx file with pandas pd.read_excel("input.xlsx", dtype=str) but i keep lose the leading zeros, even tried to use converters for the specific column but got the same output
00300 became 300
 
2:57 PM
@Warcaith Builtins aren't written for cooperative inheritance. In Python speak, they don't call super() methods.
 
3:18 PM
@MisterMiyagi Oh, alright, that's why I encountered the issues only when I used builtins but no other classes.
Thanks for the info!
 
3:57 PM
Need some help with MyPy again...
I have a Protocol defining a property, and I want to implement that with a regular class using an attribute instead of the property.
For some reason, MyPy still thinks the regular class is abstract and doesn't like instantiating it.
from typing import Protocol

class P(Protocol):
    @property
    def x(self) -> int:
        raise NotImplementedError

class I(P):
    def __init__(self, x: int):
        self.x = x  # type: ignore

I(2)  # error: Cannot instantiate abstract class "I" with abstract attribute "x"  [abstract]
Is there a way to make MyPy accept that without # type: ignore'ing every usage of I?
 
Just replace the property with x: int
And no, I can't explain why mypy doesn't like the property
 
@MisterMiyagi are you using latest version (eg: from their github). I think they added a related commit for this: github.com/python/mypy/commit/…
 
@NordineLotfi I'm trying to do the opposite. Note how the property is read-only as well.
 
ah, yeah, you're right
 
@Aran-Fey I'd like to avoid that since x is read-only on some implementations.
 
4:10 PM
Ah, that makes sense
 
 
2 hours later…
7:21 PM
def test_profile_uid(self):
        data = {
            "user_name" : "Naveen",
            "password" : "123456"
        }
        token = jwt.encode({"payload" :json.dumps(data, indent=4, sort_keys=True, default=str)} ,"mysecret", 'HS256')

        headers = {
            "Authorization":f"Bearer {token}"
        }

        response = self.client.get('/users/e928caec0efe45368613fe5f3f5dc228', headers= headers)

        assert response.status_code == 200
        assert response.data == []
can anyone help me in how to generate token for unittesting this api?
I'm using PyJWT in app to generate token

FAILED backened/tests/test_users.py::UserTestCase::test_profile_uid - KeyError: 'uid'

in this I've used uuid as uid(e928caec0efe45368613fe5f3f5dc228)
route
@getuid_bp.route('/users/<uid>', methods=['GET'])
@token_required
 
can I bump mu question here?
 
@WantingtobeanAndroidDevelor Please take a look at the room rules. We ask not to promote question before they are 48h old to avoid duplicate and hard-to-find discussions.
 
7:37 PM
@PM2Ring did you see my last ping? just curious :)
 
7:48 PM
anyone ?
 
8:01 PM
@NordineLotfi Yes. The new version is easier to read, and more user-friendly.
 
8:13 PM
What should subprocess.Popen PID be if you terminate the process?
Can't find any information about it.
 
Good question, but it probably just keeps the PID it had when it was still alive
 
Guys Pylance vs Pyright, which do you think is better for type hinting?
Or are Pyright incorporated into pylance and are identical?
 
Alright, it seems that my implementation is correct then. I've worked with other libraries where PID gets reset to zero when the process terminates.
 
@WantingtobeanAndroidDevelor I don't know if they're identical, but yes, pywrong is included in pyspear
 
In fact what are you using for type hint warnings?
Because I have been finding warnings given by Pylance to be quite terrible
Or at least it is the pylance giving the message sorry if I misunderstood
 
8:22 PM
I don't use a type checker, they all suck
 
@Aran-Fey You are your own type checker! ;)
 
@Aran-Fey I thoroughly agree, I had them turned off for a while
 
I hate that there's so much differences between all the type checkers. Like, if I do something right in one of them, I somehow do the completely opposite in the other.
 
But for this slightly complex work I was doing.
I spent long time prototyping the complex algorithm, I thought it's time for a refactor.
Turned the typehint warnings on.

But the typehint puzzle is such an unnecessarily time sink.
And worst of all, being compliant with typehint warnings many times make your code more verbose and unreadable.
 
@PM2Ring ah, thank you :)
 
8:28 PM
My brother likes to complain that python is slowly killing itself, and at this point I just go "Good, hurry up. I want something better" ¯\_(ツ)_/¯
 
@Warcaith you could reset it to zero, null, None, or just keep the old one (or delete the variable or whatever hold the old/unused PID) but the result would still be relatively the same I think
@Aran-Fey I feel like while all languages are different, there is always that similar trend of "it's dying!!!" that they all share. The only ones I can see still being trendy are Rust and Go, but even those might suffer the same a couple years later
 
@NordineLotfi Yeah, sure, but I do want to avoid altering return values from subprocess. This is just a wrapper for handling the platforms a bit better.
 
of course, just was a suggestion on my end
 
@WantingtobeanAndroidDevelor I'm pretty happy with MyPy for general code health. It works pretty well for code written the way it should be written.
 
@NordineLotfi Suggestions are always welcome!
 
8:33 PM
@Aran-Fey pywrong and pyspear. :D nice
 
0
A: Typehint Union Dictionary branching error

Jamie.SgroI was able to recreate your error and resolve it with Dict[str, str | int] like so: def test(flag: bool)->Dict[str, int | str]: a: Dict[str, int | str] = {} if flag: a['a'] = 1 else: a['a'] = 'hello' return a See the linting error on my python 3.9 version: Notice...

@Aran-Fey This I also thoroughly agree but got banned from the Python discord server for saying.
 
Huh, that's a weird thing to ban someone for
 
I know, but it's just the way Discord works
if they don't agree with your opinion people get worked up and you are the one who gets banned
I wonder if there is a way to save Python.
I really liked Python, I wonder where it started to go wrong.
 
Being one of the top languages generally is bad for keeping the number of critics low.
 
8:49 PM
@WantingtobeanAndroidDevelor I bet you said more than that
 
The critics are not the problem though right?
In fact in theory, critics are good
they make a language better
 
If they actually have valid concerns, there's no problem.
Contributors make languages better.
 
So long as there is a strong direction on which criticisms to solve and which one to not
 
Loud complaints aren't a direction.
 
I think there is a big problem though when you start trying to comply with all of the criticisms.
Kind of like what Rob Pike said, if you accept all features a language can have, there will not be any point in having different languages. And they will all just be the same
I personally think that is what is kind of happening with Python
Just adopting every single features from other languages
And complying with every single usecases there could be
 
8:52 PM
@WantingtobeanAndroidDevelor And now Golang has generics...
 
I heard the syntax for it is not good though
No angled brackets <>
 
A shame they don't do generics all just the same, right?
 
I don't know, I don't really use go lang as an every day language
but can someone just implement some forceful typehint comment thing that just forces a type to change below a comment or something?
E.g.
# Typehint: a: int
and everything below that, typehint just assumes a is an int no matter what was said before
I think that would be a far more useful implementation than confusing my self with typeguards
And why is there no negative case for the type hint?
It's crazy
Using it only made my code even more confusing
 
I have a "__new__" method in a base class. In this method, how do I find the subclass that is the one inheriting from the base class, if a inheritance hierachy is used?

class Base: -> class A(Base): -> classB(A)
I have a solution already for this, but I want to know if there's something simpler than searching down the whole hierachy tree.
 
Anyone have experience using Office Open XML?
 
9:06 PM
@Warcaith You get the class as the first argument
 
:55570730 Yes, exactly. I will get the "B" class, which has the "__bases__" of (A,). I want to find the one that has the "__bases__" of (Base,)
Which basically here is just cls.__bases[0].__bases, but I want it to work in any hierachy. :P
 
Then you need a loop. Or if we disregard multiple inheritance, something like cls.__mro__[cls.__mro__.index(__class__)-1]
 
What's the difference between "__mro__" and "__bases__"?
But yeah, I'm currently using a loop for it :p
 
The MRO is a flattened sequence of all the base classes
 
Hmm.. mro is actually what I need, I think. Cool! :D
 
9:14 PM
class A: ...
class B(A): ...
class C(A): ...
class D(B, C): ...

print(D.__mro__)  # [D, B, C, A, object]
 
@ZackTarr do you mean like, with their python bindings? I know Libreoffice have pyooo, pyuno, and uno (and pyo I think) for interacting with it. There probably something similar for OpenOffice
 
:55570785 Aaah, the __mro__ is readonly, which is not the case of __bases__
 
 
1 hour later…
10:40 PM
@WantingtobeanAndroidDevelor Please continue complaining elsewhere. Thank you.
 
Yes I said We shouldn't complain here
I don't know why I get the blame for all this
 
takes a hint and cuddles it
 
but for the nth time, can a mod or two please delete the links I have posted
consider them inappropriate
 
sure, let me take care of this
and my work here is done :P
 
10:42 PM
it's done
 
*insert "but you didn't do anything" meme*
 
What fun we all had
 
I'm glad I never complained to this level
 
10:43 PM
Oh thanks, so Ouroboros is the bin?
 
Yes. Now enough of that, thanks
 
Technically it’s recycling
 
infinite recycling I might add
 
10:43 PM
circle of life and all that
 
Anybody used dart?
Ya, whatever at least it's the bin
 
Those are the pointy throwy things, right?
 
I mean they should delete it at one point but who am I to care
 
@WantingtobeanAndroidDevelor stop
 
10:44 PM
@MisterMiyagi No, only one of them
 
@WantingtobeanAndroidDevelor In case it's not clear, you're not exactly on steady ground here. If you want to keep contributing here, play nicely. Stick to python and forget about ranting. We can help with specific technical issues you might have, or you're welcome to join any existing on-topic discussion you see. We're not interested in the rest.
 
oh you don't wanna talk about dart
k fair
 
@WantingtobeanAndroidDevelor I loathe repeating myself, but here goes: We can help with specific technical issues you might have, or you're welcome to join any existing on-topic discussion you see. We're not interested in the rest.
and with that we're done for now
 
Then I feel that you could have just kindly confirmed that it is not the place for it. Rather than a provocative kick with no comment. But anyhow I don't have any questions for now so I'm just gonna leave. Bye thanks for the convo
 
10:54 PM
Googling is giving me contradictory results, so does anyone know if openpyxl can write an excel file with macros? (My attempts so far would suggest "no")
 
My immediate reaction is no
 
I'm using openpyxl at the moment. what do you mean by this? Like using your average excel editor's macro with it or?
 
(More specifically, load an excel file with macros, change some cells, then save it somewhere)
 
you can think of openpyxl as a glorified pandas but for excel files (the latter can also work for those files, but that's beside the point). You can use notation to interact with the cells of your file, such as A1, etc
 
I don't remember having any positive experience with openpyxl
 
10:56 PM
@NordineLotfi I have an empty file with macros (.xlsm) and I need to modify some cell values/formulas. Don't need to modify the macros, just preserve them
 
I feel Pandas should just be made more like an excel or somehow have CSV that can act more like an xl, then handle xl with python
 
When I do workbook.save('foo.xlsm'), excel says the file is corrupted. But I've seen some people on the internet say that it should work as long as you open the file with keep_vba=True
 
Did you have the file open with excel?
 
No
 
What's the status of .xls* files these days? In principle fully portable with official specification, in practice hit or miss?
 
10:58 PM
@Aran-Fey I didn't yet try using macros with it yet, but I'll look around and see. I think it should work as you say
 
I rarely use Excel, but my company is currently in the process of standardizing our Excel versions (we have some 2010s and some 2016s...) because of compatibility issues
So... 6-12 years ago it was hit or miss. Dunno about today :D
 
I wish you could use python to define new Excel functions
 
I don't even know where the VBA lives
 
I think spread sheet softwares in general are underrated systems
It is a Programming language. A functional, data oriented programming language.
Pretty neat imo.
 
11:01 PM
Great. You done?
 
I have mixed feelings about them. On one hand they're great because they make "programming" very accessible, but on the other hand they result in extremely WET "code"
 
And you can make plots, intuitively, that changes interactively as data change.

You don't get that kind of features even in jupyter sadly
@Aran-Fey What's a WET code?
 
spreadsheet software is great for things it's good at, but most things in the world are not spreadsheets
 
@WantingtobeanAndroidDevelor Write everything twice
Spreadsheets are the non-programmer's relational database. Most things in the world aren't rectangular, and yet here we are...
 
Ya, I wish you could define the functions as a python program somewhere, and just apply them in spreadsheet format.

I know google spread sheet does something similar but with JS, and it was pretty complex and not good experience.
@Aran-Fey I feel this take is a bit unfair though. Because I think it actually aligns with hot trends in the programmers world as well. Like interactive data exploration, and data oriented paradigm
 
11:05 PM
Please only flag messages that are offensive. Thank you.
 
@Aran-Fey if the compatibility issues are caused by the macros, then that's understandable (and sad given the time frame). I can already see there a lot of difference between each excel editor and macro system, but then again, I never used any macro system extensively, so I don't really know them.
 
I got to vote on my own message. This is fun
 
@AndrasDeak--СлаваУкраїні Oops, I clicked on the "valid" button by mistake... my bad
Who all gets to vote? Everyone? or just reputed users
 
10k+
 
11:07 PM
Can ROs see flags even if they don't have enough rep?
 
How you vote is up to you. Normally common sense of voters prevails.
@Aran-Fey I used to know the answer to that. I think the answer is "no".
 
Yep totally
 
wait, people here can vote message from this chat?
 
I had a feeling that I've asked this question before
 
@Aran-Fey No, I don't think so
 
11:08 PM
@NordineLotfi yeah, and you're way in the negatives
 
@AndrasDeak--СлаваУкраїні doesn't surprise me
 
(no, you can only vote on "rude/abusive" flags raised on the messages of others, if you have 10k+ rep)
 
@Aran-Fey No, only 10k+ users and mods
 
Had to join in to inspect the flag.. ? :p
 
11:09 PM
ROs get very bad tools to help with most stuff in chat
 
@AndrasDeak--СлаваУкраїні so I said rude/abusive message before then? :/ weird
 
Thanks Zoe, and thanks Andras for thanking Zoe for me
 
I mean I don't intend to appeal the result of the vote.
But I just wanted to justify my case for flagging as it could be seen as provocative or rude.
How it is judged in the end I agree is up to you.
 
@DelriusEuphoria no, it's probably just a coincidence
 
@NordineLotfi A person has decided to flag multiple of my comments as offensive, so it gets sent out to a vote
 
11:09 PM
@NordineLotfi not that I know of. I was only joking. Relax.
 
@AndrasDeak--СлаваУкраїні If you by "coincidence" mean "exactly what happened", you'd be correct
 
@AndrasDeak--СлаваУкраїні I see. Not that I mind either way, but thank you for confirming/answering :)
 
@ZoestandswithUkraine patrick stewart mild shock gif!
 
@roganjosh I see, interesting
 
so let's move on, please
@Aran-Fey thanks
 
11:11 PM
Didn't know you were canadian
 
also Thank you Zoe, it's rare to see you around here :)
 
Because of the excessive politeness :P
 
I think the Candian is polite joke only translates to Americans and Canadians
 
11:13 PM
Argh, I've been outwitted again...
I'm glad you're around again, you're on my wavelength
 
at least you're not stuck coding excel files
 
Although evidently I'm not always on yours...
 
@Aran-Fey good to see you too :) I'm usually not very far though, just outside
I'm only here now because of a bootstrapping issue
 
Also I just realized WET is opposite of DRY
Write Everything Twice, Don't Repeat Yourself
 
Also glad to see you Andras. I wish I could understand when you're joking or not but I guess it does add some suspense so that's nice
 
11:25 PM
@Aran-Fey did you also see this comment suggesting it's a regression that it doesn't work?
October 2015, yikes. Might still be worth checking out just to see that it indeed worked at one point.
Python 3.4, haha, maybe not then
 
Oh, I hadn't seen that, thanks. Sometimes there's gold in the comments, huh
I've got a few potential workarounds lined up now, but they'll have to wait until tomorrow
 
Is it also getting late where you are? Huh.
 
Yeah, I'm like 8 hours ahead of Canada
 
night
 

« first day (4420 days earlier)      last day (538 days later) »