« first day (3858 days earlier)      last day (1073 days later) » 
00:00 - 14:0014:00 - 19:00

12:08 AM
@Kevin Okay its complicated than I thought. Can't seem to figure what is happening with the indexing. Can you expand it a bit more?
@AndrasDeak Like?
 
Come again?
 
"Technically things we call linear relationships or linear functions are usually not linear.", I was asking for an example
 
unit_a = x*unit_b + y is almost never really linear
 
I am trying to move the word "Channel" to the beginning of the line and add ":" after it. At the moment my line is : man city vs chelsea : Channel 3. Essential I want it to be like the following: Channel 3: man city vs chelsea. I have tried the following and I am able to move the word "Channel" to the beginning using this code I..e.
 
@AndrasDeak Oh okay, cool
 
12:13 AM
sep = ': '
lines3 = lines2.split(sep, 1)[-1]
 
Linearity of a function f(u) would mean that f(a*u1 + b*u2) = a*f(u1) + b*f(u2) (OK, that's homogeneous and linear). This is only true for the "linear function" f(unit_b) = x*unit_b + y if y = 0.
@Ahmed.B Look at str.partition.
 
lines2 = man city vs chelsea : Channel 3
 
@Ahmed.B that's probably a syntax error
 
@AndrasDeak I don't get any error. It prints "Channel 3"
 
@Ahmed.B then your real code doesn't include lines2 = man city vs chelsea : Channel 3
 
12:16 AM
I think the first error will be 'man' is not defined.
 
guess again
 
Nope, syntax comes first :p
 
syntax always comes first
 
So there is a priority list for errors too? Perhaps a precedence
 
"Whichever comes first"
 
12:18 AM
@AndrasDeak my real code produces: man city vs chelsea : Channel 3
 
@Ahmed.B Why don't you give us a runnable example
 
But you can only determine if a note on a piece of paper is correct if you've made sure that the piece of paper is not actually a puppy with a pancake on its head
 
@AndrasDeak That makes sense, with too much details
 
I'm slightly surprised but also happy
 
@CoolCloud I wish I could but my code saves the result in a text file and lines2 is part of it
 
12:19 AM
@Ahmed.B anyway. I'd use lines2.partition(sep), reverse it, and join it back again
@Ahmed.B don't tell me nobody has pointed you to the concept of an MCVE yet...
 
So essential all I am trying to achieve is to move the word Channel to the front of the line
 
So basically, 'man city vs chelsea : Channel 3' is what you get always right
 
Nobody wants to see your real code and real output. We want to see small representative examples of your code and output.
 
@CoolCloud yeah
@AndrasDeak which is what I thought I described?
 
@Ahmed.B in this case I figured out what you want, but that's credit to my unrivalled brilliance. The onus is on you to come here with a runnable example that represents your problem.
 
12:22 AM
@AndrasDeak fair enough
 
But I've already told you what I think you should do based on available information. Make sure you didn't miss it ^
 
I am still learning python and trying my best.
@AndrasDeak yeah thanks for that will need to look up on how I can reverse it and join it back
 
It's alright. Asking well is a skill on its own, which needs practice. I'm telling you all this so that you can improve :)
 
>>> string = 'man city vs chelsea : Channel 3'
>>> idx = string.find(':')
>>> channel = string[idx:]
>>> match = string[:idx]
>>> final = channel[2:] + ': ' + match
I would look at partition first tbh and then look at this
 
@AndrasDeak 👍🏼
@CoolCloud thank you will first look into partition
 
12:25 AM
I think using split would make more sense here
 
@CoolCloud I did use split and got Channel in the beginning of the line up now I some how need to join the rest
 
@CoolCloud why?
 
Ummmm, concatenation?
@AndrasDeak I mean split would make more sense than my example.
 
@CoolCloud ah
 
>>> lst = string.split(':')
>>> lst[1][1:] + ': ' + lst[0]
'Channel 3: man city vs chelsea '
Perhaps something like this?
 
12:27 AM
@CoolCloud yep
@CoolCloud that's much simpler thanks
@CoolCloud gives me an error saying out of range
 
