« first day (3541 days earlier)      last day (1390 days later) » 

12:37 AM
@AndrasDeak I'm not sure I see how this is much better than using a dict, really. But then I've really only done similar things to match a string and fire off a function.
 
 
4 hours later…
4:51 AM
There is so much to get from this room even if one is in the sidelines, I would have never known they are working for features on 3.10
 
5:41 AM
anybody understand what a sqlalchemy attributeError: 'ResultProxy' object has no attribute 'count' means? it is occuring during a werkzeug.security check_password_hash function
 
5:56 AM
Providing the relevant line(s) from the Traceback would be useful, given that most of us will not have the context of how that error was generated.
 
Traceback (most recent call last):
File "C:\Users\Diana\pythonWorkspace\project1\venv\Lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\Diana\pythonWorkspace\project1\venv\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\Diana\pythonWorkspace\project1\venv\Lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Diana\pythonWorkspace\project1\venv\Lib\site-packages\flask\_compat.py", line 39, in reraise
theres the traceback I have been trying to find out how to understand the error and how it actually gets called but have had no luck
 
6:41 AM
@Kwsswart The error comes from line 54 of your code. Unless werkzeug is buggy you're calling check_password_hash wrong.
 
@AndrasDeak I read the traceback as saying the error is in line 55. How did you get line 54?
 
Typo
 
@LinkBerest thanks for your reply, hopefully I didn't sound too negative with my reply. I ended up resolving my own issue but I've been getting into SQLAlchemy and I'm trying to ensure I'm modeling my problem domain as best as possible
 
@Kwsswart wild guess. You used .all() when querying for the user and not .first()
 
@ArthurCollé There is no "discussion" allowed on the main Stack Overflow site. Stack Overflow is a Q&A site, and has strict rules about what types of questions we allow in order to keep things focused. If you haven't already, please take the tour. However, chat rooms like this one are a place where freer discussions can happen, especially those that are related to programming but wouldn't be suitable on the main site.
Most popular programming languages have their own chat room, but as LinkBerest already mentioned, even in the Python room, folks (like me!) will occasionally talk about other languages.
 
7:04 AM
pass_ = db.execute("SELECT password FROM users WHERE name = :user", {"user": user})

        if user_:
            if not check_password_hash(pass_ , password):
                return apology("Invalid password or username", 403)
@AndrasDeak its above the code
 
@Kwsswart Yeah, I'm not really sure why you're using an ORM at this point :P
@Kwsswart I've grabbed some bits of my code here
 
@Kwsswart please see our code formatting guide to chat for future reference. And you can't combine code blocks with replies in chat, alas
 
Probably need to add a new "Common issue" to the FAQ.
"Trying to format as code in a reply to another message."
 
@roganjosh the aim of it is to do without it and also want to learn to do it without orm so orm is easier
 
Using an orm to do something without an orm is easier?
 
7:11 AM
@CodyGray that has crossed my mind
never going to happen, of course
 
@AndrasDeak That's convenient. Considering the only thing that crossed my mind is pestering you about it.
 
We could add it to our own guide
Unless that's what you meant in the first place
You probably did
 
@roganjosh basically I want to understand how to do it properly without the orm and then go onto orm after
 
@AndrasDeak Yes, that's what I meant. Your guide is what you linked to.
I see it was last edited by Kevin. Maybe I should be pestering him instead.
But you're here! And probably more fun?
 
@Kwsswart ok, well print(pass_, type(pass_)). Tis not what it seems
 
7:17 AM
@roganjosh in this are you using a class to check_password_hash?
@roganjosh does this mean that the mistake is coming from the name i have given the variable?
 
I'm using a class to represent a user that carries a lot of other functionality that I didn't copy/paste in that snippet. One such functionality is determining whether they're logged in or not
 
@CodyGray I did, but you said "FAQ" which it isn't, because nobody ever asks about formatting, they just mess it up happily
 
I am currently trying to do this without the orm method I have managed to get the register function to work well and add users to the database
 
@AndrasDeak Come on, everyone knows that FAQ means "questions we wish users would frequently ask", rather than "questions that users do frequently ask".
 
