« first day (2340 days earlier)      last day (2612 days later) » 

6:00 PM
Ah okay, thanks
 
Hello. PEP8 does not say anything (?) about path depth (depth of folder/subFolders). I remember I read somewhere it should not exceed 2, could you confirm/infirm this? Thank you.
 
I don't think I've ever heard anything like that.
I think my biggest project maxes out at a depth of 4
 
That sounds weird to enforce
You shouldn't go for a Java style highly nested folder structure, just use as little nesting as possible in a way that still usefully carves up your application
 
Thank you very much for the feedback, Kevin and Robert.
 
The highest priority here, I think, is to have a logical project structure. Keeping a flat hierarchy should emerge logically from that constraint, but if you need to go deeper, do it
 
DSM
6:10 PM
I have nothing against Kevin or Robert's insights but custom says we don't star answers..
 
anu
hi
 
DSM
I guess we've made exceptions when someone comes up with something impressive enough to warrant everyone's attentions.
 
@DSM Yes, this is true.
 
anu
i have the following scenario
 
I usually like to wait for the messages to scroll up off the screen, to minimize the likelihood of the starrer noticing. Also so I can absorb some of the star power for appx ten minutes.
 
DSM
6:12 PM
I also usually unstar disciplinary instructions, even if they're justified. Feels needlessly punitive.
 
Are there any other PEPs that deal with style guidelines, or is it just #8? I dimly recall there might be another one related to less common scenarios. Or did I dream that.
Ctrl-Fing for "style" through the pep list only reveals #7 and #8, style guides for C and Python respectively. Likelihood of fever dream has increased to 80%.
@anu We are prepared to receive your scenario. Fire when ready.
 
anu
class Foo:
	bar_list = []
	class Bar:
		var = None
		def getVar(self):
			return self.var
		def setVar(self,e):
			self.var = e
	def blah(self,a,b):
		#create new Bar and do some other stuff and
		#return something useful
		newbar = Bar()
		#do something something with a and b
		c = a % b
		newbar.setVar(c)

class Baz(Foo):

	def createBars(self):
	#need to create Bar objects here
Here, how do i create a new Bar object and access the bar_list ?
 
Is there, in Silicon Valley, a bar called Foo Bar?
6
 
anu
I tried using super()
when i "print super", I see Bar listed. But, I can't access it.
 
DSM
That code dump is suspicious in many ways. Is the indentation correct?
 
wim
6:17 PM
nested classes eww
 
@RobertGrant If not, we should open one
 
@anu How about:
class Baz(Foo):

	def createBars(self):
	#need to create Bar objects here
		x = self.Bar()
		print(self.bar_list)
Incidentally if you call Foo().blah it will crash with NameError: name 'Bar' is not defined
 
> Getters and setters are evil. Evil, evil, I say! Python objects are not Java beans. Do not write getters and setters. This is what the 'property' built-in is for. And do not take that to mean that you should write getters and setters, and then wrap them in 'property'. That means that until you prove that you need anything more than a simple attribute access, don't write getters and setters.
6
 
Endorsed
 
DSM
Since it looks like we're working with old-style classes in Python 2 I'm not sure we can use property :-P ;-)
 
6:24 PM
@property works even with old style classes, IIRC
I see that @<propertyname>.setter was introduced in 2.6. What did they use before then? Did they just not have a decorator for that?
 
DSM
I'm pretty sure they don't work with old-style classes, although there's no explicit error when they're used in the class def'n. They just fail to work at runtime.
 
the best kind of errors
 
@Kevin Turns out that the descriptor protocol showed up in 2.2 ... guess you'd just write one by hand.
 
anu
@Kevin yeah, i see why, because its not self.bar
let me try the code you suggested
 
This page confirms that old-style classes don't support @property, but it runs OK on my machine. I guess things have changed between then and now?
class OldStyle:
    def __init__(self, x):
        self._x = x

    @property
    def x(self):
        return self._x

print(OldStyle(23).x)
#output: 23
Yes, I'm running it in 2.7 despite the parens around the print arg
 
6:35 PM
maybe you're in a kevinscript2.7 env
 
Could be a Berenst(e|a)in Bears type situation, with the inhabitants of this room occupying different universes with slightly different Python syntax rules
 