cabbage
@Ahmed.B I have not fully read the conversation, but things would be a lot easier for people helping you if you can create an MCVE as pointed out
 
12:43 AM
@Ahmed.B Does the string change anytime?
 
@CoolCloud it does yes
@python_user 👍🏼
 
@Ahmed.B Would it not be of the same format always? TEAM A vs TEAM B : Channel X ?
 
@python_user this is the MCVE, buf it's too M. Some strings don't contain colons.
 
ahh I see, if the that is the case, then I guess partition would make sense as it always returns a 3 tuple
 
No way
 
12:45 AM
I guess too?
 
huh, let me go re read the entire thing before I make any further suggestions
 
>>> txt = 'TEAM A vs TEAM B : Channel X'
>>> tup = txt.partition(' : ')
>>> tup
('TEAM A vs TEAM B', ' : ', 'Channel X')
>>> tup[2] + tup[1] + tup[0]
'Channel X : TEAM A vs TEAM B'
 
we can still insist on hammering screws into a shape that can be used to carve out wheels
 
If the format changes then you will have to think of a more complicated search pattern
@AndrasDeak Well I am out of ideas for now
 
12:48 AM
@Nuclear_Man_D If that F was for respect, then thanks
 
pretty sure its the other F :p
 
No thanks then :P
 
btw a question I have been following was bountied for 50 rep, bounty hunters can look into this stackoverflow.com/questions/67394401/…
 
"I want to use an approach that doesn't work." "Here's an approach that works." "Yes, this works, but I want a version that doesn't work.".
No thanks.
 
yeah that kinda throw me off as well, but if they are willing to bounty it, curiosity got the highest of them
 
1:00 AM
if it weren't bountied I'd close it as unclear
 
you cant close a bounty question? the button is visible I didnt mind clicking it, I tried some frame hacks (ok, one frame hack :/) before I stopped coming for a solution
 
No, it's blocked.
 
ahh I see, it shows a pop up when I click close, I thought the options itself would be blocked
 
Should've
 
I guess from a coding perspective it is easy to just add a popup at the end rather than writing code to block UI
I wish * unpacking worked inside list comprehension, that would have been one less for loop
 
1:34 AM
Hello, just got to know about chat :)
 
Hi :D
 
I don't have anything to ask atm, but I will keep in mind to come here if I face some beginner doubts
 
@Alice Sure, but this is not just the space for asking doubts. Basically a chill-out place for python-ers :p
 
I guess its called a Pythonista, like rustacean
cbg Alice
 
Ah yea, pythonista. Reminds me of madridista
 
1:40 AM
it reminds me of Barista :p
 
It also reminds me of Bautista :p
 
rustacean sounds a lot cooler than pythonista to me
 
When you say it out, sounds like your talking about some Asian dude ;P
 
apparently you are right, there is something called as Pythoneer, though it has two e's
 
@Alice welcome
 
1:58 AM
@python_user im super not a bounty hunter and I generally wouldnt answer something like that but...curiosity got the best of me, and it's saturday.
 
yeah I did get a notification for someone answering it, been looking at it, I like how OP instantly accepts it, but its a lot better than my attempt
didnt realize you were in this room
 
I cycle between forgetting this room exists, and then coming here every day.
 
That was fast from the OP
Why does it not show that the bounty is awarded?
 
I think bounties aren't awarded until the timer is up
 
Kay then all the best
 
2:02 AM
I gave a bounty once and there is a time after which you can give
 
Also thought it was interesting that OP accepted it so quickly. There are potentially more possibilities here, and there's maybe an interesting solution with asspressions?
 
till then its locked, if the time expires there is some logic to who gets it
 
Maybe the OP is fed up and directly just went for it
 
that really can be a simple two / three liner
res = {}
for i, *j in seq: res.setdefault(i, []).extend(j)
 
I mean ideally you'd use a defaultdict (setdefault is uber clunky)
(imo)
but yeah it's just
 
