« first day (3967 days earlier)      last day (987 days later) » 
00:00 - 17:0017:00 - 00:00

5:00 PM
my_list = [a,b], where a and b are the objects that have [1,2,3] and [4,5,6]
 
Similarly, creating a lambda or def function just to pass it to map is silly. Just use a list comp. You should (generally) avoid using map or filter, unless their function arg is a compiled function or other callable, eg int
 
try this
a = [1,2,3]
b = [4,5,6]
new_list = a + b try this
 
Ok, I tried it. But I don't think that produces the output that SAJW was looking for.
 
@MalikHamza that produces one list, I am searching for a list of lists
@Kevin will try
@Kevin yes this works:
a_list=[1,2,3]
b_list=[4,5,6]
newlist=[a_list,b_list]
print(newlist)
 
@Kevin Yes, it's working
 
5:11 PM
Do you understand what's happening here?
a = ["SAJW"]
a.append(a)
print(a)
Also try print(a[1][1][0])
 
turtles all the way down :)
 
@PM2Ring no because of :
a = ["SAJW"]
b=[1,2,3]
a.append(b)
print(a)
I don't understand why it makes "['SAJW', [...]]"
 
It's a list that contains itself.
Python is smart enough to not try to print the whole thing.
 
5:27 PM
Because that would be a loop with no break?
 
@MalikHamza That's not generally true! Comprehensions will only be faster when their map/filter are local expressions. When map/filter expressions use globals, a comprehension pays the cost of the global lookup for each item.
 
@SAJW Correct. The ... is Python's way of telling us that it's detected a structure containing a reference cycle.
 
@MisterMiyagi I agree with you.
 
@MisterMiyagi Fair point. But you can always make a local reference.
 
@PM2Ring Indeed. Just wanted to clear up the misconception that comps are magically "fast".
Though I'd say it doesn't matter either way in practice. The differences are minuscule, readability is much more important.
 
5:43 PM
I find that it's easier to just lie about the speed, because querents accept that a lot more readily than "it's aesthetically preferable for difficult reasons relating to human psychology"
 
@PM2Ring ok, but why does it "cut" a.append(a) to [...] it could just print (in the cace of a=[1,2,3]) [1,2,3,[1,2,3]]
 
"Use list comps because they're faster"
"Oh ok! Will do! Thanks :-)"

Vs

