« first day (1383 days earlier)      last day (3790 days later) » 
00:00 - 17:0017:00 - 00:00

00:11
it's been a while since I last pythoned
why is the output of this line print()
()
how is this valid syntax?
cbg
nevermind
@Vader I guess you're using 3.x ?
yep
there you go then :)
00:20
;)
 
6 hours later…
05:53
@Vader print() does print empty line in python 3
python 2 it prints (), meaining empty tuple
valid in both
since beginning
cbg cbg
06:27
cbg cbg cbg
06:58
' '.join(['cbg' for_ in range(4)])
07:09
Or, even better!
In [7]: def cbg(cbg=[]):
   ...:     cbg.append('cbg')
   ...:     print(' '.join(cbg))
   ...:

In [8]: cbg()
cbg

In [9]: cbg()
cbg cbg

In [10]: cbg()
cbg cbg cbg
Go forth my friends and cbg()
Perfect use case
:D
Default Mutable Argument FTW.
@AnttiHaapala Strange I would have thought that you'd need print(,) to print an empty tuple but after checking you're indeed correct. I always thought to get an empty tuple you needed the comma but okay.
07:33
Cbg :)
cbg all
08:35
@Ffisegydd comma needed only for 1-tuple
Ah ok, like ('str',)?
TIL...
08:50
ahha :d
no wonder nokia microsoft closed down oulu
"Oulu was indeed a major Android site for Nokia. Anyone willing to invest in Android ecosystem should consider setting up a shop here as it is possible to recruit entire teams, for any aspect of product creation, very easily now. "
 
1 hour later…
09:58
cbg
cbg @MartijnPieters
cbg @Martijn
well - that was clever of someone - have an automated system that checks for unread emails, looks for zip files, retrieves them, then puts the spreadsheets within them into a database...
apparently, someone's gone to that email account and managed to mark 3800 emails as unread - guess what the system's currently busy doing... sighs
Sounds a little like CargoLifter.
@JonClements :-D
Clever! Ahem.
The annoying thing is... I'm having to go through the code now, as it wasn't part of the system I designed... so I'm not sure if I can safely kill the updating process...
10:13
Ahhh sod it... I'll leave it running and get on with something else - late breakfast maybe... rbrb
Ahhh - nice - it's done 2010's emails.... getting a feeling this could take a while :)
Oi, I flagged that as Low Quality..
Ah, your edit auto-approved my flag.
okay, carry on!
auto-approved? :d
maybe he's using chrome with google translate :P
then it makes perfect sense to answer in the language he's writing :D
we had this problem with some crowdsourced sentiment analysis
ppl were supposed to label as spam everything that was not in englsih :D
so we got indonesian texts come through :P
10:46
Ummm.... can't find the invoice I just spent 5 minutes writing out
don't tell me I didn't bloomin' well save it
ahhh... just didn't save it in the invoice folder... sent now... woohoo... onto the next task.... sighs
11:21
hallo
can anyone tell how to get a socket object from a file descriptor?
@Evgeni Is the FD for a socket?
socket.fromfd() looks applicable.
yes
but the socket i have the fd for already exists.
won't it "hurt" to create a new one?
No idea; the documentation states the FD is duplicated.
/* Dup the fd so it and the socket can be closed independently */
fd = dup(fd);
if (fd < 0)
    return set_error();