my next aim is to allow the login to search and save in a session
 
7:20 AM
@AndrasDeak We could call it FIT, Frequently Ignored Topic
 
@Kwsswart You're drifting from the initial error. I suggested what to print to debug it
 
but keep getting that error and looking online doesnt seem to tell me much about what that error means
 
QWAAFU (Questions Whose Answers Are Frequently Unknown)?
TYSK (Things You Should Know). I think that's my favorite.
Then you can just "tysk" at people.
In a friendly and welcoming way, of course.
 
@Kwsswart essentially, SQL (and SQLA) has no idea how many results that query might generate. It would be in a list if you weren't using SQLA but since you are, it has fancy wrappers that are basically lists. You need to index the result to get the actual password. That's what the error is about.
 
@roganjosh I see so when printing it the pass_ value i receive this <sqlalchemy.engine.result.ResultProxy object at 0x000001838BF9D280>
@roganjosh ok I see so you have to call.first() on it
to identify you want to get the first query
 
7:29 AM
No, I don't think you can call .first() on it. Since you're using raw it would be LIMIT 1 (which would be a good idea to add to your query here anyway)
mm, now I need to go see if that's possible :P
In the meantime, I think you want to use .fetchone() on the result
 
@roganjosh So first tried with the LIMIT 1 and same error as before
then tried the .fetchone() and i get this error: Could not locate column in row for column 'count'
 
err
I'm not sure whether the fact I can find a bunch of unanswered questions around that error makes me feel better and less dumb, or just worse
Emergency tea break
 
@roganjosh not sure if I understand
 
cbg, sorry to intrude with the ongoing chat, if I want the dict.pop(key,'Key Not Found') in a list I have to write my own helper method with IndexErrorhandling or are new versions of python have something new?
I am always interested in popping the last element, so when the list is exhausted I must get a None
 
thing is running all those queries directly on the db in pgadmin give be the output i expect
 
7:46 AM
@python_learner I think i'd do foo.pop() if foo else None
 
that is a nice way to do it, thanks @Arne
 
@Kwsswart I have returned with tea. It's pretty early in the day for me to be confused but this should help :) Do you have a foreign key on your users table?
 
@roganjosh no users table is literally id, name, password, email
 
you're welcome. writing a safe_pop would also be completely ok. And if you care about code coverage, preferable.
 
Sorry, saw something similar but bad yesterday and thought this was that too
 
7:54 AM
@Kwsswart what do you get if you use list(pass_)?
 
@holdenweb very unhappy with what I've seen about PEP 622. Seems like a mixup of extensive syntax, special-casing of existing syntax and implicit name-bindings.
 
do you have an idea what the target audience for 622 is, what kind of code they'd write with it?
 
Since the asspression PEP, my assumption is "scratches an itch at dropbox".
 
@roganjosh I used passL = list(pass_) print(f"{passL}") and result was : [('pbkdf2:sha256:150000$34AiiEwu$2eceb81c11c8b5af49df23fa2b2f9d53c5a06890f1aa90f24488db56f6cb2d6a',)]
so I got the password
 
How strange
 
