« first day (1869 days earlier)      last day (3065 days later) » 

1:48 AM
Noooo, my computer crashed while I was away for two days and I lost my progress towards the fanatic badge. :( I was 79 days in.
 
 
5 hours later…
6:22 AM
How do I compute the divergence of a vector array (e.g. the arrays returned by np.gradient) in PythoN?
I tried the most-voted answer at stackoverflow.com/questions/11435809/… but it doesn't work
 
 
2 hours later…
8:24 AM
Why in the world does this throw an error?
import numpy as np

def f(i, j):
return [i, j]

a = np.fromfunction(np.vectorize(f), [8, 8], dtype=object)
print(a)
"ValueError: setting an array element with a sequence."
I specified dtype=object
 
9:04 AM
cbg
 
cabbage
 
cabbage
I know where you are
 
No you don't. :) The danasoft location info isn't very accurate. It just does a location lookup on your ISP, so it can be ok if you're in a big city, or you use a local ISP. But my ISP is based in a city that's 500km away from my actual location.
 
:P
and I thought Finland was rural :d
 
WHOIS (pronounced as the phrase who is) is a query and response protocol that is widely used for querying databases that store the registered users or assignees of an Internet resource, such as a domain name, an IP address block, or an autonomous system, but is also used for a wider range of other information. The protocol stores and delivers database content in a human-readable format. The WHOIS protocol is documented in RFC 3912. == HistoryEdit == When the Internet was emerging out of the ARPANET, there was only one organization that handled all domain registrations, which was DARPA itself. The...
 
9:19 AM
at my former workplace in Oulu, our VPN came out to the internet in Wilsonville, Oregon. It was the most idiotic setup ever. Once I needed to download 500 MB, so I took my bicycle, rode home 2 km away, used my 100 M ethernet at my student apartment, stored on the usb stick, returned to the office and saved 30 minutes
 
Finland's pretty small compared to Australia. Internet here is ok in areas with reasonably high population density, but it's pretty poor elsewhere. Most of our population live in the major cities, or in the eastern coastal strip. But it's just not economical to provide good internet to the small percentage of the population outside those zones.
I actually live near a coastal city that has good fibre optic internet, but I'm just a bit too far away from the city centre, so I have to make do with ADSL2+. But at least that's better than having to pay for a satellite internet connection.
@AnttiHaapala LOL. Pedal-powered internet. That reminds me of the old saying from the days when USB didn't exist and 14400 bps modems were considered fast:
"Never underestimate the bandwidth of a station-wagon loaded with tapes hurtling down the highway".
 
We still only have 100Mbps setup here, not a student apartment though. This is an old apartment building with fibre conn. but the apartments themselves are served with VDSL via phone cabling which sucks.
 
9:46 AM
The upgrading of Australia's internet infrastructure is in turmoil. Originally, we were supposed to get fibre to the user (at least, in the regions of high enough population density), but since a change of federal government a few years ago (from left-wing to right-wing) that's been scaled back so that fibre will go to the street, but individual premises will be connected by copper to the fibre node in the street.
See National Broadband Network if you want to read the sad details.
A quick question about Python's exec. How much overhead is involved in exec'ing code? Does it run in the current context of the script, or does a new interpreter instance get invoked? Or doesn't that question make sense? :)
 
current context ofc
so you pay for the parsing and compiling if it is source code
just precompile and the overhead is almost nonexistent
compile the code wrapped in a function and get the function out of exec for even better performance
"Most of Australia's copper network is affected by water due to extensive use of faulty gel for insulation in the past."
 
@AnttiHaapala Cool. Still, I guess it's a good idea to avoid exec unless you really need it.
 
@PM2Ring btw the fibre in Finland is in no way gov-supported, and that is why it sucks that much.
 
During times of heavy rain here ADSL speeds can plummet... or you may get lots of dropouts, if you can connect at all.
 
in Finland the politics are peculiar in a way because we now have a stable 4 party system with 2 of them receiving substantial amount of their backing from the rural areas,
and that is why you never can think about 93 % of people
you need to do everything for the 7 %
 
10:02 AM
You'd think that governments would understand the economic value of having good internet infrastructure. FWIW, it's over 30 years ago that Al Gore started promoting the whole idea of the Information Superhighway and explaining its economic value. But I guess politicians tend to focus on short-term goals...
Australia goes through cycles of 2 party and 3 party. Although the 3rd party is never as popular as the big 2 it can still hold the balance of power. For many decades the main right-wing party has been a coalition of a city-based party and a rural party.
We also tend to get a few strong independent politicians (either dissidents from one of the major parties, or wealthy industrialists that create their own power base), and when the balance of power between the major parties is close (as is currently the case) those independents can have a huge influence.
 
10:59 AM
@PM2Ring the current government does not understand value of anything.
they're cutting billions from education and science and such.
instead we get special projects for digitalizing the farm houses.
 
Are you talking about Finland or Australia? Or both? :)
 
