« first day (3796 days earlier)      last day (1142 days later) » 
00:00 - 20:0020:00 - 21:00

12:31 AM
hey, would it cause any problem is i changed all my database classes on python to lower cases
ex ( instead of 'class Users' >> 'class users' ) ?

the reason why i'm asking this because I kept confusing myself, and it's kinda annoying , all classes are capitalized unlike the actual database columns
i suggest having both of them in lower cases, is that ok?
 
12:43 AM
@LoopingDev with very few exceptions, database table and column names, like sql reserved words, are case insensitive.
 
i think so too but not sure, i guess there is no harm in using flask-migrate to change it back if necessary.
I'll go for it , thanks :)
 
* I can't think of the exceptions. maybe ms access, older mysql-innodb. the actual filenames which store db and table data are case sensitive but the engine will ignore case
 
yeah it looks irrelevant what sql actually does things and how it work
 
but changing all your class names in Python to lowercase breaks Python conventions - for no real benefit. once you realise that "all case-variations of User.ID in Python" == "all case variations of user.id in SQL", the different-case in code vs sql will make no difference to you
 
1:00 AM
well it's sort of mind step where whenever i want to pull something from the database i think of the class name and by default the class name is in 'lowercase' but leaving the clases capitalize would force me to think of the class name rather than the column's , which doesnt make much sense to me.

it wont break anything because I've started this project from scratch and it's fairly empty at this point.

I could dump the whole database and raise a newer one if i want to and won't hurt the process even a tiny bit.
 
 
2 hours later…
3:24 AM
cbg, is it ok to manually have an enumerate like my code below instead of suggestions in this stackoverflow.com/questions/48070863/…? are the answers syntactic sugars?
idx = 0
async for i in async_iterable:
    # do something with `i`
    idx += 1
 
 
4 hours later…
7:06 AM
@python_user Yeah, not a big deal
 
7:26 AM
seeing an SO question usually gives me higher expectations :D
 
8:24 AM
Wow, functools.partial isn't a descriptor?!
 
8:38 AM
cbg-ning
 
9:36 AM
@Aran-Fey nope. functools is full of x and Xmethod twins. :/
Can't think of a case where having partial invoke its argument as a descriptor would be a problem, TBH.
 
If there's one good thing about today, it's that I've discovered a miracle cure for low blood pressure: Working with sphinx
The sphinx experience summed up in one answer: stackoverflow.com/a/18399167/12465136
5
 
10:04 AM
@python_user If you need a break as in the question, I recommend to <shameless plug> use asyncstdlib. If not, the manual loop is perfectly fine and much cheaper.
 
@Aran-Fey i did not see that coming, chuckled audibly
 
@MisterMiyagi my usecase is that I want to know how many times the for loop runs before it gets an exception, so its basically for a debug run
 
ah yeah, while debugging "anything goes" really
flaskbacks to eval...
 
debug code soon becomes actual code that handles Exception for me :D
 
@python_user in that case, if the iterator holds state you should use an aclose(aiter(...)) or asyncstdlib.scoped_iter context. But often you still get away doing it the usual way.
 
10:16 AM
I will install your library and see how it goes, I am planning to understand async and seeing how stdlib works in async seems like a nice way
the more I think of this the more I find actual non async enumerate redundant
 
hi fellow members
i have a query would any one like to give his feedback?
 
hello :)
 
2
Q: print data on a sample image but the text is going out of image

Abdurehman Dar ALL of the data in the picture is taken from an excel sheet size of the image is 220×320 I cant increase the image size. But i want Line 4 data that is exiting the image to go down below row 4. import pandas as pd df = pd.read_excel('vetements.xlsx') from PIL import Image, ImageDraw, ImageFont d...

kindly look into it if anyone of you have time i'm new to the great world of python and got stuck in my first problem
 
All this a-cruft just feels like I'm looking at a different language, call it aPython. Python 4.0 should unify these paradigms so that all this hoop-jumping just gets handled.
 
@PaulMcG or Nodethon or Pynode or something? :p
or even node.py? :p
 
10:31 AM
@AbdurehmanDar textwrap.wrap('text to wrap') can help you with this, if you are going to go with the last comment
 
can you guide me little bit more about text warp? or send me a link to get to know about it.?
 
@PaulMcG in my limited understanding of the topic, this unification faces a fundamental barrier of how sync and async cannot sit together with each other
 
thanks man!!!! appericiated
 
