« first day (3613 days earlier)      last day (1336 days later) » 

3:06 AM
@vinter The Python room rules require you to wait 48hrs before soliciting answers here. Also, that's not a Python or even a programming question, it's an algorithmic question (albeit interesting), so borderline-offtopic on SO, try the other SE network sites, it should probably be migrated.
 
Dev
4:04 AM
Hello All, I am looking for help on a string manipulation
Input String, s = "ID bigint,FIRST_NM string,LAST_NM string,FILLER1 string"
Desired Output, st = "ID,FIRST_NM,LAST_NM,FILLER1"
Basically,objective is to remove anything between space and comma at all occurrences in input string
Any help is much appreciated
 
 
1 hour later…
5:26 AM
@Dev Is the format of input string fixed like there will always be bigint on the first element and string on the rest of them??
 
5:45 AM
i'm trying to solve this using RegEx. (:
 
6:04 AM
cbg
@Dev you can try this [i.split()[0] for i in input_string.split(',')]
 
@python_learner LoL, i was trying RegEx in vain. But i just read the documentation in process so good for me.
 
I tried getting into regex but it was so confusing for me so I stopped, maybe regexes are faster I am not sure
 
@python_learner RegEx are good but only for complex things. (but if one masters regexes, it's just so good to use).
i'm still into the documentation for regexes for future refs (:
 
 
2 hours later…
7:49 AM
@vinter Sorry, what exactly are you asking for? You already have an answer, in fact you are linking to it.
@crypticツ subprocess.run will already wait for completion of the process. If that is not sufficient, if you are not using subprocess.run, we need more information.
 
NYC
cbg
 
8:20 AM
@MisterMiyagi It was unanswered at the point of posting the link in this group. Anyway, I got the logic and answer
 
8:51 AM
@vinter that's an untruth. You literally linked to the answer here.
Stack Overflow's limited engine doesn't support time travel
 
 
2 hours later…
10:50 AM
wow I did not realize fstrings could be embedded in fstrings, very useful
although probably a better idea to avoid that lol
 
 
1 hour later…
12:13 PM
Note to self: the error is not with your code, it is with the browser caching what you had before.
 
12:27 PM
@toonarmycaptain see here
 
1:06 PM
@roganjosh Nice.
 
Tis a handy reminder :P
You working on dressing up the frontend then? Why put yourself through that on a Sunday? :P
 
@roganjosh Nah, mostly last night, decided actually working on a personal website was a good idea. Reset my machine last night, which didn't solve my issue, which was why a bare '/' was redirecting to a function rather than that function's response (bare text at this point).
And caching in the browser occurred to me this AM.
Besides, what meaning do days of the week have anymore?
 
Indeed, though discovering that the day is, in fact, Sunday gives an nice excuse to get out of something I dislike. You going with Bootstrap for your site or something else?
 
I thought I'd use code rather than parts of shoes...
Or a deceased pirate (your pick).
 
1:18 PM
Oh wow, you're gonna run with CSS from scratch? That's a hat-tip from me
 
I'll probably (maybe) take this exercise to learn some basic js/css this time, though yes.
Oh, I thought Bootstrap was js? I guess being a framework it would probably handle css too. Never thought about it. Vague consideration of React or something. It's the bikeshedding (that I end up doing) associated with frontendy stuff that causes me to walk away.
 
I really wouldn't mix React with Flask
The main draw of Bootstrap, at least for me, is the responsive card system. I spent a day learning React and it was enough for me to realise that it's chaotic to mix it with Jinja2
 
Ok. I understood the part before the comma, and after the period. lol
Fair enough though, duly noted. A quick google search shows a bunch of tutorials for Flask+React though.
 
If you load my site and start resizing the browser window, or load on a phone/tablet and rotate the screen, you'll see that the boxes move from being side-by-side to being stacked. That's essentially what a "responsive" design is. That's because each box is actually a Bootstrap "card" and you can get them to display differently depending on viewport size
@toonarmycaptain It might exist but you then have to API-ify your whole backend
Whereas, Flask already comes with the templating engine you need
 
1:33 PM
@roganjosh Fair enough. I do plan on experimenting with API-ifying another semi-hiated project.
@roganjosh Makes sense.
 
See also (and the following comments):
Feb 17 at 21:26, by Code-Apprentice
@roganjosh yah, mixing React with some templating language is a path to misery
 
Is there a python GUI library which has capabilities similar to HTML/CSS in terms of look?
I want those transparent backgrounds for any widget and rounding of the vertices specifically.
 
1:54 PM
@Abhijeet.py I'd have thought the easiest way was to build a local web server, then your users can use their browsers which actually DO have the required capabilities.
@aadibajpai David Beasley had a lot of fun with f-string abuse when 3.6 came out.
 
@holdenweb But it appears that it's not an efficient way, especially when one is trying to build standalone applications.
 
Well, if you want efficient (and I'll be you can't tell me what you mean by it) expect to spend at least five times the ncessary effort.
 
@Abhijeet.py Actually, not really. Paritosh spoke about using freeze to make an executable of a flask app in here a while back
 
I just need the capabilities of transparent backgrounds for widgets, round edges and maybe, shadows.
 
I mistrust any assertion containing the word "just" ...
... "maybe" makes it seem even more suspect.
 
2:00 PM
even worse: "definitely"
 
Yeah, that's definitely just a no-no.
Shed update: I have now installed the wall insulation (never come across insulation slab before, much easier than the rolls I've had to deal with in the past). I have begun fitting walls made of 12mm plywood (a full sheet of which, I discovered when ten were delivered, weighs about 60kg).
 
2:21 PM
@holdenweb are those insulation slabs made of polystyrene foam? Or is it something else?
I knew that plywood is heavy :)
 
2:34 PM
I forgot that I once downloaded Odoo. Now I'm invited to a conference with 180 "inspiring" talks. I don't suppose anyone wants this exciting opportunity? I'm washing my hair on 30th Sept... and 1st Oct.
 
@roganjosh Is it in person?
 
it's hard to wash your hair online
 
I see, roganjosh is actually Rapunzel
 
It's even harder/more dangerous to use electronic equipment in a hair-washing environment
 
@AndrasDeak Comfortably confident I've more hair than most in this room...I agree.
 
2:37 PM
180 talks about ERP systems. That in itself feels impressive
 
@roganjosh I don't know much about them...I feel like I've heard my dad mention odoo though, so he might be interested. Plus it's Father's Day ;)
 
