« first day (4422 days earlier)      last day (531 days later) » 

6:21 AM
@Thingamabobs your code is doing something completely different from theirs. You explicitly discard the exception, they explicitly don’t.
 
6:47 AM
@MisterMiyagi agree did a mistake there.
 
7:27 AM
How can we use our business logic method (suppose code written for registration eg:- registration() ) for testing? I don’t want to use client or app context for that purpose. Flask Application
 
8:21 AM
@NaveenPandia Maybe ask normal question on the site with enough details to actually answer instead of spamming chat every few hours with vague unanswerable question?
 
8:34 AM
Umm... that's a kinda nifty feature... :p
cbg all... long time no see... how's everyone?
 
throws Jon a bone
Same old, same old. Year's coming to an end so everything that piled up needs to get done pronto.
 
@MisterMiyagi woo hoo!!!!!
@MisterMiyagi yeah... life's been interesting recently... right now just getting all the ecommmerce systems I'm responsible for ready for black friday (which for some started weeks ago) and then xmas... sighs
 
That special time of the year... :D
The mood is pretty positive around here, though, what with Christmas markets finally opening and everyone deciding to have a bit of fun again.
 
Well... guess let's see what 2023 brings - what with climate stuff, pandemics and wars... not 100% it's going to be great... but... paws crossed!
First sample timestamp match [UNIX_MS] for field [Updated]
Guessing timestamp field is [Updated] with format [UNIX_MS]
I like that they've gone to the bother of providing explanations - it mostly gets it right... but at least when it doesn't you can see what you could have done without being explicit about things in the first place
 
8:58 AM
Which tool is that? Looks nice to have such an explanation.
 
You trading GBP/USD now? :P
 
@roganjosh was wondering how long it would take someone to notice that :p
nope... just doing a framework thingy for someone to do so...
@MisterMiyagi it's the importer in Kibana for Elastic...
 
I opened an OANDA account but I don't think I'll be going near the FOREX any time soon
 