DSM
@Kevin: try assigning to it. Return something more interesting, like self._x * 2. Then try obj = OldStyle(23); obj.x = 10; print(obj.x).
 
@Kevin Works for me back to 2.4 (when decorators were introduced).
The Deocrator sounds like a sci-fi villain.
 
Ok, let's see...
class OldStyle:
    def __init__(self, x):
        self._x = x
    @property
    def x(self):
        return self._x * 2

obj = OldStyle(23)
obj.x = 10
print obj.x
#output: 10
Mm hmm, that's a problem right there
 
Hi, I have a question that might not proper for this channel. Please say me if it usually to associate severity of the bugs with some colour
 
6:46 PM
But not entirely unexpected since there's no setter. But what I do find surprising is:
class OldStyle:
    def __init__(self, x):
        self._x = x
    @property
    def x(self):
        return self._x * 2
    @x.setter
    def x(self, val):
        self._x = val

obj = OldStyle(23)
obj.x = 10
print obj.x
#output: 10
The setter never gets called here.
@user1929959 Console output is typically monochrome.
(i.e. black and white)
(or black and green if you like to feel like a hacker)
> class property - Return a property attribute for new-style classes (classes that derive from object).
I really should read the documentation all the way through, next time
 
coffeescript, java beans...programmers' horrible sense of humour is slowly dawning on me
 
DSM
Or just trust my Old Man Wisdom(tm).
 