@PaulMcG would love to see it, just don't know how. I guess most people don't want to pay the async overhead when they don't need it.
Alas, it would be much simpler if Python were suited for compiling...
 
10:36 AM
i've lately started wondering what it would take for a "python-like" language to exist that tries to allow compiling
 
We do these things not because they are easy, but because we thought they were going to be easy.
 
@ParitoshSingh IMO it would be enough to just allow marking things as "not mutable".
Monkeypatching is fun and games, but just not needed for most things.
I just need to solve how to bootstrap types...
 
it's just a thought at this stage, but it would be amazing to get a derived language that essentially allowed people to write python or "as close to python" as possible, but make it more performant and support good compiling
@MisterMiyagi i suppose, but then i wonder would people would make the switch for just that little feature. i was wondering more along the lines of making types "sticky" and allowing type inference and so on
so it would fundamentally not be "python" anymore, but with clear gains for python coders to use it with almost no friction for tangible benefits to compilation and efficiency perhaps.
Dont think it would be easy though
 
dunno how/why I'm getting a connection timeout error on the mainsite but chat is working normally... (diff machines/networks obviously)
 
@ParitoshSingh I'm not a fan of making types themselves "magically immutable". That seriously hinders some of the meta-programming that is often useful, and means one has to bake-in the type-system upfront.
 
10:46 AM
@ParitoshSingh Typethon
give it three more minor versions and we're there
 
There's already MyPyC...
Speaking of which, did someone try that?
 
@MisterMiyagi aye. it's a major design decision though, because this very feature singlehandely means python compilation can no longer optimize and make fast code
gosh, the python type system...it breaks my heart
i genuinely dont think it should exist, even today :P it feels so "tacked on" yet its started infiltrating every code base im working with now
 
@ParitoshSingh My idea would be to allow to decide which things are im/mutable. If that one class is your performance bottleneck and doesn't need magic, by all rights declare it immutable and have the compiler take a go at it.
FWIW, I blame PyPy for giving me some strange ideas...
 
hmm. you might be onto something there. that doesnt sound half bad to me to be completely honest. i suppose i'll have to sacrifice on the "keep code as close to current python as possible" aspect for perhaps just this 1 keyword
but it does sound like an infinitely easier route to take
 
Well, I just need to solve how to bootstrap types...
curses Girard
 
10:53 AM
@MisterMiyagi but it's not just mutability, right? It's also that names can be anything.
 
i think you'd "have to" make this variable name "stick" with this object for it to work in any capacity.
so the implication is, if you declare this as immutable, the name is probably also tightly bound in the same go. otherwise subsequent lines still have to do their lookups for that variable name
but that is a very strong deviation from how python currently treats variables
 
@AndrasDeak But only because namespaces are mutable, eh? ;)
 
@ParitoshSingh "same go" of what? We're talking compile time, but names are looked up at runtime...
 
of compilation imo
 
@AndrasDeak IMO a JIT is the only thing that would work properly to have "good enough" semantics.
 
10:58 AM
that's also my layman's impression
and JIT works pretty well for the numerical stuff
 
Though Julia demonstrates designing for a JIT is enough to translate certain program AOT.
Which is usually what one wants – no point solving every case completely, just the few ones with impact.
 
I guess the reason this mostly works for numerics is that native python types are too wobbly
you know where you're at if you have an array of doubles
 
PyPy has some interesting prior work on only providing the runtime features your code actually needs, not the one it claims it needs. They have some nice tricks of exploiting immutability of builtins to prove that arbitrary size list of arbitrary size integers is indistinguishable from an array of unboxed native ints.
 
huh, that sounds pretty neat
 
11:18 AM
How would I go about testing my module against every version of typing.py that ever existed? I can write a script to pull all versions of the file from the cpython repo, but then what?
 
isn't it "easier" to build all those older pythons?
 
Hmm, maybe
 
Are there historic binaries? Then you can use a windows virtual machine.
 
Don't think so, looks like I'd have to compile it myself
 
compiling stuff is good - get to take some time off :p
 
12:24 PM
if one edits only the tags on a closed question via the quick menu/list/shortcut next to the tags - does that put it on the review queue for re-opening?
 
I think it's just title/body edits...
 
ok, good to know. will leave the unmentioned question in question untouched for now. it has no hope
 
1:07 PM
Ugh, somehow the typing internals keep getting worse instead of improving
Previously you could extract (almost) any generic's TypeVars like List.__parameters__, but now... List has nothing, list has nothing, and even if you know that lists are a MutableSequence, MutableSequence also has yammin' nothing
 
