« first day (3758 days earlier)      last day (1175 days later) » 

12:08 AM
@Hakaishin collections.namedtuple, then. But idk why you'd be so adamantly against them such that "I won't even use them when it makes my life easier!"
also, you could just use typing.Any
 
12:20 AM
@Hakaishin Are all three args required? or do some of them have defaults? ('None') Personally I'd rarely have a 3-arg constructor that didn't default the last arg or two.
 
really? tons of stuff i do requires more than 1 or 2 args (which dont really make sense to have defaults or kwargs)
i guess you probably dont make a lot of POD-types
since I think that's mostly where I use them
 
12:35 AM
@alkasm Uhuh. Depends entirely on whether your classes are just one-to-one wrappers for well-behaved datatypes that never have NAs, or something requiring more complicated default behaviors e.g. a User class where we're only guaranteed we get username or email, not lastname, cellphone, zipcode, age, list of contacts etc.
You're reminding me of restaurant- and map-locators which are primarily intended to be used when user is logged in (to some rewards program, aka. tracking, tracking everywhere...), so when they're not logged in, they default location to an 'average' location e.g. Kansas/ Missouri/ etc. instead of a less stupid default based on your IP address. I must have interacted with four of those in the last week alone. (hey, what is the default centroid-of-population for 'everyone on Earth'?)
 
@smci yeah I can see that. I work with a lot of simple data types so end up having quite a few namedtuples hanging around my codebases
 
at least they dont all live at null island
 
@alkasm Hey! Get off my island! :P
 
oh sorry i was looking for the nan archipelago
 
12:44 AM
I just love those restaurant chains that chirpily geolocate you "Your nearest location is Midland, Texas. Would you like to order takeout or delivery?". To be even more Douglas Adams, they should give me a delivery estimate for 1450 miles.
 
lol ive had doordash do that to me before
search for a restaurant that's down the street
 
I imagine people in Alaska, Hawaii, Guam, FSM get this even more...
 
distance: 3000 miles
??? lol
 
"When you have to use Great-Circle routes to calculate the distance, something's off"
Someday there'll be drones that do Mach 6..12, except they won't be delivering sandwiches to hipsters.
@alkasm Isn't it Bing that does a really bad job on default geolocation?
 
wouldnt know
 
 
1 hour later…
2:04 AM
cbg
 
 
2 hours later…
4:11 AM
@Dodge cbg, how goes?
 
4:34 AM
is using print for debugging bad practice? should I be using pdb?
 
@python_user I use print a lot, at least initially, tests, and inserting the occasional print statement in a test if I want to confirm something, and then reach for the debugger. I've never really used pdb though, PyCharm's debugger has been enough for me.
 
@toonarmycaptain I'm well, thanks for asking. How are you?
 
thanks for the input toonarmycaptain
 
I lie slightly...sometimes I'll reach for that first, usually to find what a variable is at a step. Just as often I'll rerun a test though, with an assert var == what_i_expect, then assert var != what_I_expect which with pytest will give you what the var is and what you were asserting it was.
@Dodge I'm good, busy with house and kids. I've been at home with a 4 month old addition, and we've been taking advantage of a bathroom flood to put in wood floors in part of the house.
You?
lol, I you just said good. It's late. You been up to much?
 
@toonarmycaptain I've been super busy, hardly get to hang out here much lately. I'll often read the transcript on my phone. Do you think PyTexas will be live and back on schedule this year?
 
4:47 AM
@Dodge In-person this April? I have my doubts. Might be online though, but I haven't heard anything.
 
What programming projects have you been writing lately?
 
Not much, created a personal website late last year. Been maintaining mostly. This week I ported to Github Actions one of my projects that seemed to have been hitting some sort of limit on the free tier of TravisCI.
 