Finland
when they formed the current coalition the prime-minister-to-be said that there'd be a strategic program for the cabinet, with little detail.
well the program said for example that "during the 4-year term the government will allocate funds for the study of use of cow manure for energy production"
 
11:14 AM
Ah. Not exactly rocket science... OTOH, cow manure is a major methane producer, so I guess there are benefits in using it as an energy source (since methane is much more active as a greenhouse gas than carbon dioxide is).
 
11:35 AM
Hey, Asked this question some time ago and it isnt getting any traction. Anybody in here know how to help me in this question?
0
Q: Kivy updating label by function

GenGenTrying to work out how the bind with setter works in kivy. I find the documentation in the API really bad. They have a lot of expectation that there is tons of assumed knowledge around their kivy engine. ANYWAY, rant over. Here is my code. class ScreenOne(Screen): story = StringPr...

 
12:10 PM
@GenGen Sorry, I don't know Kivy (although I'm thinking of learning about it...). But I can see a problem or two with your code.
In your ScreenTwo class there's some confusion between L1 and self.L1. Plain L1 is just a local variable of the method, but self.L1 is an instance attribute of the class; they aren't the same thing. If you don't need to refer to that Label outside the __init__ method you can just use plain L1 otherwise you need to use self.L1.
Also, why is story a class attribute of the ScreenOne class? I suspect that it should be an instance attribute self.story that you initialise in the __init__ method.
 
12:49 PM
@PM2Ring : Hi, thanks for looking into my code. The self.L1 was me trying to figure out why the label wasnt updating. I have placed L1 attribute just about everywhere around my code to figure out what is going on in kivy. The story class is an attribute of ScreenOne class because of my code ( self.screenOne = ScreenOne() ) Where I intend on dragging the string property story across into the screenTwo init method to be used.
I will paste updating code in pastbin pastebin.com/1jFy0YqR
Keep in mind that Heading[i] and id_ref are lists that data is being obtianed from.
Idea is to get the button text to represent the label text when the screen changes.
If I can figure out 1 label assigned to the button then I can carry the current_story reference over to bigger better things to populate my screen two
 
Ok. But I still reckon that story should be an instance attribute. When you do self.story = heading[current_story] in the ScreenOne.changer method it doesn't modify your story class attribute: it creates a new instance attribute that masks the class attribute.
 
let me try it. 1 sec
Just getting attribute errors brining it into the init_ method and then trying to reference to it
I wish the documentation around this was written better and had better examples to look through
@PM2Ring I mainly used this example to try and build my code stackoverflow.com/questions/23817559/…
 
cel
1:21 PM
Any opinions regarding my meta proposal? meta.stackoverflow.com/questions/311325/…
 
I don't know ipython but that proposal sounds reasonable.
 
