« first day (1390 days earlier)      last day (3783 days later) » 

04:05
print keyword.kwlist
^^ shows the list of keywords. But how i get the doc for particular keyword.
particularly the doc for in keyword.
HI @Faheem...
 
2 hours later…
06:07
i'm having a problem using pysftp in python3.4, i can only update files that require less than 3 or so seconds to update, after this time i am getting no uploading traffic on my network, i can download fine, and connect and upload properly using filezilla, however with pysftp i am getting this weird behavior,
06:39
I have a problem with installing pip2. I want to use PyDrive that has been writed for python2, and I can't install PyDrive on python2 with pip install PyDrive.
What error message do you get?
Does PyDrive support python 2?
cbg all
Yes it does. I get this error : paste.ubuntu.com/7967813
You're using python 3.4?
Yes, My default python is 3.4. But I want to install PyDrive for python 2.7
06:48
Are you using a virtualenv?
I tried to use virtualenv. But I couldn't. I get same error again
this is my question in site : stackoverflow.com/questions/25138213/…
You have installed python 2 right?
Yes I have:
habibi@habibi-All-Series:~$ python --version
Python 2.7.6
Type which pip into bash
/home/habibi/ENV/bin/pip
07:03
Type which python into bash (just to check)
/home/habibi/ENV/bin/python
Yeah ok. Well if you use pip (not pip2) it should work fine
No idea why it wouldn't
(ENV)habibi@habibi-All-Series:~$ sudo pip install PyDrive
Requirement already satisfied (use --upgrade to upgrade): PyDrive in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): google-api-python-client>=1.2 in /usr/local/lib/python3.4/dist-packages (from PyDrive)
Requirement already satisfied (use --upgrade to upgrade): PyYAML>=3.0 in /usr/local/lib/python3.4/dist-packages (from PyDrive)
Requirement already satisfied (use --upgrade to upgrade): httplib2>=0.8 in /usr/lib/python3/dist-packages (from google-api-python-client>=1.2->PyDrive)
Don't do sudo pip
Just pip install
yes, it worked. But now error chaged:
Traceback (most recent call last):
File "upload.py", line 1, in <module>
from pydrive.auth import GoogleAuth
File "/home/habibi/ENV/lib/python3.4/site-packages/pydrive/auth.py", line 160
except socket.error, e:
^
SyntaxError: invalid syntax
07:07
Well that's a SyntaxError and is something to do with your code.
But it's coming from pydrive
Ah yeah good spot.
Wait… That should be valid in python2.
And it's still coming from python 3.4
@MohamadMehdiHabibi start again. Deactivate and delete your virtualenv.
Then re-make one, making sure you select 2.x as a python version
Then activate it and install using pip, but don't use sudo pip install, just use pip install
the result of : which pip is /usr/local/bin/pip. is it deactive?
how can i delete it?
07:11
Type deactivate to deactivate a venv
It looks now like you've deactivated it (based on where your pip is)
would anyone recommend using waf for python 3? pyinstaller should be releasing a python3 version around the end of the month, not sure if i should wait or
07:27
$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python3.4/dist-packages
Cleaning up...
habibi@habibi-All-Series:~/ENV/bin$ source activate
(ENV)habibi@habibi-All-Series:~/ENV/bin$ which pip
/home/habibi/ENV/bin/pip
(ENV)habibi@habibi-All-Series:~/ENV/bin$ pip install PyDrive
Requirement already satisfied (use --upgrade to upgrade): PyDrive in /home/habibi/ENV/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): google-api-python-client>=1.2 in /home/habibi/ENV/lib/python3.4/site-packages (from PyDrive)
Requirement already satisfied (use --upgrade to upgrade): PyYAML>=3.0 in /home/habibi/ENV/lib/python3.4/site-packages (from PyDrive)
Unfortunately I have to leave for work now. @MohamadMehdiHabibi as I said I suggest you start again, deactivate your venv and delete it (literally remove the folders). I don't know how experienced you are with Python but I'd suggest you go read some tutorials/docs on virtualenv/pip etc as you're doing something wrong and it's not obvious what you're doing wrong from what detail you've provided.
@Ffisegydd thanks alot. NP
It looks like you're using a python3.4 virtualenv. Don't forget that without the virtualenv pip uses python3.4.
I use this to install virtualenv: pip install virtualenv. is it wrong?
You should be using pip2
07:42
finally, it worked. I should use python2.7 when create virtualenv :stackoverflow.com/questions/1534210/…
08:00
cbg all.
@Jon Tim replied with an answer
 