2:07 AM
its just dict.get but acts as a hypothetical dict.set, that is my mind model for that
 
res = defaultdict(list)
for k, *vals in seq:
    res[k].extend(vals)
 
aint got time to import from collections :p
 
but thats like, the best module
 
yeah, its really cool for adding +1 when you dont want to use a counter, or the nested defaultdict lambda trick
 
I'm gonna try the walrus operator and see if there's something cool there
 
2:10 AM
reading the bounty page, you will get the bounty as long as OP doenst give it to someone else
 
2:32 AM
Since my answer is always executing the side effect first, I can just reference d[k] so walrus doesn't really get me anything.
I was thinking I could maybe use it to bind to a value inside a dictionary (d[k] := ...) but that's not allowed.
 
gratz on the Bounty
 
thanks, although more rep doesn't really do anything for me at this point so :shrug:
oh god is it possible to use the walrus to define the starting dictionary inside the comprehension itself?
 
wont it be created on each new iteration?
its a SyntaxError apparently
 
what is?
 
this {d.update({k: d.get(k, []) + vals}) or k: d[k] for k, *vals in [(d:={}), x][1]}?
 
2:43 AM
oh wow [(d:={}), x][1] is horrifying
 
lol I thought it would work
 
yeah its a good attempt
 
a cheap hack would be (d:={}) or {d.update({k: d.get(k, []) + vals}) or k: d[k] for k, *vals in x}
 
yeah but might as well just do d = {}; d = ... at that point
 
at this point I want a assignment operator that acts like += -= so I can use the new merge operator | for dicts
 
2:45 AM
oh I forgot that existed
 
if that were a possibility you can get rid of the update calls probably
 
was that in 3.9?
 
yeah, 3.9
 
I'm still surprised "assignment expression in a comprehension iterable expression" is explicitly caught and understood
I wonder why
I mean aside from it being absolutely awful
 
that shows that they can indeed parse that
maybe Python core devs are holding this feature hostage, and release it 10 versions later :p
 
2:51 AM
damn can't hide it in an anonymous function either
I guess it just can't appear anywhere inside the in ...
 
bugs.python.org/msg355140 pretty much what you said
 
good detective work!
 
thank google for that :p
 
I tried to cheat the system and it didn't work
 
with what?
 
3:05 AM
{d.update({k: d.get(k, []) + vals}) or k: d[k] for first, (k, *vals) in zip(chain([True], repeat(False)), x) if first and not (d:={})}
 
you got past the SyntaxError
 
yeah
result is wrong tho
 
how does d reset? first is True only the first time right
 
yeah
 
ohh it doesn't even go for the next iterations
 
3:12 AM
oh oops
brilliant!
it works
 
while True:
    print(':HeadScratch:')
 
{d.update({k: d.get(k, []) + vals}) or k: d[k] for first, (k, *vals) in zip(chain([True], repeat(False)), x) if first and not (d:={}) or True}
 
that was what I was going to suggest
 
yeah i didn't realize my error, thanks for catching it
 
you can make it if first and not (d:={}) or d to make it more "less readable"
 
3:16 AM
if not first or not (d:={})
 
that is even better
 
alternatively from de morgans, not (first and (d := {}))
 
I dont use de morgans, at this point I just trial and error my way of substituting not and or
 
lol
I mean unless you have N > 4 conditions it's really not gonna take you too long either way, you already have a hunch on the few of them
but my degree is in math so I have to at least pretend like I learned something
now to try to get rid of the zip(chain...)
enumerate..
{d.update({k: d.get(k, []) + vals}) or k: d[k] for i, (k, *vals) in enumerate(x) if i or not (d:={})}
 
If this: (?=13735.|6239.).*?.(?=,|\n) I made a regular expression, for a number which starts at 13736 or 6239 then . then bunch of numbers or signs who end with , or \n, What would be my regular expression if I my string starts with all numbers exept these two 13735 and 6239?
 
3:22 AM
@alkasm nice
@CoolCloud tbh it took me a while to understand his logic
 
And it takes me forever, so...
 
that is cause you are stuck in the while loop scratching your head :p
 