5:10 AM
I might take it away from Appveyor as well...I'm rerunning the tests for updating some dependencies on there a third time now...I had 2 python versions fail the first time, 1 the second time, some tcl error because servers aren't setup with GUI stuff.
And Github Actions seems to run Win/*nix builds fine, probably MacOS too.
 
Sounds like a pain. Is that a "serverless" deployment platform?
 
Which? I'm just using Appveyor to run tests. I think both can be used to deploy/build executables/installables etc
 
Oh okay. I thought you were saying you'd take your site from Appveyor.
 
Nah, just stop bothering to run the CI on there, since Github actions is running my tests on Windows and Linux.
 
 
3 hours later…
7:54 AM
Cbg fellas
 
8:27 AM
cbg
Anyone know how to use mixins with a NamedTuple in 3.9? I was using this (stackoverflow.com/a/47440629/5087436) successfully but after writing some new tests, I found out this doesn't work in 3.9.
 
I recommend not to. NamedTuples aren't really classes in the common sense.
 
(It is important that the object is a tuple, which is why I'm not just using a dataclass or my own type)
 
Are you looking at adding methods or fields via the mixin?
 
methods. Class decorator, then?
 
@alkasm Pretty sure that code has a subtle bug. The namespace should be passed into here return type(typename, bases, {}), not in the super().__new__ call
 
8:34 AM
@alkasm Yeah, class decorator should be fine. You can just attach the methods to the NamedTuple class after it has been created.
 
Dare I ask why your operators must be tuples?
 
Because they're being passed to OpenCV which wants them to be tuples (I think numpy arrays also work in every case, but I like them being immutable)
At the same time if they were numpy arrays, wouldn't need to mixin arithmetic operations, eh
@Aran-Fey as the dict argument to type()?
 
Yeah. Give me a minute to whip up a small demo...
 
Thanks, I appreciate it
 
Well, that's the first time I've seen this error ._.
> RuntimeError: __class__ not set defining 'TestMixin' as <class '__main__.TestMixin'>. Was __classcell__ propagated to type.__new__?
 
8:42 AM
Never heard of a __classcell__
 
class DemoMixin:
    def get_class(self):
        return 'DemoMixin'

class TestTuple(DemoMixin, metaclass=NamedTupleMetaEx):
    a: int = 0

    def get_class(self):
        return 'TestTuple'

print(TestTuple().get_class())
Try that. The metaclass reorders your MRO in a weird way
well, not the MRO itself, but the attributes of your class
 
:head spinning:
 
TL;DR: Avoid messing with typing.NamedTuple to avoid current and future headaches :P
 
hey guys anybody here know if it is possible to place incoming json into a wtform object as the submitted data and run validations accordingly
I have looked into wtforms-json.readthedocs.io/en/latest but doesn't seem to be working as needed I also have the csrf token sent in the headers along with the json
 
So, is that because super().__new__ is doing: bases = bases + (cls_obj,)? It should be flipped right?
 
8:53 AM
That's debatable. It would fix the error, but then you also wouldn't be able to override any NamedTuple methods in your mixins. If you want to be able to do that, then you have to extract the __annotations__ from namespace, pass them into super().__new__, and pass the rest of namespace into type(...)
On 2nd thought, it wouldn't really be a fix, it would only produce an even more subtle bug ¯\_(ツ)_/¯
(If you tried something like vars(TestTuple)['get_class'], you'd get a KeyError)
 
lol wtf
 
using a dataclass for your code and dataclass.as_tuple for openCV not an option?
 
I basically want to be able to use the objects naturally and pass them directly in, not require calling a method to convert them
...decorator it is!
I mean this is mostly an exercise anyways, because it's a fun test bed project to do so.
 
> CPython implementation detail: In CPython 3.6 and later, the __class__ cell is passed to the metaclass as a __classcell__ entry in the class namespace. If present, this must be propagated up to the type.__new__ call in order for the class to be initialized correctly. Failing to do so will result in a DeprecationWarning in Python 3.6, and a RuntimeWarning in the future.
Aha, that explains that error
 
OpenCV has structs for these types, like a Size, Point, Rect, etc. But those aren't exposed in the Python API. Instead, funcs that take those types take tuples instead. But those structs have nice methods, so it's like OK well you can just use a namedtuple and add methods so they behave like the structs. But then I wanted to share code among them, so broke it up into a mixin, and...here we are.
 
9:44 AM
cbg all, I am planning to use aiohttp to replace my requests calls in my python code, other than adhering to async syntax, should I make any other change to my existing code? (db connections more specifically)
 
It's pretty similar to requests as far as I know, so you probably won't need to do anything else I think
 
thanks, I will use them then
 
10:16 AM
jsut wrote first question since ban :/ hope it is good enough to lift me out of the ban... put a lot of effort into making it nice
 
that (your question) is very detailed
 
I have tried to make it as detailed with the links I have been looking through and with the situation... a bit of a difficult one because there arent many error messages to go on
and not much to go on online
 
10:32 AM
stackoverflow.com/questions/65952644/… seems fairly harsh to downvote all the answers o.O
 
Ha, a downvote or two will be the least of their worries after answering such an obvious newbie question that's actually two questions
OP's gonna have a billion follow-up questions for them, just watch
 
o.0 oh damn
 
"I know the usage of input() function . my problem is the result can't detect input function . it just ...."
it already started, :D
 
OP speak for "I have no yammin' clue what I'm doing"
Haha, I just realized that everyone (including me) misunderstood the question
 
Hmm how so lol
 
10:44 AM
It's not "How do I take user input?" but rather "Why does vscode automatically input the path to this bat file?"
 
yeah, it sounds like they are seeing behaviour that isn't normal, and the question is, why. Personally i dont have even a theory or clue as to why this would happen
 
Wanna place bets if the OP will provide sufficient information to figure out the problem? I'm torn between "no" and "yes, but it'll take at least 3 hours"
 
11:00 AM
sounds like he has activated the environment wrong?
 
11:12 AM
i think latter Aran :P
 
 
1 hour later…
12:26 PM
Curious if anyone knows this, i was playing around with tesseract OCR psm modes for some work, and noticed some drastic improvements in changing the modes. (specifically, mode 11 did a ridiculously good job, but a few modes were even worse than default)
In my mind though, an ocr model is primarily based around pixels on the image, right? Why does psm have such a big impact on outputs?
Logically, im assuming there must be some extra steps behind the scenes that i'm missing, but couldn't find any good source on this
 
 
6 hours later…
6:07 PM
hey guys, what does it mean when your index is on a different line when you print out a dataframe
            Email_Month Email_Year          key value
key
April201900       April       2019  April201900    10
for example
this is the default behavior of selecting a column in a df to set_index() with
and instead if I return the .values() of the column (or series) then you have a flat structure more like what you usually see with a df index (no extra line)
 
is it not just that the index has a name?
 
if an index is named can that have adverse interactions with a column of the same name
 
"if", I'm not sure, I don't use pandas
 
(in this case i didnt drop the key column since it was actually desired to keep the column)
anyways, that was kind of more like an aside that I dug a little deeper into and doesnt seem to be the source of my main problems
 
 
2 hours later…
8:49 PM
hi, I am coding in api environment of an engineering software. the code bellow is from the script i have developed so far. in part of my code, i need to iterate on the StifInstances but i do not know how to do this with python codes. is there anyway to iterate over StifInstance with any inline iterations or any other ideas?

myAssembly.InstanceFromBooleanMerge(
domain=GEOMETRY,
instances=(BeamInstance, StifInstance[1], StifInstance[2], StifInstance[3],
keepIntersections=ON, name='Part', originalInstances=SUPPRESS)
doing an outer iterations was not working, i mean it disturbed my model.
 
Hi, people
 
@AaronHall hello
 
9:04 PM
@enthu sorry, I don't understand what you're trying to do. But the code you have looks broken: instances starts out like a tuple but then it has keywords inside.
I suspect a closing parenthesis is missing. And still I don't know what you're asking.
 
@AndrasDeak i did not copy the code completely. I want to do something like StifInstance[i] for i in range...
 
instances=(BeamInstance, *StifInstance)
 
So you want to iterate over StifInstances. The first (only?) thing we need to know is where those instances are stored. A list? A dict? Nowhere?
 
9:20 PM
@AndrasDeak did not work
 
That reminds me, what happened to the train wreck from earlier? Has the OP updated it at all since it got closed?
 
@enthu then it can't be done
 
@Aran-Fey these are different parts in a fem software, which i am trying to merge. they are not arrays or numbers, for instance StifInstance has lots of codes in its back
@AndrasDeak all right, too sad... :(
 
Perhaps if there was more information about your problem and "it doesn't work"...
 
@Aran-Fey i think they are tuples... I can bring it it outside the code
 
9:25 PM
So what's wrong with a simple for instance in tuple_of_instances: then?
 
can i append members to a tuple outside my main code? something like this:

tempList = (BeamInstance, StifInstance[i])

myAssembly.InstanceFromBooleanMerge(
instances=tempList)
 
please don't call a tuple "list"
 
@AndrasDeak sorry i mis-use keywords. because i am not having rich python knowledge...
 
you can't append to a tuple from anywhere, but you can append to a list
I don't see any appending happening in that code snippet though
 
@Aran-Fey they want to build a new tuple, that's just a language barrier thing, not an issue. The issue is the dangling [i] which I'm sure is undefined, and that's a conceptual problem.
 
9:29 PM
577
Q: Convert list to tuple in Python

LynnHI'm trying to convert a list to a tuple. Most solutions on Google offer the following code: l = [4,5,6] tuple(l) However, the code results in an error message when I run it: TypeError: 'tuple' object is not callable How can I fix this problem?

 
@enthu unfortunately we can't really communicate effectively, so the only other option for us is to see actual, hard code.
And a very good explanation of what you're trying to do.
 
@AndrasDeak But if that's the question then you already provided the solution earlier...
 
@Aran-Fey yes, but that did not work ¯\_(ツ)_/¯
 
@AndrasDeak ok, thank you. I understand
 
Yeah, I have no idea what's going on anymore. Why are we suddenly converting lists to tuples?
 
9:32 PM
i thought i can append S[i]s to a list and then convert it to a tuple
sorry i think my questions is too simple and i made you confused... thanks all. leave it away.
 
Yeah, you can. But we still have no clue what you're actually trying to achieve
 
@enthu remove your original problem for a moment. Define BeamInstance = 3; StifInstance = (-1, 42, 'potato'), and then look at res = (BeamInstance, *StifInstance) and try to tell us why this isn't what you're looking for. And take note of what I did here: I tried to come up with an MCVE for you.
 
@Aran-Fey i am coding in api of a fem software, i need merge instances using a script code there. but when i iterate in a script code, it fails.
 
That's far too abstract to be of any use. What does "merge" mean there? How does it fail? What does iterating have to do with anything?
 
@enthu I've just walked into this but can you please give a mcve because your question is confusing me. We're happy to help but I can't get a foothold on what you're asking
 
9:35 PM
@AndrasDeak i understand that your suggestion works well. when i bring it to the script codes, it does not work. no problem by your example. it just fails in the script of the software...
 
@enthu OK
 
@roganjosh how can i provide a mcve when all my code is scripts of a software, you can not run it in a python ide except if you do it in the software... i am confused how to do it.
 
I'm pretty sure that this is what's going on: You have an XY problem. Your problem is X, and you think the correct way to solve your problem is Y. So you ask how to do Y, instead of asking how to do X. Then we ask for more details and you suddenly start talking about Z, another possible way to achieve X. Don't ask us anything about iterating or converting lists to tuples. Tell us what your actual goal is.
 
Nice chat weirdness. I can open my last comment for editing to fix "can';t" which I did, but when I open that comment for editing, the fix is in the text
 
but I reloaded and it's edited now
 
9:39 PM
Fill in the blanks:
"My input is <insert input here>"
"The output I want is <insert desired output here>"
 
Indeed it is. Maybe I've seen this bug before. I forget what strange things I've encountered on chat :)
@enthu part of the process of making an MCVE is thinking exactly that. It helps you focus on the specific problem, because most of the context is probably not relevant
 
my input is: (BeamInstance, StifInstance[0], StifInstance[1], StifInstance[2])
my output is: i want to make it making it general, the StifInstance[n]...
 
Well, I can't run that
 
@enthu do you realize that you're explaining a part of the problem that we agreed I told you how to solve?
 
Then Andras already gave you the solution like half an hour ago: (BeamInstance, *StifInstance)
 
9:44 PM
you said yourself that the problem is elsewhere...
Anyway, I don't want to pile on. The others can (try to) help.
 
all right. sorry i wasted you time. thank you all.
 
Our aim is to understand the problem and help where we can. Rather than abandon things, I think it's useful to take the feedback on board and try reframe the way you look at the problem (I appreciate that I've not been part of that discussion)
 
@roganjosh i understand. but sometimes i try to do my best to come as close as possible to the framework people here expect the questions should be asked but i cannot. the more i try, the less i succeed. and this brings me to the point that i think i am like a fool or have very lower understanding. problem by my side. you all did your best. thanks, by the way.
 
I don't think it's so much that case. If you give illustrative examples then people will help (I have no doubt of that). If you can't make an isolated, small, example of the issue you're facing then you don't have a grasp on the problem yourself
 
10:27 PM
Sorry, I just had to laugh at my comment here. Also, possibly stackoverflow.com/q/65962534/198633
 
too new for cv-pls...
If you look at the source of the question there's a screenshot they couldn't inline due to no rep.
So if anything it's just sad as usual
 
If that question gets edited into a decent shape before the cv-pls grace period ends, I'm gonna... I'm gonna... I don't know... I'm gonna answer a question on SO
 
it's the pandas tag...
 
I've taken that into account
 
11:00 PM
@inspectorG4dget definite close vote. That's not even a question!
Foul Ole Ron is grumpy tonight.
 

« first day (3758 days earlier)      last day (1175 days later) »