"Use list comps because they look nicer."
"I will consider your advice." [posts a question a week later using filter and lambdas]
@SAJW a is not equal to [1,2,3,[1,2,3]] in that case. It is equal to [1,2,3,[1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3,
Sorry, ran out of characters. Continuing: [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3, [1,2,3,
etc
 
@Kevin Just wave your hands and recite the Lorem Pythonic.
 
ok! so some_list.apppend(some_other_list) should be used wisely??
 
The scenarios where you'd need to do that are so rare that you probably don't need to even remember it as a rule of thumb
 
5:51 PM
@SAJW Just like assignment, appending does not create a copy.
It's actually very important that nothing in Python implicitly creates a copy.
 
can someone land me a hand please , i need all commas between #{ and }
 
Perhaps something like "a pound sign, followed by a left curly bracket, followed by zero or more of (zero or more non-commas, followed by one or more commas), followed by zero or more non-commas, followed by a right curly bracket"
I can't remember how to denote capturing groups vs noncapturing groups, so I can't give a complete functional solution. But that's the gist
 
@Kevin can you not update the example ?
 
Alas I cannot
 
6:00 PM
ok no worries the fact you answered me is a blessing
 
I may have more free time tomorrow, so drop on by if you're still stuck
 
@Kevin thank you
 
@MisterMiyagi I'm curious about your use of "faster" here. Aren't expressions in a list comprehension also local to the comprehension, given that the scope doesn't leak from list comps in Python 3? I wouldn't have batted an eyelid if you'd said "as fast as" but I know you're not one to often misspeak on these kind of things
 
@PM2Ring Handy, but now I'm considering whether there's a grammatical ambiguity when the input contains lots of commas and nothing else. I don't think it triggers catastrophic backtracking in sensible regex engines, but even so it vexes me
 
It should be ok. I don't think that pattern would invoke any backtracking...
 
6:10 PM
Yeah probably. I wonder if "does this pattern sometimes backtrack?" is a decidable problem...
 
6:36 PM
probably not... I'm reminded of meta.stackexchange.com/questions/160182/…
 
@roganjosh The deciding thing that I don't know a fancy name for is whether the expression accesses a global/builtin. For example, a - 5 for a in ... is pretty fast because everything is local but abs(a) for a in ... has to lookup abs for each element. That repeated lookup can be noticeable.
 
evening
 
In contrast, map(abs, ...) looks up abs only once.
 
In which case, I guess my question is why, if they created a list comp scope, it couldn't be bound in that scope? I fully expect a simple counter-argument that I'm not seeing :P
 
can i find help with something regarding sed ?
 
6:40 PM
You can't make a list comprehension dynamic, so I would have thought you could just make a local reference at runtime (as standard in CPython)?
 
@Joseph ● Outlook not so good.
 
@MisterMiyagi ok XD it was worth a try
 
@roganjosh As with most cases of "Why don't they", I raise thee "it might have side effects". :P
 
what is the solution for 267(note: one more than 0-255) devices on one network?
 
Bah, I've seen plenty of [print(x) for x in y]. I thought we were done with this! (But I guess I see your point even if I can't think of a toy example :P)
 
6:44 PM
@SAJW IPv6
@roganjosh Meh, don't mention it. I doubt in practice anyone would notice if they changed it.
 
@roganjosh I think they'd probably notice if it was [print(x) for x in range(sys.maxint)]... :p
 
That'll blow anyway, even if it wasn't bound in the scope of the list comp?
I guess i'm just curious about why map can get a free pass to not keep calling something in the wider scope (or maybe I mis-interpreted this) but list comps can't
 
it looks it up just once
 
Yep, but no such luck for the new list comprehensions (I say "new" - I haven't really looked at these fundamentals since before I was transitioning from 2 -> 3 as a newbie programmer in the first place). I need to re-visit the fundamentals
I do remember being baffled by names being leaked from Python 2 list comprehensions, though, without having any clue on what was happening. Ahh, memories :P
 
@roganjosh It's just how they are defined. map doesn't do the lookup itself, it gets it as a argument – which is then automatically local to map.
 
it's roughly (not probably not 100% equivalent to), something like:
f = locals()['some_method']
for something in somethings:
	f(something)
vs
 
also...cabbage, long time no talk
 
for something in somethings:
    f = locals()['some_method']
    f(something)
 
cbg :)
 
6:58 PM
so it is "address" for something to send, not "adress" which is not an English word
 
oh hey @Code-Apprentice - how're things?
 
good...I'm not doing much Python lately. Started a new job over a month ago doing Ruby on Rails and C#
 
(in German it's Adresse)
 
Mostly been working in the RoR code. Have barely set up the C# project and starting to do some tasks in it this next sprint.
 
@MisterMiyagi aha. Case closed. Simple enough, but now I see exactly why it would be down to interpretation in the case of list comps vs. map. Much appreciated, I hadn't looked at it like that
 
7:00 PM
@JonClements HBU?
 
@Code-Apprentice shouldn't complain :)
(although being British - I'll find something to complain about at some point no doubt :p)
 
You would have had a whole month of rain every day to complain about had Code not just joined on one of sunnier days
 
and if I can't find anything to complain about - I'll fall back to complaining about the weather for one reason or another :)
think I got 90% kevin'd there...
 
:P
 
@MisterMiyagi what Idon't understand, why can anything above 255 not be dsiplayed as 192.1.2.x where x is just some number between 0 and 255
in the "normal" ip
 
7:09 PM
food time and a break from the keyboard rbrb for now...
 
rbrb
 
(oh and @roganjosh - when are you up for that game of duke we've not managed to do for ages now :p)
 
@JonClements This weekend? Send me a message for your availability on Sat if that's good for you?
 
That should work - I know I'm working midnight Sat... through to about 6am to do backups, upgrade some systems and a couple of other updates, so some point Sat. afternoon should work... let's just see how it goes I guess :)
 
Night shift over the weekend. Much fun. Very wow.
 
7:15 PM
(I've tested it on the development systems and it all went quite smoothly... but reality has a way of that not happening when you want to move dev. to staging and then staging to production... ¯\_(ツ)_/¯)
bbl
 
@SAJW Because those numbers are decimal representation of two-digit hexadecimal values. There is no larger x than 0xFF.
The a.b.c.d notation is actually just a way to display a 32-bit/4-byte number in a human readable form.
So your "192.1.2.x" actually means "0xC0010200 to 0xC00102FF".
 
 
1 hour later…
8:44 PM
Whenever I tell people to use generator expressions and comprehensions over map and filter I describe the comprehension as having an mapping lambda at the beginning and an optional filtering lambda at the end. After putting it that way, I almost never have people asking me "which should I use?" and if they do, I inform them that the language developers want them to use the generator expressions and comprehensions - to which I get almost no pushback.
I'm thinking of prefixing that with "I don't care what you use, but..." to ensure I don't trigger their "whatever he says to do I'll do the opposite" gene.
 
I think that misses the point of my confusion, though. I couldn't understand why the called function couldn't just be bound in the scope of the list comp in CPython itself. But, I guess that oversteps the "explicit is better than implicit" mantra
2 hours ago, by MisterMiyagi
@roganjosh Meh, don't mention it. I doubt in practice anyone would notice if they changed it.
^ holds if we just assume that people don't abuse things
 
@roganjosh that could make for some evil debugging sessions.
Functions know whether a name is a local, closure, or global, and they do the lookup at runtime.
 
Yup, which is why MM shifted my perspective on things. I hadn't looked at it from that angle, and I'd like to think I could actually swap-out my list comps for map in my own libraries (where it's actually possible) and get exactly the same behaviour. But I do see now why it's too-big of an assumption for list comps to make
 
In Python 3 map becomes a lazy iterable instead of a function that returns lists, so it's not an equivalent swap anymore. I liked comprehensions for 2/3 compatible code when we were making the switch to 3 for that reason.
 
9:00 PM
@roganjosh We're all consenting segfaults here.
 
I like how someone said "responsible MemoryErrors" at one point
 
@MisterMiyagi As long as there's no Nasal Demons. I didn't sign up for those.
 
9:16 PM
funs = abs, np.sqrt, (2).__pow__
[abs(i) for i, fun in enumerate(funs, 3) if (abs:=fun)(i)]
if all good reasons fail, there's always asspressions to make a point
 
That's foresight. Thank god they support that.
For all your protestations, you're pretty damn deft at making asspressions :P
 
I shall bring down the establishment from the inside
 
I guess I'll just be the trope character jumping around behind your back yelling "yeah, what he said!" and "let me at 'em"
 
"let me at 'em" - are you a scrappy doo wanna be now or something? :p
 
Oh my, I don't want to steal your pup role!
 
9:30 PM
Scooby-Dooby-Don't :p
 
So to be short: if I use 257 devices on the same network I need Ipv6?
 
@SAJW when will this become Python? I've seen you ask these vague network administration questions all day.
 
@AndrasDeak Sorry, I revoke my question and don't pollute this chat anymore with this.
 
10:01 PM
@SAJW It may be a language thing, but "pollute" is pretty extreme. I don't think any ROs believe that, or we would have moved your messages to Ouroborous. I think Andras is just asking for some clarity on how you want to apply this in Python, and what difficulties you've faced
 
At the moment I want to setup a local server with a "to be executed" python file.(NOT command line)
 
Ok. But that's not stand-alone in terms of your problem. I don't want you to feel bad about the feedback you got but, at the same time, it doesn't mean I think you should give it to us in pieces
@rb3652 please see our room rules, particularly in regards to waiting 48 hours before bringing questions here
 
@roganjosh I understand, but I previously had questions that eventually never got answered.
 
Ok, that's unfortunate. But that doesn't mean you can override the rules of this chat room, I'm afraid.
 
10:16 PM
Cbg all
 
OK
@roganjosh Any other ways that I can bring attention my question so that people can see/answer it?
 
@rb3652 not that I know of. It will become eligible for a bounty at the same time as it becomes eligible to be posted here (not a coincidence).
 
I see (although I don't think I have enough reputation for bounty).
 
@roganjosh I wrote and deleted like 4 posts to finally write: I don't know what my "big" problem is.
 
Thank you anyways.
 
10:22 PM
@SAJW sounds like progress, then?
 
@SAJW Is there one part where you can't go forward?
 
The number of questions I drafted out on main and just deleted when I went to make an MCVE... or even here. I still do it. Something clicks and I find the answer.
 
Yeah, I solved the last two questions I was about to post when making sure it was clear
 
10:43 PM
I finally finished my report, I can't believe it
 
Huzzah! That'll be a weight off your shoulders?
 
A huge one indeed! Now all I need to do is prepare the presentation
...and take a loan to print the report
 
I want something better than this:
def password_checker(password,guess):
    if len(password)!=len(guess):
        return False
    for i in range(len(password)):
        if password[i]!=guess[i]:
            return False
    return True
what should I search?
I can only find solutions to check if a password meets certain requirements such as using digits, special characters ect.
 
I may be stupid but why don't you just compare the two inputs directly?
 
Passwords should be hashed. End of.
 
10:53 PM
And yeah also this ^
 
Never deal with passwords in plaintext. You can look at hashlib and compare hashes
 
And don't forget to salt your hashes.
Also, I like catchup and jalepenos on my hashbrowns.
 
I was about to suggest passlib but that may not be needed here
 
11:15 PM
@roganjosh far too complicated... everyone knows rot-13 is the way to go these days :p
guess it won't be long before "Eternal September" and we start getting questions saying: "I'm writing my own encryption algorithm that shifts characters by one but can't work out why when trying to decrypt it - I get the wrong result" :p
 
@JonClements Oof that's the type of question that got me my first points :(
 
hopefully you've discovered str.translate in the mean time?
 
I mean, I surely discovered it. I'd have to try it some day to get how to use it
 
trans = str.maketrans('abcdefghijklm', 'nopqrstuvwxyz')
text = "I mean, I surely discovered it. I'd have to try it some day to get how to use it"
text.translate(trans)
# "I zrnn, I surryy qvspovrrrq vt. I'q unvr to try vt sozr qny to trt uow to usr vt"
a bit like that
(ignoring caps and all that - but a basic example)
 
Oh that's actually pretty neat
Well thanks for the example
 
11:29 PM
actually - it's a pretty naff example - the docs explain it better but it's not hard to use
Also handy the str.maketrans has a delete chars option, so you can do something like: 'I am a sentence without any vowels or spaces'.translate(str.maketrans('', '', ' AEIOUaeiou'))
and get msntncwthtnyvwlsrspcs
 
I think the principal use case I see for now is cleaning data files, which looks more efficient than chaining multiple replace()
 
well... chaining replaces in situations where you have something like 'hello'.replace('e', 'o').replace('o', x') etc... generally doesn't end well
 
Yeah, maybe chaining was not the correct term here laurel
 
'hello'.replace('e', 'o').replace('o', 'x') and 'hello'.translate(str.maketrans('eo', 'ox')) are fairly different things :)
 
The latter looks way safer
 
11:37 PM
Well... the former gives you hxllx and the later gives you hollx
(mostly the latter is what's actually desired)
 
Always nice to learn new things like that, even if I don't see a use case for now (I'm sure I'll need it one day)
 
well... you say "I'm sure I'll need it one day" - I've never needed it for actual systems :)
anyway - possibly worth pointing out if you didn't already know there's string.ascii_lowercase - you could have used instead of alphabet = [...]... but just nit-picking now
 
Yeah I figured my question was kind of bad but I wanted to focus on % to be honest. Thanks for the tip though!
 
00:00 - 17:0017:00 - 00:00

« first day (3967 days earlier)      last day (987 days later) »