lol
 
Error 404, no break found
 
^C
 
3:24 AM
Phew, thanks
 
sorry, could be that i have it
 
alkasm going to edit that in your answer?
@pythonabsir if you want to check startswith you can try string.startswith('13735') or string.startswith('6239')
 
I dunno it's pretty gross
{d.update({k: d.get(k, []) + vals}) or k: d[k] for k, *vals in [(None,), *x] if k is not None or not (d:={})}
here's one without enumerate
but adds a restriction on keys, so I guess enumerate is better..
 
why a tuple of None, ? [None] is one less comma
 
Just needs to be any value, not necessarily None
so that I can check k against it
oh wait, that gives me an extra entry in the dict.
oh wait this doesn't work at all, dangit.
 
3:34 AM
it works doesnt it? other than the None being extra?
 
no, prepend a del d; in front of every line, otherwise you'll accidentally fool yourself :P
 
{None: [], 'a': [14, 15, 7, 16], 'b': [3, 15], 'c': [22, 1, 5]} this is what I get, which looks correct to me (None aside)
 
oh, whew, I'm seeing the error from the del d itself lol
@python_user I default to immutable containers.
 
(d:={d.update({k: d.get(k, []) + vals}) or k: d[k] for k, *vals in [(None,), *x] if k is not None or not (d:={})}).pop(None) two walruses are better than one
 
I was actually going to use a second walrus to define a first object
that way it doesn't restrict the value in the dictionary
ah the not in not (d:={}) just needs to be removed to toss out the None entry btw
 
3:41 AM
this is why you trial and error
 
ok using a walrus for the "first" object doesn't work since the value can't be used inside the in ... (if you use the walrus in there, you get the syntax error, if you try to use the value that a walrus defined elsewhere in the expression, it's not defined)
I guess enumerate is the best you can do
 
@python_user I tried (?!10116.|10090.)\b[0-9]{3,}.[A-Za-z0-9_]{2,}(?=,|\n)\b why .startswith? seemed to work on regex101, but no. will search this pattern then with findall
 
startswith is not a regex, it is a string method in python
 
3:55 AM
rbrb
 
What does rbrb mean though
 
rubarb
see the room rules, then follow the link about cabbage.
 
Yea the salad, I did not know it was the abbreviation of that
 
yep yep
Ok, I added the asspression to the answer. Now with extra bad! stackoverflow.com/a/67453653/5087436
also added a disclaimer about how all of these are bad
alright, time to go get a burrito.
 
@python userdf = pd.DataFrame({'Name':['243.N-P00034057,189.BGIB03-TA','128.P000000117
'128.Nn_GM00-026,243.B10740-PA',
'128.P000000117,967.00042,243.OCU-__16, ']})
valst = df_t.to_csv(header=None, index= False).strip('\n').split('\n')
import regex as re
for val in valst:
#print(val)
#fx = re.findall('10090.[A-Za-z0-9]{7,}', val)

#my_indices_species_2 = df.index[df['Name'].str.contains(pattern)].tolist()
#my_indices_species_2
sorry, my strings are in a panda dataframe, thats why I tried the regex, to exclude all which are not in there.
here, all patterns which dont start with 243., 128.
sorry, to exlude all patterns which are too much, so if i get the indices, I can exclude them.
here dataframe goes from 0:2; row 1 is alright, row0, and row2 have other patterns as well.
 
 
2 hours later…
6:09 AM
can someone help me with this please ? stackoverflow.com/questions/67454749/…
 
6:41 AM
@pythonabsir I dont know how you can apply that in the context of pandas, i dont use pandas
 
 
2 hours later…
8:35 AM
is there an easy way to return a some finite amounts of individual strings without using tuples. like
return "a" , "b"
but not as
return ("a", "b")
tuple object
 
...why? What's wrong with tuples?
 
the actual case may be harder than the above sample,
https://stackoverflow.com/questions/67419765/resolve-a-tuple-return-object-in-python
can some data type actually 'pour' the output objects into the designated variable
input = "a", "b" #for visualization
output = input
-----
ouput now becomes "a","b" rather than tuple("a","b")
i find it uneasy to dump elements from tuple, intoo my variable; especially when my case involves nested tuples
 
Nope, this isn't possible with just a map. You'll need a piece of code that loop over all elements in the tuple and appends them to the result
 
i find that iteration part so demanding, and easily confusing
thanks anyway
 
It's probably easiest if you make process always return a tuple
 
8:50 AM
and then pour it out into my output, every time using an iterator.
 
9:48 AM
@python_user There comes a time to realise you are pushing comprehensions too far, and that concise code is not always the best code ;-)
 