7:59 AM
if I were to turn pass_ = list(db.execute(query) would i be able to access the value via pass_[0]?
then comparing via that?
 
@Arne There's of course the functional crowd, where pattern matching common (and useful!). But, there it is usually a more generic thing that also falls in line with dispatch and such.
 
pass_[0][0] (it's a tuple in that list). As I said, you would normally get back a list from SQL queries and SQLA is a wrapper in some senses. I still don't understand the other error
 
In PEP622, it seems to be one big, self-contained chunk that clashes with many existing things.
 
huh, I thought it was a move away from functional patterns to declarative patterns.
if that even makes sense
 
Might be a matter of wording. I know it from languages that are proclaimed functional.
 
8:03 AM
Is there a method to get length of digits of a 'base b Integer' As in, the number is already in a different base than decimal.
 
@roganjosh yet another weird one
 
@Kwsswart Please post that in dpaste/gist/pastebin
 
but yeah, it feels like a feature that has a high chance of just bloating the complexity of the language as well as muddying the water of "there should be one way"
 
@Arne FWIW, I kinda liked the pampy matching library. Never had a use-case for it. Defenitely prefer keeping library-things as library-things, not syntax fests.
 
8:08 AM
I'm not familiar with these kind of errors. Lord knows I error a lot, but you've got something wonky going on here :P
Like, honestly wonky. I'm not so sure about this quest to pass on the ORM. I'm not even sure what brings about that error; what's your user_loader function?
 
@pyeR_biz do you mean something like "get the number of digits of 10111101" or "get the number of digits of 0b10111101"? I.e., is the number a string or a regular integer literal in another base?
 
@MisterMiyagi regular integer literal in another base
@MisterMiyagi I could use string, but I also need to perform a floor division on the integer literal in another base ( x // base)...but python is doing that considering x as a decimal number.
 
@Kwsswart you'll need to leave this one with me for a bit I think. Given that you've started with parameterized SQL and password hashing, I want to try help you but I'm struggling to get a foothold on what's going wrong here :(
 
@roganjosh ok man I will do should I post a question on main or wait until tonight
 
8:24 AM
I don't think it's answerable (as a whole. I mean, obviously there's an answer but how deep is this rabbit hole?). Given my curiosity at what could be raising these errors, if you dump it to github, I'll run it locally
 
@pyeR_biz We need to be very clear here on what you are trying to do. Numbers do not have a base, and operations on them do not depend on base. Literals have a base, and must be handled either as base-less numbers or base-full strings. Can you provide some sample input and output, perhaps??
 
thats the git repository
 
Oki doki. I'll set up my menagerie and get back to you if I figure it out :)
 
i have hidden the .env so as to not give postgredetails
 
Good thinking ;)
 
8:31 AM
Hi there. Hear the joke i just made: A hungry Python goes to a python school. It asks: "do you have salt?I'm ready for breakfast.". The teacher says:" No. But try the pickel module. It's spicy" :-) :-) :-)
 
@MisterMiyagi dpaste.com/0XH9665
@MisterMiyagi Sorry the 'x' in the function is supposed to be 'digits'
 
@pyeR_biz You're counting the base-3 digits of the number of the base-10 literal 211022. That is indeed 12. If you want to specify a number in an arbitrary base, use int("211022", 3) for example.
 
8:49 AM
Correct. I got the results I needed in my program from this change. It's the programming example given for Kaprekar's routine: https://en.wikipedia.org/wiki/Kaprekar%27s_routine

It's interesting that the output I get is in decimal, which is fine. The values are correct.
 
@roganjosh is there a way we can have a personal chat going to discuss this more without disturbing and also can keep history if i end up needing to go offline
 
@pyeR_biz When working with numbers, it can be important to distinguish between the value and the representation. It's somewhat related to the difference between characters and encodings.
Python uses base-10 as the default representation, since that is what most people use day-to-day. That does not mean that the numbers are base-10, though.
 
@MisterMiyagi Yes, I had realized that, and was searching something along the lines of "How to divide numbers in Python in base b" . I did not know you can declare the base of a number. Thank you, learned a lot from this.
 
Pow, closed :)
 
just "pow" - not "kablooey kaboom kerplunk pow!"? :p
 
There's like 16 frames on this page of the comic, it just wouldn't fit :/
 
9:30 AM
Now I'm wondering what those spikey bubbles are called that aren't speech bubbles. Action bubbles? Once I learned about "growls" in browsers, I realised I don't have intuition for naming things
 
It's not a question that's ever occurred to me :)
 
"Don't think of a white elephant". It's a callback in this edition of the comic :P
Oh, and everybody just lost The Game. inb4 that one
 
9:45 AM
cabbage fellas
I have to write a micro-service which does some crud operations, I have not done this before and I am not sure if I should like Use SQL alchemy and models or just write plain sql querries in the code itself
Any advice?
with respect to security in mind too
 
