« first day (1992 days earlier)      last day (2939 days later) » 

1:59 AM
cbg
@tristan dang it man! I got really excited for SoPyCon when I read that....then I re-read it. :P :)
 
2:27 AM
Could someone help me out with this question...? stackoverflow.com/questions/36298512/…
 
Sorry about that then, really needed help and didn't read it before jumping in chat.
 
for what its worth, I typically use matrix math for that type of problem
 
2:44 AM
we're not allowed to use matrixes
def diagonal_conflict(board, r, c):
	while not (r<0 or c<0):
		r-=1
		c-=1
	while not (r>len(board)):
		r+=1
		c+=1
have that so far, if anyone could critique or help finish it
 
@Jessica Are you still here begging people to do your homework for you?
 
3:20 AM
They need a shirt with davidism's being a programmer quote - I'd wear it
 
When I run my code it compiles but nothing is printed :(
 
what code?
 
3:45 AM
Basically my teacher wants us to write a Mancala game in Python. We first had to write in Java, and now we have to convert it into python
This is my first time ever working with python so I may just be wrong completely with my logic
 
not what I meant - I saw all that in the transcript - I meant what code runs but won't print anything
 
It's still a huge work in progress! pastebin.com/eu7nk379
 
4:01 AM
you never call main
 
how do you do that?
 
add the following code at the bottom:
if __name__ == "__main__":
    main()
then you'll get the syntax error index out of range I bet
 
YES SIR! I DID HA
Traceback (most recent call last):
  File "hw4.py", line 69, in <module>
    main()
  File "hw4.py", line 12, in main
    printBoard()
  File "hw4.py", line 42, in printBoard
    print "\t{}\t{}\t{}".format(board[12], board[11], board[10])
IndexError: list index out of range
 
cause you define an empty list and then try to call an index in it
 
cbg!
 
4:08 AM
@JGreenwell and I believe I'm doing this function incorrect

def Bowlmoving(b):
beans=board[b]
board[b]=0

index=b+1;
while beans > 0:
board[index]+=1;
beans-=1;
printBoard()
index+=1
if index > 13:
index = 0
As I should be append
right?
 
your logic is wrong, honestly. I'm assuming board is meant to be a list of possible positions on the board (0-13)?
cabbage @idjaw
 
yes sir.
My java code works fine but the python one doesn't which was expected
 
if such you should first define the board's max size so change board = [] to board = [0] * 13 (which would create a list of 13 elements all 0)
 
I see. That actually got the board to begin printing. So let me ask a quick question
In java we do things like this
public static void moveFromBowl(int bowl) {
int numBeans = board[bowl];
board[bowl] = 0;

int index = bowl+1;
while(numBeans > 0) {
board[index]++;
numBeans--;
printOutBoard();
index++;
//reset index if required
if(index > 13) {
index = 0;
}
}
}

When we write in Python, a List(in python) is not an array and for that reason they are not fixed size. When we creat ea new list its an empty ilsit and we can add things to the list, and the length of it will automatically change with each thing we add and remove.
In order to add elements to a list in python we use .append() correct?
 
yes, think of Python's lists as Java's ArrayLists
hence the common name
 
4:21 AM
I see! I have been looking at them in an incorrect way this entire time!
 
okay, conceptually this code is a bit off...are you aware of Stacks (cause if I had to do this using lists I'd use it like a stack)
 
I'm enjoying doing it more than I did in Java
I guess it's because its a whole new animal for me
 
and I'd treat each space as a bin
 
4:55 AM
mounds of cabbage
I created a draft for the common question I brought up here yesterday: sopython.com/canon/98/typeerror-x-object-is-not-callable
and posted a pointer to it in this answer: meta.stackoverflow.com/a/320011/874188
any suggestions for taking this from draft to production?
the order of the linked questions is not what I would like but apparently they are sorted numerically and this cannot be affected?
in the excerpt I summarize callable as "function, method, or class" -- am I missing something obvious there?
 
5:23 AM
@tripleee thanks, I'll check this out tomorrow. I pinned it for others to look at.
 
5:40 AM
@davidism thanks!
 
6:06 AM
Hello everyone, I am new to Python. Don't have any experience now can you guys tell me the features of this technology?
 
@xeeB What languages do you have experience in?
 
javascript, java, c++
and also tell me as a beginner how should I start with Python?
 
with hello world

print("hello world")

ok, now you can go on to phase 2
 
Hello world its pretty clear print is a function which is taking string and then printing on the screen as it is, now print can deal with strings, characters, floats, and integers but it can not deal with Boolean values right?
it is same as console.log of javascript, System.out of Java, and cout of c++
 
Actually in python, it prints boolean values.
print(5==1)
will print False
 
6:14 AM
what will happen with this ---> print(true)
I know there is no as such use of doing this kind of thing but still we should have questions
 
it will output a variable named true. because boolean values in python are capitalised. So you probably meant
print(True)
Which will print True
 
@xeeB just try out
 
ok sorry for that mistake, i didn't know that true is in fact True in Python
I tried
 
Now will this work?

print("1 does equal 1" if 1==1 else "I lied")
Who knows? try it out.
 
6:17 AM
Wait
1 does equal 1
 
The first thing that comes to mind with complex numbers is electricity. But there's many other uses for it
 
Tell me about it.
 
@xeeB go google them
Frankly if you do not know what they are, you will not need them
 
@xeeB This is a python chat. Not electrical engineering chat
 
I can google, i know it but with discussions i can get the slight view of these things and then I can read about it just like in class Teacher gives us just the clues rest of the work we have to do
 
6:20 AM
Or math
 
Ok! lol
 
@AnttiHaapala True that.
 
But if something is related here we can discuss
 
Go pester people in math.stackexhange about complex numbers
It is not
 
but why we have them in Python of course there is a use
 
6:22 AM
garlic
 
@xeeB There's matrices in python. But unless you have a python specific question about it, then it should not be asked here
 
Ok thank you
I will be back with more research on python, then we can talk about it's features
 
@xeeB Sure.
 
cbg @AnttiHaapala
 
6:42 AM
@xeeB where Python code is typically 3-5 times shorter than equivalent Java code, it is often 5-10 times shorter than equivalent C++ code! Anecdotal evidence suggests that one Python programmer can finish in two months what two C++ programmers can't complete in a year. Python shines as a glue language, used to combine components written in C++.
 
Honestly Thumbs up I am really interested in Python I will start working soon.
 
Written in C ;)
C++ isn't straightforward to link against from other languages really
 
name mangling?
 
Well and everything. Basically at least the linkage is always "C" but there can be other issues
 
7:38 AM
Cabbage!
 
7:50 AM
@Arunex Pyth code is a lot shorter than Python
that doesn't mean anything really
@PM2Ring wow thanks. I will
 
hello guys why i get int size as 24 when i type sys.getsizeof(4)
 
@RockOnGom what do you expect to get?
 
in python everything is object what would be why it is 24 but this takes so much memory
 
8:06 AM
Mine says 14 (Python 3)
 
mine says 28
> so much
 
mine says 124
 
@Ilja yours won
 
mine says 24 :D
 
just a reminder that we have "infinite" precision integers
 
8:09 AM
>>> import sys
>>> sys.getsizeof(128)
14
>>> sys.getsizeof(1280000)
16
>>> sys.getsizeof(1280000000000000)
20
>>> sys.getsizeof(12800000000000000000000000000000000000000000000000000000000000)
40
Fun.
 
this ^
>>> a = list(range(-5, 1000))
>>> b = list(range(-5, 1000))
>>> [id(x) == id(y) for x, y in zip(a, b)].count(True)
262
>>> [id(x) == id(y) for x, y in zip(a, b)].count(False)
743
 
morning
 
or x is y
 
actually the size of int doesn't matter for my stuation, i have to keep lots of int in memory. for example 1 million number cost to me 1 million * 24 bytes, what must i do to deincrese the size of memory
 
use numpy
 
8:14 AM
numpy!
always use numpy;)
 