10:43 AM
@PIngu what is "a","b" even, in contrast to tuple("a","b")?
@Aran-Fey can you translate?
 
"a","b" is supposed to be an imaginary type that automagically unpacks itself into "a" and "b" when you do... something... with it. I think.
 
Ah... you seemed so OK with the discussion I thought I was missing something :P
 
It's like... there's the reasonable part of the problem, which I addressed, and the weird part of the problem, which I chose to leave untouched
 
The latter makes this sound a lot like an XY problem
 
11:06 AM
@PIngu Note that the way you are asking this doesn't make much sense – "a", "b" is ("a", "b") – hence the confusion here. What you seem to be looking for is unpacking, which is an operation, not a thing, since it also requires something to unpack into.
 
And it's not clear at all what the result of the "pouring" would be.
 
Instead of returning a scalar-that-does-not-need-unpacking or a tuple-that-needs-unpacking, always return a tuple and always unpack it, even if it has only one element.
 
My best guess is (recursive) flattening plus str.join
 
For the linked to question, just flattening should do.
 
@holdenweb yeah, I am pretty sure I wont remember what that comprehension is if you ask me to explain that a week later
 
11:13 AM
I hope we're not talking about code posted on SO
 
Write-only comprehensions are my favorite kind
 
^true, I regularly catch myself trying whether it works...
 
Python core devs, please make x = *[1,2]; f(x) valid syntax, equivalent to f(1,2)
 
11:34 AM
umm... that's disappointing... did a docker-compose up and waiting about 2 hours for it to download all the images, compile a shed load of stuff, then it doesn't work because it's got errors in it... not sure if it's a ploy to make me pay for their cloud service but it's not encouraging about their level of testing/devotion to their open source model
set some time aside today to review saleor.io/open-source - as thought it has potential and could possibly use/extend it for some existing projects... not off to the greatest of starts it seems :p
 
The Pay to Win of open source? :P
 
heh :)
 
hey @AndrasDeak
i am here
i googled what is XY problem
 
Hello :)
 
i am a grammarian and not very fluent in python
as much as in grammer
 
11:46 AM
That's alright. We just have to figure out what you're really trying to do.
 
but graduated cs50
 
You should try to explain what result you want to end up with that's "a","b" yet not a tuple. And also how you want to end up using this variable.
 
i have a list with many objects
list = [a, b, c]
now my program iterates through each of the elements inside the list
 
Hold on.
 
waiting
 
11:48 AM
Can you put together a very short example that we can run ourselves to see what you're trying to do?
Then we don't get into misunderstandings. Code is exact.
 
code is a research one. so i am stuck with abstractions
i can share google colabs
one
sometimes rare times, depiction of problem itself becomes problematic,
 
@PIngu abstractions are perfect if they are representative
 
and i end up being framed for some idiosyncratic
researcher
 
Coming up with a good MCVE takes work and practice, but it helps both you and answerers
 
okay
got is
'got it
 
11:54 AM
If you can't describe your input and desired output, then the problem is not with your code, but with your requirements
 
So here's my interpretation of the problem: You have an iterable and a function you want to map over that iterable. Sometimes, this operation has to turn one input element into multiple output elements.
 
thanks @Kevin
i am cooking a colabs code
will share soon, and pass it to the floor
 
IMO, the crux of the problem is the "sometimes" - if your function always returns a sequence of output elements, the whole thing becomes much less messy.
 
