« first day (2691 days earlier)      last day (2258 days later) » 
01:00 - 20:0020:00 - 00:00

1:00 AM
@Marius I've used MPTT on one project
 
 
2 hours later…
4:20 AM
hmm is there any way to communicate with a running python script?
IE I have some application working like:
while True:
    DoCalculation()
    if communication_test_here():
        break;
 
woo just unlocked chat
 
I'll be running said script as a (child) process from another application: is there hence something like above that can be done?
I know I could run the child process as a server but that seems kind of overly complicated for something where I only wish to have a "graceful exit" command.
 
 
2 hours later…
6:10 AM
@paul23 Use input() and write to the process's stdin?
 
 
2 hours later…
8:18 AM
cbg
 
8:40 AM
cbg
 
 
1 hour later…
9:55 AM
Morning! I need some design advice. I'm having some parameters passed to my script & I'm building a class that reads these parameters, processes them and set them as properties of the object. The thing is my scripts use different parameters, sometimes the same are reused over scripts.
So I have a basic Message() class, but also one that takes the often reused parameters ConfigMessage() (derived from Message), Then I have another class AnalysisMessage, which again derives from ConfigMessage and TrainingMessage, which also derives from ConfigMessage.
Now, I end up with the problem of having to add new derivatives for small differences.
Is there any pattern that can help me with this? Or another approach?
 
Probably a bit late for this now, but it helped me write better python code.
In that vein, you can keep things contained to a single message type and add properties dynamically. Or do you absolutely need to know which properties to expect whenever a message object is passed?
 
@Arne, I was thinking about that. However in the constructor I cannot specify then all the properties, which seems like bad design
Well I could, but then it would be a huge list of None's and some are totally irrelevant to the actual parameters of the script.
 
10:12 AM
recbg
@Arne also: start writing classes :P
or ...
actually classes are bad:
start writing objects and interfaces
but yeah, I ack with that above^, stop writing classes
why are you deriving
why are you not using keyword-only arguments? :P
what's wrong with def create_analysis_message(foo, bar, baz):
 
say the most general parameters are: accountName, accountKey => Message class. Then it also has some configuration file path sometimes: configPath => ConfigMessage class. Sometimes it has a start & enddate => AnalysisMessage class which inherits from ConfigMessage.
 
Then write properties for the fields that are obligatory and dump the rest into a dict =)
properties are only fancy key: value pairs after all
 
But using a class helps in the sense that you know what the message looks like. The attributes it has. While using a dict is very dynamic and unpredicatable.
 
whether that is good or bad depends on how your program works. Do you actually check on each message object what type it has, or do they get more or less the same treatment anyway?
structure is only good if it simplifies your problem
 
I do not, but the fact that I know it's a "AnalysisMessage", assures me that it has a start/enddate.
 
10:24 AM
You could also just check if 'start_date' in msg.misc_data. If that line covers all the same cases as a class definition, you should probably use it instead.
*disclaimer: I am just a stranger who dislikes custom classes
 
Sounds to me like you should define some mixins. Then inherit from Message and all the mixins you need: class ConfigMessage(ConfigMixin, Message): pass, class AnalysisMessage(DateRangeMixin, Message): pass, class ConfigAnalysisMessage(ConfigMixin, DateRangeMixin, Message): pass, etc
 
^ better than a strict hierarchy
 
That's just using multiple inheritance, no?
 
Yep.
Well, it's multiple inheritance, but there's a difference between mixins and normal classes
 
I've honeslty never encountered mixins before. One of the first google hits: Are python mixins an anti-pattern :-D
 
10:34 AM
Not that it really matters. Mixins might have a little less code, but it's not like they can do something that normal classes can't
So yes, multiple inheritance sounds exactly like what you want. Each class handles its own attributes and then passes the remaining input to the next class. Everything's modular and can be combined to form new kinds of Messages.
 
I saw mixins used quite a lot in scikit-learn, which is a really popular python package. Not that that should alleviate all concerns, but at least some smart people thought mixins are good enough for their codebase
 
I really hope that "Are python mixins an anti-pattern" article ended with a big fat red underlined NO
 
