« first day (3748 days earlier)      last day (1183 days later) » 

2:35 AM
cbg all,Is there a better way for this? Many as in with seems less readable (more than 3 in actual use case)? Would like to avoid creating new ftp connections, should I just use normal StringIO.close() without using with?
with FTP(host, user, pass_) as ftp:
    with StringIO() as io_1, StringIO() as io_2, StringIO() as io_3:
        # do ftp stuff
I did some research and stackoverflow.com/a/11892712/12502959 says one doesnt need to close a StringIO object, so should I just leave with?
 
you can generally take Martijn's answers for granted
 
that what I usually do :), but I was wondering why even have a .close() then, probably from the inherited TextIOWrapper class then
 
the docs says that "The text buffer is discarded when the close() method is called" so perhaps there's some memory considerations to make, but unless your StringIOs grow very large and live for a lot shorter time than the function they are enclosed in it probably doesn't matter
@python_user at worst to implement all the methods of a file-like object, yes
 
thanks, I will dump with for the StringIO then
 
2:53 AM
@python_user although it seems that back in 2012 StringIO wasn't usable as a context manager
 
ohh, I missed seeing that in the docs
 
ahh, if it was added new there probably would have been something like "new in version 3.x"
I was searching for that
 
yeah
I'm not going to pollute my laptop by opening python 2 documentation
 
laurel, wonder how long it will take for 2.7 to be removed from the doc page, like 1.x
or maybe 1.x wasn't as popular as 2.7 was
 
3:01 AM
Hmm, it seems tauthon is still a thing. I like how they keep backporting all these python 3 features in an attempt to not use python 3.
 
I didnt even know about that, its a good read for me later today
 
just don't waste too much of your time reading it
 
:D, seems like an ambitious projects for the wrong reasons, his effort will probably save legacy systems
 
necrophilia is frowned upon in polite circles
 
laurel, good one
 
4:05 AM
guys i have another question. I'm working with large data in csv. i would love to have a csv viewer besides excel. since excel lock the file everytime i want to modify it with my code (while debugging). anyone know such tool that don't lock my file so that i can monitor changes on my csv?
I'm using vscode. i tried the "excel viewer" extension. its have a good looking table. but i cannot use the search feature
also there's a lot of good tool for this but doesn't support custom separator in csv like this ";". which his really nerve wrecking
is*
 
4:58 AM
@Aran-Fey damn right I was! And can't you see why?! because Python demands it. The correct api would have been
my_dict = defaultdict(factoryfunction=lambda key: unicodedata.name(key).startswith(prefix))
except that... "oops", python doesn't support passing in the function in this instance.
... which is still better than C++ which does not support passing functions in any instance :D
 
 
3 hours later…
7:55 AM
I pretty much agree with everything what he said in that presentation except this API being class or being a function thing. I think I do not have enough experience to decide about that.
 
Hi
 
Greetings
 
I saw some interesting thread here:
https://stackoverflow.com/questions/63474649/call-python-function-inside-a-jenkinsfile
but no one replied
 
8:43 AM
do you know if this is possible?
 
@A.Man If you are asking me, yes, it is possible. People may not answer your question for multiple reasons. It is not mandatory to answer.
 
@AnttiHaapala No, the correct api would've been def has_unicode_prefix(prefix, key), or if you really want to implement it as a class, it sure as heck shouldn't be a subclass of dict ಠ_ಠ
 
Yes I know, it's just looked to me like simple question (wasn't asked by me) with simple answer. again, maybe I'm wrong
 
@A.Man You might answer it if it is that simple.
 
@AndrasDeak do you have any left?
 
9:02 AM
@Aran-Fey I do not want to subclass a dictionary. I want an object that sends messages when a key that does not exist is accessed and the object receiving those messages tells what is the key that should be created.
 
You're saying you want the results to be cached? Then why not slap a @lru_cache on a def has_unicode_prefix(prefix, key) function?
 
 
2 hours later…
10:47 AM
@Aran-Fey because I do not want to key tuples. I want something that maps one thing to another not two things to third.
 
In other words, you don't want to pass 2 parameters? That's what we have partial for
And if you have to do it with a class, why inherit from dict? You need something that takes a value as input and returns another value, and you choose a dict? Every single operation other than my_dict_thingy[key] is invalid, but your dict doesn't complain if anyone tries
Someone accidentally does cyrillic['a'] = 3 and your code is like "sure, cool, no problem"
 
Hi everyone, So i was just curious about the immutable objects in python and was reading this article from the internet that shares the class from MIT
http://radar.oreilly.com/2014/10/python-tuples-immutable-but-potentially-changing.html