thnk for all your concerns @Aran-Fey, @AndrasDeak
there you go
i wished there be a way to unpack the elements of the return tuples
when returned
thanks in advance
 
errr... @PIngu I'm still not sure what you're trying to achieve there? That seems like a crazy function?
 
12:08 PM
What's wrong with the solutions given to stackoverflow.com/q/67419765/953482 that already produce your desired output? As far as I can tell, the problem is solved.
 
def process(char):
  if char == "c":
    yield "x","y"
  if char == "d":
    yield "p"
    yield ["q","r"]
  if char == "a":
    yield "aa"
  else:
    yield char
might work in that specific case but ummm... ugh...
 
Oh, the process function in this new code is different from the one in the SO post. OK.
I endorse the advice given earlier, that this problem becomes a hundred times easier if process always returns a tuple
 
its a tuple anyway
because two return object are naturally put instide the tuple and delivered
 
def process(char):
  if char == "c":
    return "x","y"  #two element tuple
  if char == "d":
    return "p",["q","r"] #two element tuple
  if char == "a":
    return "aa", #one element tuple
  else:
    return char, #one element tuple

mainlist = ["a", "b", "c", "d"]
result = [item for arg in mainlist for item in process(arg)]
print(result)
#['aa', 'b', 'x', 'y', 'p', ['q', 'r']]
@PIngu Only in your first two if blocks. The values returned by the third if and the else are not tuples. Unless you add a comma to the end like I just did, of course
 
Are you inventing words again @Kevin? :p
 
12:16 PM
@Kevin that comma did the job i think
 
@JonClements I'm never not doing that
 
i know i am very amateurish, but @kevin
thanks for the ',' and the easier for loop
 
No problem, I hope it's useful for you :-)
 
your result = [item for arg in mainlist for item in process(arg)]
did the trick for me, comma was a bonus
 
Excellent
 
12:23 PM
i will remember you guys in case i release my beta before this decade
 
Hehe, good luck with it :)
 
my programs are 80% grammer(acutal indic grammer), 20% python
the former demands my time, and i remain a cry baby when it comes to later
 
The result = ... line is a fairly typical recipe for "flattening" nested lists or tuples. But it only works properly if every element of the main list/tuple is also a list/tuple. That's why it's essential that process always returns a tuple, and not a sometimes tuple / sometimes string
 
@Kevin i am flattered
 
1:06 PM
Hi guys. There's a game I'm modding that I'll like to find the install directory. People might install it on their other drives other than their C drives, but there's always a path that is constant. steamapps\common\GAME\

I used a program called ultrasearch and once I put the path in it directly located the drive the game was installed it. Is there a module with python that can help me locate that path always?
Steamapps is not the starting point of the path but rather the middle
 
I don't know of any Python library that can search through the file system for a particular directory. I bet you could put one together in 30 minutes using os.walk, but it would probably be pretty slow.
I wonder if Steam provides information about its directory in a way that other applications can easily find it... For example, maybe it adds itself to the user's PATH environment variable. Or it has a key in the registry somewhere.
 
@Dave If it's a steam game (as steamapps implies) you can get the path from the steam client.
 
1:22 PM
you can have the client in one location and install the game in other locations
people with ssd and hdd do that
 
Do you mind telling us the name of the game? Steam's FAQ says that the recommended practices for designing mods can vary from game to game, and the game's creator may have specific advice.
 
@MisterMiyagi Some of my users don't even know how to get the steam path, so I'm trying to make everything automated.
The game is Naruto Storm 4
 
Ok, cool
 
@python_user Also, yes my game like this is on another drive, but once I just do steamapps\common\NARUTO SHIPPUDEN Ultimate Ninja STORM 4 I immediately find the path.
 
I believe someone asked something like what you asked, earlier here, idk if its you
 
1:25 PM
Ok, I see that Naruto Storm 4 has mods on NexusMods, so we at least know that this is possible
 
how easy / difficult it is to ask the user to point to the shortcut desktop and then you write python code to get the original location from that shortcut?
 