10:09 AM
@roganjosh ah, my streak is broken =(
 
@Arne Blame Andras. He started it
 
hiya
I have a numpy array of True/False values called vals. I have another list y and I want only those values from y where vals at the same index is True. How can I do that? If it were a pandas series it would be really easy
got it.. [item for item, keep in zip(y, vals) if keep]
@MisterMiyagi oh cool
what would it be with itertools?
 
nice! I hadn't heard of it before
compress is a terrible name for it
 
10:26 AM
I only know about it since I built an async version of itertools. Never would have thought this existed before.
 
@Anush [lst[ind] for ind in vals.nonzero()[0]]
or just np.array(lst)[vals] if that's an option
@MisterMiyagi so it's basically an itertools version of built-in filter...? Just with a __getitem__...
 
@AndrasDeak thanks. I went for np.array(lst)[vals] in the end
 
Of course it's better to keep that list as a numpy array from the start. I mean it will probably look nicer.
 
@AndrasDeak It's somewhat ugly to build with filter, better suited for a comprehension. But yes, it is basically filter+itemgetter wrapped around zip+map+itemgetter.
 
10:41 AM
Right, need the index too. OK, I'll allow it.
though I'd certainly go with Anush's original list comp without numpy
 
 
2 hours later…
12:42 PM
cbg
 
cbg
 
cbg
 
1:09 PM
cbg, is there a difference in defining a function inside a function? I want the function in_ for use only with in the out function
def out():
    def in_():
        return 'In'
    return in_()
should i define in_ outside the function? will the function in_ be defined every time out is called?
other than the trivial example I have given is there a downside to doing this? I read some articles and they were talking about closures which I dont really know
 
>>> dis.dis(out)
  2           0 LOAD_CONST               1 (<code object in_ at 0x7f0b47b43c90, file "<stdin>", line 2>)
              2 LOAD_CONST               2 ('out.<locals>.in_')
              4 MAKE_FUNCTION            0
              6 STORE_FAST               0 (in_)

  4           8 LOAD_FAST                0 (in_)
             10 CALL_FUNCTION            0
             12 RETURN_VALUE

Disassembly of <code object in_ at 0x7f0b47b43c90, file "<stdin>", line 2>:
  3           0 LOAD_CONST               1 ('In')
I believe it will create the nested function on each call
 
what is this? O_0
 
Closures mean that in_ can use names from out's scope
 
should read the dis docs
 
@python_learner yes. It shows the bytecode of functions.
 
1:15 PM
this can answer half the questions I face, that library will help me a lot, thank you
 
For very specific functions it can make sense to define a nested function, but most often you'll only see this when you need something from out's local names. A typical example is wrapping a function, for instance. Or defining some auxiliary function
@python_learner no problem
 
so I am better off just passing the value to a function that I define outside then
 
@python_learner although it seems that the nested function might only be compiled once, when the outer function is defined. Note the two LOAD_CONST instructions at the start.
@python_learner entirely depends on the use case
but probably yes
 
Would it not be a useful heuristic to say that nested function definitions point to an issue, if they're not being used as decorators?
 
If someone more familiar with python's internals corrects me they can ping you with an update if I said something dumb
@roganjosh no, I more often use interpolators and the like which are passed to something like scipy.optimize.minimize, when it doesn't fit in a lambda
 
1:19 PM
I wonder why they dont teach this at college, they just told me functions can be nested but did not tell about the bytecode
 
@python_learner bytecode is a bit of a red herring here, I was just trying to figure out an exact answer (but as you see I got less sure of my original answer)
Scoping in nested functions is more relevant in everyday (and novice) use. See also the nonlocal keyword
 
I cant really comment on that, I will have to understand how to read the output of the dis call first
 
@python_learner the nested function makes it a lot more complex than usual. Try disassembling simpler (flat) functions with it first, see how it looks like.
 
do they work on classes as well?
I wrote a LinkedList class with a nested class for Node
will have to see if it works for that
 
I wouldn't think so, because it's more about execution of function-like things (so functions and comprehensions). But yeah, do try it out.
One key point in the output is that you have to think in terms of a stack. Bytecode instructions pop off and use arguments from the top of the stack. So the two LOAD_CONST instructions put two values on the stack, then the MAKE_FUNCTION uses those to create a function which it puts on top of the stack. That's what STORE_FAST then uses for the name in_.
 
1:24 PM
so one store fast call is enough for two functions?
also the docs say Disassemble the x object. x can denote either a module, a class,..... so yes I guess
before I ask any questions I will look up on some basic tutorial
will save both our time :)
 