11:04 AM
most of this looks like an antipattern to begin with.
what is a message...
what is a config message
I am still not sure that the classes are an answer at all :D
 
11:27 AM
Cabbage
 
Hi .. I am new to python, i have a python project (project1)... now in another project (Project2) i created a python script and wants to use project1 folder's API.. I am using IntelIJ. how can i provide project1 reference to project2
please help me
 
11
Q: How to import functions from other projects in Python?

Big DoggI have some code in a project which I'd like to reuse in another project. What do I need to do (in both folders) so that I can do this? The directory structure is something like: Foo Project1 file1.py file2.py Bar Project2 fileX.py fileY.py I want to use functions from file1.py and f...

 
Thanks Ashish
 
11:43 AM
I have a string which contains non ascii character and I want to replace some string but it gives unicode error
and If I am trying to do the same with the help of decode and ignore='error' in regex it removes the non-ascii character
any suggestion to do the same ?
I want to keep those special characters
 
python2 or python3?
 
pytthon2
 
consider using python3
 
sorry I cant
whole project is in python2
:(
 
might be worth a question on the main site and a detailed description of the problem, I'm afraid I can't help you without knowing more
 
11:49 AM
ok will provide you in few min \
 
No need to paste the link here, everyone who can answer questions watches the python queue anyways =)
(also, it's against our room's guidelines)
 
Actually, questions that originate here are a bit different. I believe the spirit of the rule is that it prevents parallel discussion of a problem here in chat and on the main site. So if a question starts here, I think it would make sense to link it here (preferably without a one-box :P) when moving the discussion to the main site.
 
@AmanJaiswal What is that non-ascii character in (encoding)? You need to handle the appropriate encoding and then try the decode. There would be a lot of questions regarding the same out there
 
@AndrasDeak ah, good to know
 
I'm unsure so we could try finding signs in the transcript...
this is mostly my personal take on the rule
 
12:25 PM
IMO this one was is okay to stay on chat. OP is most likely unaware of what all he might get into and it's not a good experience (unicode-decode horrors) unless they have at least some knowledge / previous exp. in that area.
Which is why, Python 3 is a God Guido bless!
 
12:55 PM
In addition to it being OK to post a link to a question in here if the question started its life in here, I'm less interested in enforcing the solicitation guidelines for even the clear-cut violations. IIRC from the last room meeting, that was the direction we wanted to move in.
If quietly ignoring a solicitation produces 0 nuisance messages, and chiding a solicitor produces 10 nuisance messages (as they argue their case ad nauseam) then it's not even a contest what we should do
 
@AaronHall "sorry, I forget the name of the other guy. RIGHT, Joel Spolsky!". Hehe
 
If quietly ignoring the message causes them to re-post the link every thirty minutes, then that's a good time for special action.
 
Huh, do you really read pypi as "py pee eye"? I read it as "py pee". But I can kind of see why it's wrong...
 
Since I entered sem-retirement at 50k, I don't even believe the original justification of "everyone interested in answering the questions is monitoring the question queue" any more, because I'm my own counterexample: I'm interested but not monitoring.
 
@Kevin I think I saw that phrase float around and just reposted it
I'll try to be more friendly next time
 
1:02 PM
I hope you don't feel like I'm ragging on you. I just like to stand on soap boxes.
 
All good, if it serves creating a better room I am in favor of it
 
1:38 PM
OK, so Guido says both "EOL party in 2 years" and "there will be a python 4.0 but it will be a very smooth ride" in that video.
 
smooth ride -> python4 code can use python3 libs? He didn't commit, but what else could be called smooth.
 
an earlier discussion revealed an older unofficial note that 4.0 shouldn't be more traumatizing than 3.7 from 3.6
but we'll see, I guess
 
cbg
anyone know how to do join query in mongo db
as i am not finding any
and i am using loop to get the count which takes 10 minutes to process
 
@SohaibAsif welcome :) often a link to a pastbin of your Python code helps
 