Very interesting to me, i kinda understood the reference going from one tuple to another

However, there's one thing I'm unclear and that is how can a value change , how can they become mutable
Shed some light?
 
Tuples can't become mutable. What you can do is you can store a mutable object inside a tuple
tup = ([], [])
tup[0].append('hi')
 
@Aran-Fey so lrucache partial :D
 
Obviously you do it the other way round
 
11:02 AM
@Aran-Fey tup[0] += ['hi'] :D
@Aran-Fey obviously not.
 
depends on whether you both are on the same page with interpreting what came first in the statement "lrucache partial" also. The way i read that statement, it's like lrucache (of) (partial (of function))
 
@Aran-Fey alright so if i say I add another list or remove list from tup, it will still be called tuple? we are adding/removing ref of memory there but the main ref stays the same, right?
 
@HabibRehman if you can add a list to it it wasn't a tuple in the first place
 
@HabibRehman add or "remove list from tup" wouldn't be possible without making a new tuple. Note that Aran's examples are adding items to the lists that are inside the tuple.
Aka, the tuple still happily has and holds the same things it began with, and the same number of things. Just those things happen to be mutable lists here, and thus they are capable of mutating
 
@AnttiHaapala Look, I'm done trying to prod you for actual information. You're constantly like "No, I want an object that does X" or just "no". Not once have you explained why. If you don't want to have a productive discussion, have your discussion without me
 
11:12 AM
ohh, I read [] as list, it's not?
Reading diff between array and list seemed like you can have multiple types in list but can't in array
if its not list then what does it represent here []

@ParitoshSingh @AndrasDeak
 
@ParitoshSingh That's also how I read it, and that's obviously not how any sane person would implement it. Why do that when you can just do partial of (lrucache of function) instead?
 
@HabibRehman [] is a list. you can have multiple types in list.
@Aran-Fey I personally don't understand the context or recognize the difference between those two approaches well enough to form an opinion here, oops!
 
@HabibRehman there are built-in arrays in python but almost nobody uses them. What do you mean by array?
 
If you apply the cache to the function itself, then every single pair of key, prefix inputs is cached. But if you cache the output of each partial separately, then you can end up with multiple caches that cache the same inputs
And just from a design perspective, it makes more sense to apply the cache to the function. If speed is a concern, then just slap a cache on top of your function. That way you have a finished product, and users who call your function don't have to worry about it themselves
 
never mind, when you said "if you can add a list to it, it wasn't a tuple in the first place" so to mind a tuple had multiple lists as shown in Aran-Fey's example tup = ([],[])
so i doubt myself if its not list then what it is, because he showed multiple list in a tuple exmaple already
just searched tuple vs lists, found that tuples can't change so that means if it was created with any object, it'll stay with those lists forever
 
11:37 AM
@Aran-Fey hm. Each partial is essentially a different prefix though yeah? So effectively (key1, prefix42) and (key1, prefix100) would be two different values in the cache, or (key1) for partial of 42 and key1 for partial of 100 would be one value each for two different caches, yes?
So, if your code is pre-defining the partials it's equivalent. If the end user is expected to make the partials then perhaps it's more headache for them. However, all this abstract talk hurts my brain frankly speaking, apologies if i dont make sense
 
Right, in the best case scenario it's equivalent. But if you create multiple partials with the same prefix and feed them the same key as input, then you will end up caching the same prefix+key pair twice, in two different caches
 
Ah yep. yeah, if one makes multiple partials with same prefix that's going to be a waste
 
Wrapping the lru_cache around the partial would have the advantage that the caches do not interfere with each other. So doing lots of things with one key would then still leave the cache for the other key intact.
pro-tip: add a lru-cache to your lru-cache-partial factory!
 
Yeah, if using too much memory is a concern and setting the lru_cache's maxsize isn't a viable solution, then it might make sense to cache each partial individually
But I'm not going to speculate about such potential requirements after I've asked Antti "why?" a billion times and never gotten a single answer
 
11:57 AM
I missed the point when caching entered the picture, so no idea there.
 
The code Antti originally posted had a cache built in, equivalent to caching each partial individually. But he never said that kind of cache was a requirement
 
Just to catch up on the discussion - is the current argument right now whether parametrizing a function through partial or a surrounding class is better?
 
That's what it boils down to, yeah
Or at least that's one of the reasons why I don't like Antti's original code
 
I have a hard time imagining a scenario where I'd prefer partial. If it's a state, objects are easier to handle and understand.
 
FWIW, my deciding factor is usually "do I need a docstring for this?".
 