You're better off that way anyway, I'm not very well-informed about these
unlike most regulars here
 
you work as a python dev? if you dont mind me asking, I wonder once I get a job I will be dealing with these often
 
Coming to pyparsing 3.0.0, railroad diagrams! A nice enhancement provided by Michael Milton, of Australia.
 
but thanks again, that is something I would have never known otherwise
 
A portion of the diagram from the delta_time.py example.
 
1:34 PM
@PaulMcG ohh, I'm curious! maybe I'll finally understand some of the code I "co-authored" here =)
my short attention span appreciates visual documentation a great deal
 
I did not really appreciate this effort until I ran it on some complex parsers. In this particular example Unnamed2 is some expression of quantity, which could be an integer, or the words "one", "two", etc., or "a couple of" (synonymous with 2).
 
Is it already on the current master?
 
How it's done: pyparsing-docs.readthedocs.io/en/latest/… - includes a link to a SQL SELECT parser.
Yes, it's checked into master. I'll push to PyPI this weekend.
 
sweet! 3.0 already, or just an alpha/beta?
 
@Kwsswart I've got the site running locally. What do I need to do to recreate the errors?
 
1:44 PM
@Arne This weekend will be alpha2
 
1:54 PM
@python_learner Concerning the dis: Note that the LOAD_CONST in the outer function is for the inner function's code object. The inner function is still re-built every time the outer function is called, via the MAKE_FUNCTION opcode.
 
gtg, but I get an import error for the railroad package. I'll try some more this evening
 
This is relevant if the inner function defines some mutable/default arguments.
The code being reused roughly means the source code is processed only once.
 
thanks for the additional info
 
2:33 PM
@python_learner I'm one of the few here who doesn't
@MisterMiyagi does that mean it's only compiled once?
 
for someone who is not a dev you sure know a lot of python, from your answers but then again i dont understand many of what goes in this room
 
@AndrasDeak the bytecode is created only once. That's the .__code__ object of the function. The wrapper object, closures and default values are created anew.
 
@python_learner I don't think anyone does really :p
 
I'm not 100% sure how CPython currently defines "compiling", but the term is probably accurate enough.
 
laurel, guess I needn't worry then
 
2:45 PM
needs focus / multiple questions stackoverflow.com/questions/62596682/…
 
kablooey kaboom kerplunk pow, closed
 
@roganjosh laurel :)
 
@python_learner I'm more confident than knowledgeable, but thanks ;)
@MisterMiyagi OK, so I didn't say something very dumb. Thanks.
 
@JonClements hey, I'm the one who cast the third vote!
 
But you didn't do it comic book style! :)
 
2:48 PM
true. Style over substance, I guess :)
 
Indeed, a tricky situation. I needed to close the loop on a previous discussion, though
 
@AndrasDeak I'm just spewing technical trivia to compensate for a dull day of crawling /proc.
Your description was perfectly adequate.
 
Thanks, I'm not very sure about whatever goes on under the hood...
 
3:25 PM
@Arne I didn't read the whole thing, but I know I don't like it. It felt unpythonic from the start, but then when I saw case str() | bytes(): and wondered "Why didn't they just write case '' | b'': there?" that gave me a concrete reason to dislike it
I would be sad, but not surprised, if it were to be accepted
 
@MisterMiyagi how about "what compile does"?
 
 
1 hour later…
4:34 PM
For info about compile, I recommend Antti's classic answer about eval, exec, & compile: stackoverflow.com/a/29456463/4014959
 
 
1 hour later…
>>> import datetime
>>> import pytz
>>> dt = datetime.datetime(
...             2020, 4, 3, 12, 0, 0,
...             tzinfo=pytz.timezone('America/Chicago')
...         )
>>> str(dt)
'2020-04-03 12:00:00-05:51'
>>>
What is this -05:51 on the end of this date?
I'm expecting -05:00
 