the initial typing stuff was nice, even if incomplete. the way it is now - if used fully - may as well be writing Kotlin. just wish it could compile to C++ or assembly, instead of just java bytecode. I guess that's why Go exists. just my $0.02
 
2:02 PM
@Aran-Fey I think you have to use get_args now. But I haven't bothered after trying it some time ago. Way too much of a hassle.
 
2:15 PM
Can anybody helo me with this- I want a list of integers but those integers should be in binary. For eg: I declare a=[1,2,3,4,5]. Now I want the program to return [0b1, 0b10, 0b11, 0b100, 0b101]. I am using the bin() function in loop to convert each element of list a
The problem is the output I get is in binary numbers treated as strings like [‘0b1’...........]
I want the output to be a list of integer in binary like [0b1.....]
could anyone help how I can do that
 
There is no such thing as "binary number". 1, 0x1, 0b1, 0o1 and so on all are the same value.
Numbers don't store their "representation", just their value.
What are you trying to do with these "binary numbers"?
 
Yes I want to get a list where each element is the binary representation of the integers in a. When I use bin(), each element after transformation is being treated as as string rather than integer
I need them in my code further
 
Well, because "the binary representation" is a string.
 
i want the list to be precisely [0b1, 0b10....]
 
That's like saying you want the list to be precisely [2**0, 2**1, 2**2, ...]. You can write that, but there is no unique value representing that.
Other than a string, that is.
 
2:23 PM
Does this mean you want the output to be precisely "[0b1, 0b10, ...]"? That can be done. But 1 is just 1.
It can be easily represented as "0b1", "0o1", and "0x1". But its still 1.
 
Yes I want the output to be precisely [0b1, 0
Ignore that just a sec
 
I want pizza
 
i understand what you are saying .....an integer is is an integer whether in binary or decimal. What I want is that the output be [0b1, 0b10, 0b11, 0b100, 0b101] rather than [‘0b1’, ‘0b10’, ‘0b11’, ‘0b100’, ‘0b101’]
 
It is common for beginners to mistakenly equate "what this value is" with "what I get when I print out this value". And by beginners, I mean people with up to a year of learning Python. I thing tutorials gloss over this, and its an important hurdle for learners to get over, because Python makes it so easy to see a default representation of something, when the actual content may be very different. Or that a different representation is somehow a different value.
You'll need a ", ".join in there somewhere I think
 
:51738551 generator
 
2:28 PM
yeah, just realized. sek
 
Nice take on str(lst), though
 
Can that be done
 
@Shashaank yes
 
f"[{', '.join(bin(val) for val in vals)}]"
 
Build a string that has what you need
 
2:29 PM
@AndrasDeak how, can you let me know
 
Eighth time's the charm
 
@Shashaank no
 
Would anyone else like to tell me how May I do it
 
@AndrasDeak that sounds like a great idea... and some decent garlic bread as well...
 
morning cabbages, folks
 
2:36 PM
@JonClements I'd be down for a fruid salad :)
 
that sounds a little boring until you got me thinking what on earth "fruid" could be :)
 
@AndrasDeak I wan an integer not a string. Why would I build a string
 
@Shashaank I see
 
a fruid is what you get when you genetically cross a member of the high-ranking class in ancient Celtic cultures with a tomato... either that or a Japanese liquid/gas
 
ooo... that last option is a little PC risque :)
 
2:42 PM
@Shashaank We have been through this, no? An integer is a value – 1, 0x1, 0b1 and so on are the same. If you want a specific textual representation, that's by design a str because str is for text.
 
Ooops! totally see it now that you mentioned it, even though I didn't mean it like that at all. I really need to stop posting before coffee
 
@MisterMiyagi How do I use this str
 
In [459]: a
Out[459]: [1, 2, 3, 4, 5]

In [460]: [bin(i) for i in a]
Out[460]: ['0b1', '0b10', '0b11', '0b100', '0b101']

In [461]: bins  = [bin(i) for i in a]

In [462]: for b in bins:
     ...:     print(b)
     ...:
0b1
0b10
0b11
0b100
0b101
 
@Shashaank Sorry, I don't understand the question. You use the string like... any other string.
print it, write it to a file, whatever you want to do with it.
 
Put it in a stew
 
3:03 PM
@inspectorG4dget I want the output as [0b1, 0b10, 0b11, 0b100, 0b101]....In this way each individual element of the list is treated as an integer. If I use your code, I get ( after generating a list with b ) [‘0b1’, ‘0b10’.......] ...here each element of list is being treated as a string type
 