12:09 PM
Cbg All.
I am in need of assistance from the room's individuals.
 
@Arne So given the objective "I need to verify whether the unicode name of key starts with prefix", what would you want the interface to be like, ideally? PrefixChecker(prefix)[key]? has_prefix(prefix, key)? Something else?
 
@AnttiHaapala ... what an atrocity. You gotta be kidding me. This whole discussion reminds me of this joke: xkcd.com/1270 and ofc xkcd.com/1312
 
@Aran-Fey without having any more context, probably has_prefix(prefix, key)
 
I know a knowledgeable person who is looking for an Information Technology job- can I request the room to share their LinkedIn accounts and accounts of others (persons, businesses, etc) who are actively employing- which will assist with the applying process.
If you would like a copy of the CV I can send it through.
 
@Destroyer-byte Not sure, but it feels a bit like the wrong place here for this
 
12:15 PM
@Arne Agreed. I don't have more context either, except that apparently Antti doesn't want to pass in 2 arguments, for unknown reasons. That's where partial came into the picture
 
@Arne Happy to hear, that common sense is still around
 
huh
 
@Hakaishin, I understand. 👍
Is there a room for Job discussions?
 
@Destroyer-byte Dont know, but my gut feeling tells me people on se wont be very fond of it. I think people go to linkedin or xing for job discussions
 
there are SE job post listings fwiw Destroyer stackoverflow.com/jobs
 
12:20 PM
@Hakaishin, that makes sense- thanks a lot for guiding me.
@python_user, yeah I was having a look at those, and thought of speaking to the room's learned individuals.
I shall continue having a look at SE job postings
 
I have had less luck with SE, possibly because they all require people with experience (country skill and all filters set as per my need)
 
Indeed, I was reading the job openings, and they require people with a lot of experience.
Thanks a lot Pears, I shall continue my search now. 👍
 
12:46 PM
@Destroyer-byte not on SO
 
@Aran-Fey that wasn't the thing though.
it was a "how do I deduce if something is Cyrillic."
and then I said "here's the interface: letter in cyrillic"
 
But that's how you chose to implement it. You take a key and a prefix as input and spit out a boolean. And I think there are better ways to do that than with a class that inherits from dict
 
@Hakaishin "funny". I am programming in Python.
of course there is. Nothing should ever inherit from anything
the problem is what I want to do is "easiest" to do in Python in this way, because, duh.
 
Umm, would it really have been more difficult to not inherit from dict and instead write a __getitem__ method that's decorated with lru_cache? Not that that would've been a great design, but it certainly would've been better...
 
you really shouldn't be decorating a method with lru_cache.
 
12:57 PM
Would've been better than inheriting from dict IMO. But yeah, it's bad design either way. So your justification for writing bad code is just "it's easier", then?
 
"In 1997 I took a summer course about Java at MIT. The professor, Lynn Andrea Stein — an award-winning computer science educator — made the point that the usual “variables as boxes” metaphor actually hinders the understanding of reference variables in OO languages."
^that is because in C, C++ etc variables are objects. (except C++ references that are not objects :D)
@Aran-Fey of course it is. What I want is a defaultdict that does the sensible thing that takes a function that maps key=>value. But it doesn't. :(
 
You want a dict? Why?
 
I want a set actually :P
 
Oh, variables as boxes was how i had learnt about variables at first. Suffice to say, i had to completely break that analogy down before python would make sense to me
 
there is no "defaultset" :D
 
1:00 PM
You want a set? Why?
 
because I wanted a set of "all" cyrillic letters.
 
Why, though? Why not a function that maps letters to a boolean indicating whether they're cyrillic or not?
 
(but it was implemented as lazy set because unicodedata is slow)
it is an objects that accepts a message that maps letters to a boolean indicating whether they're cyrillic or not.
but now the nice part is that I've got an object named "cyrillic_letters" and I can write c in cyrillic_letters
 
Why don't we like defaultdict for this purpose? Is it using too much memory or something?
 
instead of some braindamaged java nounitis: "cyrillic_letter_matcher.my_letter_is_cyrillic(c)"
 
1:03 PM
Ohai Kevin!
 
Hmm
 
@AndrasDeak 👍
 
Oh, in doesn't do what I expect here I guess
@ParitoshSingh Yo
 
@AnttiHaapala Okay, but that still doesn't mean you want a dict. What you want is a dict's ability to do indexing and membership testing. But you almost certainly do not want a dict's ability to be iterated over, or to delete keys, or to assign keys
 
cbg
 