6:11 PM
@Code-Apprentice I don't quite understand it, but this seems relevant.
 
@Code-Apprentice iirc. you need pytz.timezone('America/Chicago').localize(datetime.datetime(...)) instead of passing tzinfo
 
@ThiefMaster yah, I found that localize() works. Thanks for confirming that's the right way to do it.
 
6:27 PM
@roganjosh apparently tzinfo is flat out broken for timezones that observe DST
 
Fantastic. Lucky I don't live in one of those countries...
Do you have a link for what's broken?
 
@roganjosh well it will soon stop in the E...nevermind
 
Lol. I sometimes forget it's still a thing happening. The news is full of stuff and things, it's hard to get them in order :P
 
33
A: unexpected results converting timezones in python

user3834473From the partial documentation: http://pytz.sourceforge.net/#localized-times-and-date-arithmetic Unfortunately using the tzinfo argument of the standard datetime constructors ‘’does not work’’ with pytz for many timezones. [...] It is safe for timezones without daylight saving transitions tho...

stackoverflow.com/a/62578255/1440565 apparently there's a dateutil package in current python and zoneinfo will be coming in 3.9.
 
6:47 PM
mm, I've had some big cock-ups with dateutil in the past. They were my fault, in retrospect, but I'm wary of what its parser can do
 
7:26 PM
offtopic HNQ: Now that's what I call a crisis What could substitute coffee in a modern post-apocalyptic society?
 
No imagination needed; It was always tea, even before the apocalypse :P
 
8:00 PM
Hi, what kind of resources should I look at (or search for) if I want to learn more about Python at the "meta" level and how the operating system and anaconda environments interact with it? By that I mean, what does the Python interpreter do when it encounters import statements, if there are multiple Python executables in a system, how does the system decide which one to use and what libraries/packages/modules are available to that particular instance, etc.
 
 
1 hour later…
9:11 PM
@roganjosh I need to retract my previous statement. tzinfo isn't broken per se. Assigning tzinfo to a timezone object created with pytz is broken.
 
Guys any ideas of modules that in python or directions on Physico-Chemical Methods? Turorialing doesnt do any good, in need for real world application. So ideas about the tools out there are appreciated.
Tranfer Phanomena, sedimentation but DatenLogger control too for example.
 
Hello!
What's up?
 
Hello there
LOL i can speak greek
 
Really?
Where are you from?
 
ti kaneis @ChrisP ? edw programma grafeis esi
 
9:19 PM
@ExoticBirdsMerchant English, please
 
@AndrasDeak its just a polite gesture
 
@ExoticBirdsMerchant I am fine.
I don't really like greeklish.
greeklish = greek with latin characters.
 
I can use greek characters too Αγγλικα παρακαλώ = English Please
i know i know hehe
I can Greek a little Latin too, German , English you know the high languages. Heheh maybe some day we will be speaking with objects in daily life like in Python
 
I don't know how to format the code here in chat.stackoverflow
`` many times doesn't work.
For example:
import module
 
@ChrisP if only there was some kind of guide to help with that. Something that you could read
 
9:25 PM
I read but i don't find the appropriate code style it's needed.
 
Type the piece of code that bashes your brains and then use Ctrl + K
 
@ExoticBirdsMerchant let's not encourage using this room as a sandbox. Chris has been pointed to the formatting guide a lot of times.
 
Ctrl + K == Control Κώδικα :)
 
What's the right way to use frame inside canvas (tkinter).

1. create_window
2. grid
3. place
4. pack
5. other?
 
10:03 PM
but can't readily find good dupe. OP uses print(*it) on an iterable, then wonders why it consumed the entire iterable. stackoverflow.com/questions/62603149/…
 
 
2 hours later…
11:37 PM
@ChrisP depends on what your using the frame for - I use (after creating the Canvas & Frame): .pack, .create_window, .bind("<foo>", a function using canvas.itemconfig() passed on the second argument)
If you can make a simple Tk window which shows what you want to ask then I can help further
 

« first day (3541 days earlier)      last day (1390 days later) »