this is an XY problem. As others have stated, a is already the list of integers. So I need to ask: what do you plan on doing this these "binary integers" (if I can call them that) after you get them in this representation?
 
I endorse MisterMiyagi's approach, it produces some very list-like looking output
>>> vals = [1,2,3,4]
>>> print(f"[{', '.join(bin(val) for val in vals)}]")
[0b1, 0b10, 0b11, 0b100]
 
@inspectorG4dget I need it in my code further of d separation in a reduced graph
 
@Shashaank I don't understand what that means. What is a "d separation"? what is a "reduced graph"? Are you using these values as axis tick labels?
 
@Kevin can I store this (output) in some variable
 
3:10 PM
Sure. x = f"[{', '.join(bin(val) for val in vals)}]"
Its type will be str though, as you have already observed
 
@Shashaank it is a string. its a string that "looks" like the picture you have in your mind, because that's what representations are. just "pitcures" of the real thing
 
d separation is a graph technique in Bayesian networks. Reduced graph is the graph obtained by deleting a particular node
@Kevin Thanks. The ‘x’ will be treated as a list by the compiler further, right?
 
Nope, str
>>> x = f"[{', '.join(bin(val) for val in vals)}]"
>>> type(x)
<class 'str'>
 
@Kevin is there no way to get a list out of it
 
i am kind of amazed by the backlog i've read so far. It's like you've "said" you get it, but your followup questions have demonstrated you don't. And just about everyone has already filled you in on why that's not a thing.
 
3:13 PM
You could make it become a list, for example using ast.literal_eval, but then it will become a list of integers, displayed in decimal
>>> y = ast.literal_eval(x)
>>> type(y)
<class 'list'>
>>> print(y)
[1, 2, 3, 4]
 
For yam's sake, there are no binary integers, they are just integers! If a function needs their binary representation, then that function should do that conversion. But the list of integers is the list of integers, regardless of how they are represented.
 
@Kevin so there is no way to store [0b1, 0b10, 0b11, 0b100, 0b101] in a list ( I need to store in a list because an important function which will be called has to use that as a list of integers but in binary form) such that individual elements be treated as an integer type...
 
Not with just the built-in types, no.
Can you rewrite your important function so that it takes a list of regular integers, and does the binary conversion later?
 
@Shashaank no such thing as "a list of integers in binary form".
but I'm really worried, that you really want: [1, 10, 11, 100, 101]
vals = [1, 2, 3, 4, 5]
[int(bin(val)[2:]) for val in vals]
# [1, 10, 11, 100, 101]
 
Hmm, when you say the function uses the integers in binary form, do you mean that it does boolean logic, like "is the third bit set?".
 
3:19 PM
@PaulMcG I am saying exactly the same thing.
 
I don't know if this helps, but just in case you weren't aware... Binary operators work perfectly well on regular integers, no conversion required
>>> (23 | 42) << 2
252
 
yeah, which also implies there's a very good chance your "important function" either already handles ints correctly, or can be written to handle ints as you needed, giving you results "as if" you had worked with their binary representations
 
Agreed
 
any recommendations for an online course on general programming best practices, preferably using python
I'm thinking about things like how to write readable code, code structure, project design, ide usage, git usage, deployement.
Maybe some OOP and functional principles in the mix. And preferably a course with an exam maybe.
 
CS50
 
3:30 PM
Coworker is on an kind of improvement plan and asked me what I would recommend
 
it starts with C but has python as well, I have not taken it personally but it has great reviews
there is a "style" helper they use that is like a beginner flake8
 
hello guys
where can i ask mongodb question
 
The best lesson on readable code is to sit in on our ninety minute arguments about whether [ a, b, c ] is valid styling
 
it's my first time when I use the StackOverflow chat feature
 
@fasil If you're using Python to talk to MongoDB, then you could ask in here
But if the question is heavy on MongoDB and light on Python, we might not have any useful advice
 
3:36 PM
@Kevin okay thanks.
i want to implement comment feature for a post.
so a user can create one comment per post,
post
id:p1

user
id:u1

comment
id:c1
postId:p1
userId:u1
 
Hmm, not sure you can enforce the rule of "no more than one comment per user per post" using just table relationships
Most commenting systems allow a user to create more than one comment per post, for the record
 
would a unique constraint on (user_id, post_id) not solve that? Or does mongo not work that way? (never used mongo before)
 