cel
mh
I'll wait a little bit and see how it goes. It's WE, so I shouldn't be too surprised that the feedback is not overwhelming
 
1:38 PM
@GenGen Rightio. As I said earlier, I don't know Kivy. But I see that code's using a class attribute for the Property. If you want to modify a class attribute you need to refer to it properly. So in ScreenOne.changer you need: ScreenOne.story = heading[current_story]
 
testing. 1 sec
 
@GenGen Or maybe not. :) Since that will bind ScreenOne.story to heading[current_story] and destroy the old binding. Do you have some way to update Property objects?
 
Well, if I just through in a print statement when I press the button to tell me what story is it is updating properly. I can see that story is correct. As soon as I try to update the label though it just gets stuck on its text.
 
My guess is that there will be some method that will allow you to mutate the value of a Property, and you'll need to use that method.
 
cbg
Hi @PM2Ring :-)
 
1:46 PM
Hi, Avinash.
 
Just wish kivy had something simple like L1.text = story
 
@GenGen Ok. I just had a quick look at the docs. Updating it by assignment may work, since that should call the Property objects setter method, but if it doesn't, try using the .set() method to change the value of your Property. And if that doesn't work, I should shut up, or I'll just confuse you further. :)
 
@GenGen is there any android app build through kivy have posted on playstore?
 
Hi @AnttiHaapala
 
1:55 PM
@PM2Ring can you link me to which docs you looked at so that I am on the same page as you? @AvinashRaj not to my knowledge. Kivy gives you examples scripts to look through but without a guide you might as well be walking into narnia without a map
 
:-)
 
@GenGen Um, the .set() in my previous post is the link.
BTW, have you ever done GUI / event-driven programming before (in any language), or is Kivy the first GUI framework you've tried to use? Event-driven programming can be a bit hard to get your head around at first, and trying to learn & remember all the bits & pieces you need to build a GUI on top of that can make the whole process somewhat overwhelming. But try not to get discouraged. Work on simple things at first and expand on them very slowly, and don't try to do too much too soon.
 
Yeah, sorry. I only saw that after I posted.
I have worked in tkinter before. Much easier thank kivy by truckloads
non python related gui I have pretty much worked in engines.
such as unreal and unity
different languages too. Only reason I am attracted to kivy is its cross platform capabilities. I recon if I get a good handle on this it will make life a bit more fun
 
Oh, ok. Tkinter is definitely a good introduction to GUI / event-driven stuff. It's big enough to do decent GUIs, but not so big that you get lost or overwhelmed. :)
 
yeah, exactly. its fun for the fun thigns.
def changer(self,*args):
global current_story
current_story_id = args[0]
current_story = id_ref.index(current_story_id)
#self.story = heading[current_story]
story = heading[current_story]
self.manager.current = 'screen2'
print story
If I just set a print on the story
I get the printed value changing in the console.
Thats all good but updaing the label. is being a pane
*pain
 
2:06 PM
@PM2Ring I heared that tkinter is for developing smaller gui apps but for larger applications, we must go with PyQt.
 
@GenGen Yeah, but that's just creating a new local var called story.
 
Im running around in circles in my head that I feel like I might just electrocute myself with a toaster wire attached into my noes. haha. cries
 
@AvinashRaj I've only been using Tkinter for a couple of months, and while it has its quirks it's mostly been fun to use. I don't know Qt, but I've had a fair bit of experience with GTK+, which I've used on & off for about a decade.
@GenGen Give me a minute & I'll post a short illustration of what I was saying before re: class attributes vs instance attributes.
 
Ok. thanks.
 
class Test(object):
    me = 'hello'

    def __str__(self):
       return 'Test: self.me=%s, Test.me=%s' % (self.me, Test.me)

    def change(self, s):
        self.me = s

a = Test()
print a
a.change('wow')
print a
 
2:09 PM
In the mean time I need to get a breath of fresh air before I go mad. be back in 10min
oh, that was fast
 
