« first day (1603 days earlier)      last day (3362 days later) » 

7:00 PM
ok now
it decrypts too, and encrypts a file :D
I think they deserve best grades if they understand how that works
in any case, runtime performance ain't going to be the worst :D
@JonClements extend collections.abc.Mapping
@MattDMo can't think about filter for anything :D
 
oh well, I guess not everything can be functional...
 
mhmh
if you can tihnk of a fast function that accepts any argumetn and always returns true or false
then I think we can use filter here
*truish
hmmm :D
id :P
ah but of course
python 3 write returns truish value and python 2 falsish
so we can use filter there and no need to use a deque
 
where's my kebab... hungry
 
super now :D
I used filter to hide the difference between python 2 and 3 :D
and all can be used to consume the caesar iterator since I am not mapping to the return value of output.write
@MattDMo happy? :D
 
perfect :)
 
7:10 PM
err... well, I was thinking for these assignments we should provide a completely practical, and documented code base, not massively obscured
sure, they'll end up way out of grasp for a GCSE student and learners, but it'd be usable and useful to others
 
@JonClements what is so obscure about my code? :D
 
Well, if it takes me nearly a minute to grok what it's doing... (and I'd like to thing myself reasonably okay at Python), then god help anyone else :p
 
hmm
so what should I do :D
 
Rewrite :D
 
damnit :D
 
7:18 PM
well... I'm going to have a kebab, put a film on and have a beer, enjoy the rest of my Saturday, and try not to think about the 14hours work required tomorrow
Randomly clicked on "Species 3" - might be interesting
bought the first two on DVD about 15 years ago...
no doubt it's going to be shite... but... that'll do nicely for now - a brain numbing, dis-believable film is sometimes welcome
yup - 15 mins in... this is going to be a shite film
 
ok done :d
 
the only plus side so far is that it's streaming in HD, which works well on the TV
 
@AnttiHaapala I see what you did there :D
 
7:33 PM
@JonClements do you like it better now?
 
umm, just reading up on some stuff on the other screen
I was taught at school there were 3 states of matter - solid, liquid and gas
appears there's at least 4, most likely 7 states
 
there are now 2 versions on the wiki
I actually tried to make that as efficient as possible :D
 
Hi :)
I have been working with Flask and are learning MySQLdb atm but i think its hard to combine / work with MySQLdb and Flask together. Should i find a other lib like SQLAlchemy for Flask or something?
 
In a multithreaded program, a Producer produces N number of tasks and M Consumers are processing them. And each of those consumers produce O number of tasks and processed by the same M consumers. Now, how will I know that all the data is processed and terminate the program?
 
my starmap does not work...
@Emyen yes
@Emyen and afaik mysqldb is about dead
 
7:47 PM
@AnttiHaapala I noticed that, hehe ;P
 
it has been "python 3 will be supported in a future release" for 5 years
iter_input = iter(input)
input_tee = tee(iter_input)
return starmap(table.get, zip(zip(cycle(key), iter_input), input_tee))
i tried this but it just yields twice?
any ideas
should match (key, input), input as args to dict.get
 
@AnttiHaapala when I'm forced to - I find pymysql reliable enough
and it's pure Python... so slightly slower than something linked with the mysql client libs, but ultimately, that's never my bottleneck anyway, so not concerned about it
 
yeah, in a project setup that contains MySQL it is very obvious where the bottleneck is ;)
how does starmap work?
@JonClements hmmh
@JonClements what is wrong with my starmap??
it just yields 2 chars
that is:
starmap(table.get, zip(zip(cycle(key), iter_input), input_tee))

vs

map(lambda k, c: table.get((k, c), c), cycle(key), input)
 
hey guys I have a quick numpy question for ya
I have a np.array with shape of 480x600x3
 
8:02 PM
an image
 
I was to turn this into three 480x600 values
how do I do that?
Yes
 
channel separation
 
well actually a frame of a video
 
my numpy-slicing-fu is not very good
isnt it c1, c2, c3 = [ frame[..., i] for i in range(3) ]
at least
 