@toonarmycaptain the perfect gift!
 
@roganjosh xD
 
@Aran-Fey I really need to get over my aversion of random people touching my head and talking to me. It means I miss out on Odoo fun :(
Odools of fun? Nah, it doesn't work :(
 
3:06 PM
@roganjosh Odoos of fun...kinda works for me.
 
Without the "l"? It doesn't pass my internal QC checks, but I'm continually concerned about the things that do so maybe I'm faulty
In my quest to explain the 2-day hair-washing, I've since discovered that Clinical Lycanthropy is an actual thing, though. That'll keep me busy for a bit
 
AAB
3:47 PM
Hi all,
I went through KMP
have understood a few things need to know if what I have understood is correct :|
 
Hello. What is KMP?
 
AAB
Knuth Morris Pratt String matching algorithm
@roganjosh yup
I have gone through a few pages
so just wanna know if I have understood lps correctly
 
lps?
 
AAB
longest prefix match table construction correctly
 
@AndrasDeak Fibreglass with some bonding materials: jewson.co.uk/p/… - I cut it to size with a bread knife, and if you cut it correctly it just stays between the battens.
 
3:50 PM
@toonarmycaptain see I was in this lifestyle for a few months but then uni began last week
 
@holdenweb nice
 
@holdenweb nice I should check that out!
 
@aadibajpai School is back for my family too...but none of us leave the house, so...
 
yeah I'm doing it over zoom too, haven't been out for a while now
low-key terrible for me because of tz differences so it's more like night classes
 
Every time I try to pick up some js, I get frustrated because I want to type python syntax. And then...scripts that can be run alone but don't work unless run through node...time to do the kitchen.
 
4:27 PM
Can I do this? ` if not os.path.exists(path) and os.path.exists(path):`
to check if both directories exist or not?
 
Uh, presumably you want to check two different paths there, and not use path in both branches?
 
could not understand what you mean.
I do want to check two different paths
 
The code you posted is essentially if x and not x:, which is guaranteed to be False
 
@Aran-Fey that's why I am confused
 
So what you really want to do is if os.path.exists(path1) and os.path.exists(path2)?
 
4:35 PM
I want to check whether both the paths exist or not, it is for sure that both exist or do not, I am confused about syntax, do I use nested ifs?
 
I think I'm misunderstanding the question, because all you need is an and
 
@Aran-Fey what if the do not exist, do I write makedir() in an exception?
@Aran-Fey yeah I've put an and but I am confused about the exception case
 
Exception? There is no exception
It's either True or False
 
Oh yeah I meant the False condition
 
@Aran-Fey it's not you
 
4:43 PM
If you want to create the folders, then yes, call makedirs. If you want to do something else, then do something else. I'm really not sure what the problem is
 
@AshwinPhadke please spend an hour formulating a coherent question first.
 
5:05 PM
@AshwinPhadke Much better to use os.makedirs, which will create the necessary directories (including intermediate directories) if necessary and do nothing if they all already exist (as long as you set exist_ok=True in your calls). Simples!
That way you don't need to query whether they exist, and in the absence of an exception you can be guaranteed that they will exist after.
 
Any reason why we continue to use/promote the os version of these methods when we now have corollaries to most of them in pathlib.Path, which seems to me a friendlier (and less C-like) API?
Of course, I'm always a sucker for operator overloading...
 
5:28 PM
we don't want to exclude people using 3.3
 
5:38 PM
We don't? <dismantles picket>
 
 
1 hour later…
6:44 PM
I want to replace all numbers like 897-919-283 by adding a "+1-" in front using regex re.sub().
I have written as re.sub(r"([0-9-]*)", r"+1-\1", record)
But it's adding +1- to every characters
Can anyone tell me how to replace the number like above with a +1- in front?
 
I'd append a [^-] at the end to signal the end of a "number"
or maybe a lookahead
 
@AndrasDeak Not working
@AndrasDeak Can you please elaborate?
 
You'll have to tell python where a "number" ends. Why is 897-919-283 a block and why not 897 or 897- or 897-919?
 
6:59 PM
* means "0 or more", so your pattern matches literally everywhere. Use + to make it match only when there's actually at least one number
 
that too
Or will + be greedy enough? Possible
 
After changing * to + it's working
Thanks
 
It'll also match dashes without any numbers attached to them though
>>> re.sub(r"([0-9-]+)", r"+1-\1", "world-class")
'world+1--class'
 
 
3 hours later…
10:27 PM
sorry it is irrelevant for python, do we have any room for lisp/autolisp chats?
 
hello anyone can help me in django ? i have problem
 
i searched but did not find any
 
@EnthusiasticEngineer not that I know of
 
10:39 PM
cabbage
I have a polygon with local co ordinates like
20509.2462745155,-125891.862952247
there are 4 of these which form a polygon, this is a vertice
 
(singular of vertices is vertex)
 
I use, Shapely's Polygon() method to convert them into postgis geometry type to store in db
Now i want to do the reverse and its seeming very hard
@AndrasDeak Ah. right , word was in my throat
How , do I get back the original co ordinates from polygon object? I must admit, when I initially wrote code to convert , i underestimated how hard it would be to revert this
 
Have you consulted the Polygon docs yet?
 
Shapely? Umm... not really , I just spent 2 hours googling
 
So... you are asking "How do I retrieve the coordinates used to create a shapely Polygon object?". You'd start with the documentation of the Polygon class first. If that doesn't help, look at the source.
in your defense the shapely docs seem to be terrible
 
10:48 PM
The thing is, posgis is returning a wkb object thingy
 
@Anarach look at the docs of whatever your object is...
 
I have been , It feels like , it shouldnt be so hard
 
11:05 PM
ok , some progress, I am able to bring it to Polygon object from postgis type using STAsText function.
'POLYGON((100 100,100 99,99 99,99 100,100 100))'
 

« first day (3613 days earlier)      last day (1336 days later) »