« first day (2103 days earlier)      last day (3070 days later) » 

18:00
also, they had very generous return policy...
but now, tough luck with your not-so-quite-fitting clothes
rather odd tho, they'd been opening new malls
then were talking about some restructuring, then no news until 1 pm "chapter 7 title 11" (of course there's no such chapter)
@Kevin I want to save each output to a variable, so that I can call anyone of them as required for my further operations — ratamboli 7 mins ago
Oh boy, where do I even begin.
I should probably tell OP he wants a list...? Honestly I don't know if I want to involve myself any further
list is the only thing that would make sense to me but his code makes it look like he should know how to use a list
k. i can't extract the text from the xpath "//*[@id="right"]/table[1]/tbody/tr[2]/td[1]" from this link. I'm using lxml.html. It returns an empty list []. It should return everything!
How do I extract the text?
18:07
so either he copied the code and doesn't know what it is doing (which would be a pain) or he is trying to ask a different question which would need further clarification
it's the first table "hotels and restaurants inspection files". I'm able to extract that header text, at least....
hello all :D
what's up
@JossieCalderon idk, try with shorter expressions first
18:20
I don't know anything about lxml but my thoughts are with you at this time
That's a gross xpath
I could say I've seen worse, but that's a lie
♥ xpath
And I've seen way more complex than that :) Although never done it with stuff that doesn't have an xsd to guarantee its format
i can't control how gross the xpath looks!
@RobertGrant Yeah, I wouldn't touch non-xsd xml with an lxml-sized pole
DSM
DSM
Would a regular expression help?, he asked, innocently.
18:23
@JossieCalderon how about beautifulsoup and css selector
snrk
@DSM don't be mean
#right > table:nth-child(1) > ...
@AnttiHaapala beautifulsoup worked!!!!!!!!!
18:43
@JossieCalderon hope it was bs4 not beautifulsoup 3
:D
I've barely written a line of Python today, other than for SO answers.
It's been PHP and Java instead today.
:D:D
@MartijnPieters you should start preaching in instead.
I could never get into PhP
18:49
if only this guy had known about associative arrays.
otoh, if only they'd known that you can nest functions in JavaScript....
19:13
But i did flag it
about 3 weeks ago.
Just tossing this out here: Facebook London is looking for Data Scientists..
Ping me if you want to know more.
@Ffisegydd, DSM: ^ (long shots, I know)
I was just gonna say Fizzbot should apply
:)
wrong
I don't know how I got to that conclusion.. but actually it has very poor support for error handling, and not much is needed.
Just as well, I wouldn't like that kind of "keep going even if the identifier doesn't exist" behavior anyway. 99 times out of 100 I'd prefer a typo like that to noisily crash the program as early as possible
Sometimes I miss compile-time error checking.
Hey folks I am reading "Machine learning with python". The author shows some code for perceptron implementation. which looks like pseudocode to me.
19:24
Me and DSM could form a crack data science team at FB. We could make it into a sitcom, he'd be the grizzled veteran data scientist who has seen too much of the world, I'd be the young peppy newcomer trying to teach him that rainbows still exist. Except, of course, that in actual fact I'm the brutally cynical young man and in general DSM is quite upbeat. Go figure.
import numpy as np
class Perceptron(object):
"""Perceptron classifier.
Parameters
------------
eta : float
Learning rate (between 0.0 and 1.0)
n_iter : int
Passes over the training dataset.
Attributes
-----------
w_ : 1d-array
Weights after fitting.
errors_ : list
Number of misclassifications in every epoch.
and so on
is this pseudo code
?
It's docstring. Everything after """ is a comment.
Well, is there more code after that?
As the doctstring never ends as it is.
but you do not declare a variable as float, right?
19:26
You could write eta : purple monkey dishwasher and it would still work, because Python doesn't read docstrings.
no it's comment for you to know what should that particular variable type be :)
so i would just write
eta
and that would be the variable declaration?
or
nope
eta = 0.4
eta #float
I think you should try a Python tutorial before you continue with your book.
19:27
It wouldn't be anything. You could roll your face over the keyboard and it would still be as valid as writing eta #float
You will get more from the book if you can understand Python.
ok but there is no value given for instantiation, it set in the constructor
Again, try a tutorial.
It will explain everything.
start from basics :)
hm, still thanks
19:28
Please do provide your output if you do roll your face on your keyboard. I'm currently analyzing the differences in random outputs
I currently have a sample of two. More would be helpful
Currently debating with myself about whether I should mention type annotations...
Ok, I won't :-)
You shouldn't do that in general, especially not for someone new to Python. If we keep quiet then type annotations and mypy might just go away.
I don't like type annotations either but sometimes you just get that "well actually..." impulse against your better judgement
19:30
You feel the urge to be technically correct, I understand this.
Fine, I'll try not to destroy fledgling minds for a small amount of personal gratification.
Eh, what do I care? I'm the Van Helsing for help vampires (not that Käsebrot is a HV, just a general comment)
sigh...too many people think they can simply jump straight into a "Data Science in X" or "Data Mining in X" book without understanding the basics. Shortcuts usually don't work (or end up being longer)
I like the symmetry of Van Helsing / Help Vampire, there.
I was going to go with "antichrist for HVs" but then I thought "surely vampires would like the antichrist..." so I went for VH.
19:33
that violates the definition of a shortcut. it was not really a short cut. its a long cut
@JGreenwell python does not to be so hard. But you guys could have just said what is going on
Fizz Helsing - Vampire Hunter

