« first day (1928 days earlier)      last day (3245 days later) » 

00:02
@davidism I know that, I'm just saying it's an example for something that needs high maintenance
@AaronHall and oops
I am currently (at this moment) developing on Windows 8.1, 10, and Linux (Ubuntu) - hooray for virtual machines (and the Linux distro/VMWare cost nothing)
yep
stinks about the Windows though
:)
I'll try to install linux then. But it's a whole another beast (I'll try it out after this midterms week)
well, mostly I just run tests for the visualizations I built in Linux to make sure they work well with someone else's C# code (or my own occasionally) so like 90% Linux
All data processing is handled on Linux/Python/Jupyter environment. Doing that on Windows? shudder
also on a plus side, I finally get to migrate that stuff to Python 3 :)
 
2 hours later…
02:01
Hi, is there anyone?
I am very curious to know one thing
I know that using something like
url_for(feature=request.path.split('/')[3], url_add=att.get('url_as'))
I can pass feature and url_add to my view and then add or substract this url_as in my current url
is there any way to do it on html side i.e. inside url_for??
I don't know what you mean, you just did write code "inside" url_for.
ok, imagine I have a url like www.example/en/code/a+b+c+d
now att.get('url_as') = 'e', Now I need to add this e at the end of this url, so it should look like
www.example/en/code/a+b+c+d+e
I know how to do it inside view
but what if I need to do this in url_for and then send new url to my view, is it possible?
no, you would write your own function to do that, or generate it in the view and pass it to the template
02:15
ok, thanks..I tried something like
url_for(feature=request.path.split('/')[3]+"+"+att.get('url_slug')) and It worked
But then I can not check for duplicate 'e' in my url
Therefore I was wondering is it possible or not, Thank :)
@User2403 so you want a list of items, separated by +, and want to add to the list to generate another url?
yes, something like that, and also its on checkbox, so if the item is in list then on click it should be remover and if it is not in list then it should be added
so you want to generate this url on the browser side as the user selects checkboxes?
then you would use JavaScript, not Flask at all
exactly
I did it by creating a view in flask :)
ya, that I can..I was just wondering is it possible through flask
If you just want to know what checkboxes were selected, you can just do that with a form, you don't need to generate your own url.
I'm having a hard time understanding what your goal is. See XY problem.
02:26
My boss asked me to do it through flask and I did it but have to use redirect in view.py, he accepted it and said "is it possible to do it on browser side? just try"
So did you try? Why were you asking about Flask then?
He want me to do it by using
<a href="{{ url_for('xyz',
l_c=g.current_lang,
feat=request.path.split('/')[3],
u_add=att.get('u_add'))}}">
{{ att.get('n') }}
</a>
and then pass it to a view
3 mins ago, by davidism
I'm having a hard time understanding what your goal is. See XY problem.
okk
I want to generate a url on the browser side as the user selects the Link, is it possible to do it without javascript?
You're just describing submitting a form.
Submitting a form where method="GET" adds arguments to the url based on the form values.
02:47
from flask import Flask, render_template_string, request

app = Flask(__name__)