@Kevin thought it was black and green for hackers :(
 
It's thanks to your OMW that I kept investigating rather than get bored fifteen seconds in and go to look at funny cat pictures
If DSM and me disagree, it's probably for an interesting reason
 
Hello all. I have a question related to program execution time across different terminals in ubuntu. I wrote a N^2 program which had to iterate through a logic for about 1,000,000 and print the result. Upon running the program across different platforms (web, ide, Ubuntu's default terminal and x-term), I got different execution time. The program ran fastest on x-term followed Ubuntu's terminal. The version of python is the same. So why did this happen ? Someone have any clue ?
 
wim
6:55 PM
old style classes don't do descriptors. property is implemented with descriptor protocol. that's all there is too it
Best solution: use Python 3 and avoid all these traps in the first place
 
@ShrijanAryal what differences are we talking about?
 
@ShrijanAryal not quite sure what you mean by different platforms there
 
@ShrijanAryal How fast did it run when you just computed the result, rather than printing it?
 
As in you called the code in different ways?
 
wim
I humbly suggest stackoverflow.com/q/41864375/674039 as a dupe-target for property-not-working-on-class-because-I-didn't-inherit-object problem
 
7:00 PM
I'm curious how obj = OldStyle(23); print obj.x can print 46 if old style classes don't support descriptors at all. Shouldn't it print, like, <__builtins__.property instance at 0xDEADBEEF> or something?
 
monkeypatched class?
or whatsitsname
it would do the same thing without the @property, right?
 
i used "time" module to calculate the execution time and ran a piece of code in the same computer. The x-term took 270.xx seconds to print all the results while running the code through Ubuntu's terminal took 321.xx seconds. Provided that both are terminal emulators, why does it take more time for one than the other in the same PC with same version of Python ?
 
Let's see. Without property:
class OldStyle:
    def __init__(self, x):
        self._x = x
    #@property
    def x(self):
        return self._x * 2

obj = OldStyle(23); print obj.x
#output: <bound method OldStyle.x of <__main__.OldStyle instance at 0x0287BDC8>>
 
@ShrijanAryal consider Zero's question (IO is slow)
@Kevin oh poo, sorry, I missed the lack of obj.x=46 :|
undefined behaviour?:P
 
@ShrijanAryal Different consoles render output at different speeds, just like Chrome and Firefox are not identically fast at rendering HTML.
 
7:05 PM
5
Q: Python descriptors with old-style classes

alexvasselI tried to google something about it. Why do non-data descriptors work with old-style classes? Docs say that they should not: "Note that descriptors are only invoked for new style objects or classes (ones that subclass object() or type()).". class Descriptor(object): def __init__(self): ...

^This seems to match my question.
 
@AndrasDeak @ZeroPiraeus makes sense. Thanks!
 
I'm interpreting the answer as "It's undefined behavior". 0.23 quatloos to @Andras.
 
\o/
rare sight in python
 
> We document what we're willing to guarantee. The exposure of descriptors in old-style classes was an incidental implementation detail.

Sorry, I'm going to close this one. Besides, it's time to start forgetting Python 2 and move along :-)
Posted in 2013. Love that optimism in the last sentence.
 
any minute now
 
wim
7:09 PM
it's like shooting a man in the leg and asking if he can still walk ... well, maybe ... ?
 
DSM
Most people who haven't upgraded yet probably won't until their favourite third-party library is no longer available for 2.
 
scipy.org won't load meh
 
DSM
^^ they have terrible uptime.
 
@wim "Interesting. And how about ... [BLAM!] ... now?"
 
I don't object to the code doing whatever it wants, but I am mildly peeved that the documentation doesn't spell it out clearer
 
7:10 PM
I found what I wanted on github, fortunately
 
"X only happens in scenario Y" is very very different from "X is only guaranteed to happen in scenario Y"
 
Hello
 
wim
scipy.org probably just tries to fetch numpy.org and then add some of their own html to season ...
 
Hey @AndrasDeak Can you help me with scrapy
@andras
 
7:12 PM
@AviNash welcome, please read our room rules: sopython.com/chatroom
 
"Losing all my money only occurs when I am mugged" So as long as I don't get mugged, I have infinite money!
 
@AviNash even if I could (I can't), pinging me twice for no reason wouldn't exactly make me want to help you
 
The first rule of scrapy is: the verb is scrape, not scrap.
 
If I ever invent an Internet-destroying virus, I'll name it "web scrapper"
 
DSM
Do they pronounce it scrape-eye or scray-pee?
 
7:13 PM
@andras That's fine thanks
 
(I read it as scrappy)
(yes, I'm a horrible person)
 
The first rule of Scrapy is that it's probably overkill for whatever you're trying to do.
 
I also read it as scrappy.
 
I bet you all pronounce Debian with a short e, too. Monsters!
 
Now let's discuss whether "read" in my last message is read as "read" or "read"
 
7:15 PM
definitely read
 
Sorry, the answer I was looking for was "read"
 
@ZeroPiraeus Debian = dee-buy-an or am I wrong
 
Acceptable, but personally I go with Dee-bee-uhn.
 
I read it in ~German
 
I prefer Dee bee ehn.
 
DSM
7:17 PM
Dehb--e-as-in-the-letter-E--uhn.
 
But I'm willing to accommodate different final syllables there
 
debbie-UNGH
 
Need that "what part of the US are you from" pronunciation test, but for the Internet instead.
Given that you don't typically hear most of the things you're reading about pronounced, I wonder what the influences are for coming up with pronunciations.
 
@DSM that's mine
 
Especially when they're not real words.
 
7:18 PM
Now let's argue about which syllable should get the emphasis. DEbian or deBIan?
 
It's a contraction of Deb and Ian
 
mine is convoluted with the fact that I read half the stuff in Hungarian :/
 
As in the names Debbie and Ian
 
such as MCVE
 
So, DEbian makes sense to me
 
7:19 PM
@AndrasDeak Muckvey
 
Unless you pronounce Debbie D'Bee
 
Only pleBEians prounounce it like DEbian
 
> 1.7 How does one pronounce Debian and what does this word mean?

The project name is pronounced Deb'-ee-en, with a short e in Deb, and emphasis on the first syllable. This word is a contraction of the names of Debra and Ian Murdock, who founded the project. (Dictionaries seem to offer some ambiguity in the pronunciation of Ian (!), but Ian prefers ee'-en.)
 
Booyah!
(Sorry, Debra not Debbie)
 
7:22 PM
hahaa, I can't believe I was close
 
That's amazing
 
DSM
@davidism: the name "Mackenzie" got its Z from the fact the Z character was easier to find in printing press fonts, so sometimes reading issue change pronunciation..
 
in your face, properly-speaking-in-English persons
 
The design or intention of the author is neither available nor desirable as a standard for judging the success of a work of literary art.
 
I think I need to amend my KevinScript documentation. "Q: How does one pronounce KevinScript? A: The project name is pronounced 'KevinScript'"
 
7:23 PM
@DSM what was it before Z?
 
"The word is a contraction of the name of Kevin Kevinson, who founded the project, and the word 'script'"
 
DSM
@AndrasDeak: yogh
 
@Kevin ... which comes from the second half of KevinScript
@DSM naaaaah, you're just pulling my leg
 
So it's not "Kevin's C, ripped" then?
 
@AndrasDeak Sorry, KS cannot yet handle recursive contractions. Support is planned for v 1.3.
 
7:25 PM
I thought it was Kevin's Crypt, the burial place of Kevin's enemies
 
DSM
@AndrasDeak: no, seriously!
 
interesting, never heard of yogh
 
Or Kevin's Gripped - the book club for thriller lovers
 
We already had this conversation
Oct 17 '16 at 15:16, by Kevin
I have a crypt but it keeps getting smaller as I trick my enemies into looking for a rare bottle of Amontillado and then brick them up in a disused chamber.
 
Now I also know that yoghurt should be written az zurt
 
7:26 PM
Yes I remember
 
... where "ripped" is as in abs, not DVDs.
 
I was trying to search for it
 
DSM
@AndrasDeak: and so you probably wouldn't, unless (1) you like the history of English language, and/or (2) your family is Scots..
 
Indeed neither apply:)
I like how languages change, but history of English is just asking for trouble
 
@ZeroPiraeus Close - I'm ripping off JS, not C ;-)
Gotta have my first-class functions
Actually, does C have functions as objects? I wouldn't know.
 
DSM
7:34 PM
Aargh my inbox is being flooded with cake invitations
 
It's a lie
 
Oh, there's a handy language chart on en.wikipedia.org/wiki/First-class_function. TL;DR: kind of.
Gotta have my first-class functions nested functions
 
DSM
I'm not sure I knew that set of distinctions.
 
Python only has five green categories and one yellow. For shame.
 
@Kevin C has pointers that you can point to functions. So, kind of.
C doesn't actually have objects though. It has structs
 
7:36 PM
KevinScript has nested anonymous functions. Jealous? }>:-)
 