@RockOnGom I keep about that much in my application
 
ha ha thanks guys i will test numpy immediatly
 
and it stays there all the time
 
@RockOnGom also, if you have to "keep in memory" huge arrays or matrices, consider memmapping or that hdf5 thing
 
it's fine
 
8:16 AM
if they are really huge
 
mine uses 300 MB but it's fine
 
Also consider switching to Hadoop. It has the wifis.
 
but yeah, 1M * 24 bytes isn't that much
 
eventually I am gonna switch to neo4j for my graph
and solve every problem I have
 
i note memmapping to
 
8:20 AM
@AnttiHaapala you should've told the complex guy that the main use of complex numbers is numpy.mgrid[1:10:100j] as a shorthand for linspace;)
 
8:32 AM
@Ilja Note that such a usage of id can have dangerous side effects. You shouldn’t necessarily trust that output.
nvm actually. I was somewhere else.
 
@poke did you mean things like taking the id of subsequent temporary objects and thus getting the same id
 
yeah
 
been bitten by that :D
nothing serious, but was confused for a while
oh ffs, a colleague included ANSI codes for blinking text in a git commit message
 
8:55 AM
that's eval
 
9:06 AM
friends, there is any method to print an instance :
l_aux = libro.Libro(libros[indice_libro][1])
I need to print this l_aux
 