output
Test: self.me=hello, Test.me=hello
Test: self.me=wow, Test.me=hello
If we alter the change method to:
    def change(self, s):
        Test.me = s
then we get
Test: self.me=hello, Test.me=hello
Test: self.me=wow, Test.me=wow
 
ok, 1 sec. Im just trying to compare my code with that example to wrap myself into a direction
 
gotta python-3.x bronze badge..
 
Nice
 
I'm willing to join sopython team..
It asks me for role..
 
2:20 PM
@AvinashRaj Regex maharajah :)
 
@PM2Ring ok, not getting attribute error but not updating the label either. I found something else strange. If I set a print "ping" in my ScreenTwo def init module its not printing the ping each time the screenchanges That tells me its not running the code inside the init each time.
So maybe. I should be updating the label somewhere else. Is what I am saying.
Update the label in the changer function instead of in the init module
or let it run a function within the class screenTwo that updates.
hmmm...
 
@PM2Ring lol..
 
@GenGen __init__ is only run when you create a new instance of a class.
 
so placing any text to update the label inside that is pretty much a waste?
 
2:31 PM
@GenGen Well, yeah. But the code you've posted doesn't do that, as far as I can tell. It just initialises variables & sets up bindings, and you put the actual change stuff into your changer methods, which makes sense. But I repeat, I don't know Kivy, so I'm kinda flying blind.
 
I appreciate the blind flying. Trust me, it helps in a big way. :)
ugh. cant get it to work. If you guys know anybody that knows kivy or has solved a similiar problem please please point them in my questions direction. Im off to bed. 2:30am for me. Gnight
 
Night, @GenGen.
 
3:12 PM
Hello Everyone
@PM2Ring @AvinashRaj @GenGen , could you please comment on this?
 
Hi, Sana. Sorry, I know nothing about multi-threading and multi-processing in python.
Please don't link your fresh SO questions here. Give them at least one day, as explained in the Room Rules.
 
OK Sorry!!
I will b waiting for a day
 
In the mean time, take a look at the Linked and Related questions on your quewstions page. You should find some useful advice and examples there.
Anyway, it's getting late here. Goodnight / rhubarb, all.
 
I just got a steam controller. Bretty great actually
 
4:21 PM
Really? I wasn't a fan of it with Rocket League.
 
4:34 PM
It takes a really long time to get used to, but when you are
 
5:20 PM
1
Q: Openshift Django Scaling

Serjik IsagholianI'm creating Django app on OpenShift on Python 3.3 with no scaling, it works fine. So when I browse the app gives me a django url error and with /admin brings me the admin login page. But as I create it with scaling I get this error 503 Service Unavailable No server is available to hand...

 
5:34 PM
@SerjikIsagholian hello to you too?
 
cbg all
 
5:51 PM
Not exactly sure if this is the place to ask, but do we need this tag? stackoverflow.com/review/suggested-edits/10369858
 
6:04 PM
@Ffisegydd Hi there
 
print('Hello World')
how is everyone?
Is anyone here?
 
6:22 PM
Yes.
@SerjikIsagholian do you think it might be more polite to actually say something before you decide to dump your question into the room? Some sort of greeting, or "Please take a look at this"?
 
woa... you python guys seem really welcoming. php room really dislikes such presentations :p
and thanks for taking care of the tag, I did not know what to do @Ffisegydd
 
6:44 PM
@Ffisegydd Don't you think trying to help and answer the questions is better than down vote
By the way, I really stuck on this in the project
 