feeding the offspring rbrb
 
rbrb
 
@Kevin Does it have nested anonymous asyncronous functions, though?
 
No but I'm not opposed to adding them if I ever get a spare hundred man-hours or so
 
Or, of course, hundred-man hours.
 
7:40 PM
recbg. Apparently another offspring made some PB&J
 
I only have one keyboard so I'm limited to about sixty-man hours.
 
self-sustaining offspring systems sound real useful
 
But think of the efficiency, with each worker only having to concentrate on one character
 
DSM
Leapfrog oblig
 
7:44 PM
One more oblig for good measure youtube.com/watch?v=dYBjVTMUQY0
 
I need some help guys , I need to parse the sub url in a loop and scrap the data from them
 
@AviNash please review our room rules: sopython.com/chatroom
use a paste service such as dpaste.com for large blocks of code
 
Was it Hendrix that once played a guitar using a violin?
 
@ZeroPiraeus What?
 
Back in the day a week or so after the release of Daft Punk's Get Lucky there was a fan cover of it by four music students who all played it on the same piano simultaneously. It was pretty good. I've never been able to find it again, sadly.
 
7:48 PM
No, it was Nigel Tufnel.
 
@DSM Quite impressive. I wonder how long they had to practice before they stopped elbowing one another in the face.
 
okay @davidism
 
DSM
@Kevin: are you sure it wasn't five?
 
It could have been five.
 
DSM
I'm thinking of this one.
 
7:49 PM
I should not jump in and just paste links. my bad :|
 
DSM
Wait, what, how many independent groups of people did the multipiano thing?!
 
cbg
 
\o cbg
 
Let's see, I remember it having a particular kind of choreography... Let's see if one of these match.
 
7:50 PM
@DSM I remember it being common after the first video, more followed... like it was a spreading virus
 
DSM
That makes sense. I remember everyone doing-- what was it, Call Me Maybe lipsync videos a few years ago?
 
anu
@Kevin
 
wim
lost all function keys in pycharm ... anyone seen that? how to fix?
 
Does anyone here use scrapy?
 
Guys noise cancelling headphones are the best investment I've ever made
 
anu
7:53 PM
@Kevin i tried the code you suggested.
class Foo:
	bar_list = []
	class Bar:
		var = None
		def getVar(self):
			return self.var
		def setVar(self,e):
			self.var = e
	def blah(self,a,b):
		#create new Bar and do some other stuff and
		#return something useful
		newbar = Bar()
		#do something something with a and b
		c = a % b
		newbar.setVar(c)

