« first day (2323 days earlier)      last day (2850 days later) » 
00:00 - 20:0020:00 - 00:00

20:07
http://www.python-course.eu/sql_python.php
mysql.connector
Seems to be doing what i need for MySQL/MariaDB
@MooingRawr looking at the body of work of Miyazaki, I don't think he gives a crap about what people think or make of his movies
Noooooooooo why why why
Fizzy Badnews
he's just trying to get money out of us while we're trying to figure out how much this new book sucks
Oh, is it free online? I keep forgetting
I posted that link earlier today. Summary of reactions: MooingRawr thought it was a prank, Withnail thought it was about time, I thought it's a step in the right direction.
> Put a # (octothorpe) character at the beginning of a line. What did it do? Try to find out what this character does.
how is it not a prank?:P
and sorry, I've been distracted with work all week, I haven't even tried to keep up with the transcript:/
20:17
It's a prank only in the sense that all of existence is a cruel joke
I still think his work is Satire to a degree :(
it would be a step (and a very good one) in the right direction, if it wasn't for my preconceptions about the author
@AndrasDeak how dare you ignore us for your work.
@AndrasDeak Well, if this is any indication is Like == to test equality. 1 is 1 == True
Pretty bad.
Data Types is the best, though
> strings Stores textual information. x = "hello"
I wonder when Python got the strings type
20:37
Was there a good justification for not subclassing dict and adding __getattr__ == __getitem__? I feel like I read that it wasn't a good idea somewhere.
153
Q: Accessing dict keys like an attribute in Python?

Izz ad-Din RuhulessinI find it more conveniant to access dict keys as obj.foo instead of obj['foo'], so I wrote this snippet: class AttributeDict(dict): def __getattr__(self, attr): return self[attr] def __setattr__(self, attr, value): self[attr] = value However, I assume there must be some...

I'm jumping in to ember.js
splaaash
Phew, was worries about burns for a second.
yeah...had to add that js to not scare anyone
Nah it's just that underground city with a failing generator
ember has a mascot...cute
Tomster!
20:41
Every piece of tech needs a cute mascot IMO
^^
What's room 6's mascot?
I'm surprised no on has made a cute little friendly Python
davidism....I think it's time to make a cute flask-like character
put it on the to-do list
highest of priorities
I'll just put big anime eyes on the logo, that makes anything cute.
that passes
20:43
@davidism people may be surprised by foo.bar raising KeyError instead of AttributeError
Would overriding getattr in that way cause the dict's actual attributes to be overshadowed? Could you still do myDictSublcassInstance.items()?
If it does, that's a problem. If it doesn't, that's a problem.
overshadowing would be a violation of the Liskov substitution principle, and thus probably be bad OO design. Even if you promise to be super careful about it.
I have a feeling the best way to solve the problem is some sort of dict to NameSpace converter
@idjaw How about this one?
20:50
:D almost got my weeb out. Need to control what to type in here.
Gotta hide that power level.
hahhaah....that's the flask mascot after hours of debugging and nothing works. The flask comes out
@Kevin I get that reference :D and glad to see someone else knows it too.
For the record, it doesn't overshadow items.
class Fred(dict):
    __getattr__ = dict.__getitem__
    __setattr__ = dict.__setitem__

d = Fred()
d.foo = 23
print(d.items())
#result:
#[('foo', 23)]
#or
#dict_items([('foo', 23)])
#depending on version
__getattr__ is only triggered if the attribute is not present in the mro.
20:57
But what about when you legitimately have a member called "items"? I will accept "don't do that then" as an answer
In that case we can't use the substitution principle to say that it's bad OO.
Not being able to do d.items = 23; print(d.items) and get back "23" isn't a violation because you couldn't do that with a basic dict to begin with
You can say that it's bad OO because its interface has a number of non-obvious corner cases, but that's far more subjective.
def frobnicate_object(obj):
    "Duck typing is great! Give me an object with a foo param, that's it!"
    try:
        print(obj.foo)
    except AttributeError:
        print("You're missing a foo!")
It doesn't break dict LSP, it breaks object LSP
Just have them do types.SimpleNamespace(**input_dict)
21:27
@AnonInternational in that link you posted here they teach passing values to SQL queries using string formatting. That's very dangerous. You should pretty much never do that.
that's how you h4x :P
good ol' bobby tables
wim
wim
21:47
pytest users
what's the best way to get your project into sys.path ?
I've used PYTHONPATH environment variable before , but perhaps there is a way we can do it in the pytest.ini conf file?
pytest.ini conf naturally, have your package installed in dev mode
wim
wim
pip install -e . is not enough
it is not?
wim
wim
no, it's not
actually I do not know what I am doing here for it to work, but it works :D
wim
wim
21:51
it works but only by accident if you have your project setup a certain way
the first entry of sys.path is probably where your conftest.py is
so you have a src/ folder?
wim
wim
but, you don't have to do it like that
I keep source code and test code completely separate , not interspersed
I do that too but I have package/ and tests/
you should find a cookiecutter that is laid out as you want and is supposed to work with py.test
wim
wim
and does it work if you execute "pytest" from the same directory which contains ./package/ and ./tests/ ?
wim
wim
21:54
what's in your pytest.ini ?
I've got setup.cfg
[pytest]
minversion = 2.8.2
testpaths = tests
addopts = -rsx --tb=short --cov-config=coveragerc-python3 --cov-report=term-missing --cov=tonnikala
seems to work with newest pytest
but again, Idk if it would work if one has src/...
setup.py: packages=find_packages(exclude=['tests']),
test_suite='tests.test_all',
hmm wat ?:D
actually that's not used any longer (that test_suite)
I guess I should remove it, there is no test_all
wim
wim
do you use python setup.py test ?
or do you just run pytest
pytest
just pytest
There's pytest-runner if you really want to be able to do setup.py test.
but, this is an old pre-pytest project so not all things are as instructed in pytest manuals :d
wim
wim
22:00
I don't care for python setup.py test
I only changed it to the extent to make it running
setup.py test sucks in any case...
previously it used to install eggs into current working directory and what not
Yeah, that's why I stopped using setup_requires for Git support, it would install the packages in the working directory. Was that ever fixed?
wim
wim
previously? still does
2
A: Can a package be required only for tests, not for installation?

wimYes, it's simple in setuptools: # setup.py from setuptools import setup setup( name='your_app', ... install_requires=... extras_require={ 'dev': [ 'pytest', 'pandas', 'coverage', # etc ] }, ) Now when you develop on the app, use: pip install -...

I use the extras_require method to avoid this crap
Or just run your tests with tox, and install the test dependencies there.
wim
wim
22:03
Here's what I want to get working
just git clone / run pytest
at the moment I have an extra step in the middle there (the pip install --editable stuff)
is that what tox is supposed to do? create the venv, install dependencies, etc?
I never use tox honestly
Yeah, it handles all that.
Assuming you had tox installed already, you could clone then call tox.
wim
wim
I suppose I could do it, I thought it was more for targetting multiple python versions, and for this project I am going 3.6 only
Most of the time you're cloning in order to develop, right? So you would presumably want to install in dev mode anyway.
Silly noob question: I know that sudo pip install is unsafe and why, but my impression is that virtualenvs work locally in that they work inside a given subdirectory. Would pip install --user let me install stuff globally-as-far-as-my-user-is-concerned?
I think so, I'm not really familiar with --user.
22:09
yes...
thanks
considering that I don't develop stuff for multiple versions or with specific packages, I don't think a virtualenv would be convenient for me
Ah, I don't use that because I don't have pip installed at the system level, only virtualenv.
seriously?
no one discussed the cloudflare vuln???!
except idjaw?
who mentioned it at
8 hours ago, by idjaw
eeesh. Cloudflare vulnerability
wim
wim
yes, pip install --user does exactly that
who does it make vulnerable?
\o/
wim
wim
22:11
it installs to ~/.local/ usually
run python -m site to see where on your system
I'm OK with that, I just want somethng that's accessible from anywhere while not doing anything frowned upon
@AndrasDeak so, cloudflare has a front proxy / accelerator / cdn that caches things...
Here's the issue reported by a Google security person: bugs.chromium.org/p/project-zero/issues/detail?id=1139
I've been using sudo pip but I read the starboard and had an epiphany (not a very profound one, obviously, but enough for me to start caring:P)
wim
wim
pip install --user should be the default , but in true python packaging style - they have been talking about it for 3 years instead of doing it. github.com/pypa/pip/issues/1668
22:12
@AndrasDeak their custom C proxy code had an error, whereby it would, like in heartbleed, copy random data outside the intended buffer from the cache into output...
@wim yeah, I think I heard that line before, I just didn't understand it
wim
wim
you should pretty much NEVER use sudo pip
@AnttiHaapala I see, so vulnerable for the user
so you go to www.foo.com, that uses cdn, under certain conditions the website ends with garbage that contains for example reddit user credentials...
@AndrasDeak no, vulnerability for anyone ... :D
They found it by fuzzing HTTP requests. Inserting certain types of random data in the request would cause CloudFlare to dump memory.
22:13
and it wasn't really that random...
And the memory often contained recognizable private information.
it's a good thing nobody uses cloudflare, right? Right...?
@AndrasDeak no one, like ...
authy.com coinbase.com betterment.com transferwise.com prosper.com digitalocean.com patreon.com bitpay.com news.ycombinator.com producthunt.com medium.com reddit.com 4chan.org yelp.com okcupid.com zendesk.com uber.com namecheap.com poloniex.com localbitcoins.com kraken.com 23andme.com curse.com counsyl.com
these above have been confirmedly leaking private information
@AndrasDeak and it has stayed in search engine caches too :D
people could find uber credentials with google searches :D
22:16
> We fetched a few live samples, and we observed encryption keys, cookies, passwords, chunks of POST data and even HTTPS requests for other major cloudflare-hosted sites from other users. Once we understood what we were seeing and the implications, we immediately stopped and contacted cloudflare security.
oops
@AnttiHaapala a friend told me that pirate bay uses it too
apparently the code was in the part that fuzzies email addresses so that they're not in plain text
well, it wasn't, at least:D
if there were malformed email addresses on the page in html content, they'd leak information from other sites...
@AndrasDeak it was :?
was it?
that's what I read
22:19
the report davidism linked to suggests that figuring out the data needed some work, it wasn't obvious
but I don't speak computerish well enough
ah ok not then :D
ah but yes
it's all a bit fuzzy to me
For example, in certain circumstances (detailed below) if the web page ended with a broken HTML tag like this:

<script type=
22:21
It's really cool to have guys whose job is to find shit like this. Sounds like a depressingly underappreciated job.
trying to use a try/except statement to check if a value is int or float
z = a[2]/b[2]
try:
z = int(z)
except:
print("lol")
even if z = a[2]/b[2] = 1.25, the try bit still runs true, turning z into 1..?
is float(z), and is_integer() a stupid approach?
wim
wim
@AnttiHaapala which directory is your conftest.py file in
(if you have one)
@AndrasDeak they're the same guys who write shit like this
@SylentNyte you can easily call int(x) for a number x...
22:23
@wim I don't have a conftest.py
wim
wim
ahhhh
I think I've found it
@AndrasDeak lmao before i was using isinstance(x,int)
wim
wim
touch an empty conftest like tests/conftest.py
@SylentNyte you'll only get an exception there if z is a string with a non-int inside
wim
wim
then run pytest again
I'm guessing it might ImportError now
22:24
no, still works.
@AndrasDeak so then how can i check if its either an int or a float
wim
wim
hmmm, well there goes that idea
@SylentNyte what are you trying to do? If you want integer division, use //
how do you import your stuff in tests?
global imports?
wim
wim
yeah , absolute imports
import myproj
22:25
@SylentNyte if you're looking at the ratio of two integers, your most precise chance is if a[2]%b[2]==0. Otherwise floats have a method called is_integer which tells you if its value is integer. But considering floating point arithmetic, you should generally not rely on this
wim
wim
but it's the pip install -e . that puts that thing onto sys.path
wim
wim
if there is a conftest.py in the tests directory, it doesn't work
weird!
yea i figured
i solved it
and if you use python 2 then a[2]/b[2] will always be an integer, unless you from __future__ import division
22:26
I've got really old tests, so I am still using unittest.TestCases here
just did a[2] % b[2]
that's for the best ^
perhaps some problems are caused by ...
i was wanting to see if doing a[2]/b[2] would give me a remainder
@AnttiHaapala I'm OK with that, it still beats people writing shit like this in write-only mode:P
22:27
so my initial thought was to see if i can convert it to an int, as an int cant have decimal places so it will throw an error and i will catch it, i solved this by doing a[2] % b[2]
A remainder is what modulo is for, not division
Ah
yea
was having a brain fart moment
thanks tho
no worries
whatever you're writing, if you need to run it on Python 2, use from __future__ import division
I usually test stuff like this in the REPL, play stupid and try 3./2. etc. and see what does what I want it to do
wim
wim
22:32
3./2. won't tell you anything
same on all python version
which I would realize if I played around in the REPL:P
my point was the part about the REPL
22:55
Hey all I'm stuck can someone help me with a simple open file write to file script?
Hi. You don't need to ask if you can ask, just ask, and if someone can help, they will.
If I paste code here, will it show up okay?
I guess I can try it :D
wait a sec
1. if it's longer than a few lines, consider using a pastebin or something similar
2. if you post it here: multiline messages enable a "fixed font" button on the right --> (or, ctrl+k does the same) that preserves indentation
with open(inputFilename,'r') as in_f, open(outputFilename,'w') as out_f:
    lines = 0
    for line in in_f:
        if lines == 0:
            lines+=1
        else:
            column = line.split(',')
            print "{}\t{}\t{}".format(str(column[0]),str(column[1]),str(column[2]))
           out_f.write('{}\t{}\t{}'.format(
                str(column[0]),
                str(column[1]),
                str(column[2]))
Ok, so this gives me a "Syntax error" and it only happens when I'm trying to write
good job, most guys don't nail it for first try:P
22:59
Thanks haha
@user3474042 not an indentation error?
no, sorry that indentation was from my cut and paste
you'll need to read/post the full traceback; it contains useful information
I get a pop up "There's an error in your program: invalid syntax
@user3474042 you can edit/delete messages up to 2 minutes after posting
@user3474042 try it in the native python interpreter
23:01
@AndrasDeak cool
sounds like your IDE is being stupid
what do you mean try it in the native python interpreter?
I'm running it in the ide
call python my_script.py from a terminal/command prompt
idle i mean
oh ok
I don't know IDLE but a proper traceback contains the line number of the problem, +-1 line usually
23:03
yea it says
  File "annotfromfile.py", line 23

                                    ^
SyntaxError: invalid syntax
The last line after the ")" is all red highlighted to infinity
that's strange because what you posted has less than 23 lines
yes
it has 22
I counted 12
    out_f.write('{}\t{}\t{}'.format(
        str(column[0]),
        str(column[1]),
        str(hexdata[0]))
count the parentheses
and make sure that your MCVE doesn't remove your bug next time:P
hahaha
thanks
Jeeeze
that was a newb mistake
23:06
I use vim for writing code, it has syntax highlighting and makes finding mismatched parentheses really easy
it's obviously not an IDE though
I have no idea how to use vim
I see people doing it
but it scares me :D
DSM
DSM
Lots of other editors are also syntax-aware and can flash the opening parenthesis when you try closing one. That's usually all it takes.
Yeah, you need to learn first. I was forced to learn it when I started using an hpc cluster, but it turned out to be an amazingly profitable investment
@DSM sssssh
vim vim vim :P
do you want the emacsists to win?
DSM
DSM
I AM ONE
23:08
I loved notepad++ since college, but its not good for python. Really bad with the indentations and python is very sensitive on that
I knew something was off about you
DSM
DSM
Mar 25 '16 at 12:20, by DSM
How cute! People using starter editors not written in lisp. It's like a dog wearing a hat standing on another dog weaing a sweater. #onetrueeditor
you might be better off with Eclipse. I don't use it (vim for me) but I know people who have large python software projects in it. Atom and Sublime are good if you use a Mac.
DSM
DSM
My test coverage just hit 99.3% from 71% right before I'm about to head home so I'm in an excellent mood. :-)
sounds great, good job:)
23:11
ah the 1% getting away with everything once again
DSM
DSM
I now will take advantage of my newfound one-percenter privilege and bail. Weekend rhubarb for all!
have a nice one, rhubarb
wim
wim
walking pathlib objects yields strings :(
>>> next(os.walk(pathlib.Path('/usr/local')))[0]
'/usr/local'
>>> type(_)
str
total sadface.jpg
where is pathlib.Path.walk ?!
what should it yield?
wim
wim
it should yield a bunch of pathlib.Path obviously
23:19
ah, obviously
I see, os.walk vs pathlib.Path
Don't all os functions just work on/with strings?
wim
wim
probably
imo, if you give it strings it should yield you strings. if you give it paths, it should yield you paths.
yeah, os.walk probably just calls str() on it
PEP428 says that pathlib used to be a 3rd party module, that might be a reason why os is not pathlib-aware... (?)
Hmm, PEP519 suggests that path objects are the future. So will os be changed/deprecated?
> Abstract

This PEP proposes a protocol for classes which represent a file system path to be able to provide a str or bytes representation. Changes to Python's standard library are also proposed to utilize this protocol where appropriate to facilitate the use of path objects where historically only str and/or bytes file system paths are accepted. The goal is to facilitate the migration of users towards rich path objects while providing an easy way to work with code expecting str or bytes .
I guess they failed to change this part of Python's standard library to facilitate the use of path objects
hmm, my python 3.5 won't even accept a Path inside os.walk
(right, found the "3.6" part of the PEP :P)
@wim can't you try something with os.PathLike?
though I guess if it worked for something like that it would also work for a pathlib.Path
OK, here goes nothing, I'll try to install 3.6 inside a virtualenv
23:49
From that pep: "The various path-manipulation functions of os.path [9] will be updated to accept path objects. For polymorphic functions that accept both bytes and strings, they will be updated to simply use os.fspath() ."
or, I could just install 3.7 using make altinstall, tempting
@paul23 yes, but wim doesn't need os.path (a module), he needs os.walk (a method inside the os top module)
and 519 has been fully implemented, I think
(almost-fully?)
It was in respect to "os will be changed/deprecated"..
00:00 - 20:0020:00 - 00:00

« first day (2323 days earlier)      last day (2850 days later) »