2 hours later…
09:47
In our thrilling series "shitty stdlib code" season 3 opening episode: datetime exceptions:
for i in range(20, 100, 20):
    try:
        datetime.datetime.utcfromtimestamp(2 ** i)
    except Exception as e:
        print(type(e), e)
this is sheer idiocy:
we cannot have iso 8601 parsing in the datetime module, but the breakage
Changed in version 3.3: Raise OverflowError instead of ValueError if the timestamp is out of the range of values supported by the platform C gmtime() function. Raise OSError instead of ValueError on gmtime() failure.
@AnttiHaapala What is that supposed to do?
so now we can deduce WHY the timestamp fails, but it does not help us at all. (the error is: too large)
and I joined #python and it was a mistake, again
10:03
Heh
@AnttiHaapala what is your timestamp?
@Azd325 the case there is: if year is larger than 9999 then you get ValueError
if you put in a string you get ValueError
if you put a timestamp that results in an overflow from mktime you get an OSError
and if you put in a timestamp that is larger than the time_t you get OverflowError
so to convert a timestamp to utc datetime on python 3.3+ you need to do
    try:
         result = datetime.datetime.utcfromtimestamp(ts)
    except OSError as e:
         raise OverflowError("Too Big") from e
    except ValueError as e:
         if not isinstance(ts, (int, float)):
             raise ValueError("Probably not a proper argument")

         raise OverflowError("Too Big")