3:51 PM
I also don't know
 
4:19 PM
@MisterMiyagi get_args gives you arguments (e.g. get_args(list[int]) == (int,)), but I need parameters - how many type arguments the class accepts, and what their variance is :|
(e.g. get_params(Generator) == (+T_co, -T_contra, +V_co))
Apparently in 3.9 nothing knows anything about its own type arguments. You can do completely nonsensical stuff like list[int, str] with no problem
So I either have to make a complete database of types and their type arguments, or scrape it out of the docstring. I'm not sure which option I hate less
Never mind, that information isn't even in the docstring, only in the online docs
 
5:04 PM
Does anyone know of a tensorflow/keras model that can identify and label distinct people in video files?
 
5:18 PM
when people talk about monoliths, do you they just mean a django backend standard project type of thing?
do you still use django if you want to do microservices?
 
5:34 PM
@Kevin Besides which, using foreign key references is largely discouraged in mongo-world.
In general mongo relies on the program to enforce document constraints, and doesn't go in for referential integrity much.
@Trajan There's no specific reason why you can't run microservices on Django, but it is seen as rather "heavyweight" for such purposes nowadays due to its own bundled nature.
 
@holdenweb why heavyweight?
 
Because Django is so structured that even a very small web application requires a Django process to load a significant chunk of the framework: it wasn't designed in a sufficiently modular fashion. Flask, for example, takes a contrasting approach.
 
ok thanks
so what are you losing by using flask?
 
Convenience, mostly. Simplicity of deployment. Others may add to this list.
 
in what ways? sorry im not familar with that sort of problems
 
5:44 PM
you're losing basically what django offers. Whether that's a gain or a loss becomes both project dependent and somewhat subjective
 
@ParitoshSingh what does django offer?
 
a full fledged "batteries included" approach to building websites
 
Convenience because Django relieves you of a lot of design choices by providing integrated technologies (think ORM, templating, pagination, ...). Simplicity because Django is a known quantity to hosting companies.
 
as opposed to flask's "minimal" approach
:51740181 rubber duck strikes again, eh?
 
5:48 PM
@ParitoshSingh why would you want mvc? surely you want your own react/vue app on the frontend?
 
uhm, django and flask both are "backend" frameworks.
 
yeah but why do you need a template engine? surely it will just get it the way?
 
You don't necessarily "need" a template engine. It does provide the convenience of doing all the app in a single place. But the cost is that the templates often become highly coupled with the business logic in the Python code.
 
as an outsider looking in, it must not have gotten in the way for a lot of people who use it.
 
5:50 PM
@Code-Apprentice which surely you dont want?
 
I've done Django projects both as a monolith and as a separate REST backend with a JavaScript framework frontend. The later seems much preferrable.
 
@Trajan read the answer there. flask's dev server shouldnt be used to serve in production
 
hey , how i could use Dict with list that has a json or muliple json objects inside of it like so:
` data = [{'A0': 'a0', 'B0': 'b0', 'C0': 'c0'},{'A1': 'a1', 'B1': 'b1', 'C1': 'c1'}]

`

I tried to do it like so :

for x in data:
_A = data[x]["A0"]

but I got this error :

`TypeError: list indices must be integers or slices, not dict`
 
Wait why can't I have this title? Title cannot contain "How to understand my porfiling report?".
 
@Code-Apprentice django rest?
surely you dont want views, templates, forms in django ever?
 
5:53 PM
remember, for x in data means x is holding the "items" in the list, not an index number. this is python.
So, data[x] makes absolutely no sense whatsoever here.
 
so just x ?
 
try simply x["A0"] and better yet, it helps to use better names for things
 
cbg patch
 
yup, thanks a lot!
 
lol adding clion and perf made the title acceptable, gotta love random rules
 
5:55 PM
"Flask applications are mostly single-page applications (SPAs). It’s a good choice for small and medium-sized sites such as forums and personal blogs. Django is perfectly suited for large projects like e-commerce sites and CMSs."
arent all large apps like facebook spas now? but would django be better for large projcets?
 
large being the subjective term here, but possibly, yeah. you can make large projects with flask too though, so it really comes down to the same bottom line. do you want a battries included approach to web dev or a minimal "add pieces as you see best" approach
 
@Trajan "want" is subjective. Also, Django has it's own definition of "views" which are required to make anything useful with it.
so you can write a Django app with templates, including forms, if you want.
 
ok but for the most modern web apps
 