1:14 PM
@ParitoshSingh I feel like it's a good first step when learning to program. Ofc it's only an metaphor and not the whole truth, but so is everything
 
If the problem is "it sucks that I can't have custom __contains__ logic without writing a class", I don't know if I'd call that a Python-specific problem.
 
or a problem at all
 
I'm on the fence about that because sometimes I do want to burn down the entire edifice of modern OOP and rebuild a glorious new future upon its ashes
So I can relate
But burning down edifices is hard, and saying "ok, even though single method classes usually suck, you're allowed to write one if you need it for operator overloading" is easy, so I'm willing to compromise my principles there
 
Ah refactoring code is so nice, no better feeling than having a huge mess of 100 lines of lists with indices transformed into a bunch of readable CLASSES which are 10 lines :)
also I realized in the process if I have variable names which go like foo_bar_xyz. They became objects foo.bar.xyz which is much nicer
 
I do wish I could index into my JSON-like data structures with attribute names though
Python devs, please allow {"bar": {"xyz": 23}}.bar.xyz to evaluate to 23
 
1:43 PM
including {"foo bar": 2}.foo bar == 2, I guess? :P
 
Yeah, let's rip the bandaid off and allow whitespace in identifiers already
 
that would be neat
 
@Aran-Fey partially true yes.
@Kevin naah, I am not saying everything should be writable so... but the smalltalkish thing is
you send an object only those messages that you need to send.
 
2:05 PM
@Kevin I think I saw someone's git repo in this room having a module for this, let me see if I can find this
 
Let us not think too hard about whether {1.2: 3}.1.2 should have a meaningful result
 
github.com/holdenweb/hu, I guess this is what I was thinking of
 
👍
 
2:27 PM
I sometimes wish that I could do x = object(); x.__contains__ = lambda: whatever
Not because I have a practical use case, but because it appeals to my intuition about how I want OOP to work
Too bad that dunder methods are usually looked up on the class rather than the instance (iirc)
 
make a factory that produces such an object via a decorator?
 
well, that's what eigenclasses are there for. use them.
I occasionally long for a type where each special method just calls an attribute if available. Then I revise my requirements.
 
If eigenclass is a synonym for metaclass, I'm not sure how it helps me. Not that I have ever really understood metaclasses to begin with.
 
2:52 PM
@Kevin It has to work like that because of metaclasses. If dundermethods could be implemented on the object or on the class, then it would be near-impossible to write a meaningful metaclass
 
@Kevin I still blame the confusion over this point on poor wording. It's not that "special methods are special because they cannot live on the instance". No method lives on the instance, by definition. Instances can have attributes and these may be callable, but they are not methods.
 
Just imagine:
class Person:
    def __init__(self, name):
        self.name = name

    def __str__(self):
        return self.name

print(Person)  # AttributeError: class 'Person' has no attribute 'name'
 
The actual cheating happens one level lower, in that some metaclass special methods are ignored sometimes; e.g. skipping mcs.__getattr__ to get cls.__add__ for calling __add__ on self.
@Aran-Fey And yet we have attributes on instances, and properties on classes... ;)
 
Admittedly, python could allow dundermethods on non-class objects. But that's just a mess
@MisterMiyagi Only sometimes?
 
@AndrasDeak Have mercy on the organisations with large legacy codebases they plan to replace. If they want to backport, let them. It doesn't hurt Python 3.
 
3:04 PM
@Aran-Fey "Sometimes" as in "I don't feel like precisely saying when" :P
 
"always" sounds good to me :P
 
@holdenweb how long does that typically take? It seems that 3.4 was released nigh 7 years ago. Of course it's easy for me to say, as I'm my only user and I have very little python code to maintain.
 
@AnttiHaapala Are you sure you don't just want to implement __missing__?
 
He did
 
That method can take whatever action it wants on missing keys.
Right, I'm out again. This whole discussion has taken on a combative tone that I dislike. As you were.
 
3:13 PM
@holdenweb hmm? I hope you don't mean me; I'm not even involved in the discussion, and I didn't mean to come across like that
 
3:27 PM
Nah, he means me. Possibly Antti as well, but definitely me
 
Well you both are so that's fair :D Just wanted to be sure.
 
hey guys,
Just wanna let you know tha tI'm probably gonna be offline for several days. I came down with roof-tiles disease (shingles)
 
@inspectorG4dget hope you get well soon
 
3:44 PM
@AndrasDeak thanks
 
@inspectorG4dget Take care with that. It took me out for two weeks, and healing took years. I hope you are on prescription meds already.
It's not at all pleasant if you get a bad dose - fortunately mine was relatively mild.
I hope you too have a relatively mild case. Get well soon!
 