print(repr(l_aux))?
is repr() defined for that?
 
still show same output : <dbr.libro.Libro instance at 0xb154ae0c>
 
what did you expect?
you wanted to print the instance
<dbr.libro.Libro instance at 0xb154ae0c> looks like an instance:)
 
@poke well it took a while for me to notice the lists for a and b
 
ANW
9:27 AM
= Can someone answer this python-related? It has been more than 2 days since I asked it
and cabage
 
ANW
hi
 
nevermind
putting just scl enable python33 bash in a bash file should work without $(), right? what am I missing?
 
ANW
Yes, it works but the process spawns so the next script would not get executed.
 
I guess I should admit I don't know what scl is
 
9:30 AM
Why not use a virtual environment?
 
ANW
#!/bin/bash
scl enable python33 bash && python script.py
/opt/rh/python33/root/usr/bin/python3.3 script.py
scl enable python33 'python script.py'
@AndrasDeak ALl valid scripts, but won't work with bash ^^
@IntrepidBrit not sure if it would work, or how to use it..
 
@ANW Can you only use Python 3 after you do that scl enable thing? Can’t you call the Python 3 executable directly?
 
A virtual environment allows you to have multiple self contained python environments on a single system. Very useful if you have projects that require different versions of libraries installed
 
@poke yeah that's what I don't understand
 
(Should look at doing that anyway, even if you resolve your current issue)
 
9:34 AM
does the /opt/... thing not run/exist without scl enable??
 
> So, in a nutshell, it seem there is no way to run a python3 script via cronjob, if you have anything but python3 as default in your machine.
That’s just plain wrong, I’ve launched a countless number of cronjobs running Python 3.
 
ANW
@poke it can't be called directly, that is the problem. if you read the question I have explained that unless you call the scl command, the executable won't appear.
 
@ANW but does that make sense?
I mean, ls /opt/... finds nothing?
is it not just whereis that doesn't see it?
 
ANW
@poke it is possible to run python3 script via cron, but I would have to make python3 system default .. which means most things in centos won't work since for example yum relies in python2.7
 
have you tried without scl, with the full path to the python3 binary?
or just running /opt/.../python3.3 -V first
 
ANW
9:36 AM
[root@bt ~]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[root@bt ~]# scl enable python33 bash
[root@bt ~]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /opt/rh/python33/root/usr/bin/python3.3m /opt/rh/python33/root/usr/bin/python3.3-config /opt/rh/python33/root/usr/bin/python3.3m-config /opt/rh/python33/root/usr/bin/python /opt/rh/python33/root/usr/bin/python3.3 /usr/share/man/man1/py
@AndrasDeak check that .. you'll see the problem.
 
no, I don't
 
ANW
without running scl the python3 executable won't appear.
 