@KronoS seems like you should just reshape to remove one index, so that you have an array of 3
 
8:10 PM
>>> x.shape
(480, 600, 3)
>>> y = x[...,1]
>>> y.shape
(480, 600)
 
Which will create a copy
you can shift the axis and view the array differently without doing so
 
yeah
but it will always be slower :D
hmm
except if you indeed shape the array and acces it like that
 
May I ask a question regarding non-BMP character, re module, narrow and wide build?
 
yes, but answer is Python 3.3 :D
 
Yes, I know the answer to all this madness is Python 3.3
 
8:18 PM
@AnttiHaapala you can .reshape() to a new object, that will be a view of the existing array - so only strides/indexing changes - not a new copy
 
@JonClements but cache locality will be bad
 
Does re module interpret u'[\U00010000]' as character class of 1 character in wide build?
 
why? creating a reshaped copy, with its indices, is far worse than creating a new shape with those indices...
 
IF you use u''
then they are interpreted outside re
unicode escapes that is
 
that's where I think you are wrong
Unicode escape are recognized in raw unicode string
 
8:20 PM
*are not
>>> re.compile(ur'[\U00010000]').match(u'\U00010000')
<_sre.SRE_Match object at 0x7fe1e45bd440>
so I guess the answer is "yes"
 
@AnttiHaapala Please add anchor
> Python 2.7.8 (default, Jul 28 2014, 01:34:03)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ur'\U00010000' == u'\U00010000'
True
 
>>> re.compile(ur'^[\U00010000]$').match(u'\U00010001')
>>> re.compile(ur'^[\U00010000]$').match(u'\U00010000')
<_sre.SRE_Match object at 0x7fe1e45bd440>
>>> ur'\U00010000' == u'\U00010000'
True
>>> len(ur'\U00010000')
1
narrow build I do not have and I don't want to have
 
@AnttiHaapala Yup, my point
 
anyway, for anything with unicode, python 3.3+ is bliss
 
@KronoS might have got this slightly wrong, but new_view = your_ndarray.reshape((3, 480, 600))
 
8:24 PM
@AnttiHaapala Thanks for the test
 
you have narrow or wide?
guess cygwin is also wide
 
I uses narrow build, the one that comes with cygwin
 
>>> re.compile(ur'[\U00010000]', re.DEBUG)
in
literal 55296
literal 56320
<_sre.SRE_Pattern object at 0x200f4b58>
 
>>> import sys
>>> sys.maxunicode
1114111
:D
 
8:26 PM
Is that from your cygwin?
 
>>> re.compile(ur'[\U00010000]', re.DEBUG)
literal 65536
no
mine
hmm, I didn't know how a narrow build behaves, I am living on linux so I have no idea at all :D
(thank god)
 
Narrow build is like another Java
or JavaScript
 
or another windows :D
 
^What was the version you were testing on?
 
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 
8:37 PM
sorry guys... just got a call... BRB
 
8:59 PM
@MattDMo don't think the OP "installed" numpy at all
 
@Antti I'm kind of thinking that, too. I'll have them move C:\Python34\numpy to a different directory and see if that changes anything. If it doesn't, I'll just point them to Gohlke's repository and have them install Numpy from there.
 
the error means that
the numpy.__config__ is not importable
because in the numpy source tarball there is no __config__.py
I cannot find any directory in /usr/lib/python2.7/dist-packages/numpy where I couldn't import numpy
 
9:13 PM
you were right, when he moved the numpy directory elsewhere he couldn't import numpy from IDLE at all. I pointed him to Gohlke and gave him detailed instructions, hopefully that'll work.
 
9:27 PM
on a side note: does anyone else play bridge here?
 
no
what's that ;)
(well I know)
 
my aunt and uncle are serious bridge fanatics. I've never played, though...
 