@Arne The last semi-official pronouncement about 4.0 was that "it will be held to the same backwards compatibility obligations as a Python 3.X to 3.X+1 update"
Oops Andras beat me to it. Reading comprehension.
 
1:51 PM
Yeah, I like that article
 
i have a simple example
 
Can someone help me animate a contour plot? You can see the full question here: stackoverflow.com/questions/49010057/…
 
Your question was closed as a dupe 13 minutes ago and last edited 14 minutes ago.
 
I just want to know if you can update a contourf plot in a loop or nested loop without wrapping the loop(s) in a function
 
Neat.
 
2:04 PM
all of the duplicate responses rely on a generating function, but im unable to use one
if its not possible thats fine and i'll figure something else out
 
I don't really understand the question but it's possible.
 
can someone guide me about this type of case
 
@SohaibAsif Posting the link once is enough.
"Can I do something like the following?" I suggest you try it and see if it works. (If you're thinking "I already tried it and I got an error", why didn't you mention that in your question?)
 
morning cbg
 
2:16 PM
cbg
mildly annoyed that I don't have a sql server profiler at my work place yet I need to open a .trc file :( sigh these things should happen on Monday not Tuesday
BTW Kevin, did Evening Kevin listen to morning Kevin ?
 
2:36 PM
@MooingRawr Yeah. Possibly because stage 2 was 1% coding, 99% browsing Youtube for specific kinds of videos.
He/we/I also tried to do a little work on stage 3, but could not progress because github refused to accept his/our/my commits. Something about an SSL something-or-other error.
I tried it from git gui and from the command line and from the "add new files..." page on Github and none of them worked, so ¯\_(ツ)_/¯
I'll try committing from my work computer, which should narrow down whether the problem is with the repository, or my computer's credentials, or my internet connection, or what
 
I see best of luck. The good ol work by watching videos all day :D
 
@Kevin is it your own repo?
 
Yeah.
In particular, it is github.com/kms70847/kms70847.github.io, named as such because that's what pages.github.com told me to name it
As a test, I was able to successfully make a small commit to another one of my projects. Although I might have seen some kind of warning message as I did so? But it definitely went through.
So I think I can rule out "Github does not recognize your home computer as owning the kms70847 account", because I was able to add a new project, and commit to an existing project.
And anyway even if my computer's git credentials were donked up, committing straight from the web interface should work as long as I'm logged in
 
Update your Git
 
2:51 PM
Ok, cool. The "most common error users see" doesn't match my memory of what I saw, but nonetheless I am happy to blame Microsoft for my problems.
 
It’s GitHub that changed things...
 
TIL there's no E in the American grading system. Whaaaat?
 
Let me blame Microsoft anyway :-D
 
A B C D [WHY IS THERE NO E] F
 
I'll make use of this when I get a free minute
 
2:53 PM
they should've made F the new E and call it egregious or something
 
@AndrasDeak University? Same in Germany, 1-4 is pass, 5/E is fail, 6/F doesn't exist (it's a thing in highschool though, and basically "did close to nothing, not just bad enough to fail"
 
my issue is the missing letter...
it's as if you had 1-4 pass, 5 doesn't exist, 6 fail
 
@AndrasDeak Google says it's because A B C and D are all passing grades. F is not a passing grade, so it does not follow the naming standards of the passing grade enum. The fact that "failing" starts with the letter F and therefore appears to be just one letter away from meeting the passing grade enum naming standards, is a coincidence
 
well I don't like it >:(
A B C D | Useless
 
If instead of "failing" we called it "sucking" then the grades would be A B C D and S, and nobody would say "what happened to E, F, G ... Q, R?"
Hmm I think I need remedial spelling lessons
 
2:56 PM
The bad thing about German grades is that there are actually 0.7, 1.0, 1.3, 1.7, 2.0, 2.3, 2.7, 3.0, 3.3, 3.7, 4.0, 4.3, 5
 
the what now? :D
 
That’s 1+, 1, 1-, 2+, 2, 2-, 3+, 3, 3-, 4+, 4, 4-, 5
 
So no letter grades?
 
Letters are for the weak
 
@poke ah...
 