I'm already on the meds. But this thing is pretty painful. Mine are on my scalp and eyelid. So I'm really looking forward to being done with this
 
@AndrasDeak Not pointing fingers at anyone in particular. Just an impression I got.
 
4:29 PM
@inspectorG4dget feel better soon gadget :)
 
@inspectorG4dget look after yourself and stay safe!
 
@AndrasDeak I feel partly responsible for stirring things up last night, and was kinda hoping things might have settled down. We were, after all, discussing implementation choices, not some fundamentalist religious principle. I hope. It's hardly worth expending emotional energy on.
@inspectorG4dget Also that may be a sign your work is taking too much of a toll. Self-care should be your first priority until you're well again.
@inspectorG4dget That's a good thing. Mine was in roughly the same places. There may be some rather painful swelling, I'm sorry to say. Look after yourself.
 
5:40 PM
Hi guys,

Can anyone tell me how to pip uninstall when the package was installed using pip install package -t .?

(pip uninstall package -t . doesn't seem to work)
 
5:52 PM
No clue, but I'd try pip uninstall package and pip uninstall /path/to/installation/directory/package
 
6:03 PM
normally pip puts more than one folder in the dir you've chosen to install in so I'm not sure what I would put as that last slash :/
 
@JamesMcIntyre you uninstall packages by distribution name?
@JamesMcIntyre pip freeze then pick from list...
ah no
pip -t didn't write metadata? :D
"you can't"
 
6:44 PM
@JamesMcIntyre I'm guessing you use -t to avoid dropping files into your Python configuration, which would require root privileges? If so, virtualenvs are probably what you need.
 
Hi Antti, sorry I'm not understanding. I've tried doing "pip uninstall mailmerge" but it says it can't find it. I was installed by, within a python command line, doing cd and then dragging the project folder in and hitting enter and then doing "pip install mailmerge -t ."

I'm not understanding how you're suggesting I can uninstall?
I've considered using vertual enviroments in the past but they don't work very well in my use case. the most sussucss I've had so far is now that I've discovered installing with -t to have a local version of a package for a specific project which is working great. I'm actually normally installing it into a temp folder and then I normally only need one or a few files/folders from the install in the temp folder.

I'm just trying to learn how it all works and for anything I do need to install the full package into a project folder; if there's an easy way to uninstall again
 
@JamesMcIntyre -t is meant for the case when you're building a one-off package directory for for example lambda layers, docker, etc...
you cannot uninstall... or ... well you can... but ...
17
Q: pip: Uninstalling package from specific directory

Denis ItskovichI installed package into specific local directory using pip install -t <dir>. Now I want to uninstall it, but I cannot find a way to uninstall from that specific directory. For uninstall there is no valid option -t | --target, which exists for install command.

 
7:01 PM
You've answered my question. Thank you :)

I would probably say that I do use -t for one off package directories. I my work, I build lots of one off little scripts which neither need their own enviroments (I would have a zillion enviroments) and I've found that installing everything to a primary enviroment casues conflics so this one of -t case is perfect.
 
so if you feel you need to "uninstall" then
throw out the bathwater and the baby and all
 
@AnttiHaapala haha yes, I think that's the plan (y)
Have a good night guys!
 
but seriously virtualenv venv should work too
 
7:21 PM
@AnttiHaapala why dont you just delete the directory you installed the package to manually ?
 
that's Antti's "bathwater and baby" solution
 
7:40 PM
Do sockets work with buildozer?
 
7:52 PM
Hi guys does anyone here know how to use git stash? I was having a problem with this command git restore -s stash@{0} -- <filename>
 
@erotavlas well where did you get that command from?
 
And what is your git version?
 
my problem is with the stash@{0} part, when I do git stash show stash@{0} it doesn't show anything
oh no, its git version 2.22 :/
i always thought I had latest
upgraded to 2.3 but still doesn't work
simply git stash show shows me a list of changes
 
8:20 PM
the linked answer says git show stash, not git stash show stash
 
8:31 PM
:D
 
@AndrasDeak git stash show :| jemma.dev/blog/git-stash
 
i guess they are both correct? a bit confusing though
in any case I successfully git stash apply 'ed my changes :) I kind of wanted to learn how to select particular changes and apply only those (not all) but I'll have to do more investigation on that
 
one is a git show command, the other a git stash command
 
git stash show is the recommended command to use according to this stackoverflow.com/a/21743193/1462656
 
9:13 PM
@holdenweb thanks everyone
 

« first day (3748 days earlier)      last day (1183 days later) »