@SerjikIsagholian 1) No, they're different actions that aren't mutually exclusive, 2) (I'm presuming) that you're assuming that I downvoted you?
 
Anybody please help me with OpenShift?
 
@SerjikIsagholian you've linked your question once, please don't spam the room with it.
Why are you inviting me to a room?
 
@Ffisegydd So what's your way to getting answers without spam the room?
 
Wait for someone to answer it? The fact is that it's not this room's place to get you an answer.
 
6:51 PM
Hey guys, how's this for a beginner buy list?
http://i.imgur.com/RS6G6nL.png
 
You had linked your question previously (in fact it was still on my screen!) and then you were asking for help again.
Please be considerate of the other members of this room and don't spam looking for help.
 
@Ffisegydd So will you try to help me with trying to do the same I've done on OpenShift?
 
No.
Because I know nothing about it.
 
Oh tnx, so to whom knows
 
@SerjikIsagholian please don't ask again, at least not for an appreciable amount of time (a good few hours) anyone who is here who could help would have already read this.
 
6:58 PM
maybe someone could help me though? Should I buy those books or do you know something better ?
 
@JustasSame this is the Python room and only one book on there is Python.
 
oh wow
those are all related to python
 
So really we can only comment on one book.
 
Evening all
 
Were they? Let me look again.
No they're not. One is.
And if you say "Bash is to do with Python cos I could use it with Python" then I'll say "A book on PC monitors is to do with Python cos..."
 
7:03 PM
If you want to be friggin good at something you need to know more than just that language. But sorry for asking, if I knew there were so many buthurt people over here I would have most certainly not.
 
@JustasSame there's really no need to get offensive. For starters, how do you think we can comment on topics that aren't to do with Python? We may have some knowledge of, for e.g., Javascript, but you'd be better served asking elsewhere for something like that.
 
@Ffisegydd Sorry, but your comments seemed to be a little harsh for just a question.
 
Then (and you may well find this harsh too) you should grow a thicker skin.
You can't expect us to comment on tech that we may not have knowledge of, especially when it comes to someone else spending actual money on our recommendations.
 
Okay, ignore the past conversation (if we can call it that). Which python books would you suggest to buy for a noob?
 
yeah, we probably wouldn't be helpful anyway... people here are mostly python, so you'd only be asking about 1 book on that list, and only the people who have bought that one individual book
 
7:09 PM
Sorry for barging in, but saying people are butthurt is some order of magnitudes harsher than being told by topic experts that things you think are related actually aren't @JustasSame
 
Plus you didn't exactly ask an easy question, you just said "What do you think of this shopping list?" Well? What do you need? Are you a 10 year programmer looking to try Python? Or are you a new user? Here we go :P For a new user I'd actually suggest tutorials over books, but if you really want some books then Programming Python by Mark Lutz is quite thorough, though quite heavy.
It goes into a lot of detail, so if you're just looking to fool around with Python then really go for (free) online tutorials.
But if you're new and want a good reference book, then it's good.
 
Thank you, gonna check it out
 
I would say practical programming is best, try some project euler and see where you get stuck
 
I'd also suggest the Python Pocket Reference (similar to the Bash one). It's great for once you've learned the language and need to quickly look something up on the go.
 
Will probably buy this latter, when I will know a bit of python :) Thanks for suggestions, adding Euler to bookmarks
@Ffisegydd Maybe you know what the difference is between Programming Python or Learning Python?
 
7:21 PM
@JustasSame Programming is a good and thorough reference book, Learning is a book for learning it initially.
If I had to suggest, I'd actually suggest doing online tutorials and buying Programming, rather than buying Learning (unless you buy both :P)
 
I would buy them both if I had the money :D Sadly as I live in Lithuania I have to pay for expensive shipping too.
 
@Ffisegydd The one with the knight on the cover? I have that one too. It's great for a few little "need to know" things
 
7:34 PM
I can haz code review? gist.github.com/awalGarg/… tried to keep it self explanatory but not sure if I did a great job :/
 
Bother. I've been playing around with pandas and my rep, and figured out that at my current pace, assuming it's linear, I won't hit 100K until August or September of 2019. 3.75 years until I get my swag. Yam it!
 
@Matt I believe in you.
 