2:58 PM
I mean A is really a 4.0. And so on.
So really its the same system when you think of GPA.
 
We use numbers that map to other numbers, and also have an alternative number scheme as well! (Numbers 15 down to 0)
 
@Kevin Wouldn't [S]ucking bring you back to a D?
 
Hoho.
 
@poke I see. Wouldnt that compare thought to A, A-, B+,B,B-.... ?
 
maybe
 
3:00 PM
len([1+..5]) != 15 D=
 
And that fulfills our PG-13 blue humor quota for the day, please wait until tomorrow before using another D joke
 
woah, that was more unreadable than I thought
 
12 if you say there is a +, normal, and - for B,C and D. Then A, A-, and F.
 
@Arne The 15-number one includes 5+, 5, 5- and 6 actually
 
So were missing 3 @poke
 
3:01 PM
of course
 
It’s used in the Abitur like that
 
got to map the different severities of failure appropriately
 
Might be closer to out weighted grades.
 
Speaking of grades. The weirdest system is when you study law in Germany.
They have a point system from 0 to 18 (yes, 18!)
 
can we just all agree that grading systems are generally a mess?
 
3:03 PM
And actually, getting to 10–12 realistically makes you one of the very best.. (only around 15% achieve that)
 
cabbage all
Anyone use an RSS reader?
 
yup
 
Oh look, someone summarized all that nicely: en.wikipedia.org/wiki/Academic_grading_in_Germany#Overview
 
@AndrasDeak What do you use? I'm looking for something that works nicely on both windows an android, a cross-platform ability that seems rather underserved.
 
ha.
the one I use has "linux" in the name so I'm not your guy
 
3:08 PM
@AndrasDeak At this point I'm so annoyed with distracting arrays of tiles I'd consider something that ran in a VM :/
 
Well I've been using liferea (< linux feed reader) for many years. I liked google's reader a lot more, but for my basic need of keeping track of comics and a few blogs it's fine
 
@poke I think 4- being a pass/no pass was always up to discussion though. In that sense, yes, it's a huge mess. The percentages they listed should also have the [citation needed] thing in big read flashing letters.
still the closest thing to a consens out there probably
 
Well, that 15% is pretty accurate according to the experience of multiple friends :P
 
@AndrasDeak Google's reader died in 2013.
 
@poke I think he meant the wiki page
 
3:13 PM
I am doing regex in Python but am failing to combine my rules here. I would like to validate my phone number with three requirements. 1. It must start with +26373 [for which i use /^\+26373/] 2. It must be of length 13 including the +, no less and 3. Must be numbers only for which I saw[ 0-9]. eg +263736072177. The last 7 digits can vary. How I do that
 
@toonarmycaptain yes
 
@AndrasDeak I took that percentage from (a different) wiki page
 
ah!
 
Oh
 
oooh?
 
3:14 PM
But now that you say it, there is a [citation needed] in that percentage column on that link
no idea what that is supposed to mean though…
 
that it's not backed up by written facts (or pseudo-facts)
 
Oh, probably what percentage of “correct answers” makes up that grade
@AndrasDeak That’s not what I was referring to ;P
 
yeah you were :P
 
I was referring to the column
 
@JWizard r"^+26373\d{7}"?
 
3:16 PM
[citation needed] -> [wild estimate, since people don't bother to map their grading schemes to normal distributions]
 
@Arne [… and many subjects are so random and arbitrarily graded that you cannot compare them anyway…]
 
Nor sure what you mean by "numbers only for which I saw". If you mean "only numbers that appeared in the "26373" prefix", I don't understand why you can match 072177, since 0 and 1 aren't in the prefix
 
(essays and poem analyses… *cough*)
 
@poke Yes! Thanks for reminding me of this. When subjective grading leads to not-so-normal distributions.
I think that's amazing
 
DSM
Morning cabbage for all.
 
3:18 PM
@Kevin Let me try it. I meant to say the whole string must be numbers only.
 
cbg for DSM
 
Afternoon cbg
 
cbg for all :)
 
@Kevin I have tested the regex ` r"^+26373\d{7}"`regexpal.com/93378. It is not able to match +263736072177
 