Have you ever installed a mod for Naruto Storm 4 yourself? What is the installation process like? Do you need to install a mod loader, or manually drop files somewhere, etc?
Hmm, it seems like even popular mods for this game, such as nexusmods.com/narutoultimateninjastorm4/mods/6, ask the user to manually locate the game's directory and drop the file in the correct folder. So much for a totally automatic process.
 
Yet again neural networks do the needful.
 
they even support scene releases 0_O
 
That page might be useful, since it lists five different directories that the game's files are usually stored in. So your script could at least look in all of those before saying "sorry, I can't find it, do it yourself"
 
1:33 PM
@python_user Extracting data from a Windows shortcut is surprisingly difficult. At least if you don't know much about Microsoft. If you do, it's no longer surprising.
 
@Kevin or it can start os.walking if the arcane 5 paths technique fails
 
Yeah.
 
Seems this is really hard. I wanted to use the registry but Valve changed the keys.
 
@Aran-Fey I see, probably easier to just ask the user to point the original location:D
 
Speak of the devil, my os.walk directory finder prototype just finished. It took 766 seconds to search through my C drive.
 
1:36 PM
HDD?
 
@Kevin Do you think it would be able to search every drive? I'm sure that would be useful.
 
@AndrasDeak I don't know the particulars. It's just the standard built-in drive that came with my laptop. I doubt it's anything fancy.
 
@Kevin ???
Does it sometimes say whirr and click?
 
I'd avoid using os.walk for this. I'm not sure if it's BFS or DFS, but you'll definitely find the folder faster if you search every drive simultaneously with a BFS.
 
@Dave I don't see why not. stackoverflow.com/questions/827371/… lists a number of ways to find all the drives Windows can see. Just feed them one at a time to your directory searcher.
 
1:40 PM
If there's any mechanical sound other than the fan coming from your laptop you have an HDD. But I'm a bit shocked that you have no idea :D
 
I hear the occasional click during startup, or right before my computer bluescreens
 
yup, that's an HDD
 
@Kevin Ok that's great. I think I can start from there.
@Aran-Fey I've not learnt anything about algorithms, so I won't know how to even code that.
 
Hmm, a BFSy walk algorithm... That sounds like a fun idea. I will attempt to put a prototype together.
 
@AndrasDeak so not everyone has an 8tb SSD drive on their laptop... seems like a crime if that's the case... :p
 
1:43 PM
@Kevin you'd have to roundrobin the drives
 
Just make a deque. Pop from the left and append to the right. It's like 7 lines of code
 
fair enough
 
@Aran-Fey Send an example
Also, is it possible to search for a substring in path? This is like useful if you only know some of the path like me.
 
Most straightforward way is if substring in path: print("substring is part of path"), but you may want something more sophisticated to filter out false positives
 
I've gotta go soon, so I'll let Kevin handle it
 
1:53 PM
For instance "games/tetris" in "c:/articles about games/tetris" evaluates to True even though you haven't found a directory named "games" specifically
 
slightly related, will BFS on multi thread be faster? I dont understand what stackoverflow.com/questions/11920490/… this means
walking is an IO bound operation, so wouldn't threading make it faster?
 
@python_user you can only read in one place at a time
 
If you assign one drive letter to each thread and ask it to search only that drive, then sure, it's probably faster.
 
IO is "faster" when you overlay it with CPU-bound work
@Kevin assuming the drives are different physical disks
 
Yeah
 
1:56 PM
@Kevin ok that makes sense. Let me try it out just to see if it would work for me
 
And if the drives are on the same physical disk then BFS might be slower (assuming that both BFS and DFS would finish scanning the whole disk)
 
so SSD have no physical parts, so this does not apply there?
 
Well, my BFSy walk prototype is 100 times slower than just using os.walk... Maybe there's a ton of overhead in asking the OS for each directory's information individually, and os.walk has some magic like "tell me about directory X, and dogear that page of directory info, because we're coming right back to it"
 
00:00 - 14:0014:00 - 19:00

« first day (3858 days earlier)      last day (1073 days later) »