so guys, I have this lovely project I'm maintaining where a ton of functions all have these logging try/excepts and I'm making modules out of it. The main script is suppose to be able to set it own logging location, but the annoying thing is that atm this is creating an unnecessary dependency to a config file in every module, one which I dont even really know what to do with when I'm testing the code.
 
the answer is simple. toss a coin
 
5:58 PM
What would you guys say is the best way to setup logging here
 
@Code-Apprentice if you were going to write the next airbnb how would you structure it with python backend?
 
@Trajan can flask even do interactive single page app stuff like javascript without calling js
@Trajan this is why i was learning django rest framework with a javascript front-end
 
@Skyler yes but everyone uses react/vue now so there must be an advatange for that
 
@Trajan you mean flask+react?
 
i feel like there;s a very nice mixup of concepts between frontend and backend going on here.
 
6:00 PM
@PaulMcG I wish I could star this 10x
 
@Skyler nobody is hring for python only web apps, always react/vue on the frontend
@ParitoshSingh what am i messing up
 
@ParitoshSingh from what I understand SPA is saying something about how the frontend operates and I thought flask can only really do serverside rendering without help from js
 
@Trajan What do you mean exactly? Are you asking if I'd use Django or Flask? Or are you asking how I would design the classes and functions to implement the backend?
 
or rather I suppose its the js that gets some help from the flask since it does the actual rendering (after any flask jinja template stuff)
 
@Trajan the fact that python will happy connect to just about any frontend, and so react/vue shouldnt even be entering the conversation.
 
6:02 PM
@Code-Apprentice what technologies? like flask-python backend and react? or am i missing things?
 
@Skyler If by rendering, you mean spitting out the data to a response, it can render JavaScript in that data just as easily as HTML.
 
@ParitoshSingh when i mean react/vue, i mean not some html templating enginee provided by the backend
 
basically spitting out html/compiled jinja responses
 
@Trajan For building a web app from scratch, my preferred stack would be a Django backend implementing a REST API and separate frontend with a JavaScript framework. I know React bet, but I'd be open to using another framework instead.
 
@Trajan yes. you mean something that will "sit on the frontend". aka at that point why does it matter what backend is generating the data? use php, ruby, python, <insert languge x here> and <framework x y z> here.
 
6:05 PM
@Code-Apprentice why django with rest? what happens if you wanted nosql like big tech?
 
yep, this is what im learning in my freetime, for now im keeping it kind of simple since im learning JS too, but for designing the html components I'm also using handlebars
 
@Trajan You can do that, too, sure.
 
probably as I work on more complicated projects I'll learn some of the heftier js libraries but for now finding a tutorial that's written by modern javascript standards is hard enough as is
 
Django can easily be configured to talk to any database backend you want, sql or nosql
or both
 
I have two 3d arrays:
import numpy as np

a = np.array([[[1, 2, 3], [4, 5, 6]],
              [[9, 3, 7], [9, 0, 0]],
              [[0, 2, 1], [5, 2, 8]]])

b = np.array([[[2, 8, 2], [8, 7, 7]],
              [[8, 3, 7], [7, 9, 2]],
              [[9, 9, 1], [7, 1, 3]]])
 
6:07 PM
@Skyler Spitting out HTML does not preclude JavaScript. At the very least, you can just include <script> tags. If you get ambitious, your template can spit out react code, too...but if you get that far, you might as well write a separate frontend instead.
 
@Code-Apprentice ok so why did reddit and lyft choose flaks?
 
@Trajan IDK, you'll have to ask them.
 
@Trajan ask people who made it. actually...dont.
 
I want to iterate through the two arrays parallelly, but only the first two layers; I want the inner arrays side by side.
Using regular loops and `zip()` would be
 
I'm sure they have blog posts out there
 
6:07 PM
for i, j in zip(a, b):
    for t in zip(i, j):
        print(t)
 
ok guys
 
here's the bottom line. you're thinking that theres "one right answer". there's enough users of both django and flask to show otherwise
 
instagram is django but what's their spa frontend
 
My attempt:
for i in np.dstack((a, b)):
    print(i)
for i in np.dstack((a, b)):
print(i)
 
also one thing that's really frustrating, I wish there was wordpress like collections of django page templates sitting around
 
6:09 PM
Output:
[[1 2 3 2 8 2]
 [4 5 6 8 7 7]]
[[9 3 7 8 3 7]
 [9 0 0 7 9 2]]
[[0 2 1 9 9 1]
 [5 2 8 7 1 3]]
 