whereis doesn't tell me anything
read what I wrote
please
what does ls /opt/rh/python33/root/usr/bin/python3.3 return?
can you run it without scl called previously?
 
ANW
@AndrasDeak yes. I have that, that is even more complex problem to explain..
I installed it via yum and compiled python3.3 from scr, and did /opt/rh/python33/root/usr/bin/python3.3 script.py
 
and it works?
and doing the same in cron doesn't work?
 
ANW
9:39 AM
yes, and no
 
wtf
 
ANW
:)
Ok, I'll explain . :\
 
What user is running the cron job? Does the user have access to the executable? Does the user have access to the script?
 
I assumed it was root...
 
ANW
@poke Yes, I am running it as root, I even gave chmod 777 -R ..
oh, wait .. I'm logged in as root, but I don't know how bash is running it .. I assume it is as root.
I see no permission errors in the logs, so ..
I'm bound to believe this is not a privilege-related issue.
 
9:42 AM
Start with simpler things to ensure that the cronjob is correctly executed.
Start with a echo foo > /tmp/somefile
 
ANW
cronjob 100% working.
* * * * * echo $(date) >> /dir/to/py/scripts/foo.txt
it works, every minute.
tail /var/log/cron
^ shows no errors.
 
Then try /opt/rh/python33/root/usr/bin/python3.3 -V > foo.txt next
 
cbg!
 
for those interested in DjangoCon 2016 - here's the live streaming of the event 2016.djangocon.eu/live
 
ANW
9:50 AM
sorry my laptop froze
@poke there is a reason non-scl based use like that won't work. I have installed python3 via rpm, and compiled it from src and used the absolute path to run my python script and there is a slight problem with that
 
“there is a reason […] that won’t work” – Then what’s the reason, and why does this not answer your problem already?
 
ANW
oh, sorry forgot the important part, because, my script.py requires MySQLdb, and requests if I logged in manually via scl enable python33 bash I can dopip install MySQL, pip install request and launch the script as simple as python script.py but with the /opt/rh/python33/root/usr/bin/python3.3 script.py I can only execute the scripts, without being able to install the required modules for it.
 
/opt/rh/python33/root/usr/bin/python3.3 -m pip install MySQL requests
I really don’t understand your problem…
 
ANW
wtf!!
I can install modules like that???!!
 
Every Python installation comes with its own module collection. So if you want to make a PyPI module available for installation X, of course you need to install it with the pip that belongs to the installation X. And the safest way is to call the pip module of executable directly.
 
9:59 AM
@iulian cheers
 
Alternatively, you could probably also do: /opt/rh/python33/root/usr/bin/pip3.3 – The executable should be set up that way.
 
ANW
let me fire up linux, and check this out now. I can't waait.
 
Hi i am parsing a xml using Lxml module and it has Chinese characters,so after parsing i am getting junk characters
-1
Q: How to parse Chinese character while parsing using lxml

Navin DalalInput xml contain text such as 孫爾媃 對 盧靜及其他 SUN ER JO,When i am parsing this xml using lxml these Chinese character are coming output as invalid characters?Below is my code. from lxml import etree as le import os import random import re def randomgen(): x=random.randrange(1,10000000) re...

 
Hello !
Anyone here know how to use Regex ?
I have a simple thing to do but I don't find how :(
 
Oh dear lord @tristan. Do not watch the DjangoCon live feed right now. You might blow a gasket
 
10:05 AM
pythex.org visit this site
 
@Addict Don’t ask to ask, just ask.
 
Sorry @poke first time here.
 
Then you might want to read sopython.com/chatroom first :)
 
@Addict for making new regex visit pythex.org
@Addict shot your question
 
[{id:0,},{id:1,},{id:2,},] Here is the typical scheme of a Line that I need to parse. I need it to be a valid JSON. Does anyone can give me the regexp that achieve this if it's a simple one ?
Thanks @poke, gonna read this once i'm done with this issue that's stucking me in my project since 2 days
 
ANW
10:08 AM
@poke do you know what this error means?
 
And thanks for your link too @NavinDalal !
 
@Addict Why don't you let the python json library do the validation for you?
 