need to escape the plus?
 
3:24 PM
@AndrasDeak Yeah I tried r"^\+26373\d{7} with no luck again
 
>>> re.match(r"^\+26373\d{7}$", "+263736072177")
<_sre.SRE_Match object; span=(0, 13), match='+263736072177'>
 
How do you enter that… with the r" part?
 
Yeah, sorry, forgot the backslash. Also it needs a dollar sign or match will happily accept numbers larger than 13 chars
 
Let me try the latest then
 
As the others are hinting, remember not to include the "r" and quote marks if you're testing on any kind of online regex tester
 
3:27 PM
@Kevin Woow, thanks. Thats where I was getting it wrong...let me test using my IDE
 
Online testers may differ from Python's engine in other subtle ways, so I always let the IDE have the last word on whether a pattern actually works or not
 
Most online testers use JavaScript, so you are already pretty limited in what you can do
 
Which is not to say that online testers can't be valuable debugging tools. Just remember who it is that breads your butter at the end of the day. (Python does.)
 
@Kevin It worked, thanks. You saved my day!
 
Cool.
 
3:37 PM
I’m really jealous of people who’s biggest struggle of the day is a regex… :S
 
regex101 or something similar lets you choose engines and python is included
 
DSM
There's a trick for modifying a first-order Euler integrator to get it to be stable (you basically modify the timestep to decrease with the increasing scale of the change). I remember it as folklore, but saw a paper confirming the details a few years back, and now can't find it. I could rederive it, I think, but I'm lazy. :-/
 
Hmm, can I expect hash(someString) to give the same value on successive executions of my program?
 
DSM
No.
 
Because I am expecting it, and my program is giving me nondeterministic values
 
DSM
3:45 PM
python --help and look for HASHSEED.
 
so the technical answer is "you can but you shouldn't" ;)
 
Ok, what's the laziest way to implement a checksum
 
hashlib?
 
@Kevin len()
 
hehe :D
 
DSM
3:46 PM
Well played, sir.
 
file size is honestly my lazy approach to checksums when I can’t be bothered.
 
len would actually work 95% of the time for my purposes, and the 5% of cases where it fails would not be particularly catastrophic
 
Hi guys, I had a question regarding something I don't know how to test for myself.
 
I'm just trying to detect when the contents of a file have changed, and make backups for post-mortem analysis. Not doing this right only means that my progress reports will be less self-congratulatory
 
DSM
I heard once of an astronomer who wanted to batch download some webcomics which had a habit of only partially downloading. He wound up using length + a hash of the start and the end + some random values chosen using a fixed-seed generator.
 
3:48 PM
wait im stupid
 
The rubber duck strikes again
 
you're welcome ;)
 
Well, CRC32 is simple and fast
 
@DSM I don't think I've seen it, but that looks like the example in this wiki page. It might be helpful because it seems to be a first-order Euler (I hope)
 
3:52 PM
I'm going with hashlib.sha224(file.read().encode()).hexdigest() for the record
 
File length to CRC32 to SHA224… that escalated quickly.
 
DSM
@AndrasDeak: I'm not thinking of Richardson, unfort. I might have to ask an old colleague of mine who also remembers the paper. I might also have it printed out somewhere.. I should really upload every paper which I'm at all interested in to google drive or something. :-/
 
unfortunately I have surprisingly little experience with integration techniques :(
 
@Kevin filename ==
 
I need more than a 0% success rate ;-)
Ok, to be fair, just comparing file names will be successful in the same way "def changed(): return False` is successful: it correctly identifies when no changes have been made.
Which is the majority of the time, maybe 80%
It would be more correct to say "I need a false negative rate lower than 100%"
 
4:13 PM
The last question I answered was Jan 31. ;_;
 
You did it, you answered every unique question. You're done.
 
I was expecting more fireworks when that happened. Or maybe a cake.
 
[Kevin pulls a lever on the wall and confetti falls from the ceiling]
 
Hey, hello. Got a quick question cos my Googling skills failed me. Do any of you, my dear firends, happen to know if there's a pssibility to display a lockscreen widget in Windows 10 using Python?
 