haven't played in a while, but I enjoy it, trying to find a regular partner ;(
Bughouse chess (also known as Exchange chess, Siamese chess, Tandem chess, Transfer chess, Double bughouse, Cross chess, or simply bughouse or bug) is a popular chess variant played on two chessboards by four players in teams of two. Normal chess rules apply, except that captured pieces on one board are passed on to the players of the other board, who then have the option of putting these pieces on their board. The game is usually played at a fast time control; this, together with the passing and dropping of pieces, can make the game look chaotic and random to the casual onlooker; hence the name...
also want to start playing ^^^ again
 
Air
Anyone from this room happen to come across this post in a queue? Not sure if it's still open because weekend, or?
 
@Air didn't see that one - it's got my cv now
 
Air
9:39 PM
I think the author only read the "I disagree" part of my comment =/
Or else I'm missing the /s tag
 
:D
yeah, your comment was a total woooosh
 
Air
Probably for the best, it's kind of a bitchy comment
 
you may remove your comment now :D
the post is closed
 
Air
@AnttiHaapala I'll let the roomba take care of it.
 
@Air kewl, didn't know about argparse4j
 
Air
9:49 PM
LOL - neither did I
 
not that I'd have had to do a command line app in java for ages
 
Air
That was actually one I came across in the new helper queue
It was such a soft pitch that I went ahead and wrote up the answer
I haven't done anything in Java since taking a really terrible college course that used it... eh, 6 years ago maybe?
 
hmm... :D
 
@Antti what are you proposing?
 
op overwrote sum = 0
8
Q: 'int' object is not callable when the object is a list? Python

Matt PhillipscoinCount = [2 for i in range(4)] total = sum(coinCount) This gives me TypeError: 'int' object is not callable I don't understand why because print type(coinCount) Gives me type <'list'>

@AnttiHaapala you are right, I mistakely put sum=0 above — Micheal 2 mins ago
 
Umm.... dubious
 
why?
I edited the title on that target
Thanks so much guys — Micheal 1 min ago
 
closed as dupe - edit the post to include that comment that sum = 0 was somewhere, otherwise it doesn't quite work
 
10:11 PM
so :D reopen and then hammer as a simple typo :D
 
Air
Can't hammer as typo, typo is an off topic reason?
 
haha yes
sadfjkalskdjfaslkdf
that's what you get when the op can't ask questions
 
Air
How'd you come across that argparse4j question, anyway? Just browsing? I can't remember if I took off the python tag from it or not
 
just headache
just looked at your profile :D
@JonClements I do not know how to edit that sum=0 there...
the code does not even run :D
ok edited
  csvstr = str(csv).strip("b'") :D:D:D:D:D:D
0
Q: Downloading CSV files in Python

KamsterSo I am trying to download stock data using the code below from urllib import request #Download all daily stock data for firm in ["SONC"]: for year in ["2009", "2010", "2011", "2012", "2013", "2014", "2015"]: for month in ["01","02","03","04","05","06","07","08","09","10","11","12"]: ...

 
@AnttiHaapala bah... I reopened that Q... washing my hands of it now... not sure what the OP is going on about
 
10:20 PM
@JonClements whyy?
I did write the sum = 0 there
By giving minus to the questions, and mark it as duplicate, you are preventing the users from asking and getting help, my account is blocked right now! – Micheal 2 mins ago
ASkljfdjsadflkjsfadglkjsdf
 
OP's insisting it's not... blah blah blah blah... can't be bothered... blah blah blah
 
it was the perfect dupe
and even in the dupe target the op didn't want to show the code where the 'sum' was assigned, and it too was int, not even a float :D
my question, many users can get help from it
incorrect, that is how the dupe works
@JonClements exactly this new question is useless without the dupe :D
no one can even find it by the title
 
wow... this OP fluked this one: stackoverflow.com/questions/28920719/…
 