class Baz(Foo):
	def createBars(self):
		x = self.Bar()
		print x
		print self.bar_list

baz = Baz()
bar.createBars()
however this is the output i got
Anupams-MacBook-Pro:test anupamkumar$ python foobar.py
Traceback (most recent call last):
  File "foobar.py", line 24, in <module>
    bar.createBars()
NameError: name 'bar' is not defined
 
@corvid not if they produce a "static-buzzing" noise like mine does... :\
 
Didn't I just finish telling someone else to use a paste service for large blocks of text?
 
@MooingRawr are you using the motherboard I/O?
 
@anu try baz.createBars() instead
 
I notice a "pulse" sound, maybe it's different for other ones
 
7:54 PM
@Programmer I'm using my phone :\ lol
 
anu
ah
 
@AviNash You were just asked to review the room rules, which say:
> You may ask your question without a preamble.
For example, you do not need to say “anyone here know Django?” before asking a question about Django. Even if you do, the Django experts in the room might not step forward until hearing the actual question. They may not wish to commit themselves to help until they know how much effort it will entail.
 
Oh, weird.
 
@DSM Yeah, I think that's it. I recall the players coming in from the left with a particular energy that Rawr's video doesn't quite match.
 
@ZeroPiraeus I already kicked them, they were persistently not reading the rules.
 
7:55 PM
@corvid my dad gave me an old pair - they work great on an airplane
 
8 mins ago, by davidism
use a paste service such as http://dpaste.com for large blocks of code
 
Now the meta-mystery is: how did I fail to find a video that had a million hits? Usually I can zero in on things that have google juice that potent.
 
Reboot. Lol.
No, don't use a paste service. Just don't post large blocks of code. Post only what is relevant.
 
@WayneWerner my office is right next to a road, in a city known for terrible drivers, so maybe that's why they're so great
 
oh yeah, you'd have the same sort of benefits
I pretty much only noticed a noise reduction for white-noise-ish noise
 
7:57 PM
@Brandin What OP was posting was fairly relevant, just large... and OP should have used a paste service for it....
 
I don't know, but it probably should have just been shortened. Relevant bits only. I hate paste services with a passion. They should be banned.
 
@corvid my new office building is next to a major street and the highway, plus they advertise it to be glass modern style... Oh joy, I get to take the 'corvid experience' :D
 
On Code Review for example there are no pastebin's. And those are complete solutions in need of review. It works just fine.
 
DSM
That seems like a bit of a strained comparison, IMHO (chat vs. site Q, I mean.)
 
That's Code Review... and it's a posting board style. This is a chatroom. Different places = different requirement. No offensive but many people enjoy the pasting services of dpaste, or pastebin.
 
8:00 PM
No. I declare it should be banned.
 
Definitely the main site shouldn't have any pastebins. Questions there don't need to conserve screen real-estate. But it's nice for chat to scroll slowly enough for people to keep up.
 
second time I got Kevin'd by DSM, it's a sign... but what does it mean
 
DSM
In the immortal words from the Princess Bride: "get used to disappointment."
 
@MooingRawr soon you will understand why my brain is so fried
 
I have that movie in VHS still. Somewhere in the basement...
@corvid jokes on you, I don't have a brain :D /s
 
8:19 PM
cbg all
 
Cbg.
 
Hm. I solved one of my own problems, but the code isn't really not so much "minimal" and is more like a "recipe." =_=;
 
tries to parse 'isn't really not so much "minimal"', fails.
 
cbg
 
oh yes and cbg :-)
 
8:25 PM
isn't really so much*
that 'not' was a mistake.
A TERRIBLE, TERRIBLE MISTAKE
 
*that was not a mistake, there you go again ;)
 
That was a misinterpretation. u,u
XD
 
Has anyone read 'Think Stats'?
 
#BREAKING Scotland independence vote would be 'divisive': Downing St
Well, uh, yes.
 
lol:D
No wonder Sherlock lives on that street. That's it, right?:P
 
8:37 PM
this was interesting, apparently psycopg supports the replication protocol
 
Is it enough for an answer to have intelligible and useful pseudocode, or should it contain a complete block of functional code?
It's been so long since I've answered anything actually kind of complex.
 