Reminds me of the bit from Sandman where the bad guy has just apparently destroyed the protagonist, and he's standing alone in the empty white void of the dream realm and he says "when I became king, I thought people would clap" and the camera zooms out to show the complete emptiness of his surroundings. "I thought somebody would say something"
@KrzysiekSetlak You can interact with a good amount of the Windows API through the pywin third party module, and failing that, via the built-in ctypes module. If the Windows API provides and interface for creating lockscreen widgets, then you have a good chance of being able to make one in Python.
 
You are on an island surrounded by an orange sea. On the horizon you see a colossal ninja figure, listing and half-melted into the waves. Jon Skeet is here, on his back looking at the stars. "My stomach hurts", he says.
8
 
It's story time! sits
 
That's the ending :-P
 
Thx, @Kevin, this starting point was exactly what I needed, cheers!
 
cbg
 
4:26 PM
Did...did he eat the ninja? Is the ninja Martijn?
 
You missed the beginning and middle, which had lots of cool robots and an octahedron armed with sweet death rays.
 
Also a lot of teenage self doubt and discovery.
 
I usually fast-forward through those parts.
 
VoHiYo
 
4:51 PM
I wanted to print to stderr for the first time in my life and I found a question by baby wim, aww
(He'd been on the site for 2 weeks)
 
print >> sys.stderr, 'spam' wat
Python 2 was a wild time
 
Pytest's internals are entirely undocumented, and I'm trying to debug a weird overlapping conftest bug.
For some reason, the conftest in a separate search directory is overriding the conftest for the directory of the current test.
 
@davidism can't be worse than sqlalchemy internals ;)
 
Pytest's plugin/hook/conftest system is a giant plate of spaghetti.
This is in relation to testing Flask's examples by the way. I added a conftest to the new tutorial and it's interfering with the conftest for Flask's tests.
 
@ThiefMaster I've definitely found something in Alembic I'd like to fix
"Fix", or "make work how I'd want it to"
 
5:13 PM
Hmm, I can commit files to Github from my work computer just fine. So if Github really mucked something up for Windows computers, it's strange that it would affect my home computer and not my work computer.
 
you're getting dangerously close to "it's my fault" territory
 
Also I would find it curious if a change to Git for Windows would have any impact at all on the "upload a file" button on the github web page
Or the "create a new file" button, rather.
I'll probably put this riddle aside for now and just upload commits via home computer -> flash drive -> work computer -> github, and just try to deal with the 8 hour latency
 
@ThiefMaster aha, it was actually because of Pytest adding all the test dirs to the path, and __name__='conftest' was causing Flask's root_path to always point at the last test dir added.
So we need to stop using Flask(__name__) in test fixtures.
 
5:42 PM
would it make sense to add a special case for conftest?
(probably not, or it would at least be ugly)
 
Nah, I think it's pretty unique to Flask itself, where we have tests and our examples in the same repo have tests.
 
6:06 PM
Cabbage all.
 
@Simon cbg!
 
6:27 PM
@ZackTarr Any luck with the projects. None my end.
@Code-Apprentice Thick-ish snow this morning. Melted this afternoon.
 
@Simon My car was buried in snow this morning. And the bottom layer was mostly ice. Took 15 minutes to clean and scrape it before going to work.
 
6:47 PM
I think you might have it a bit worse than me :p
 
yah, the snow has not yet melted off
 
@Simon Sadly havent had a chance to look into any. Keep me posted on your findings though!
 
OK I will.
 
I know, how about you guys create a project together ?
 
¯\_(ツ)_/¯ It's an option.
 
6:59 PM
Very true!
 
wim
The problem with wrong comments is you can't downvote them. The only way to rebuke them is to post another comment, generating more comment noise
It's not a function name, it's an object property. — Barmar 15 mins ago
 
heh, it's gained an upvote since you linked it here
 
wim
7:15 PM
yes, lol.
 
hopefully nobody is dumb enough here to upvote something without trying to understand it in context
 
7:28 PM
@ZackTarr I'd like a nice RSS reader/aggregation that works on both Windows and Android, preferably also available in-browser, but that's not a deal-breaker as use offline is a greater priority. I have, looks in pocket, USD$22, AUD$0.20, and an unused hair tie. Go!
 
Well are we defining "property" as "a general OOP concept where values can be accessed with dot notation, as in a.b" or "a Python concept, dependent on descriptors, where attribute access can cause arbitrary code to execute" Because df.name is a property for one of these but not the other
Granted you can ask two programmers what "property" means in the general OOP sense and get three different answers
 
the question and answer give adequate context to the problem
 
DSM
"adequate context" <- album title or song title? Decisions, decisions.
 
"But Kevin," you hypothetically say, "the wikipedia article for properties specifically says that they are class members with getter and setter method calls, so don't you think that your first definition is overly broad?". I think you have a smart mouth, hypothetical reader.
 
7:35 PM
@DSM Band name -> self titled
 
user4229770
Good evening guys, I have a recursion function in python, and if i want to call it in my recursion function again, i get "undefined variable" ?
 
DSM
Code or it didn't happen.
 
user4229770
The issue is that If i write that recursive function outside a class it is fine, but if it inside i get that error
 
DSM
"matter of taste and training" is an excellent title.
 
7:38 PM
Are you calling the method the way that methods inside classes need to be called? This isn't specific to recursive functions.
 
user4229770
I see... I am very new to python
 
DSM
@Kevin: are you figuring it's just a missing self.?
 
he's working on his badge
 
user4229770
Oh yeah, i did self. it works :O
 
that gold badge is near
 
7:41 PM
#wrong
class A:
    def fibonacci(x):
        if x <= 1:
            return 1
        return fibonacci(x-1) + fibonacci(x-2)
print(A.fibonacci(5))

#right
class B:
    def fibonacci(self, x):
        if x <= 1:
            return 1
        return self.fibonacci(x-1) + self.fibonacci(x-2)
print(B().fibonacci(5))

#also right
class C:
    @staticmethod
    def fibonacci(x):
        if x <= 1:
            return 1
        return C.fibonacci(x-1) + C.fibonacci(x-2)
print(C.fibonacci(5))
 
user4229770
I got it now :) Much appreciated :)
 