@app.route('/')
def index():
    items = request.args.getlist('items')
    return render_template_string("""<form>
        <label>1 <input type="checkbox" name="items" value="1" {% if '1' in items%}checked{% endif %}/></label><br/>
        <label>2 <input type="checkbox" name="items" value="2" {% if '2' in items%}checked{% endif %}/></label><br/>
        <label>3 <input type="checkbox" name="items" value="3" {% if '3' in items%}checked{% endif %}/></label><br/>
@User2403 there, that generates a url based on a list of checkboxes
okk, Ya, I thing that will work...
Thanks
Do I have to do something special to seek a file that I passed to a csv.DictReader? According to the docs I shouldn't have to, but it doesn't seem to be working.
no, nothing special
Also, sanity check, f.seek(1) should set the cursor on f to the second line?
no, it sets it after the first byte
03:01
Even if I open it in text mode?
So do I have to do f.seek(bytes_per_line * line_number)? And if so, how do I calculate the number of bytes per line?
just read a line, next(f)
Oh, right.
So should I just do for _ in range(line_to_seek):next(f)?
there's probably an SO question about this, but that sounds fine
See, the questions I found (and I thought the docs) seemed to say that seek was the right way to do it.
37
Q: When processing CSV data, how do I ignore the first line of data?

user1496646I am asking Python to print the minimum number from a column of CSV data, but the top row is the column number, and I don't want Python to take the top row into account. How can I make sure Python ignores the first line? This is the code so far: import csv with open('all16.csv', 'rb') as inf: ...

03:07
well, if each line is the same length, then it's one way you could, but you might as well just use the built in iteration
I never got the sniffer to work for me...
Huh, I guess I stand corrected.
@AaronHall that answer sounds way too complicated, just do next(f)
it has skiprows keyword argument.
"let's install a huge library to skip reading some lines"
03:09
Also, in unrelated news, I finally started using vim a week or so ago. It is really nice for stuff I don't need PyCharm for.
"let's use a library we should already be using because it solves the problem fast instead of coding up a solution in 10 times the lines"
6 mins ago, by Morgan Thrapp
So should I just do for _ in range(line_to_seek):next(f)?
that's one line, ~26 characters, no huge library, can't get much shorter
@AaronHall though I do agree with you... my god those kwargs
let's install a crow
pip install crow
Huh, apparently that's actually a package.
> Service ochestration based on etcd
Once I see that people are importing csv, I don't have the patience to code up low level Python.
Ah, yes, of course.
csv is a bretty gud package though, it's easy to use
Yeah, I've never had any issues with it. The Dict(Reader|Writer) classes are super nice.
03:18
I've used it to manage code releases, but I wrapped all kinds of validation around it. It's a non-standard.
well, I guess it is non-standard because you can configure it to parse files delimited by a not-comma-character
"It's a non-standard, so you should install a huge library to read it."
Regardelss of Pandas' other merits, that's a pretty ridiculous statement.
Pandas are jerks, they just eat bamboo
You messed up the joke.
do they not eat bamboo? I've never had one over for dinner :\
Eats, Shoots & Leaves: The Zero Tolerance Approach to Punctuation is a non-fiction book written by Lynne Truss, the former host of BBC Radio 4's Cutting a Dash programme. In the book, published in 2003, Truss bemoans the state of punctuation in the United Kingdom and the United States and describes how rules are being relaxed in today's society. Her goal is to remind readers of the importance of punctuation in the English language by mixing humour and instruction. Truss dedicates the book "to the memory of the striking Bolshevik printers of St. Petersburg who, in 1905, demanded to be paid the same...
How can you hate a face that cute.
DSM
DSM
Coming in late, but the csv module is pretty good at reading stuff. Can't handle complex delimiters, but okay. Not very good for processing anything.
it's at least convenient, really. Gets the job done quickly
Yeah, but if you just need to read or write some data, there you go.
03:25
If you load up a csv, what's next? data analysis? You going to munge it? Just dump it into a pandas dataframe with the top level API function. If people are asking me for advice, and I get a lot of that in our meetups, I give them a single install of anaconda (they get requests, flask, pandas, etc...) and show them pandas.load_csv and I have spent less than a minute total helping them, and they have their data in a format they can use with tons of options ("here's the docs, read it").
@AaronHall please, tone it down
It's a scalable solution that works for me and them.
All I have to do is read the CSV and dump it almost unmodified into an API.
DSM
DSM
@davidism: hey, have I thanked you lately for your flask answers? Colleague and I have a flask + plot.ly app which is being presented to the decisionmakers tomorrow.
Actually, that's the wrong open. :-) In 2 you need "rb", and in 3 you need newline="". ;-)
import csv
with open('file.csv', 'r') as csv_file:
  data = csv.reader(csv_file) # or csv.DictReader(csv_file)
03:28
'rU'?
3 lines isn't too much to complain about, easy to read too
Use the U flag, if you don't know where your file is coming from.
Only in 2, 3 will do it automagically.
And if you insist on doing it the hard way.
@corvid when you need to read some CSV, wouldn't you rather follow a patented three step program that will improve your life by a person who's advice is sought out a lot at meetups, installing a whole python distribution and library, but never actually discover that it's built in?
03:31
@AaronHall how is three lines hard?
yep, 'U' is deprecated in 3
@DSM sounds cool :-)
DSM
DSM
If one's only doing simple row-based ops, then csv is the way to go. If you're processing the data in more complicated ways, a more complicated library makes sense. What am I missing?
Using three lines is apparently harder than one line, I guess?
@DSM you're right, but the question was literally "how do I seek to a line then read the csv"
03:33
easier to use the built in libraries, they're consistently good... external libraries are iffy sometimes
That sounds like part of a much bigger problem.
DSM
DSM
To be honest, I agree that "read the csv" is usually step 1 of "read the csv, store it into a convenient structure, do operations on it, and then write the output".
769
Q: What is the XY problem?

GnomeWhat is the XY problem? When asking questions, how do I recognize when I'm falling into it? How do I avoid it? Return to FAQ index

Of course, that's extrapolating beyond the scope of the question
to be fair, we recommend SQLAlchemy a lot, but usually with the statement "hey, if you're doing a lot of database stuff, you could switch to this"
03:36
It's really not an XY. I'm just trying to resume my import from the line where it failed.
and in all the times I've used CSV and wanted to skip some lines, I haven't been doing anything that needed pandas.
Fun fact: Pandas is short for Panel Data.
DSM
DSM
I believe you, though I almost never read a csv without wanting to do DataFrame-level ops. Different problem spaces, I guess.
yeah :-)
I just got back, what did I miss?
03:38
@DSM so what did you think of Flask? I guess any problems you had were answered.
There's some (removed) stuff, and not being a room owner, I can't read it.
guys why are there so many good movies?
DSM
DSM
Took me a few tries to get the hang of it (my first few goes were functional but ugly). And it was only part of the whole "so what do I do server-side, what do I do client-side, how much JS do I need to write, etc." collection of questions that a numericist asks when he needs to figure out how to make some shiny http://stuff
darn, you'll be forever in the dark about the important secrets we wrote in a chat room
@corvid so people get and spend money
and keep the capitalism machine going
03:40
@corvid I'm really into South Korean crime dramas right now. They are really good.
Just trying to show a polite interest.
I should really learn flask some day. It seems like this web thing might be important some day.
I feel like movies are a very volatile way to make money
Once you make a name, though...
DSM
DSM
@davidism: I've been watching some Korean stuff lately too. Watched a Korean detective series, and I really enjoyed the movie Assassination last year.
03:41
Watched New World, good characters, emotion, action
DSM
DSM
Plus the region of my town I live in is nicknamed "North Korea" because of the "North" in its name and its high density of Korean-Canadians.
didn't Korea kind of have a pretty good golden age of movies, then go a bit downhill after some censorship laws?
Well that was from 2013, not sure when the laws happened
The easiest way to get to the real problem is usually asking Why five times. — Gordon Oct 21 '12 at 17:25
DSM
DSM
Dunno, but since movie censorship laws gave us noir, they can have good consequences too.
03:43
How's that?
censorship => noir, links plz
I also heard the Japanese movie called "Confessions" was really good, haven't seen it though
If you want a good bad movie, there's always the French District 13
District B 13 (French title Banlieue 13 or B13), is a 2004 French action film, directed by Pierre Morel and written and produced by Luc Besson. The film is notable for its depiction of parkour in a number of stunt sequences that were completed without the use of wires or computer generated effects. Because of this, some film critics have drawn comparisons to the popular Thai film Ong-Bak. David Belle, regarded as the founder of parkour, plays Leïto, one of the protagonists in the film. == PlotEdit == In 2010, social problems have overrun the poorer suburbs of Paris; especially Banlieue 13, commonly...
DSM
DSM
@AaronHall: like most things it's an oversimplication, but to quote Wikipedia: "Film noir is often said to be defined by "moral ambiguity",[177] yet the Production Code obliged almost all classic noirs to see that steadfast virtue was ultimately rewarded and vice, in the absence of shame and redemption, severely punished (however dramatically incredible the final rendering of mandatory justice might be)". It's one of the reasons they had such dark endings: the bad guys had to have bad outcomes.
good bad movie, like a film that's so bad that it becomes funny? Like Battlefield Earth?
It's like why drug trips always had to be portrayed as terrifying and bad. Not that they aren't in some cases, but they always had to be.
03:48
they're usually pretty bad, like that time I woke up in the Gobi desert handcuffed to a goat
DSM
DSM
On the bright side, free trip to the Gobi desert! Also free goat.
Between Trainspotting and Requiem for a Dream, any desire I had to do anything harder than pot went straight out the window.
My roommate didn't know what Requiem for a Dream was about, just that it was good, he watched it while we were out one day, we come back to him just staring blankly at the tv.
@MorganThrapp sounds like you need to watch The Wolf of Wall Street!
@corvid That was a fantastic movie.
03:58
Wow, how'd you watch it so fast?!
Snort a few lines then watch it on fast forward.
It was better as Boiler Room.
Did anyone see The Big Short?
Not yet.
I expect to eventually.
It was fantastic.
04:33
ciao, good night folks.
Hi all, list.remove(x) through ValueError is x is not in list, is there some other function to perform same but it should not through error if value is not in list
05:35
@Ffisegydd Bands of Mourning just showed up on my Kindle.
The Witness should be out some time tomorrow too.
06:05
People, this is a must read for anyone who is using Amazon. Don't skip through it.
Can we pin that or something?
It's a problem with a lot of services, not just Amazon.
Really?!! I am scared of internet now :(
Social engineering in the old hacking definition of the term.
I always thought that customer service people would ask for the personal information. Why would they ask for the address?
I sshed to amazon ec2 running ubuntu and ran `#!/bin/bash
python -u twitter_script.py > output.txt &`. Now `ps` shows the python process. I exit the ssh connection from terminal and then log in again. Now `ps` no longer shows the python process. Though it is running as `output.txt` is getting updated.
Why?
06:22
Use ps -A, it's running detached from a tty.
How can I kill it?
You either nohup'd it or otherwise detached it from the session before exiting.
kill <procid>
ps doesn't show.
I am unaware of id.
Sorry, this is the Python room, not the remote server debugging service.
yeah, thanks for -A help though~
Is there any other option of python -u where it remains attached?
06:28
use something like supervisor to manage background services, don't try to manage this manually
any relevant questions to this?
@AbhishekBhatia unix.stackexchange could be of help...
06:43
@AnttiHaapala I never figured out the weird Jinja bug, just said wontfix in the end.
:-/
so could it be threading
maybe not
I don't think it was happening in any situations except "clever" reloading scenarios.
how about the other SO question
My guess was AppEngine had a similar clever reloader
the thing that I do not quite get is ... what exactly does it reload?
single modules?
because text_type there is a global variable in the markupsafe/__init__
I wouldn't expect that it could be disappear like that at all...
it only could happen whenever the module was already being unloaded
@thefourtheye that is the problem, there should be insertleft and insertright
Just insertLeft and insertRight?
or use negative for right inserts
but now thta I look at that bug, that is just plain b0rken
>>> from collections import deque
>>> d = deque(range(20), maxlen=10)
>>> d
deque([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], maxlen=10)
>>> d.insert(3, 'New')
>>> d
deque([19, 10, 11, 'New', 13, 14, 15, 16, 17, 18], maxlen=10)
#       ^   ^        ^--- The 12 got replaced
#       |   \--- The elements before the insertion point got rotated
#       \--- The final element got rotated to first position
Totally weird
@thefourtheye in any case, the idiocy here is that they did the insert at all
it is a new addition to 3.5
07:01
@AnttiHaapala Yup, after reading the bug report only I started checking :D
And I also feel that throwing an error would be better here.
again the python problem
someone thought that .insert would be nice, "ok let's add it"
To think of it, why would someone want to insert something in the middle of a "Queue"?
well...
there are some weird stuff out there... but
seriously, there are better algorithms and better structures for that
@AnttiHaapala you mean, there are practical use cases for inserting in the middle of a Queue/Stack?
well...
someone might think there is
say if you have a priority queue
and then you model it with deque :D:D
07:05
ha ha ha. We cannot help in that case :D
because "deque is 'a double-ended queue". - "I need a priority queue. A priority queue is a queue, deque is for queues, therefore I will use a deque for my priority queue"
Always use the right tool for the job, but if you are not sure, use anything you find ;-)
Java's Deque interface has four implementations
Hmmm, two of them are for supporting Threads
user559633
07:25
@JoranBeasley right now it's more just a pluggable API. the management stuff is coming soon
That link doesn't work, ssl error. I'll assume it's a joke about GNU/Linux.
Then I'll go to sleep.
You know the joke
rhubarb
good night
07:32
@khajvah Is there a text-only version?
Metroid is love, I really wanna make a game like it.
Thank you :-)
I really wonder how they put stuff like weapons in it, and time based things.
I wanna learn a functional PL
07:36
PL?
programming language
Train cbg
I am thinking Haskell but if I learn lisp I will be able to write Emacs plugins and get stallman's approval
Oh, I'm still a little new to programming, lol.
@MartijnPieters Cabbage :-) From where to where?
07:38
@thefourtheye Home to work.
Only downside to working at Facebook: I have a commute now.
@MartijnPieters You have internet in Trains? :O :O :O
But I work from home on Wednesdays.
@thefourtheye We don't. We have a mobile phone network.
Is it interesting to work in a company like Facebook?
And there are plenty of areas without a decent signal.
@khajvah Very interesting.
I am leaning towards startups
07:39
@MartijnPieters Ah, I was about to complain about India :D
Most interesting place I've ever worked at.
@MartijnPieters I would love to read a post titled "Python at Facebook" from you ;-)
@thefourtheye See the names on python.org/dev/peps/pep-0484?
Łukasz Langa is a Facebook employee.
Oh, awesome :-) So I assume FB also uses Python extensively
07:46
We do. We also use Mercurial (written in Python), with Matt Mackall working at FB.
Large parts of the infrastructure use Python. Data scientists here use Python. Data import uses Python.
Python is used as a configuration language, etc.
what is the actual web application written in?
Java?
@MartijnPieters amazing
user559633
I think Hack and I was about to ask a related question to if Facebook would be going to PHP7
user559633
@MartijnPieters What do you mean as a "configuration language?"
user559633
e.g. Setting runtime options and service coordination?
07:49
May be like Lua?
@khajvah Hack (PHP plus coroutines and type hints)
Attempts at moving from PHP to other languages failed (too much code to move), so the one weird outlier project to make PHP a decent programming language actually won out because it worked.
@tristan Scala's build.sbt file is actually written in Scala only
It is basically a build configuration file.
nice. That sounds great.
user559633
@thefourtheye I don't understand what you're trying to tell me
Sorry. I mean, Scala is used as a Configuration Language in its own Build configuration file.
user559633
07:54
@thefourtheye Sure, but Margin told us that they're using Py for a configuration language and I'm not sure where Scala comes into this
user559633
And no need to be sorry as I'm the one that's confused
@khajvah I hack on Mercurial (all Python), haven't done too much Hack hacking.
During bootcamp (first 6 weeks or so) they toss you in the deep end and give you some tasks to work on while you get to grips with the FB culture and infrastructure.
My Hack hacking was confined to that time so far.
@tristan Hmmm, may be even I am getting confused here. It might be like Django's settings.py, where Python is used as the configuration language
user559633
@thefourtheye Where is Scala coming from?
user559633
I think we might be referencing different conversations
07:57
I used Scala as an example
user559633
Oh! Okay. My understanding was that Facebook was a Hack/PHP shop, so I was wondering where Python would be used as a "configuration language"
Oops, then I totally misunderstood your question :D
user559633
I'm also looking at code that I haven't touched in a month and I woke up 30 minutes ago, so I'm also easily confused right now
Then its your Coffee time. Yay :)
Morning Coffees are awesome
user559633
08:04
@thefourtheye Yep, espresso with condensed milk time.
Yes, the import statement has been.. extended.
user559633
@MartijnPieters Weird. I do a similar thing for TristanProject, but I haven't customized import. Why modify the import statement?
user559633
Seems like something I'd want to do that teammates would have rightly convinced me not to do.
@tristan can't quite remember, just saw the import 'git.tw' line and remembered vaguely there was a reason to.
Ah, that slide may have oversimplified things.
the actual code would look like this:
importPython('common/strace.tw', '*')
user559633
08:10
Uh, okay. Still seems...smelly.
Because namespaces. Configuration files are not quite the same thing as code, there are features that are hard or impossible to express in plain Python.
You end up importing a lot of different things all the time; it is a balance between from numpy import array, narray, ...., *twenty more names* and from numpy import * and import numpy as np, I think.
Didn't study it in detail and there is too much legacy for me to start fighting those choices now at any rate. :-)
user559633
Oh. Namespaces for configuration files only. That makes me feel less weird inside.
The OP here is making me regret even answering.
@MartijnPieters Then the configuration file will be executed by Python interpreter?
@thefourtheye yes, so you can use code to generate the config objects.
08:18
What would be the end result? Configuration will be a JSON Serialized Python dict?
Grr, not enough wireless coverage in the current section of my journey to roll back and educate that user.
user559633
hell is knowing that a section of your codebase corrupts persistent data, but forgetting where
hell is not knowing that a section of your codebase corrupts persistent data :D
08:39
Using both sudo and rm is dangerous. Using both rm and * is dangerous. Use the three in the same command and a shark will bite you, or your files. — JB. Jul 8 '15 at 19:15
user559633
08:51
how to have fun with sysadmins: name files * and ..
You can name a file .. ?
user559633
only if you believe in yourself
You can name it * though
`khajvah@khazhak-work:~/test$ ls -al`
`drwxrwxr-x 2 khajvah khajvah 4096 Հնվ 26 12:57 .`
`drwxr-xr-x 67 khajvah khajvah 4096 Հնվ 26 12:57 ..`
`-rw-rw-r-- 1 khajvah khajvah 0 Հնվ 26 12:57 *`
user559633
I think you'd just have to do a syscall to name something just '.' or '..'. I think it's the shell that gives dots special meaning

« first day (1928 days earlier)      last day (3245 days later) »