10:21
@AnttiHaapala ahh now I see
10:51
Cbg
Found a Python 3 fork of the Vowpal Wabbit wrapper here
There's still some issues with the code though so I'm going to make a PR this evening. Using 2to3 doesn't catch everything.
user559633
Hi@u @odaialghamdi ^______________^
i asked about running code in the background of flask app without accessing to the page
user559633
One of our technicians has received your post. Please expect a response in 24-48 hours.
10:55
alright then
user559633
[not really, what's going on?]
@tristan while you're playing with your bot both this and this may be of interest to you.
i googled and found something called flask-celery ? would that help ?
SmokeDetector is the bot that lives in the Tavern and it uses ChatExchange to work.
Both are written in this sexy little language called Python THAT YOU MIGHT HAVE HEARD OF.
user559633
Oh neat @Ffisegydd -- will check it out when building the stack plugin.
user559633
10:56
I fuc...fudging hate Python right now
user559633
@odaialghamdi make a post on stackoverflow. that question is really vague and i can think of a dozen approaches that don't require celery or something internet aware.
Sorry, we are no longer accepting questions from this account. See the Help Center to learn more.
user559633
Did you see the help center? Did you learn more?
don't want to :p
sure i did
10:59
Do you have a lot of deleted questions with low score?
user559633
so why is SO not accepting questions from your account?
nah
dunno :(
user559633
do you create and delete questions?
Well you've done something to trigger the warnings. And you've got to do it repeatedly to get to the fully "no more questions at all"
user559633
11:01
well, that check is there to keep us from getting annoyed by repeated bad questions, so you're doing something.
In any case, you shouldn't be using chat as an alternative to the main site just because you've been banned from asking questions.
user559633
anyway, since we're all being honest here @odaialghamdi, you should run your flask application and pass code back to a module that runs in a while loop so that it's not stopped/disturbed by requests from the front end.  e.g. in your main flask module:

from worker_file import calculate_data
...
calculate_data()

and then in worker file, make a function that's called calculate_data that looks like:

    def calculate_data():
        while True:
            ~your code here~
            return result_variable
user559633
Oh, sorry, big mistake there
user559633
def calculate_data():
    while True:
        ~your code here~
    return result_variable
user559633
11:09
you want the return outside of the while True so that it doesn't accidentally stop work early
i sometimes hate indentaion
How to override BasicAuthentication https://github.com/toastdriven/django-tastypie/blob/master/tastypie/authentication.py#L77 in right way?

I need only to add:

if not user.is_superuser:
return False

in is_authenticate() method.
user559633
yeah. python is a decent language, but the whole whitespace thing is stupid and i can't wait for it to go away (maybe in python 4?)
user559633
but that's like 10 years from now, so until then i just try to ignore the dumb whitespace thing
I should copy the entire class?
user559633
11:20
None of us know what your code looks like @mamasi
@tristan: This is original BasicAuthentication class github.com/toastdriven/django-tastypie/blob/master/tastypie/… I only need to change is_authenticated method to: dpaste.de/OekV (I marked my custom code).
user559633
o...kay. And what does your user object look like?
Is developers.google.com down for y'all too?
user559633
No @OllieFord
@tristan :( I'm getting 500'd
user559633
11:31
do you need something right now @OllieFord? i could uh... screenshot? copy/paste? something for you
@tristan Ah thanks :) Nothing urgent/specific though, just need/want to browse!
user559633
No worries buddy :)
user559633
11:46
quiet room this morning
user559633
Hi @BenjaminGruenbaum
I actually haven't done any Python in weeks, probably the longest I haven't touched it in the last few years and I'm getting a mac and going to use two other languages on that.
Anything new in the Python world?
user559633
In the past weeks or years?
I haven't touched it in weeks. I've been using it at least every week for the past few years.
11:51
cbg
user559633
Oh. Uh let's see
user559633
2.7.8 came at the end of June, 3.4 got asyncio in the stdlib
2.8 was announced and 3.x suspended.
user559633
pycon proposals are due next month if you want to be a speaker
user559633
@Ffisegydd yes, in the alternative reality in which we get what we actually want
12:02
this guy probably needs some kind of byte-packing solution for his serialization problem. So, uh, if anyone knows about that, have some easy points.
I don't suppose bytearray has a simple serialization method?
user559633
eh
user559633
you can use struct
user559633
also, good god storing that data in a pickle
@tristan I need to stick with pickle.. — CosmicRabbitMediaInc 15 secs ago
Hooray, stating requirements with no apparent rationale!
user559633
12:09
hah just saw that @Kevin. Good god.
user559633
I have to use pickle because I've already invested in writing those 3 lines
user559633
it's absolutely essential that all of my ints have methods, even in storage!
They might forget they're ints and come out as lists!
I'll give them the benefit of the doubt and go with "it's beyond my control, because of my boss/teacher/weirdly controlling spouse"
user559633
no way.
user559633
12:13
it's totally "i did this already so just change the universe around me while i sit"
My weirdly-controlling spouse always makes me use pickles :'(
A roast in the oven every day at 6, and absolutely no bytearrays in the house!
user559633
my weirdly controlling spouse is russian, so i avoid pickles because russians love pickles, but suck at making them. like the american midwest and beer.
user559633
also, i'm betting on "just spit an answer into my maw that involves using Pickle" on that Q because of his crappy variable names
I propose that "WCS" now be used as the shorthand for significant others.
user559633
12:17
/me votes in favor
Too late, the acronym was snatched up by a silicon valley startup the moment you brought it into existence.
user559633
I propose that "turnip" now be used as the shorthand for WCS
Aaaand Web Comptroller Spectrographs, Inc. has been sold to Facebook for a gorillion dollars! Congrats, WCS.
user559633
Webscale Computer Socialmetrics
It's social, and it's metrics. What's not to like?
I had a terrible idea yesterday to create a module where I could do import foo; for bar in foo: #do stuff
However I think this may be impossible, which is probably a good thing.
12:24
As I tell corvid regularly: Nothing is impossible if you believe Kevin...
I tried def __iter__(): for x in whatver: yield x inside foo.py and it didn't work
Naturally, I gave up after one attempt.
Ok, pickle guy has to use pickle because it's the only way to interface with the script he's feeding his data to. This is reasonable, more or less.
I guess there's nothing left to do but write an answer containing "you didn't do anything wrong, pickle just makes bloated files"
I haven't done so because I expect he'll only be satisfied with a detailed rundown of why pickle makes bloated files, and I can't be bothered to go source diving today.
user559633
yeah
user559633
i started that path kevin
user559633
and made some test cases and then decided that it's not worth wasting my morning explaining something to someone that doesn't care
user559633
12:40
wait, does pickle.dump append or just overwrite?
user559633
output=open('data.pkl','wb')

pickle.dump(trainimage,output)
pickle.dump(validimage,output)
pickle.dump(testimage,output)
mmm, it appends I think
I never dump more than one thing to a file, but I've seen people do it before so apparently it works?
How bout that comet probe? Woo, space!
> For me this is the sexiest, most fantastic mission there's ever been.
I am writing a python script to read semantic information from shell scripts. How do I use NLP to achieve this ?
Not for me, though. I still like the Huygens probe better. Mmm, the only images from a planetary surface beyond Mars and Venus...
For example, i need to put the following semantic info into an array...
pconsole:
stack_hard = 131072
data = 1280000
data_hard = 1280000
12:47
data = """stack_hard = 131072
data = 1280000
data_hard = 1280000"""

d = dict(line.split(" = ") for line in data.split("\n"))
print d
#result:
#{'data': '1280000', 'data_hard': '1280000', 'stack_hard': '131072'}
Thanks kevin.. I think it will help.. also, there are delimiters like ":" and tab with insane number of blank spaces b/w key & value.. eg. IP address : 192.168.1.1
(lot of blanks before 192.168... so how do i read that)
@user1058322 have you looked into any tutorials or the docs for string manipulation?
You can remove spaces from the beginning and end of a string using the string's strip method.
@Kevin I agree. (and beyond our moon)
@Ffisegydd yea.. but this is kind of handling raw information in the file line by line. @Kevin, thanks !
12:53
Not sure if "beyond" there means "other than" or "past the orbit of", but either works I guess
@user1058322 it's still string manipulation.
(First world problems) : Using travis-ci.org is great but because I use numpy/matplotlib it takes me 5 minutes to run the tests :'(
user559633
my favorite part of the pickle question (i've answered, FWIW) is that he just pulls 4bytes out of nowhere
well, three bytes for the float, plus one byte for the comma between floats... Voila! Four bytes.
user559633
(everyone go vote up my answer, etc :P)
user559633
sure, but even ints are objects.
13:00
Oops, floats aren't three bytes. sys.getsizeof(1.0) returns 24 and I divided by 8 for no reason.
Sorry everybody. Sorry.
user559633
because C++ ;)
user559633
i know why you did it kevin and i still love you
Maybe getsizeof returns the number of bits, you can't tell unless you read the documentation ;_;
user559633
yeah, i don't really like getsizeof
user559633
comes from sizeof in c, which returns bytes
13:03
I don't trust it anyway. How can it accurately determine the size of my homebrew LinkedList class instance? Is it smart enough to follow the next_node chain to the end?
And if my PlayerCharacterSprite class has a reference to the GameWorld instance, is it smart enough to not follow it?
user559633
I'd have to fire up dis to be sure, but I think that it can because the LinkedList object is self-contained
user559633
if you're checking the class obj itself, it will tell you the size of the obj/attr/methods/whatever
>>> sys.getsizeof(float)
872
that's a big numbah
user559633
if you're checking the instance, you're looking at the class obj that gets copied + any instance variables
user559633
13:09
there's no rep in answering involved questions.
codementor cleint suggests after hearing that I have a code snippet
user559633
i'm going to just vomit answers to css questions
that I can send it offline and be paid outside codementor ... not.
user559633
tell him that you only accept payment via interpretive dance off of codementor (minimum 3 costume changes)
13:10
yes
Sounds suspicious. Without a mediating party, it just becomes "Give me the money and I'll give you the stuff" "No, give the the stuff and then I'll give you the money"
but now he/she booked a session so we will see
Then an exciting shootout scene occurs.
user559633
I've been told by a client "we'll pay you when the code goes to production"
user559633
13:12
while it was ~~~*totes adorbz*~~~, lol no.
or how about "We, the G. Inc are developing a new product called G.M. We will reward you generously when the product is out of Beta"
If "production" is the nickname for the server that only the developer has control over, and the client has no way of downloading files from it or even looking at it, sure
user559633
also fun @AnttiHaapala
"I can only pay you in equity. It's in the cloud."
user559633
^^ even better when it's someone that wants to be the founder of a startup and offers you a percentage
13:18
"You're only writing the code, so I think 0.0001% is fair. Think of the payoff if Google buys us for ten billion dollars! You'll make thousands!"
"What, you don't think a ten billion dollar buyout is likely? I don't know if I want to work with someone who doesn't believe in our vision"
@Kevin I have 5 % of 0 :P
I have a list. Example: [6,7,8,8,6]
and I want to convert it to: {6:[[0,4]], 7:[[1]], 8:[[2,3]]
Is there a nice way to do it? I'm already writing it in a long and procedural method but perhaps there's some more compact method.
Where did that 4 come from? Also, all the other numbers.
Or I should better ask a question a the site?
are they... indexes?
13:30
The 0,1,2,3,4 are the indexes. right
I could write a one line solution for this, but I wouldn't call it "compact"
I'll do it anyway, though.
seq = [6,7,8,8,6]
d = {key: [[idx for idx, value in enumerate(seq) if value == key]] for key in set(seq)}
print d
#result: {8: [[2, 3]], 6: [[0, 4]], 7: [[1]]}
applauds
Warning: O(N^2) run time
Use a default dict, it won't be one line but I think it'll be O(N)?
DSM
DSM
Cabbage, all.
13:34
yeah
DSM
DSM
@Ffisegydd: yeah, grouping is usually listcomp O(N^2), groupby O(N log N), defaultdict/setdefault O(N).
@Kevin wow and thnx.
The lists will be tiny so that's not an issue, probably.
Just because I've already written it out:
from collections import defaultdict

a = [6,7,8,8,6]

d = defaultdict(list)
for i, v in enumerate(a):
    d[v].append(i)

print(d)
# defaultdict(<class 'list'>, {8: [2, 3], 6: [0, 4], 7: [1]})
Now do it so it gives {8: [[2,3]], ...} instead of {8: [2,3], ...}.
@Ffisegydd Thnx. It's slightly different output but still. I'll have to read up on the collections
13:39
It's still a dictionary, just prints slightly differently.
You could do it with a regular dict, it would just take an extra two lines.
DSM
DSM
If you use setdefault it will take the same number of "core" lines (and one fewer import, although I tend not to care about stuff like that.)
cabbage
Hi
how can I specify user-agent header field with urllib.request.urlopen()?
I mean I know, it has to be passed with the data attribute
but in what form?
the Request class which is an abstraction over this function has a separate header attribute
but the function itself does not have one..
13:51
Not sure. Whenever I use urllib, I'm happy with whatever user agent it specifies by default.
:)
But I'm not happy now ;)
Isn't requests meant to be better than urllib?
umm.. what do you mean? requests itself is a submodule of urllib
DSM
DSM
I don't use it much, but I thought the pattern was that you built a Request, and then called urllib.request.urlopen with that request as an argument.
162
Q: Should I use urllib or urllib2 or requests?

Paul BiggarIn Python (2.5), should I use urllib or urllib2 or requests? What's the difference? They seem to do the same thing.

13:54
@Ffisegydd oh you mean that one..
@Peter: You can specify the User Agent field yourself, I guess
I'm sure I can do @mi5t4n -- the question is how off :)
@PeterVaro I think they covered this in the documentation
a={'dst':'http://hotspot.broadlink.com.np/status','username':'milano','password':'apple'}
headers={'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/html','Referer': 'http://hotspot.broadlink.com.np/login',
'Host': 'hotspot.broadlink.com.np','User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
'Connection': 'keep-alive'}
conn=httplib.HTTPConnection('hotspot.broadlink.com.np')
conn.request('POST','/login',params,headers)
@thefourtheye I'm not sure if it still exists in Python 3
although it is mentioned in one place in the doc -- but I will try that
thanks
@mi5t4n umm.. I'm still using ur lib.requests.urlopen()...
DSM
DSM
13:59
I still don't understand why you don't just make a Request, which accepts headers, and call urlopen with that.
@DSM yeah, well, probably I will do -- but since that is an extra abstraction layer on this function
I thought I would pass the header myself
DSM
DSM
It's not really an extra layer, as if you don't pass a Request, the first thing it does is make one:
    def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
        # accept a URL or a Request object
        if isinstance(fullurl, str):
            req = Request(fullurl, data)
        else:
            req = fullurl
            if data is not None:
                req.data = data
@DSM ahh, seems/sounds nice -- I will try it then!
thanks
Hi everyone, can anyone help me with scons?
Okay
I want to read something using input_raw, and based on that I want to make a decision
user559633
Okay, and what do you have so far?
user559633
Code.
14:29
The problem is that scons is changing stdin and I cant read from input_raw
give me a time
just a second
This is very simple scenario:
input_raw is wrong by the way, it's raw_input
while True:
    input = raw_input('> ')
    if input=='q':
        print 'bye bye.'
        os.kill(os.getpid(), signal.SIGTERM)
this is a part of my code
Oh ok you've used the correct one in your code.
the problem comes from the time that I am using scons to run this
this is my command to run the code:
What is scons? scons.org ?
14:32
#This simply run the code
sudo scons runweb --sim --simCount 5
Yeah
its a tool like "make"
I face this error when I run it:
enter 'q' to exit
> Traceback (most recent call last):
File "bin/openVisualizerApp/openVisualizerWeb.py", line 429, in <module>
input = raw_input('> ')
EOFError
when I ran:
echo "q" | sudo scons runweb --sim --simCount 5
my program started and exited
Can't help you sorry, I have no idea how scons works or what it does to your stdin.
hmm
first codementoring
past
client was indian in kansas city
@BenjaminGruenbaum You're here too! :) How are you :)
cabbage everyone
14:38
cbg
@MostafaShahverdy doing well, how are you?
@BenjaminGruenbaum same here :)
Did your university problem work out?
cbg all
@BenjaminGruenbaum Nope... that professor is a sh..t
user559633
"SCons is a very well thought out python based replacement to make. "
user559633
There is a software that I'm working on, it is not my decision to use SCons,
user559633
fwiw: inputor shadows of other built-ins is a dangerous game
14:49
But not the most dangerous game.
That is, of course, man.
man is a game?
(Except in the 1985 Most Dangerous Game cup, when "Caribou" won the title)
user559633
mangame is either the game of being a man or like the "hustle/chase" of dudes
@Kevin you missed up your pill intake again today? :p
@Jon BRIIIIIIIAN!
14:50
@Ffisegydd STEWIE!!!!!!!!!!!!!!!!!!!!!!
DSM
DSM
Has anyone actually read the original story? That's one of those that I only know exists because of the phrase and the story's many descendants.
@JonClements To uphold proper scientific enquiry, each day I'm taking the pills in a different way to see which is most effective.
"Snugly fit pills in nose" is today's method. Results are mixed.
@DSM I think it may have been assigned reading in high school for me.
I distinctly remember the ending.
@Jon Tim posted an answer (not sure if you got my ping from earlier)
@Kevin well... let us know when this experiment concludes and we can analyse the chat transcript to see which Kevin's the least weird :)
14:53
But mostly I know it from the parody version done in Dexter's Lab.
@Ffisegydd I did yes... a fairly generic one... but at least he did post an answer :)
DSM
DSM
I remember it from high school too. Summers were fun. At least for the survivors.
user559633
i knew my pickle answer wouldn't be accepted because it's not what the asker wanted to hear
@DSM oh... your high school did Battle Royale competitions? :)
All of my high school friends had a different English teacher than me, so we can't reminisce about mutually shared summer reading lists :-( They had Where the Red Fern Grows, I had The Giver.
14:57
Of Mice And Men <3
And Flowers For Algernon. What's with these mice-related books?
Umm.... any of those pop-out books that don't have too many words?
I'm feeling somewhat left out
DSM
DSM
Do any non-Canadians read Who Has Seen the Wind in school?
Gulliver's Travels may as well have had no words, because I skipped reading it! heyoooo
@MostafaShahverdy :/
14:58
@DSM Not me.
Get the large print, dogs have bad eyesight.
We studied Macbeth as well. And "A View From The Bridge" (which are both plays but meh)
I read an annotated Macbeth, which explained all the dirty jokes. A helpful guide, that.

« first day (1390 days earlier)      last day (3783 days later) »