I did [fibo]nacci that coming
 
DSM
:-|
 
should've gone with "'nacci"
 
Why doesn't python have arrow operator assignments like R?
Like x <- 5 or 5 -> x?
 
DSM
7:48 PM
So you want multiple ways to bind a value? Why?
 
Arrow operators haven't climbed out of the 100 point hole, same as every other coulda-been feature.
 
@cᴏʟᴅsᴘᴇᴇᴅ noooooooooooooooooooooooooooooooooo
that is all
 
Often times I type something really long in the interpreter and forgot to assign it to a variable
 
home key
 
Now I have to go all the way back to the start of a line to assign
What's the mac equivalent of that?
 
7:51 PM
don't try ruining our language for your keyboard disability
 
DSM
At the console? Control-A, no?
 
Thanks, I had no clue
 
XY problem solved :P
 
Hot tip: every expression in the REPL gets secretly assigned to the variable "_" so you can retrieve the value right afterwards if you forgot to assign
>>> 2+2*2
6
>>> x = _
>>> print(x)
6
 
7:53 PM
Yes, I keep having to do variable = _ on the next line. Later when I pull up %history on IPython to copy code, I have to look for those instances and fix it :)
Of course, if the line results in a huge dump to stdout, that's annoying
 
These corn chips I got for lunch label themselves as "never ever fried" and it makes me worried, moreso than if they had just said "not fried"
It's like that one XKCD (or SMBC?) that says spoiler for PG-13 joke
 
Perhaps they're saying the chips have never been fried in any of their past lives. That is, in case chips get reincarnated after death.
 
I just assumed that by default you can cook a corn chip without ever accidentally frying one, but this extra insistence makes me imagine a manufacturing line absolutely fraught with friers on all sides
 
01:00 - 20:0020:00 - 00:00

« first day (2691 days earlier)      last day (2258 days later) »