as @holdenweb mentioned earlier, Flask and Django each have their own approaches to backend dev. There are tradeoffs. One isn't better than the other.
 
Desired output:
[[1 2 3]
 [2 8 2]]
[[4 5 6]
 [8 7 7]]
[[9 3 7]
 [8 3 7]]
[[9 0 0]
 [7 9 2]]
[[0 2 1]
 [9 9 1]]
[[5 2 8]
 [7 1 3]]
 
have to reinvent the wheel everytime you want to make a darn landing page
 
Would appreciate some help.
 
@AnnZen maybe you need to reshape()?
disclaimer: I'm a numpy noob. Just making a guess here.
 
6:10 PM
i should preface any further discussion over numpy by saying: you shouldnt be looping in the first place
 
:51740412 I wasn't. I was summarizing your earlier comments.
 
Like how convenient would it be to have some dozens of django apps you could install, config some theme colors in yaml files, and then be done with the really basic templating
 
@Skyler there are 3rd party libs that provide these features.
 
These would also likely make future work more consistent since many people would be familiar with those designs
 
6:12 PM
maybe not with YAML, but there are template libs, sure
 
@Code-Apprentice I've seen people selling a few templates, but not really full libraries of this. Open source? And any libs you'd recommend checking out
 
@Trajan Flask needs a WSGI frontend to allow it to interface with a production front-end service just like Django does. Neither have generic performance issues.
 
@holdenweb what is a wsgi?
 
things like waitress
 
@Trajan The search engine is your friend.
 
6:16 PM
scaleable gateway for web servers
 
like a load balancer?
 
@Skyler I used one called Jetpack that was a template library for the "admin site".
 
@Code-Apprentice but the two resulting arrays are actually different shapes.
 
the archecture of these things is confusing and ahrd to find out about online
 
In my code it's more like
 
6:20 PM
@Code-Apprentice idk why but like 90% of the templates i've found online are for the admin dashboard
 
@AnnZen does this mean youre mcve is flawed? perhaps make it with arrays the better demonstrate the issue
 
a = np.array([[[1, 2], [4, 5]],
              [[9, 3], [9, 0]],
              [[0, 2], [5, 2]]])

b = np.array([[[2, 8, 2], [8, 7, 7]],
              [[8, 3, 7], [7, 9, 2]],
              [[9, 9, 1], [7, 1, 3]]])
 
@Skyler What kind of a question is that? Single-page applications still use HTTP, there's nothing funky about them except they send only data and the front-end modifies the DOM appropriately. Any web server can do that. a) Send one-page app; b) respond to its requests.
 
@ParitoshSingh ok, done
 
@holdenweb yea, but flask cant modify the dom directly can it. It only sends response to direct a js front-end
 
6:23 PM
@Skyler In short, no, flask can't do a spa without Javascript. But it's not difficult to include JavaScript inside a template.
 
import numpy as np

a = np.array([[[1, 2], [4, 5]],
              [[9, 3], [9, 0]],
              [[0, 2], [5, 2]]])

b = np.array([[[2, 8, 2], [8, 7, 7]],
              [[8, 3, 7], [7, 9, 2]],
              [[9, 9, 1], [7, 1, 3]]])

for i, j in zip(a, b): # Works, but inefficient
    for k, l in zip(i, j):
        print(k, l)

for i in np.dstack((a, b)): # Flawed
    print(i)
 
@Skyler Of course it can't. No server can. The DOM lives on the client.
 
@Skyler yeah thats a frontend concern
 
That's why step 1 is "deliver the one-page app".
 
kinda wish there was a python powered web engine since python is so much cleaner then JS but then again i havent really done any direct async stuff in python to see how it is
 
6:27 PM
if my python installation finishes in time (don't ask), i'll probably have an answer for you.
if not, the general gist i'd say is, just reduce one dimension from both arrays, then stack them, and then finally manually split them in the 2-3 ratio while iterating. (have i mentioned iteration sucks for numpy? there's no getting away from "inefficient" if you iterate)
 
vectorize, dont iterate
@ParitoshSingh , sometimes i get the feeling that pandas still is working out that iterating vs. vectorizing dynamic
 
pandas is decent at what it does best, abstracting away that stuff for people who "just wanna work with tables".
 
yea, decent is the perfect word for it
 
@AnnZen not a "print" but gives you the structure you want:
np.array([*zip(a.reshape(6, 2), b.reshape(6, 3))], dtype='object')