@Addict reading the rules takes 5 minutes tops, I'm sure you can squeeze it in:)
 
guys, can I do zip on all elements if the iterables are of different sizes?
 
In [678]: zip([1,2],[3,4,5])
Out[678]: [(1, 3), (2, 4)]
is this what you mean?
 
10:10 AM
@ANW Looks like the library is missing or not found, search for the error on SO, there are a few results that might help.
 
@IntrepidBrit Because I'm using NodeJS actually but no one is able to answer RegExp questions on the dedicated Channel (for both NodeJS and RegEx rooms).
 
@Addict Note that that links contains the rules for our chat room. You are expected to know them when you’re here, so it might be a good idea to read them first instead of having the possibility that you violate them by accident just because you want to solve your problem first
 
@AndrasDeak I had read the rules (And i Like fluffy animals), that simple rules :)
 
@AndrasDeak I also want (1,5) and (2,5)
 
The JavaScript room is responsible for Node.
 
10:12 AM
@khajvah I don't understand what you exactly expect
why (1,5) and (2,5)?
why 4 elements in total, for instance?
 
@khajvah What about (1,4) then?
 
ok you are right
wait
nevermind, I need something else
 
itertools.product?
 
itertools.combinations?
 
That's where i was @poke but my question is about a RegExp in general not specificaly nodeJS. [{id:0,},{id:1,},{id:2,},] is invalid JSON, and I can't change this output (It's given from a device) so I need to parse it with RegExp but I'm totally newbie to this.
 
10:15 AM
@Addict So, you’re doing JavaScript, and are trying to use regular expressions within JavaScript, and then you come to the Python room? I don’t understand this chain of thought. – I mean, I don’t mind helping you with regular expressions here, but still, why come here?
 
No one was able to helping me on the Javascript channel and since my question is not specifically about JavaScript I tough I could ask for a Regexp here too.
 
@Addict I'm with @poke on this one. Anyhow, I don't think using regular expressions is the way to go. Why not use a dedicated json solution, which will be better at catching edge cases?
 
RegExp works the same for both JavaScript and Python right ?
 
(Why not use something like: github.com/natesilva/jayschema)
 
@AndrasDeak this seems to be it, thaks
 
10:19 AM
@IntrepidBrit This is a Json validator ? That's looks nice i'm testing this :)
 
@khajvah no prob:)
 
(I wasn't able to use JSON.parse since my JSON was not valid.)
 
@AndrasDeak itertools is magic. love it
 
it is:) I've never used it, but it is:D
 
@Addict Use this: json5.org
 
10:23 AM
That's looks like what I need @poke, I'm checking.
This actually works like a charm, thanks !
 
cabbage
Map of Current room members :)
 
Rao's haxxing my computer! Quickly, someone fetch me more tin foil!
 
lol :D
 
Serious question - do we need to send out a rescue party? Someone seems to have drifted out to sea...
 
That's Mauritius
Oh So that's you @Intrepid who shows up in the middle of UK ;)
 
10:35 AM
Ah, that makes for a nice change. I used to appear in the middle of Devon.
 
@BhargavRao Based on what data?
Location in user profiles?
 
@poke Yep.
 
Are there that many people from Germany here, or is my shadow just stronger?
 
@BhargavRao Huh. Thought Mauritius was further North. TIL...
 
@IntrepidBrit Maldives is the one that is further North :)
@poke Most probably there are others
 
ANW
10:39 AM
Hm, now I know why people are reluctant to use python3.*
it's a real PITA
 
You’re just making it a PITA.
 
ANW
Nope, trust me ..
 
I'm the only one in France \o/
 
@poke this must look nice out of context
 
ANW
I'm close by @Addict
 
10:41 AM
Where are you from @ANW ?
 
@BhargavRao thanks!:)
 
@ANW No. Trust me, who has been working productively with Python 3 for seven years.
6
 
ANW
Romandie
 
Switzerland !
 
@BhargavRao it can't be, I don't have a location set, yet there's a marker in Hungary
 