s = new_sockobject(fd, family, type, proto);
i want to get the socket from a HTTPResponse object because I'd like to know the ports it is using
ffor the particular connection
Why not just call socket.getsockname() on that socket then?
11:33
i dont have the socket
but i can call HTTPResponse.fileno()
which gives me the fd....
which i hoped to use to retrieve the underlying socket
@Evgeni Sure you do: HTTPResponse.fp is the socket.
ick, that's a file object wrapper.
make that HTTPResponse.fp._sock.
woww
sounds great
thanks
gonna try
11:51
Question body is a coding challenge, posted verbatim.
HTTPResponse.fp gives a _io.BufferedReader which has no attribute _sock
@Evgeni Ah, I looked at the Python 2 source, just a sec.
Im sorry, forgot to mention it's python 3
3.4, to be exact
No, I understood that from your doc link
My mistake
Use HTTPResponse.fp.buffer.raw._sock then
Ah, no, not text mode.
So HTTPResponse.fp.raw._sock
It's a io.BufferedReader wrapping a custom SocketIO object.
success! :-D
thanks a lot
but one theoretical question: since it's not in public interface...it's "subject to change without notice", right?
so my program could break anytime?
12:10
It can, yes, but is not very likely to.
Or you can just duplicate the file descriptor. :-P
12:28
Cabbage all! :D
@Iplodman: cbg!
Well I screwed that up.
@MartijnPieters What have you been up to lately?
Hacking, more hacking and convincing people with money they want me to hack in exchange for their money.
Ooh, I see we have a L33T H4X0Rz here.
this is a leet haxors only room
12:35
And only so if you adhere to the jargon definition of hacker.
But of course.
Not to be confused with cracker.
@MartijnPieters That got me yammed off when I first saw that xD
Interesting that "cracker" has Middle English origins.
not that the Shakespeare example proves anything, since he wrote in Old Timey English, which is still newer than Middle English.
@Kevin Middle earthen is better.
If that's a thing - I'm not much of a LOTR/The Hobbit nerd.
12:38
Cracker, sometimes white cracker or cracka, is a usually derogatory term for white people, especially poor rural whites in the Southern United States. In reference to a native of Florida or Georgia, however, it is sometimes used in a neutral or positive context and is sometimes used self-descriptively with pride (see Florida cracker and Georgia cracker). == Etymology == The etymology of the modern term "cracker" is uncertain. One theory holds that slave foremen in the antebellum South used bullwhips to discipline African slaves, with such use of the whip being described as 'cracking the whip'....
Does "Middle Earth" imply that there are at least two other Earths on either side of it? Are we in Upper Earth or Lower Earth?
Western, middle and eastern, I thought.
@kevin Or it's a chronological thing.
@Kevin So I got me a Chromebook! :D
Good, good
I still need to install Ubuntu though.
12:48
> Middle-earth is not an imaginary world. The name is the modern form (appearing in the 13th century) of midden-erd>middel-erd, an ancient name for the oikoumene, the abiding place of Men, the objectively real world, in use specifically opposed to imaginary worlds (as Fairyland) or unseen worlds (as Heaven or Hell). The theatre of my tale is this earth, the one in which we now live, but the historical period is imaginary
Mystery solved, sort of.
@MartijnPieters look what you helped create! dl.dropboxusercontent.com/u/5482205/port_finder.py
it is suppoused to read the ports involved single in a connection
what wierds me out though is that the ports always match
Hi everyone
13:03
Welcome
Thanks, I'm new here
Does anyone here know django too?
@annabananana7 please see sopython.com/pages/chatroom
In particular: if you have a question then just ask it, don't ask if anyone knows a certain topic.
haha ok, saw my message in the first 5 secs
Our Django guys like to hide until they hear a question that interests them.
i'm trying to create a simple to do list: add item from input text, list the items below the input, save the list and then load the list on another page
I have all my webpage templates set up, I'm actually stuck at the python level rather than django
So I have forms.py, models.py, and views.py. I have buttons on my to do list to Add, Save, and Load the list. I'm not sure how I can code the buttons into views.py
13:44
Wait. What. Does anyone have any idea why calling sys.argv is erasing my source code? Powershell spits out some weird error about not being able to open the file and bam it's all gone. Thank god for git but still
sys.argv is not supposed to erase anything, no
Do you have an example of this self-erasing code? I would be interested in seeing it.
Would be nice to add to the Gotcha if it was simple enough.
Yeah... do we have a rule about pastebin?
Nothing forbidding it, no
13:47
I use it as my code sharing tool of choice, in fact
I'm guessing this code is supposed to compare two files whose name you provide on the command line, yes?
yeah
Ah yeah
sys.argv[0] is the name of your python file.
So you need sys.argv[1] and [2] for your "comparison files"
sys.argv's zeroth element is the program's own path, so [1] and [2] would be the first and second command line arguments.
LOL
okay so it's just like in C gotcha
I wasn't totally sure so I actually just went ahead and printed sys.argv[0] last night when I was working on it and I guess I didn't read carefully enough... ugh facepalming hard rn
I wonder if this also deletes the other files you're diffing. Would opening them in "r" mode instead of "w" work?
13:50
oh my god
Ah yeah that's true.
yeah
this is the sloppiest thing
forgive me friends
I might write this up as a Gotcha...
I was going to say "but you can discover this behavior by doing help(sys.argv)", but that only shows the documentation for the list class XD
True, but literally first sentence in the documentation for sys talks about that. Eh, it's such a basic C thing anyway lmao
13:56
cabbage
moin cbg
@Al.Sal sopython.com/wiki/2 and scroll down to the bottom :D
@Ffisegydd <3
code golf inspiration for sure
A bit of a troll thing to do in some code. At the end of the code delete the code itself.
"This code will self destruct at the end of the message"
14:00
Or have a bit of code at the bottom that iterates through the code and modifies what it does before then deleting the modification bit.
So it can't be traced.
version control trickery too... secret of course. Multiple layers of re-writing :O
"""This is the best code in the world. It's so awesome it can only be ran once... """
Reminds me of a flash game I played once. You start with three lives. After you use them, you can never play the game again. Refreshing the page, you'll just see the player character's gravestone.
And if you win, same deal, except it's the villain's gravestone.
14:21
That sounds familiar... but imagine if that happened for console games preteens would riot
You might be able to do that for cartridge-based consoles, but for everything else, they could always just delete the save.
DSM
DSM
cup of morning cabbage for all!
(assuming modern game systems don't hide game data from you in the cloud or something. I wouldn't know.)
Some modern games have so-called "hardcore" modes
Where if you die, you lose that character forever.
And obviously it becomes more and more intense as you get higher and higher in level as it's worth more of your accumulated time.
But at least they don't stop you starting a new character.
Which is similar to how D+D is I believe?
True. Minecraft has that. And true that for d+d, but I suppose a particularly sneaky person could record every game and "save" his character LOL
14:37
Ok, I'm still not getting this code right. I have my html form and buttons, I don't think I'm posting it properly
DSM
DSM
github's new style: do not like. True, I tend to dislike new things in general, but still.
Hello guys. I have written a python script. I want to add that script to the system path so that I can run that script as linux command (for example like ls) from any directory. What's the best way to do this?
@annabananana7 What makes you think that? Something not behaving as expected?
For anyone who has time this is very informative and entertaining.
Well, one of the comments on my question stated that my form needs to post to a URL. I added the code but I'm not sure if it's correct: <form action="/admin/" method="POST">
{% csrf_token %}
DSM
DSM
14:49
@sachitad: you have a few options. It's usually simplest to have a local directory where you store your tools and add it to your PATH.
Sometimes, I just need to let it out: github.com/mitsuhiko/flask-sqlalchemy/issues/…
@DSM: Thanks for quick reply. Can you give me a example or some resources for this? Thanks in advance.
@Ffisegydd This frustrates me because my confidence is sometimes measured in orders of magnitude. For example, for "how long does it take plastic to degrade?" I would like to reply "between 10^1 and 10^6 years", but the dragging tool won't encompass that range.
DSM
DSM
@sachitad: if your file is already executable w/a python shebang line (the #! line at the top), then the rest depends on what shell you're using. Google for add path to bash or add path to tcsh or whichever one you're using. You'll wind up doing something like adding export PATH=~/tools/:$PATH to a config file, but both syntax and what file to add it to depend on your shell and environment.
@Kevin it gets even more interesting, persevere.
Incidentally I was WAY OFF with the plastic bag one.
By an OOM or two.
14:56
@DSM: Thanks, yes it's executable: chmod +x file_name and I have #!/usr/bin/env python3 at the top. I am using bash shell.
Similar for "how many reincarnations has the dalai lama had?" Knowing nothing of that belief culture, it could be anything between ten billion and "trick question, the dalai lama is always a brand new soul"
@AnttiHaapala: yeah, yeah, but you knew what I meant and removed it. :-P
DSM
DSM
@Kevin: that one I actually could get within a few. (Just checked.) Read his autobiography once.
I actually got the Dalai Lama one bang on but I was unsure of my answer and so didn't get many points as my "area" was low.
14:58
hate the "post the answer first" :D
I wish there was a feature "this guy started writing the answer first" or something
Augh, almost perfectly nailed "bones in the human body" but got 0.001 points because I had "give or take fifty"
I got that bang on but again gave myself too much lee way.
I hammered the "age of the universe" one though.
Didn't even adjust the curve.
I knew that one was in the low tens
@Ffisegydd haha, beating you by 1 rep :)
DSM
DSM
Oh.. wow. I figured I'd give the game a go but couldn't get past the first stage. I thought it was a puzzle about which door was the front door. I know ecclesiastical architecture pretty well, so I couldn't understand why it wasn't doing anything when I clicked on it. I don't think I'm cut out for these puzzles.
15:00
@davidism see this is why I shouldn't downvote answers...
I think I've read enough Less Wrong to know generally what they're trying to teach here. Too bad I always skip the mathy portions, so I'm going to bomb all the practical bayesian reasoning questions.
Something something prior beliefs, something something integrating new data.
If I read too much Less Wrong at a time, I get in a very weird mood.
Which is probably more wrong according to them.
@Ffisegydd i stopped when it asks for gallons.... -_-'
Same. Especially when I read the article about "the piece of knowledge we're not allowed to discuss, because it's only harmful if you know about it"
(which I only mention here because it's not harmful if you merely know that such knowledge exists)
(unless you're the curious type and go googling it)
Let's see. with prior knowledge that event A is 40% likely, and B is 60% likely, but B is six times more likely than usual to happen on a cloudy day... Then B is 360% likely to happen in that case.
Hmm. Something's not right there.
@davidism you're beating me by 2 now as I found another bad answer.
15:06
No downvotes or bounties until I have my mod tools!
Seriously though, I should probably downvote more often.
I'm liberal with downvotes, especially when I see ones that annoy me. People handing out bad knowledge (especially on topics that I know about) annoys me.
DSM
DSM
Should we hammer this with the one from our common questions list here or is there a better one?
wtf
I got downvote on my dictionary code :D
:P
is it you, martijn?
hmm
Answered a question, getting two upvotes. Meaning I have now overtaken @davidism again and all is right with the world :D
@DSM hmmhm yes but it was not quite the right q to hammer...
@DSM, @MartijnPieters it was about how to have the template in class body and then have an instance for each, though I did answer in my comment
DSM
DSM
15:20
@AnttiHaapala: dict(self.info) only makes a shallow copy, though, so the OP could still get into trouble depending upon the dictionary values.
@AnttiHaapala Hrm? No, not me.
@AnttiHaapala I do think it is a duplicate of that one; it certainly answer the 'why is this' problem, as self.info is still being shared.
@DSM ofc.
I often use a comment to tailor the dupe answer to the specific question, like you did.
@MartijnPieters but he was trying to set the dict in the instance already, but didnt make a copy of it.
but yeah
only sometimes i worry the mighty mjölnir swings too fast :d
I can kind-of see what you mean, but the issues are still the same. It doesn't really matter if you stored another reference to the same mutable object.
I can just as easily un-swing it.
15:25
no need :D
Wheee, got my Most Effective FGITW query to work on Stack Overflow :-D
how come jonskeet is so enlightened? :D
do you remove your answers or? to keep up the score?
ah but it is about accepted +10, being the first...
DSM
DSM
select count(*) from users where lower(displayname) like 'stijn%': ?
my enlightened percentage would be 80 exactly, only 5 nice answers accepted :(
@AnttiHaapala He has a very high number of answers with score 10 or up that are accepted, and a corresponding high number of enlightened badges.
15:37
i think the enlightened percentage is not very interesting really :P
more interesting would be who makes the most reps
Nope, but in case people want to compare.
as I said, mine would be 80, more like out of all accepted answers, how many were enlightened...
Vote any of these up to help my ranking: data.stackexchange.com/stackoverflow/query/211360 :-P
DSM
DSM
My problem with playing with dse is that I have to construct very obscure queries before I even show up. For a long time I did really well in upvote/downvote ratio, but then there was a period where these random downvotes started showing up.
15:42
There, another enlightened for you.
@AnttiHaapala Ah, great. Bugger.
that is what happens when you copy an idea to martijn to try to outsmart him :D
@MartijnPieters actually methinks my rating dropped?
@AnttiHaapala You were the first with that accepted answer that was just upvoted.
The enlightened badge will be handed out soon.
is it? 3 at the same minute, saw only nice answer
Right after the 'nice answer' badge.
anw i think you got like 3 :D
so you need to tell ppl
15:45
It's a separate batch process that hands out the enlightends, it can take up to a few hours.
"if you want to thank more, then go and upvote questions on this list"
actually you oculd put it in your profile automatically :D
@AnttiHaapala :D
The search is stackoverflow.com/…
but enlightened reuqires first to answer
Yes, it's not guaranteed I was first with those.
I am for most; you can set the answer sort order by 'oldest' and see if I am.
Not that I am serious about this, people should totally not vote just because I have an obsession with obscure statistics.
Erm, corrected search is stackoverflow.com/…
C++ lounge at it again.
I should perhaps take into account if there are other answers on the posts.
That'd require a more complex query to count the number of answers and to see if the accepted was first, rather than count awarded badges.
16:17
I'm trying to load data from a DB to display in a list, does this code make sense?
<ul>
{% for todo in todo.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ todo.todo_text }}</td></tr>
{% endfor %}
</ul>
Sure, are you having a problem?
I'm having trouble writing the save code, actually
What save code? You posted a template loop.
pickle and json are some popular modules for saving objects to a file. Not sure if that's what you mean.
Just a sec, copying the code now
That's just a snippet of my whole views.py file. Do I need the loadList function if I'm loading it in the template?
You're asking two different questions. Loading and displaying the list has nothing to do with saving an item, they're separate views.
About to take my first venture in Python to sqlite. Did Oracle for five years a looooong time ago.
Oh, sorry, I am asking 2 questions
@aliteralmind go directly to sqlalchemy
16:26
First, do I need the loadList function if I'm loading/displaying my data into the template?
you need some view to render a template, and that view needs to query the database, so yes
typically I would have an index view and a create view
I have both
Would this code work for querying the data base?
class LoadView(generic.ListView):
model = Todo
template_name = 'todo/load.html'

def get_queryset(self):
return Todo.objects.order_by('-created')
sorry, indentation's off
stackoverflow.com/questions/25041658/… If I answered this level questions in PHP I'd have great answers all the time
class LoadView(generic.ListView):
    model = Todo
    template_name = 'todo/load.html'

    def get_queryset(self):
        return Todo.objects.order_by('-created')
@davidism Reading it now. A library to go between Python and sqlite3 (or any database it seems)?
16:29
yes, it is an extremely good library for working with databases and mapping queries to objects
it has a bunch of different layers, so you can drop lower if you need performance, but in most cases the high-level declarative orm is great
@davidism That's great. Starting with it today.
@annabananana7 don't ask us whether something will work, try it yourself and ask us if you have a problem or need to clarify something
I went through all the Derek Banas tutorials last night (newthinktank.com/2013/05/sqlite3-tutoria­l), which was a nice intro to sqlite3, and a great review of SQL in general.
It's been a long time, but SQL is not that deep, and it comes right back to you.
You can check out sopython-site to see how we use SQLAlchemy for sopython.com
@annabananana7 return Todo.objects.all().order_by('-created')
16:36
Ok, I'm trying to save an item in a to-do list but I don't think it's saving
@davidism Can you give a link to a good place to start looking on sqpython-site? Lots of source code.
@aliteralmind there is only 1 con with sqlalchemy
pip is a miracle.
after you have used sqlalchemy, every other orm in python will feel like crap
I don't know what you mean. "con"?
16:39
well if you have to do something with django, well you do not like it
you just wish "I want to import sqlalchemy here"
Hi Everyone, I am trying to configure setup.py. Everything is done from dependencies to licensing. One thing is remaining , I want to add that program to the path on bash shell. Is something like this can be done via setup.py?
@aliteralmind actually, that's probably not the best code to look at to get started. Check out SQLAlchemy's docs for a tutorial.
I have 3 buttons (Add, Save, Load) in my form and they all redirect me back to /todo/create but it's blank instead of the same page with content
@davidism Will do.
This is my output for pip install SQLAlchemy:
[R:\jeffy\programming\sandbox\python]pip install SQLAlchemy
Downloading/unpacking SQLAlchemy
  Running setup.py (path:C:\Users\jeffy\AppData\Local\Temp\pip_build_jeffy\SQLAlchemy\setup.py) egg_info for package SQLAlchemy

    warning: no files found matching '*.jpg' under directory 'doc'
    warning: no files found matching 'distribute_setup.py'
    warning: no files found matching 'sa2to3.py'
    warning: no files found matching 'ez_setup.py'
    no previously-included directories found matching 'doc\build\output'
Anything to worry about, regarding the C warning?
16:42
@sachitad yes
nothing to worry
only you did not get the speedups
@Antti Ok. Thanks.
@AnttiHaapala: what should I write in setup.py so that when the person runs python setup.py it automatically ads the program to path too.
      entry_points = """\
[console_scripts]
foobar = package.module:foobar_main
"""
@sachitad ^
will make the foobar command to import func "main" from package.module
and run it
will be in /usr/local/bin, or venv/bin or wherever
@sachitad setuptools will create a wrapper like
#!/foo/bar/baz/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pyramid==1.5a2','console_scripts','pcreate'
__requires__ = 'pyramid==1.5a2'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('pyramid==1.5a2', 'console_scripts', 'pcreate')()
    )
@sachitad remember to run the setup.py egg_info when changed
16:52
Well, that's silly. The "installing the C extensions" section says nothing about how to install the C extensions.
@AnttiHaapala: Thanks.
@aliteralmind installing the c extensions is automatic as long as you have a compiler, which you will on linux at least
00:00 - 17:0017:00 - 00:00

« first day (1383 days earlier)      last day (3790 days later) »