This Christmas feel Good. Feel Fizzy Good.
Please don't touch me.
I vaguely suspect that a data scientist has a better shot learning Python on the fly compared to a random person off the street.
Or maybe I only think this because every data scientist I know is also a Pythoneer of the highest quality.
19:35
only if they are actually a data scientist or analyst or whatever we're called by people (my title seems to vary a lot depending on who is referring to me)
Yeah. A random person off the street trying to learn data science and programming at the same time will face many unique and tragic challenges.
At FC you have a job role and a job title, your job role only changes when you get promoted, but your job title changes all the time with projects. One project I'm in Data Architecture, the next I'm a System Designer (our fancy term for software dev), and now I'm currently working on Data Science. \o/
@Käsebrot they did say what was going on (it was a comment) and pointed you towards docs and tutorial to learn the basics as this is a fairly early concept in python learning - and my comment was directed more at me trying to understand my own students then you or anyone on SO
@Käsebrot Honestly, it's better for you to learn yourself. We don't really like drip-feeding people here.
ok sry for disturbing
19:38
Better for you to read a tutorial and learn yourself, than to ask others questions all the time.
Nonetheless, if you're really stuck on something (after trying everything) then come and ask.
@Ffisegydd Yeah, and not even for the sake of the room regulars. If you ask me, it's harder to learn from a disorganized group of people than from a meticulously curated and maintained tutorial.
Indeed.
I hammered a question about "unable to find vcvarsall.bat" with this, but it's not actually a very good reference. Nothing about Python 3.3+ needing a different version. Is there a better dupe target, at least for Python 3?
@Ffisegydd that's just what I was referring to. Two project ago I was a Data Scientist, which was cool cause you know Science is cool!...now I'm back to Data Analyst :P ;)....but I'm always just a researcher
@davidism hmmm that's a tough one....What you actually hammered with is the closest solution for that problem.
I remember even using that solution a few years ago when I was experiencing that very problem on windozzzze
19:41
The problem is it almost exclusively talks about Python 2, the solution for Python 3.3+ is either buried on the next page or in comments.
Also, that q has a ridiculous number of "me too" answers that just repeat what better answers say.
@Ffisegydd you are right, tried to take the shortcut here :P
@davidism you probably went through these, but this links directly to a blog post with a decent amount of information and this links to a 3.3 blog post as well
maybe they are the same links...let me compare :)
yep...same
OK, that first link is better, but still not great.
oh my goodness I don't miss Python on Windows
If it happens often enough you can collect and create a canon Q&A
But that really does not seem like a very fun one to work on :P
19:48
davidism what do you think about reopening rabbit project?
@davidism Is this handled by another gold user to re-hammer. Or do you need people to vote to re-open to close again?
I was just going to leave it for a gold badger.
k
anyone else get invited to the SO documentation section? stackoverflow.com/documentation
Did the invite happen all at once for current beta users of docs?
I've been in the beta for a while, but didn't really do anything with it. Some other regulars mentioned they were in it.
It's still in private beta, so invites are still going out probably.
19:57
Yeah I haven't really participated either.
I'm having a minor chicken-and-egg problem with well-meaning circular imports. Is there a canonical on that or is it even worth asking a question about?
@AndrasDeak yeah exactly. So that got shut down and the link I provided is where it is located now. Moved directly under SO
@idjaw the link with 404?
that's not a good new location
@AndrasDeak It works for me, so I'm assuming that means it hasn't been opened to you.
20:01
probably:)
I wouldn't expect a 404 though.
main.py is setting up the logging module, but needs info from config.py to know where to point the logger handler, but I want config.py to log as well.
I wish it was 403
but SO shows 404 or waffles whenever you're not privileged
or 418
Unrelated: the broken multiline formatting is fixed on the starboard, with @Withnail's message --->
20:02
@AdamSmith What are you logging in config.py?
config.py reads from an ini file or creates a default file if one doesn't exist. I'd like to be able to log if it's not finding that ini
For now I just commented out those logs. It's not mission critical or anything, but it'd be nice
Import config.py into your main.py, if the file has to be created then set a boolean variable somewhere and make sure you import it, then setup your logging using the config params, then once it's setup do your logging.
Yo dawg, I heard you like to log
> logging.info('Yo dawg, I heard you like to log')
logging.getLogger().log("log")
20:06
I would even set up my logger outside of main, so that any other file can just use logger wherever
and you avoid this problem
I usually have a logger.py somewhere in a utils folder or similar that just handles configuring my logger
Yes I usually do that.
not a bad idea
though that just changes my problem to logger.py instead of main.py :P
No, you can import config into multiple places.
Stick it in your top level __init__.py and then import from that into logger to do config.
right, but logger.py would need to talk to config.py to get the filehandler location, and config.py would need logger.py to have the filehandler location before it can log
unless I'm missing something obvious..?
What's the structure of your app?
20:12
up in the air at the moment. It's all flat
alternative suggestion
I'm all ears
your app will not work if your config can't find that file right?
technically you can just raise and exit because you have an extreme failure that can't even load your config files to get things set up
it's a scenario that should not be met ever. You actually want it to blow up
and yell at you
20:14
I don't know. No config files is an expected scenario on first boot
does "No config files" do extra work to do something to rectify this problem on its own?
ah
that changes things then :)
I have a default config.ini in a string in config.py that gets written out to a default location.
(well, to the only location. I don't allow the app to change logging/config locations)
Hrm I guess I could just put the log location in main.py
or make a logger.py that has it
it's not configurable
Yeah I'm still not entirely sure what your issue is.
20:19
Another common design approach I take is that I sometimes have a settings.py that is simply holding file locations to be used for config purposes
I mean, I know what it is, but I don't get why you can't just do the needful.
Well thanks Fizzy :P
Just chewing on it for a few minutes in case some stroke of brilliance comes to me.
@Adam do you have some example code?
Just the ini stuff would help.
I'll put together an MCVE that'll do the needfulest of needfuls.
Nothing minimal
I just don't know how to load inis off the top of my head.
20:23
config.ini can control the log level
config = configparser.ConfigParser().read_file("filename.ini")
What's the code to add a file if it doesn't exist?
config["LOGGING"]["level"] == logging.INFO # True by default, but user can change
_default_config_ini = r''' # some big long string '''
I wrap the above config = ... in a try block and except FileNotFoundError: with open("filename.ini", "w") as f: f.write(_default_config_ini); config = # same as above
Something like:
import configparser

config_filename = 'filename.ini'
_default_config_ini = r'''
[logging]
level = info
file = "logs.log"'''

try:
    config = configparser.ConfigParser().read_file(config_filename)
except FileNotFoundError:
    with open(config_filename, 'w') as f:
        f.write(_default_config_ini)
yeah more or less, but logfile isn't configurable -- it only ever goes to os.path.join(os.environ("LOCALAPPDATA"), "companyname", "appname", "versionnumber", "appname.log")
I've got something that I think might work.
Assume this is in a Python package called adamnoob (don't read anything into the name, first thing that came into my head).
In __init__.py you've got:
20:31
lol
import logging

from adamnoob.config import config

logger = logging.getLogger(__name__)

logger.setConfig(...) # Using config dictionary that you've just imported.
logger.info("Default config file created: {}".format(config['config_file_created']))
Then in config.py you've got:
import configparser

config_filename = 'filename.ini'
_default_config_ini = r'''
[logging]
level = info
file = "logs.log"'''

try:
    config = configparser.ConfigParser().read_file(config_filename)
    config["config_file_created"] = False
except FileNotFoundError:
    with open(config_filename, 'w') as f:
        f.write(_default_config_ini)
    config = configparser.ConfigParser().read_file(config_filename)
    config["config_file_created"] = True
Does that meet your requirements?
It's a bit rough around the edges, the try...except needs tidying up and refactoring.
But it does the needful.
that'd work. I'm poking at it a little more though.
it does the needful
(well mostly. config["config_file_created"] will throw a KeyError or something, but I get what you mean)
(a ConfigParser isn't a real dictionary, it just plays one on TV)
Shows what I know.
That's a bit silly.
it seems Bad to log for config.py inside main.py. What if I need to reload the config for some reason? I think I can get it though, just typing something up
Yes it is Bad.
20:39
lol. more info from that bankruptcy case
It can be tidied up a bit by using a logger.py file.
__init__.py becomes:
import logging

from adamnoob.config import config
from adamnoob.logger import logger
logger.py becomes:
from adamnoob import config

logger = logging.getLogger(__name__)

logger.setConfig(...) # Using config dictionary that you've just imported.
logger.info("Default config file created: {}".format(config['config_file_created']))
indeed if you bought something online and paid in cash and said you'd pick it up at their dept store, now you cannot get your stuff...
Still bad, but not Bad.
the stores are open, ppl can buy stuff, but those who ordered it online and paid in cash and said they'd pick it up at the shop cannot get their stuff..
what is more... the company had an ad campaign wherein you could get up to 40 % discounts when shopping online :D:D:D:D
sounds fishy?
sorry we don't have the item you ordered online, but now that you are here, how about all these other things you can by at our store
20:42
@idjaw no...
they had the item in the store.
ooh
the woman interviewed in this one article had got sms about her stuff being in the store, she went to receive it and they said "sorry, no, can't, illegal ya know"
is that Better or Worse than import somestuff; do_some_stuff(); import config ?
# logger.py

import logging
import os

from package.info import logpath

getLogger = logging.getLogger

package_logger = logging.getLogger("package")
fh = logging.FileHandler(logpath)
fh.setLevel(logging.DEBUG)
package_logger.setHandler(fh)
# same thing for a formatter

import config  # ew
@AnttiHaapala that's really weird
I think that's fine.
Setting up a logger is a good thing to do, usually one of the first things I'd do.
20:45
then I can do fh.setLevel(config.config["LOGGING"]["level"]) or whatever
lets config.py log with a logging.DEBUG level, then by the time anything else needs to log it's been set up to logging.INFO or logging.WARN or whatever.
so if she'd spent 3 € more to have it delivered to a mail office or to door, then she'd have it now. but since she'd asked delivery to the store to save 3 € now she can't have it and must sue them instead
bleh that's ridiculous
it is :D
so, those who paid in advance by cash now need to wait ~6 months to get (some) of their money back
Going to #SDCC2016? I'll be moderating @Syfy's #TheExpanse panel on Saturday at 3 pm! http://sched.co/7gL2
since we're all fans of The Expanse (and presumably Adam Savage)
I have no idea about TE
DSM
DSM
20:54
It's on my "to-watch" list. I enjoyed the first episode a lot, but I have this weird quirk where I need to be in the right mood to watch good TV, and the right situation hasn't happened yet..
I have lived in San Diego for 10 years and have never been to ComicCon. I don't know if I could put up with it in person, but I want to try at least once at some point.
DSM
DSM
Ehh, it's not as authentic as it used to be. #hipsternerd
@tristan I'm trying a game of FTL. It's super hard.
21:18
typos will be the death of me.
I hate typos
98 % of my errors is typos
@JossieCalderon you should use chat.stackoverflow.com/rooms/1/sandbox to experiment with chat features
I'm sure there is some smart editor out there to help you correct typos, let's say it does all permutations of your right script and then searches text for them, beacuse mostly it's like my word 9 words before
@MarkoMackic there's a feature in MATLAB's command window where it suggests variables/functions for you if what you're referring to doesn't exist
@MarkoMackic sounds like autocorrect on a phone
21:24
>> onse(4)
Undefined function 'onse' for input arguments of type 'double'.

Did you mean:
>> ones(4)
How cheap is Python's file I/O? I'm looking to count the number of lines in a file (basically like so), but doing the same in MATLAB is really expensive (edric(1) here) so I just use a system call like wc -l
@AndrasDeak well it uses string permutations , maybe ..
probably possibly
@excaza the comments on the answer suggest that wc should be faster than python
though I guess that mostly matters for large files
DSM
DSM
More likely than permutations is that it uses some difference metric like Levenshtein or something.
for smaller ones, native python might be more elegant
21:27
Flask will prompt you with corrections if you try to generate a url to an endpoint it doesn't recognize. I'm not sure what it's using, or if it's actually in Werkzeug.
@DSM that'd be more performant I guess
DSM
DSM
Python iteration speed is slow, though, so any loop over lots of lines would be slow (I'd guess).
yeah but one line regex is not
I think DSM was talking to excaza
(word|wrod|...)
21:28
(wasn't he?)
@MarkoMackic you're joking, right? Regex is incredibly slow.
DSM
DSM
@Andras: yep. :-) If I had to count lots of lines from Python I'd try to read in big chunks and then call count to push as much of the searching to C as possible.
Oy, how'd it get so late already? Rhubarb for all!
@DSM rhubarb
rhubarb from me as well
And me. Rbrb.
21:31
@davidism nope, I hear a lot of different opinions about speed of regex.. I haven't really benchmarked it :)
rhubarb, all
rbrb all;
@MarkoMackic I'm sure it depends on language as well
@davidism except to say that I was a bit disappointed with the new Magi thing on Netflix, about Sinbad.
Now rbrb
@DSM you're right, I didn't scroll down far enough yet. whoopsie :(
21:33
@AndrasDeak I'd say that is logical
good night
already ?
night than :)
last night I had 4.5 hours of sleep, then an exhausting day
I'm trying to become less of a zombie by tomorrow night:)
21:35
I haven't slept for 2 days already, I'm still holding fine
:D
You were right about bat thing :P
just don't bite anybody:P
and go to sleep when you start seeing things
(should happen in a few hours)
you mean white little things floating in the air :p
coffee makes it better :D
21:53
Hey people here is a challenge, I haven't successfully beaten this task, and here are my codes , if anyone wants to look at the task, It's interesting, it's combinatorics with some sequencing. my submissions : hackerearth.com/@markomackic/activity/hackerearth the problem : hackerearth.com/problem/algorithm/kinako-bread
It needs to solve everything under 2 seconds, and test cases are frightening :D
here is my solution dpaste.com/2YH9TQA because there you'd have to log in, before commenting on slow python loops if you look at it and read the problem, I didn't have better idea :)
22:27
oh fsck
I got a pretty nice bit of scientific spam, the ramblings of a well-known crackpot who impersonates real scientists, apparently coming from a Swedish Prof Emeritus
I'm sorry to say that this yammer is a countryman of mine:S
you can tell that our largest mental hospital has been closed for years
That's a good thing, they have no people to nurture :p if that's how it's spelled
the actual e-mail is non-trivial, it includes the crackpot's name as an image to prevent spam filters, and the raw message contains a lot of words that are backwards, I assume with a lot of RTL marks
the scary thing is that at least according to the source of the message, the sender really seems to be the Swedish guy (though I don't know anything about spoofing e-mail addresses)
I sent an e-mail to the poor Swedish fellow to inform him of these fun times...
fortunately two "papers" of the crackpot are also included for simplicity
> The real "particles" of this world are the photon, X-ray-photon and gamma-photon "particles". Other "particles" don't exist.
James Chadwick's neutron is a gas molecule which with 20 minutes after the arising decays to a positive hydrogen ion and a negative gas ion which was known till now as electron, and it not same with the gamma-photons which are emitted by the nucleus of the radioactive atoms.
Known that from the hydrogen so will be deuteron that the nucleus of the hydrogen absorbs a gamma-photon. The nucleus of the hydrogen consists of one gamma-photon. The mass of the absorbed gamma
Nutty McNutface
OK I'm done for now, I'll come back tomorrow to vent some more:D
:P
@AndrasDeak ah, obvious, just look at your government
22:47
@MarkoMackic you should be careful if your really on 2 days without sleep as you will start full on hallucinations and they suck
Go marko go!
The world record is 11 days 4 hours no sleep
HEy people, I'm a bat :P relax :D
And other then that :D nothing better then good halucinations :D
23:03
im going to marry python.
deal with it.

« first day (2103 days earlier)      last day (3070 days later) »