@JonClements there was a very good reason why that user was question banned :(
-1
Q: extra [] causing error of ValueError: Wrong number of items passed 2, placement implies 1

MichealI'm trying to measure the distance between two points in an array. I think I figured what the problem is : The C are returning like this, (an array) : [[-19.08173391 -8.28166174] [ 22.13375001 -10.90110121] [ 12.62966486 19.36313534]] But I want it like this: [[-19.0748, -8.242], [29.10...

:(
 
Air
10:36 PM
@AnttiHaapala Ah, of course... and I checked and it wasn't the one I was thinking of that was tagged [java] [python] to begin with, that must have been another question
 
@JonClements I am vtceing your "fluke"
bc there is actually no apparent reason why the original code should fail (except duplicates)
ah but I understood :D:D
sry :D
tired
 
Air
I haven't been doing much with Python recently, mostly banging my head against an Oracle database that our IT people refuse to maintain to our requirements but also won't give us enough access to maintain it ourselves. But I have been looking into Pyramid and it is next on my to-do list to play with.
 
Air
Heh, I thought I remembered you singing its praises some weeks ago
 
I worry that it might die
 
Air
10:44 PM
Oh okay then, I'll just use Django :P
 
:D
not like that :d
I started looking porting django on top of pyramido
I realized that again django is not much more than pyramid + orm + admin + templates glued together
but all of it is a big unmaintainable mess that does not obey any good python conventions
 
@Antti it's why I prefer flask/pyramid
too much at once with django... for some sites - it's absolutely perfect and quick and easy
 
all of the stuff does some import time trickery and requires that the whole lump of putty is loaded with x, y, z...
 
flask with sqlalchemy and a login is pretty much all I need to build on
 
pyramid would be ideal for under django
because of the extendability, I started looking at it
but then I again realized how horrible mess the django actually is
 
10:50 PM
I've always preferred jinja2 for templating
and always preferred sqlalchemy as an ORM
 
I prefer tonnikala
for templating :D
 
for a quick off the shelf site, that works in a way django does, I can't fault django
it's ORM is simple, it's templating is simple
 
it never is a match for anything that I do
 
it's just that it's a huge whack of code that takes hours to track down something simple
I like flask/pyramid because they're more bare bones, and you build up and add
 
but the thing is, I again realized everything is in pyramid
but in django everything is made in such a complicated manner...
like "how to write this in most lines possible"
for example the "django middleware"
 
10:52 PM
5
Q: How to re-use Django Admin login form from custom LoginRequired middleware

Jon ClementsBackground & attempted code: I'm using Django 1.6.2 (on Python 3.3) and would like all views to effectively have the login_required decorator applied to them and re-use the actual admin login form. Note that the admin app will also be in use with the default urls. I have looked at Redirect to ad...

 
it is so very complicated and adds lots of procesing to the ingress
 
I spent hours looking into that
and the answerer, also spent hours going through the code base
added it to flask the other day in about 5 minutes
 
pluggable apps :D
pyramid has the best pluggability really
 
maybe it's me... I know django has a lot of stuff... but what it is called, what module is it in, will it work with xyz? I don't wanna spend a day trawling through docs... :(
 
thanks to the config mechanism, it really can work at a config file level
 
Air
10:55 PM
@AnttiHaapala That is why I decided to try starting with it, after reading up on the options.
 
@Air for example I did integrate pyramid with raven, with my tet_raven, so one does not need to even modify any code at all; you can have your app in a zipped egg, just change the deployment .ini file
and of course you can change the code, but it is amazing how well it works even without changing the code
@JonClements docs.djangoproject.com/en/1.7/topics/http/middleware this is so complicated
 
bah... not sure why I answered that question... but it's a useful example of heapq and random
 
haha you got a downvote :D
 
wooo hooo... my first downvote this year I think
 
the problem ofc is that yours is O(n) with bad constant
if the number of lines is known
@JonClements voted for dupe
 
11:02 PM
Given a file with words per line.... you could guess an average word length and seek into it
then find the next line or something
 
mmap it
 
hello
 
:D
hello
 
is some1 in the mood for something something :D
have some issues
 
@Anak1n omg... hope you've not come here to inform me I'm your father or something? :p
 
11:03 PM
something like that :)
 
@JonClements I do not understand why the downvote, damnit that heapq usage is so clever and all
 
have some headache with python and can seems no one can help me :/
 
@JonClements you could put N there :D
 
so i;m on the hunt for python expert
 
maybe then it would be happier :D
@Anak1n congrats, you found a room full of experts
 
11:04 PM
@Anak1n please take a moment to read: sopython.com/chatroom
those are the rules for this room... spend a moment, read over them please
 
ok thank you\
 
@JonClements I guess @Anak1n is @Vader before turning into the dark side
 
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 2776))
socket.setdefaulttimeout(1000)
lista=[0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x01, 0x70, 0x61, 0x76, 0x65, 0x6c,0x00,0x70, 0x61, 0x76, 0x65, 0x6c,0x00,0x00, 0x00,0x01,0x01,0x00]
sock.send(bytes(lista[:]))
list2 =[12,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01]
sock.send(bytes(list2[:]))
print(sock.recv(100))
second send is never invoked
and can not get the reason why not
 