I would want to see real code except in a question, personally.
Doesn't necessarily have to be an MCVA though, I don't think.
 
@Augusta well, ideally proper code is preferred, unless the asker wants others to do their work
the question is always "will future readers with a similar problem find the answer helpful?"
 
It's a question I asked myself, so kind of? :v
 
Guys my eyes hurts for looking into the screen too much ;_;
 
8:49 PM
The problem is that to be complete, the code becomes something of a recipe.
Or at least it seems like it does; I'm actually working on it now.
Probably I can boil it down.
 
But I have to keep working, what should I do :(
 
What do you mean 'recipe'. Code that works is good.
 
Then I think it's petty much up to you:) If this was a new self-answered Q&A I'd suggest to make the answer as good as possible, since a lot of people (like myself) are very critical towards self-answered Q&A-s. But if I understand correctly, this is an older question of yours that you eventually solved. In this case this point doesn't apply
 
@SebastianNielsen Stop looking at the screen. Take a sheet of paper and start writing something. Set your display to turn off and then when it does, resist the urge to jiggle the mouse to wake it up. Just keep it off and write something on paper. Let it develop into a genius idea on paper.
 
if you can boil down the Q&A to a more generic version of the problem, that's most helpful usually
 
8:51 PM
@brandin I can't ;_;
 
@SebastianNielsen Blindfold yourself. Learn to "see" the code in the hum of your LCD.
 
"but I have a LED display"
 
Haha wtf
"Feel the code, become one with the code"
"you don't have to see the code, in order to write the code"
 
@SebastianNielsen In PHP, it's an advantage.
 
9:12 PM
cbg folks
any docker homies in chat right now?
the only ones I know are fizzy pop and Kevin M
 
cbg
 
9:33 PM
working off of a branch, because that branch won't pass certain tests, so I need to work off of that branch to continue work. A mess I sense...a large mess....
seems like I love chaos
 
wim
any guys that use pycharm + pytest .... ? does ctrl-click on the fixture argument of a test method take you to the fixture definition in the relevant conftest.py properly?
that doesn't work for me (takes me to the usages inside the test, which is obviously not desired behaviour...)
 
@idjaw I guess I'd qualify...
 
@enderland Oh! :) You've been added to the list :P
 
is there a way to easily mock a "file not found" exception when trying to use the mock_open method? their docs are really sparse: docs.python.org/3/library/unittest.mock.html#mock-open
 
@enderland it's an exception right? Why not just have your __enter__ raise instead?
 
9:45 PM
hmm I guess that might work
 
wait sorry was thinking of a different thing there. example is bad
it would be something like
m_open.__enter__.side_effect = TheException
something alone those lines I believe
question for you about docker :P are there any best practices or guidelines that oppose port mapping the same port. Example: 9001:9001
instead of what you usually see like 8000:80
I can't find anything explicit about that, so I'm assuming it's OK
 
@idjaw I think most people use it to run a web server, so that's why you see that sort of example
 
(does it work? guess it does)
 
@enderland yeah. Was just something that I randomly thought of while reviewing code and was just wondering if there was any preference or reason behind not having the same port bindings.
 
I mean it sort of matters if you deploy 10x containers that all map port 80 on the machine
 
9:51 PM
oh yes. absolutely ^^
btw, @enderland even easier. Just set the side_effect directly on mock_open
 
rbrb all
 
Mr. Pieters delivers -> stackoverflow.com/a/21760898/1832539
 
@idjaw lol. dooh that's obvious now haha
 
@Augusta rbrb
 
My method works for non mock_open ways that is a context manager
i.e. context manager mocking
but mock_open will let you do it directly like that
 
wim
9:53 PM
assigning the side effect as an attribute is weird , usually just pass it as a kwarg when you create the mock
 
@wim It is ugmo...but within the context of the unittest.mock world, it makes sense based on the understanding of return_value and how to utilize your objects in that way
@wim is this legit -> pypi.python.org/pypi/pytest-mock
 
wim
@idjaw oh, nice. I was looking for something like that recently, actually
 
cool!
 
wim
mock has one of the most overloaded and confusing interfaces in the whole python world
definitely violates "one obvious way to do it" imo
 

« first day (2340 days earlier)      last day (2612 days later) »