Which brings me to a question: can you do a regression/curve fit in pandas or statsmodels or whatever where you don't assume the kind of equation? I did a linear fit b/c it looked linear, but maybe it's polynomial or something...
thanks Fizzy :)
 
@MattDMo generally in fitting you have to set the function.
You could always do something like spline fitting of your existing data, but then you can't extrapolate to the future.
 
Right...
 
7:39 PM
@AwalGarg First thing that screams out is using the backslash as a line continuation is generally not considered good style
 
And even when you do spline fitting, you have to choose the type (cubic, etc).
 
@JonClements oh, wait, pycharm did that when I clicked auto-format for my if conditions, so I thought it is ... good? my bad
 
Is there a way to specify the dtype for numpy.gradient?
I'm using an array of subarrays and it's throwing a ValueError: setting an array element with a sequence.
 
@Matt Generally if you don't have enough data to be able to distinguish between "linear or polynomial" then, in the absence of any other information, apply Occam's Razor and assume the simplest.
 
@AwalGarg you don't even need them for the function parameters, and I don't think you need them for the yield from statement...
The R^2 was 0.9986, so I doubt I'll get much better. However, that covers the entire "linear" section of my rep, going back 2 years or so. It would likely still be linear if I took a more recent slice, but maybe not. I'll play around with it...
 
7:45 PM
@MattDMo hmm indeed, I should have experimented more, thanks!
 
@Matt indeed, if you knew of some time point where it changed you could model it as two separate slices.
 
ahh, so at places where , (or some other form of?) delimiter is used, I don't need the \ for line continuation, right?
 
e.g. if you knew you became much less active for the last N months, you fit from beginning to N, then from N to now.
You could make your future prediction based on whichever fit you think you'll be more like in the future.
 
I was thinking of doing a couple of sliding windows just for that.
One of the issues I'm running into is that the ordinary least squares function in statsmodels doesn't really handle datetimes very well, so I've had to add a time_delta column to my df, which makes graphing the line easier, but interpreting dates a lot harder.
@AwalGarg in the file you linked to, correct. For example, in your last yield from statement, the parameters on the following lines are all indented identically, so Python knows to continue reading them until the indent level changes.
In the function definition, the arguments are surrounded by parentheses, and are indented, so Python is doubly sure that they all belong together.
 
@MattDMo hmm, I am reading about that and I find it weird that PEP8 says that with statements need backslashes for line continuation. Why is that? expressions passed to the with statement are delimited by , too :/
 
8:00 PM
The only time I can think of that you'd really need a line continuation marker is if a string literal has to be placed on more than one line, but you don't want to use a triple-quoted string with newlines in it.
@AwalGarg which section is that in?
 
I didn't know that about with statements. However, see this paragraph just above:
> The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
 
yep, just read :)
 
So perhaps your yield from statement could have its arguments wrapped in parens
and indented, of course, just to make everything readable.
 
@MattDMo yep, indeed it can, I verified it with the python 3.5 interpreter
 
8:25 PM
Just watching University Challenge. Answer was "corvid" :D
Went to the Zoo today and got a picture of a Python, will post in a bit.
 
text = (
	"line one"
	"line two"
)
@MattDMo even then you can use ^^^
And it's gone back to 8 spaces per tab.... frigging editor
 
 
2 hours later…
10:25 PM
@Jon that's true, I had forgotten about implicit string joining...
 
 
1 hour later…
11:50 PM
quick question. I have a bunch of xpath strings mapping to different elements in a website. I want to make it easy to maintain this mapping, so that when I change the xpath mapping to one element, it works everywhere. I was thinking of just making a module with them and then import them as needed, but I feel like this might be the wrong approach for python. What would be a more pythonic way of doing this?
 
sounds fine to me
 
Would you suggest an alternative that's as maintainable ?
 
what's not maintainable about what you're doing?
 

« first day (1869 days earlier)      last day (3065 days later) »