array([[array([1, 2]), array([2, 8, 2])],
       [array([4, 5]), array([8, 7, 7])],
       [array([9, 3]), array([8, 3, 7])],
       [array([9, 0]), array([7, 9, 2])],
       [array([0, 2]), array([9, 9, 1])],
       [array([5, 2]), array([7, 1, 3])]], dtype=object)
looks "better" if done as list(zip(a.reshape(6, 2), b.reshape(6, 3)))
 
@aneroid please don't
 
6:39 PM
@AndrasDeak was it that bad? :-(
 
yes
To be fair so was her expected result.
 
^ this
 
i know numpy arrays don't like the mix'ed dimensions of sublists
 
22 hours ago, by Andras Deak
Numpy arrays barely work with generic objects. They are designed to be used with native numpy types (i.e. numbers). That's when numpy is memory-efficient and fast. With object-arrays it's neither.
 
# just writing them out for clarity
temp_a = a.reshape(-1, 2)
temp_b = b.reshape(-1, 3)
res = np.hstack((temp_a, temp_b))

for row in res:
    l, r = row[:2], row[2:]
    print(l, r)
(yes, i got python installed, yay!) this is something along the lines of what gets your expected output, but the iteration will again kill any gains you could have had in most use cases
 
6:42 PM
Has anyone asked why she wants to end up with a ragged array?
 
guilty as charged
 
to be frank I don't want to know, but I also don't want to see such non-idiomatic gymnastics to satisfy her random requirements
mostly meaning aneroid's thing, not yours, Paritosh
 
yes, we both understood you meant me...
/me has a quick cry in the corner
j/k
@ParitoshSingh thanks, was looking for something that does what hstack does
in which case, I would rather have res as the result form directly
 
yeah i just wanted to display the steps involved for clarity. one general suggestion if you ever use numpy but the final output won't sit well with it, take it "as far as you can" with just numpy. hitting with a zip upfront, going into list unpacking and then creating an abomination with object dtype is rough. at that point, you might have been better off never using numpy in the first place
 
yup, agreed. I wouldn't do that for "myself"
 
6:50 PM
So don't subject others to what you wouldn't do to yourself
Sometimes (these days on SO, not so rarely) the answer to "how can I?" is "don't", because the asker is neck deep into an XY problem
object-dtype arrays and ragged arrays specifically are an easy-to-spot case
 
@AndrasDeak I dropped that standard shortly after becoming a regular on SO. sometimes (for whatever unknown reason; potentially a bad one), ppl just need a solution to a problem. sometimes they answer questions as to why and can be pointed in the right direction, other times it results in sub-optimal non-idiomatic answers
 
that's what downvotes are for
 
@AndrasDeak specifically for numpy? got it (y) <-- I'm not going to copy-paste a thumbs up emoji
 
Protip: you can type ":thumbsup:" and even if it doens't render as an emoji, we'll understand.
 
haha, good point. but it's a lot to type vs (y)
 
7:52 PM
@AndrasDeak but they are native numpy types.
 
A sad story in 2 sentences:
> New in version 1.1.
> Deprecated in version 1.2.
 
@Aran-Fey I'm sure there's a better alternative :P
@AnnZen OK
 
@AndrasDeak I won't use the ragged array, I want to access the values of both arrays in a loop.
 
@AnnZen so do that
 
@AndrasDeak by indexing?
 
7:54 PM
@AnnZen As usual you're not telling us what your real problem is, only arbitrary and XY-ridden views into what you think you should be doing. I have no time to figure out what you really need to do. If you have a version that works, use it.
 
Sort of like this:
 
@AndrasDeak Well, with the arrival of the hot mess that is python 3.9, I have 3 options: Design my functions to return what the answer is, or return what the answer should be, or to throw the whole thing into the trash bin. For example, you can pass an arbitrary number of type arguments to list:
>>> list[int, str, 3]
list[int, str, 3]
 
@AnnZen that's too much code for chat, please post it into a code paste service and link that here
 
Given that, should is_variadic_generic(list) return True because you can pass an arbitrary number of arguments, or should it return False because you shouldn't be able to pass an arbitrary number of arguments?
oops. Been confusing int and list the whole day, no clue why
...it's been a rough day
 
same
 
7:59 PM
@AndrasDeak sorry, here: codeshare.io/2EAJVo
 
@AnnZen thanks
of course it doesn't load without JS
 
00:00 - 20:0020:00 - 21:00

« first day (3796 days earlier)      last day (1142 days later) »