quite an interesting design... (hopefully haven't yammed it up yet)... but very distributed with Kafka, Elastic, Redis and a couple of other "interesting" goodies
 
I've not been feeling well for the last few days so I've been watching a lot of the ColdFusion channel on YouTube. The number and size of scams in the block chain beggars belief
 
9:12 AM
@matszwecja Normal question??? if you don't know any answer you could've avoided that. I'm asking a question in this chat room because you may have experienced it or you may have something to share but this arrogance and terming this as a vague unanswerable question is totally unacceptable.
 
It could definitely have been said differently, but there is no way to understand what your last question actually means. I don't think anyone will be able to answer it as it is
 
@roganjosh I totally understand that sometimes answering a question can be difficult and asking a doubt can be tougher too but if someone is telling me that my question is total crap that shows his narrow-minded approach.
 
@NaveenPandia Yes, normal question on the main site, designed for asking questions and offering way more formatting options so your question and the info you provide will be much more readable. Chat is not really well suited for things requiring a lot of technical introduction to a problem.
 
9:28 AM
@matszwecja I've done that there was no response that's why I've asked you guys. Anyways I got the answers after some research. Thank you!
 
I've checked your profile and there wasn't any similiar questions to what you were asking here
 
I do have my work profile too
 
@matszwecja please can we let this drop? There are Room Owners and a moderator around if there are problems. None of us have felt that this is a major issue or we would have said something already
 
10:01 AM
@roganjosh Nice, watched the same channel too a couple days ago. If you want more scam-related videos, feel free to check out Coffeezilla's channel.
 
I think if I watch any more, I'll be ripping up my mattress and pulling my money from the banks :P
 
lol, understandable
honestly don't watch it too much all at once, since it's usually the same old stories when you don't take into account the details. rug-pull this, running-with-customers-money that. Not surprising anymore really
 
It is truly amazing what people repeatedly get away with right now. The internet has made it so much easier for people to get way out of their depth. It's not a simple technology to really understand even when you go out of your way to grasp it all (as I have) and yet people will just throw huge sums at it
This is headline news this morning, and I can kinda grasp how this became a mess. I've caught a couple of instances in the past that have happened to elderly people from my local pub and it's so easy for them to be drawn in - I really feel for those people. But on crypto - just set up some multi-level marketing with an unintelligible financial product and people will throw money at it. Scary.
 
The sad part is that people don't take into account the "return on investment" rule. Whether or not something is a scam, if you lose more money over time vs what you gain, it's useless. Unless you're doing this for entertainment which some people think they are, then it's your money, but then don't be surprised if you lose it all.
some also like to glorify and never doubt something just because they're a corporation. Even if they're regulated, things can always turn sour. Just look at the dozen companies that were regulated and went under.
 
Oh sure, and I'm not calling for regulation. Just some reinstatement of critical faculties of humanity I guess - the easy stuff to fix :P
 
10:14 AM
easy to fix, but the ones concerned need to reinstate those faculties. That's effort, and mostly dependent on them :/
 
I was most-definitely being sarcastic :P
 
ah, gotcha
 
Sometimes you have to remember that I'm a Brit ;)
 
I mean, even with Andras, It's hard for me to tell when he is being sarcastic/joking. I do know how to take a joke though, but knowing when it's one is harder for some reasons
 
The joys of multi-national text chat. The perfect storm for misunderstandings!
 
10:42 AM
I would like to use font book antiqua in FPDF. I think I need to call add_font() -method. How do I call it properly? I think I have to find a correct ttf file but how to do it?
 
It's specified in the docs
"You can specify a full path; if not, the file will be searched in FPDF_FONTPATH or SYSTEM_TTFONTS"
 
I know but how do I know the name of the correct file? There is no file like Book Antiqua.ttf in my computer according to the search but I think I have the font installed as LibreOffice can use the font.
 
@JaakkoSeppälä I was about to mention that too last time, I think last time I played with reportlab, you could specify fonts that weren't part of your font's path.
@JaakkoSeppälä you can use python to search around your filesystem or check your environment variables. Or if you're imp patient like me, you can use everything to search quickly for your file.
 
10:58 AM
LibreOffice is entirely separate to what's actually going on here, though? For all I know, it could have been compiled down into something else inside that application, meaning it wouldn't necessarily be generally available on the system. Can't you just download the tff yourself?
 
I feel like they specified LibreOffice because it contains a font that they are used to. Even if fonts can have similar names, sometimes they're modified by different people and bundled with the same name.
 
That's my interpretation too, in which case I would just download it myself and not rely on it being globally available
Certainly I don't think I'd expect LibraOffice to set FPDF_FONTPATH... maybe SYSTEM_TTFONTS but that looks like a brittle env var to expect to be populated across, for example, different OS's
 
11:50 AM
docs.python.org/3/library/os.html#os.sync Hi people, how do I find out the interval of how often unix does os.sync() by default? My google foo is letting me down
 
12:08 PM
I don't think there's an answer to that question as such... it's probably more like "When does unix save what to disk?"
 
sad
nice, there is the sync argument for fstab, that should solve my problem
 
@Hakaishin I feel like it does this asynchronously/as soon as possible. If the disk is busy enough, it might not do it right away (eg: 100% disk usage).
it might also do it when it hit the limit for automatic flushing to disk (don't remember, but on Linux there a limit for buffering, and once that limit is hit, or once there isn't any other things being sent to a buffer, then it gets written to disk)
I guess it's similar to what print does without flush=True
 
12:26 PM
@NordineLotfi oh cool, that is a good start
 
@JaakkoSeppälä Btw, you probably saw my last message, but I didn't ask if you were on Windows or not, so here is a Linux solution: find . -type f -name "*.ttf" | grep font-name-here. Of course, modify the path since I'm using the current path in this example...there also another way using fc-list if it's already part of the font DB: unix.stackexchange.com/a/490821/409852
 
12:43 PM
# is there a way to output in pretty readable presentation
numbers = [1, 2, 3]
print(dir(numbers))
 
What output do you want?
 
dir(object) prints out all the class methods, I want these in a table format
 
And why do you print dir? That's usually for debugging.
Table of what? That's just a listing again.
Do you want to have a limited number of items per line?
 
yes please
that would be great actually
I print dir(), in order to see what methods are available in an imported package
 
there this, but this mostly has "vertical" output instead of a table: stackoverflow.com/questions/23980491/… otherwise this would work instead: stackoverflow.com/questions/9535954/…
 
12:51 PM
It might be easier to just use a proper IDE or shell, such as IPython, to get that out of the box. For example in IPython, just writing numbers. and hitting tab will reveal the public methods.
 
yep, that works too. I find using Ipython for exploring API really nice, at least when autocomplete works (should work fine on pure Python installation/without third party import)
 
What about jason.dump ? or pprint ?
 
The first link I posted above briefly mentions pprint. Didn't thought about json.dump for this though
 
# I didnt know there is this solution
print(*lst, sep = "\n")
# and this one is absolute crazy
print('\n'.join(map(str, lst)))
 
Do you know that you also could do help(object) ? Is this related to what you are looking for ?
 
12:56 PM
# its a good idea too
import pprint
pprint.pprint(dir(pprint))
@Thingamabobs yes, cool
 
 
3 hours later…
3:36 PM
How do you guys choose between "from * import *" and "import *" when importing modules? Any good rule of thumb?
Oh, and don't see my "*" as wildcard, but instead as a placeholder for the modules :p
 
depends on how well identifying are the names module uses
 
@Warcaith it depends. For example, I usually try to use import * as much as possible (as a personal rule) but when obliged to (eg: with tkinter, some stuff like the message module doesn't get imported when using import tkinter so need to use from tkinter import X, see stackoverflow.com/questions/29774938/…) I just do it
 
I'm more likely to use something like from PySide6.QtWidgets import (QSizePolicy, QTabWidget, QWidget, QHBoxLayout) than from json import loads, dumps
 
ah yeah, I saw () with import statement, but never used them yet.
 
You have to if you want to split over multiple lines
 
3:42 PM
@matszwecja Yeah, and you probably do the same for example the typing module, instead of having to type "typing.Optional", "typing.Union" everywhere?
@NordineLotfi It's much clearer than having to type \ for line breaks on each line.
 
I see :o
 
@Warcaith and it doesn't break anything if you collapse that back into one line, while \ would need to be deleted
 
@Warcaith I feel like it's not just a question of being clearer, it's also to take into account the possibility that one of your stuff overwrites what you imported. eg: if you import typing.Union as Union, then you'd have to take that into account if you ever want to call something else the same name
 
What about something more simpler, like "import pathlib" vs "from pathlib import Path"? I'm debating with myself here now when I'm cleaning up some code, haha!
@NordineLotfi Yeah, that's completely true.
 
@Warcaith from pathlib import Path is imho okay... it's not likely you're going to have user code that calls something Path
 
3:48 PM
morning cabbages, folks! potato?
 
@inspectorG4dget cbg
 
@JonClements I don't know, in a big library, it's asking for trouble down the line (which is their use case here if I recall right)
also been a while Jon :)
@inspectorG4dget cbg
 
good to see you folks again. It's coming up on turkey day. Hope everyone gets to spend some time with family :)
 
@NordineLotfi is it? I've had less trouble with that than someone doing int = 1
@inspectorG4dget hope so... but being British... :p
 
@JonClements tee hee
 
3:51 PM
@JonClements I mean, if you really take into account the stuff you shouldn't use as a name, it's not a problem, but try that with 30+ modules and their sub-functions/classes/modules, and it's gonna be harder as a cognitive load. There are also the user themselves that might get tripped over by this too, so who knows
 
indeed
I made a joke once saying if you're not sure if it's been shadowed... just do type([])(some_iterable)...
(have to assume to assume that type also hasn't been shadowed - but scarily - I think some people thought that a serious thing)
 
4:32 PM
Guys is there a way to type hint two local variables that are being assigned at the same time? I.e.

a, b = 1, 'hello'
so like

a: int, b: str = 1, 'hello'
or something?
 
5:04 PM
@JonClements [].__class__(some_iterable) :upsidedownface:
 
don't make me work out how to unicode lol upside down :p
 
🙃
@WantingtobeanAndroidDevelor If you are doing simple assignments, a type: comment should work.
a, b = [1, 'two'] # type: tuple[int, str]
@Warcaith I usually prefer the fully qualified name (import *) unless it is an unambiguous concept. For example, most of my automation scripts use from pathlib import Path because "path" is a well-defined concept for them.
@MisterMiyagi Just realised the tuple isn't even needed. Just doing a, b = [1, 'two'] # type: int, str is fine.
 
6:04 PM
anyone know how to set up a vnc connection from osx to ubuntu? I'm dying here
 
6:20 PM
@inspectorG4dget I remember we talked about vnc before here: chat.stackoverflow.com/transcript/message/52333530#52333530 I think it's a decently long discussion, but there probably longer ones here.
 
@NordineLotfi thanks, but this is a different (and possibly noobier) issue. I have a vncserver running on an ubuntu box and I'm trying to connect to it through a localhost ssh tunnel on my macbook. I'm able to connect just fine, but I only a blank screen - not what is currently running on the ubuntu box (which has a monitor attached to it). Possibly relevant: the monitor displays :0, while vnc connects to :2. But I'm not able to run a vnc server on :0
(apparently one's already running, but I can't find it)
 
@inspectorG4dget what's the ssh command you're using? (you can edit it to leave out the personal stuff, see here for example of what I did to make it "lambda": chat.stackoverflow.com/transcript/message/52333703#52333703 )
(you need to click on see full text btw..)
 
@NordineLotfi on localhost: ssh username@ubuntu -L portNum:localhost:portNum. Then I'm able to vnc://localhost:portNum. I definitely have not done the DISPLAY=0:0 that you have in your config
 
the monitor isn't really relevant here, what's important is where your DE/WM is running on. if you say you see a blank screen, it's either: 1. your screen is bigger than the vnc's resolution, which you can configure (feel free to look at our old conversation, where I showed an example command where I define the resolution on the client side), 2. it create or use something else beside 0:
@inspectorG4dget yeah, you don't need to use DISPLAY=0:0 as this is mostly to "fool" Linux into giving me a vnc session even though I don't have a physical screen, so to speak. (I could have said "emulated" but I feel like it's not the right word).
your ssh command looks good though, hmm
 
@NordineLotfi thanks. Glad I didn't go down that rabbit hole
 
6:34 PM
btw, I thought of another thing that could happen here: 3. it use another DE/WM beside the one you're using right now. I saw this happen a lot when I did experiment/personal research with vnc. If you use something like lightdm as your DE manager, it kind of sometimes, in certain configuration, switch to another DE when you connect to it using VNC
that would explain the blank screen you're using, since, if it does that, I noticed that sometimes it also create a blank/default config file for your DE/WM
I think if you could open a terminal on that "blank" vnc session, then you should be able to figure out if it's either 1, 2, or 3
 
that might actually be in play here. I'm tracking down various debug points from your previous messages
actually, I don't even see the desktop on that blank vnc session - just grey. Feels like nothing's there
 
yeah, that's still your desktop. Do you have a mouse pointer/cursor there? (doesn't matter if you do or not, jus asking just in cases), also, can you right click in that blank space? Sometimes even when there no cursor/pointer in a DE/WM, you can still do that, and maybe be able to open something that will lead you to a terminal
another thing that's possible to do, can you try and see if you can open a terminal on your Linux machine, but not under the vnc session, this time under the normal session (with the monitor), then try and change the DISPLAY variable to DISPLAY=0:2 or DISPLAY=:2. Once you do either, try and launch a terminal by using DISPLAY=:2 terminal_application_name_here.
 
yes, I'm able to right/click. But I don't see any menus come up. I can do alt+tab and I don't see anything on my macbook. So I gather that the controls are indeed being forwarded to ubuntu
 
@inspectorG4dget Interesting. So it's probably 3, with or without your usual DE/WM being used. See what I said above for the DISPLAY variable.
that's how I usually force applications that don't want to start on my vnc session (if I don't have a screen). Although as you already know, I use 0:0 instead, since just using a single zero sometimes do not work (as I found).
 
@NordineLotfi looking at the NVIDIA config, I see that the monitor is set to :1. When I vnc, I'm vnc-ing to :2
 
6:47 PM
@inspectorG4dget what's the vnc client and server (you can use different one together, which is why I ask) you're using? (forgot to ask that :/). Also, if they aren't used as a GUI, can you show the command for both?
 
I'm using vncserver on ubuntu and OSX's finder's vnc://hostname:port
 
so you're using default vncserver flags? no custom ones like the one I showed last time?
(btw, I don't know if this is fine to discuss this here to this extent, maybe we should discuss this in another room since this is not relevant to python, at least directly)
 
I tried -localhost :0 and -localhost :1, but I keep getting "is taken because of /tmp/.X11-unix/X1"
@NordineLotfi good point. I'll make a room

VNC

let's talk about VNC
 
7:14 PM
If I want a constant in a class, would you assign the constant to a private class attribute or in the beginning of the module?
 
I usually declare constants at the top of the module in ALL_CAPS. That's just my convention for constants.

If you want the constant to not change (like the "final" keyword in other languages), I don't think python has native support for that

If you want each instance of the class to have it's own value for that constant (eg: my height doesn't change, but it's not the same as your height), then it should be an instance variable, not a class variable
 
@inspectorG4dget Yeah, that's a good rule for this. So real constant that should be shared among several classes should probably be at the top :)
 
if I end up having a lot of classes, I make an enum in constants.py and use it that way
* a lot of constants
 
There's either something wrong with your data, or with your code, or both. That's literally all we can tell you
 
you might also want int(f, 2)
 
not my question, but found it interesting and dont know the solution so asked here to have more insight on it
found stackoverflow.com/questions/56282563/… how to solve this, but utf-8 decode, shouldn't it solved the decoding part ?
 
That question is unanswerable until OP provides a detailed explanation of the encoding and decoding procedure
 
7:47 PM
@Warcaith or in a config object that you can pass around
 
@roganjosh Yeah, sure, but the constant is only used in that specific module and should be private.
So in this case it would not make sense having it in a configurable object I guess
 
<ponders> I wonder how private you can make something in python
 
Well, "_" indicates that it is private. If you use it in some way, well, bad for you.
;)
 
Name mangling + burying it deep in the package is all I've got. I wonder if there are some neat tricks you could layer on top (obviously not for any practical reason other than curiosity)
 
Oh, it's perhaps better to name mangled a private module constant?
 
7:52 PM
No, I definitely don't suggest name mangling
I raised it purely because Aran, Miyagi or Kevin (for example) might come up with some wild and wonderful thing I hadn't thought of
 
Haha oh, I see...
Name mangling seems useful at first, but there's probably some major issues using it.
 
Did someone ask for a crazy idea? Here's a value that's so private, nobody can access it:
class SuperExtraPrivate:
    __slots__ = ['private_value']

obj = SuperExtraPrivate()
obj.private_value = "You'll never get me"
del SuperExtraPrivate.private_value
 
I have never found need for it; I think it's only really for potential name collisions in inheritance rather than any other use. But it does feel like there could be a dark corner of the data model where one could secrete a private var
 
I believe party poopers call this a "memory leak"
 
dir gives:
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__']
So it really is actually gone at that point?
It's not in __slots__ either
 
8:02 PM
I think the only way to get it is through gc.get_referents, which is kind of cheating
 
Which version of Python is this? That's an empty list for me - is this a known bug?
Put another way, Python 3.9.13 doesn't seem to give me any indication that something is still floating around in memory
 
This is what I get with python 3.10.0
 
Ok, I can repro that :)
 
8:24 PM
@sahasrara62 I have to thank you for posting this post. It's exactly what I needed for some project :o
although the way I had also worked, but it was a bit hacky compared to this one
 
8:39 PM
@NordineLotfi welcome, you can post answer to help him. BTW may i know what kind of system you are making with this
 
@sahasrara62 It's nothing really, just weird stuff I do for fun. Mostly involve decoding/encoding as you probably know.
I had those same errors when I was playing around, so that's why I said what I said
I don't really want to answer even if I think I know the right answer, mostly because I (fear my reputation would take a hit) don't know the right way to handle binary strings that start with 0, since most popular way strip those out. Technically most people here would agree they aren't needed, but if you need a 1:1 conversion for bytes/hex <-> binary, then having a complete 8 bits long binary per byte/hex, instead of stripped when it start with zero would be more correct.
See here for one of the "popular" way I mentioned: stackoverflow.com/questions/7396849/…
the only way I would use is using a dict and mapping each byte/hex to their corresponding 8 bits long binary string. But even if it gives the result the OP wants, it would definitely be downvoted to oblivion (especially if I post it)
 
@NordineLotfi thanks for insight, i think you shouldn't worry about downvotes (-2) only , upvote(+10). but if you post it it would be helpful to everyone in future and even if you are wronng, someone will correct you and that is a good thing right ? we will get new insight on this then :D, so better to answer
 
Losing reputation is just losing Internet points. If you have a contribution you should make it and disregard this. SO internet points are what have broken the system (at least in part)
 
9:00 PM
def __new__(cls, *args, **kwargs):
    def inner(cls):
        pass

What would you call the inner "cls" argument here? I'm using "__cls" right now, but @Aran-Fey won't forgive me if I use name mangling :D
 
Without any context, my best suggestions are other_cls or just cls
 
Oh right, I was scared for getting the outer context of "cls", but that is of course not the case.
 
With context, you might use something like parent_cls or child_cls or whatever
 
other_cls was perfect here
:)
 
9:44 PM
github.com/learnergthb/time-complexity-analysis/blob/main/… In example_1 the complexity is n^2(log n) correct?
 
@roganjosh I mean, I agree 100%, but if I lose enough reputation, especially from answering someone question, I might be banned from answering (at least I recall this happened to me but for question, but now I can ask again I guess). There also the fact that I already have less than 200 reps, which is enough to talk here but, you know, it's easy for it to snowball.
I prefer answering when I'm sure what I'm gonna say is correct and better than what can be found when looking for similar/related post. If it isn't, I wouldn't post it, unless this was here.
@sahasrara62 I guess, maybe I'll answer with my own way if it's still unanswered after 24 hour (or the existing answer only provide the popular way which strip zero at the start)
 

« first day (4422 days earlier)      last day (531 days later) »