ANW
10:42 AM
@poke I think it is bad for beginners, but for experienced developers .. maybe that's different. I have never spent 4 days trying to fix a problem to no avail.
 
unless there's a countryman of mine here
 
ANW
@Addict Oui!!
 
Isn't it geoIP?
 
@AndrasDeak Maybe someone else from Hungary is here ..
 
You're on the french part ?
 
10:43 AM
so who's the sneaky Hungarian?
 
@ANW Your problem has literally nothing to do with Python 3. Your problem is only a problem with your operating system, and your application setup. Please stop trying to fault Python 3 for your complicated and untypical system.
 
ANW
I have to rewrite my code now which I have been working on for 4 months, to make it v2.7 compatible instead of 3.*
 
why did you not write it against 2.7 to begin with, if that's what your system is limited to?
 
ANW
@poke Ok.
@Ilja people in this room advised me to use 3 instead, which I regret very much now .. but that's life .. :\
 
heh:D
so it's @poke's fault rather than python3's;)
 
10:45 AM
they gave you sound advise in general, your case is not general
 
ANW
I didn't even know there was a big difference between 3.3 and 3.4
[root@localhost py]# python
Python 3.3.2 (default, Aug 14 2014, 14:25:52)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json, MySQLdb, time, datetime, os, sys
>>> exit();
[root@localhost py]# /usr/bin/python3
Python 3.4.3 (default, Jan 26 2016, 02:25:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json, MySQLdb, time, datetime, os, sys
 
that's not inherent to python version
 
Again, has nothing to do with Python 3.
48 mins ago, by poke
Every Python installation comes with its own module collection. So if you want to make a PyPI module available for installation X, of course you need to install it with the pip that belongs to the installation X. And the safest way is to call the pip module of executable directly.
 
it is your installation of <insert python version here> missing the module <insert module here>
 
ANW
@Ilja It is not actually missing a module, just that there is no module for it .. at least in this case.
[root@localhost py]# /usr/bin/python3 -m pip install MySQLdb
Collecting MySQLdb
  Could not find a version that satisfies the requirement MySQLdb (from versions: )
No matching distribution found for MySQLdb
that is for 3.4 but for 3.3 there are no issues.
 
10:49 AM
 
ANW
I can install mysql module with no hustle.
anyway ... time to remove those parenthesis now ..
 
by install you don't happen to mean import?
@ANW from __future__ import print_function
 
But print() works in python2... does it not? Or am I misunderstanding?
 
ANW
The way I understand it, you have to install (pip install x) module before you can import (import x from y) .. @Ilja
 
@ANW yes, you have that correct, but what you miss is that the module name may differ in places like pypi from the name you import
at least when I just tried installing module "MySQLdb" in my python2 virtualenv, no such module was found
 
10:52 AM
> MySQLdb does not support Python 3 but it is not the only MySQL driver for Python.
 
@AndrasDeak print(x) in Python 2 actually is print (x) where x is surrounded by parentheses. This is usually not a problem if x is just a simple expression. It becomes a problem if you do print(x, y) though. In that case, Python 2 reads it as print (x, y) so you are printing a tuple. – You can import the print_function though, and then you’re fine.
 
the weird part is that it can be installed in 3.3
@poke ooh, nice, thanks
I've never printed (x,y), so good to know
nice pitfall there
 
ANW
@AndrasDeak yes, that is what is weird, now my fear is if I try to install other mysql client will my code break ..
 
@ANW should it?
 
ANW
Well, given the track record .. I'm probably certain it will.
 
10:55 AM
stackoverflow.com/questions/36287738/… why suggested code ignores last element in the list?
 
Then use a virtual environment for that project
 
(or, more accurately, all python projects)
 
@XuMuK what suggested code?
 
It might save you some suffering in the long run
 
oh @XuMuK you mean the answer to your question
 
@AndrasDeak yes
But I take as answer because vim works perfectly
 
@ANW though it does not work with Py3, the "MySQLdb" module is named "MySQL-python" in pypi, so that's one of the many reasons your pip install ... did not work
 

« first day (1992 days earlier)      last day (2939 days later) »