what does it mean "never invoked"
 
use the force Luke
program is finished before 2nd send
 
11:07 PM
cannot be... would crash with error.
 
no error
but it don't write 2nd time and it should
 
cannot be. (also do note that [:] there is completely useless and superfluous and what not)
 
ok i will try with for
 
you add a print('here i am') before and after the 2nd send
 
if i add print\
 
11:09 PM
it is a different thing to not send, and to crash and to exit etc...
 
after 1st send
and after 2nd sent it will print
that is the strange thing
 
so it did not exit.
only send is failing
you should use sock.sendall
your timeout is too low
socket.send(string[, flags])

Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. For further information on this concept, consult the Socket Programming HOWTO.
you did not check the return value
thus use sock.sendall
 
same
just tried
 
what do you even mean that the second is not sent
how do you check that?
 
have server
 
11:13 PM
TCP is a streaming protocol
you wrote it?
 
it should return enquirer link or display that it is sent to him
nop bu it works
just give me a moment to read the link you posted
 
Not sure that's a suitable dupe target - it shows how to use random.choice on a sequence, not a file or iterable. — Jon Clements 9 secs ago
 
so who wrote that server, if it has the same kinds of mistakes of not checking return values etc :D
 
strange thing
if i tell socket.connect(("localhost",2776)) after first send
then it is ok
 
yes:
because you are thinking you do 2 recvs
but you get both data in 1
 
11:16 PM
i don't need to receive i can run the code without receive and it acts the same
 
on the server.
 
on all smpp servers not just mine
tested mine with java and it is working
so it is not server related issue
 
then you need to reconnect after ...
 
I'm new to the python and it is hard for me to find what is causing the error is it python itself or something in my vcode
 
or you didnt terminate your msg properly
99.9999 % probability it is your mistake
 
11:19 PM
i know but when doing the same thing with HTTP it works o.O
if i reconnect the i will need to reconnect every time and if i send for example 100000 messages i need to reconnect xxxx times
*then
 
i know there is api for smpp
there is also api for java
but there is no fun in that :)
 
prolly not 3 though :(
 
i did my own implementation of 3.4 protocol and it is working in java and i wanted to give it a try in python but i stack on this and can not move one
 
sorry cannot help much more, but at least: socket.sendall and check the return value of other calls
 
11:24 PM
anyway thank you guys for trying to help me appreciated
 
does the java work for persistent conns
 
yes
flawless :)
 
you did not close the socket at the end
nagle's algorithm at play?
try adding
socket.shutdown(how)

Shut down one or both halves of the connection. If how is SHUT_RD, further receives are disallowed. If how is SHUT_WR, further sends are disallowed. If how is SHUT_RDWR, further sends and receives are disallowed.
shutdown_wr after the second msg sent
(without connect)
 
11:57 PM
hello
 
"hello"? What word is that... me no understand
 
:P
 
salad you speak not?
 
this question has been revised many times, adding more requests stackoverflow.com/questions/28921049/…
 
@Jon I'll translate - "cabbage"
 
11:59 PM
:-(
 

« first day (1603 days earlier)      last day (3362 days later) »