« first day (2217 days earlier)      last day (2747 days later) » 

12:17 AM
hello guys it is my first time here
is it ok to ask how to do things here ?
 
user559633
welcome. i'm here all the time.
 
user559633
@FaisalJulaidan of course! check out the room rules first though sopython.com/chatroom
 
hello tristan
 
user559633
hey
 
do you know how can i accomplish this in python with list comprehension [1,2,3,4,5,6,7,8,9] >>> [ [1,4,7] [2,5,8] [3,6,9]
i did it like this but i think there is more efficient way
shuffled_deck = [[], [], []]
for index, card in enumerate(cards):
if index % 3 == 0:
shuffled_deck[0].append(card)
elif index % 3 == 1:
shuffled_deck[1].append(card)
else:
shuffled_deck[2].append(card)
cards is a full list such as [1,2,3,4,5,6,7,8,9] in the example i gave
if you want more explanation plz ask
 
DSM
12:24 AM
Are you familiar with Python's slice notation? Do you know what x[::3] does?
 
yes
it mean form 0 to the end 3 steps
 
DSM
Do you know how to convert a normal for loop to a list comprehension, and vice versa?
 
i know yes not all time time like in my case
:(
 
DSM
Then remember that you can change where the slice starts:
>>> cards = [1,2,3,4,5,6,7,8,9]
>>> cards[0::3]
[1, 4, 7]
>>> cards[1::3]
[2, 5, 8]
If you make a loop using that idea, you should be able to convert it to a list comprehension without too much trouble.
 
well, the list comprehensions is it the most efficient method to do what i want ?
 
12:31 AM
It doesn't really matter.
 
tell me if there is more efficient and quicker way
i want less lines
 
This really sounds like homework. Maybe it's time to apply what you've learned a bit?
 
that is what my teacher looking for in this homework XD
lol
 
Yeah, we're not going to help you. If you're having trouble, ask your teacher for help.
 
DSM
Efficiency and brevity are very different things.. but I think I've given a pretty good hint. :-)
 
12:32 AM
Thanks guys OK
 
I don't think I'll ever understand why people who are paying a bunch of money (or otherwise expending resources) to go to University don't actually want to take advantage of the environment provided to them.
 
user559633
availability of TAs and convenience of internet, i think
 
DSM
#soreadytohave247officehours
 
did it
f = [1,2,3,4,5,6,7,8,9]

l = [ [f[0::3]], [f[1::3]], [f[2::3]] ]
:D
 
Uh, no, that's not a comprehension, but whatever.
 
12:36 AM
ya it ok
it is
 
What if you want to deal to 4 people.
 
he said just do it
 
user559633
Weed legalized in MA. #imwithherb
4
 
CA too.
 
what do you mean david
 
user559633
12:36 AM
@davidism Oh man. Maybe we should give that space exploration game another look
 
What if you want to divide the values between X groups?
 
Immm i dont think i got what you want
 
Lol, I tried picking it up again after a month, it was still completely awful.
 
what you mean*
 
DSM
NMS?
 
user559633
12:37 AM
:[ i just want to bounce around in a space world where javascript programming doesn't exist for a few hours
 
Yeah
@tristan haven't watched it yet, but PreRec was playing Everspace, which looks cool.
 
DSM
I think the Python room ranks both in ejections and in RLM linkage..
 
user559633
@davidism Will check it out in a minute. Hoping it's exploration and not combat based.
 
user559633
@KevinMGranger Red Letter Media youtube.com/user/RedLetterMedia
 
12:44 AM
I think there's both.
 
user559633
Hooray :D I've been trying to get the GF into video games. Overcooked has been a relative success so far, but it's hard to unwind with a game that's meant to be frustrating/hard
 
DSM
I'm terrible at space combat (well, except maybe turn-based, he guessed.) But it turns out I enjoy so-called walking simulation games..
 
There's also Space Engine, which is only exploration, because it isn't a game.
 
user559633
Looks like a screensaver that I want to give to my first computer as a thank you.
 
DSM
Why did I not know this existed?!
I was a bloody planetary dynamicist!
 
12:47 AM
Apparently youtube links can crash my browser now. Thanks, firefox.
 
It's super impressive given that it's one developer.
 
user559633
@DSM Are there that many blood-planets that you can subspecialize?
 
Simulation down to the surface scale, with known stars and planets as well as generated ones.
 
user559633
Good lord. That's talent
 
DSM
@tristan: Kepler was very successful.
 
user559633
12:50 AM
I wish I could teleport to a high-gravity planet for workouts. Lifting is so boring and repetitive, but I could get down with stomping around a playground for 30 minutes a day.
 
user559633
Now that I have a professional space scienceman's attention: Where is Planet Hollywood, exactly?
 
Just fly to Colorado. Won't help with strength, but will with endurance.
 
user559633
I've been to Colorado. It's...overwhelmingly okay. Walking around, it's like... "holy jesus this is regular"
 
DSM
@tristan: orbits Alpha Lyrae, 'bout 25 clicks away.
 
If we're talking geographically, yes, it is a plateau. Should be pretty flat. Right?
 
DSM
12:53 AM
I liked Boulder well enough.
 
user559633
Lyrae? That's my exgirlfriend's home planet
 
user559633
Yeah, I like Boulder.
 
DSM
I didn't exactly fit in, shall we say, but everyone was very friendly, and hospitality counts for a lot with me.
 
guys quick question can i name my method like this set_into_3_piles or it should be set_into_three_piles becuase i can't find it in PEP 8
i hate naming conventions in python XD\
 
It doesn't matter.
 
DSM
1:02 AM
Except in the sense that you probably shouldn't hardcode three.. but that's up to you..
 
ohh Ok cheers
 
1:23 AM
Cabbage :-)
 
1:34 AM
cabbage
 
2:03 AM
Hi, I'm Python beginner, I need to parse text to data array in Python. Could anyone recommend me an easy opensource?
Thanks!
Sorry, bad question but I mess up something when google it.
 
DSM
What is a data array?
 
columns and row
map
sorry, I'm wrong
 
DSM
So do you just mean a list of lists? While there is a built-in array type it's 1-D.
 
[[1,2,3,4],[5,6,7,8]]
Are you looking for something like that?
 
yah, I often code Objective C so my view is array of array
 
2:13 AM
is this text delimited?
 
yah, store excel structure in python
 
great, use the already available 'csv' module
 
like csv have column name and row
 
but the csv format is my output, the input is text file, only line by line.
Thanks!
I'll try
It's read text file line by line, then I need to group some line to a cell value ... :))
A: some text
another text
B:
A: another cell text
something like that
 
DSM
2:17 AM
So it's not really delimited like a csv, then.
 
yah
group lines after tag A: to a cell in column name A
 
where does "another text" go?
 
and break to another column (like B) when meet the tag B
Then meet tag A: and put to cell row under column A again
 
So, it seems like you have some manipulation of the data to do, to put it in to something that can be written to a csv file
 
yah
 
2:20 AM
you'll have to implement that rule yourself
 
ok, thanks! maybe no opensource
I'll try more
 
You want to probably structure a dictionary that will hold this data, and use dictwriter. Something like this: docs.python.org/3/library/csv.html#csv.DictWriter
at least that is what it seems from what you are trying to do.
 
Thanks :))
 
np
 
DSM
2:38 AM
I'd forgotten how bad I was at regexps. :-(
 
hehe...@DSM I usually just smash away at regex101 until something works :P
 
DSM
I want (stuff)-colon+anything including newline but not greedy, but it's not working. :-/
 
can you give me an example? Or is that exactly it?
 
DSM
I want to get ["A: some text\nanother text\n", "B:\n", "A:.."] as above. I know I've done this before using a regex but I think I was smarter then..
 
Actually I need to input to Machine learning, something I can use but don't understand. But when can use ML, I lost power with these text files :))
 
2:49 AM
@DSM \w:.*\n? - or am i oversimplyfying?
 
I sing the delay song everyday and my boss will kick me soon.
 
DSM
@SebastianProske: that will get you the first part, but not the "another text" in A:, I think.
 
I see - maybe (?ms)^\w:.*?(?=^\w:|\Z)
 
DSM
I tip my hat to your lookahead prowess! That seems to work nicely!
 
hmm
 
2:58 AM
cbg
 
I think I'm missing something. Because using that regex with the example, I can't get it to work
 
DSM
Works for me:
In [153]: d
Out[153]: 'A: some text \nanother text \nB: \nA: another cell text\nsomething like that\n\n'

In [154]: re.findall("(?ms)^\w:.*?(?=\w:|\Z)", d)
Out[154]:
['A: some text \nanother text \n',
 'B: \n',
 'A: another cell text\nsomething like that\n\n']
 
oh...
I interpreted you wanted to capture thing before colon
only if you had a patch of colon-thing-newline non-greedy
I had a lookahead that looking for that
but Sebastian's looks much more elegant
\w+(?=:.*\\n.*?)
 
DSM
Ah, no, the non-greedy part was just that I didn't want to capture B: as well. I was trying things like (\w*:.*)?(?=\w*:) which wasn't working, with or without re.DOTALL.
 
ah OK.
 
3:05 AM
Or (?m)^\w:(?:.*(?:\n(?!\w:).*)*) if you'd want to unroll the lazy .*?
 
oh, I've not learned regex yet :))
 
he was referring to DSM's regex question.
 
Yes I did - and I should think a moment more before posting, the (?m)^ isn't even needed in this case, so just \w:.*(?:\n(?!\w:).*)* - doesn't look that elegant, but is quicker
 
DSM
@SebastianProske: that makes my eyes glaze over, which is probably why I write generators instead in practice. :-)
 
silly question, (? still implies lookahead?
I thought (?= was lookahead?
 
3:14 AM
(?: starts a non capturing group, (?m etc. are inline modifiers, (?! is a negative lookahead
 
I can't understand this. I'm linking my executable to the _imaging shared library but python still can't find it.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File " ... /embpython/stdlib.zip/PIL/Image.py", line 67, in <module>
ImportError: cannot import name '_imaging'
Or it finds it, but can't import it for some reason.
 
 
1 hour later…
@AnttiHaapala halp me
I'm desperate
 
I've told you:
 
I'm on linux now. It's a different situation.
Haven't tried your solution to the windows issue yet.
 
you need to have the library in that kind of path...
it cannot be in zip
 
right
ok
 
4:47 AM
the problem is that PIL is a package and you somehow need to have __init__.py too...
 
wait
 
is this python 2 or 3?
 
Python 3.5
 
ah good.
 
ok but PIL's init.py is inside of stdlib.zip
 
4:48 AM
Then you should only need to have directory PIL in sys.path
 
should I get it out of there?
 
no need
I guess...
should be enough to have PIL/_imaging.*.so
but they need to be in PIL subdirectory
 
why?
 
so if you have something like:
 
I just have _imaging.cpython-35m-x86_64-linux-gnu.so in the root dir
 
4:50 AM
because that is how python searches for them
doesn't work
 
ok
 
instead do something like have lib folder in there say, then you add that in sys.path
 
so I should put _imaging.cpython-35m-x86_64-linux-gnu.so inside a directory called PIL
 
and in lib you have lib/PIL/_imaging*
yes
 
so lib/PIL/_imaging.cpython-35m-x86_64-linux-gnu.so
then link to that
and add that path to sys.path
 
4:52 AM
and your sys.path could say "path/to/my.zip:path/to/lib"
 
that's what I'm doing already
so just add lib/PIL/ to sys.path
 
no, lib into sys.path
and within lib there's the PIL subdirectory with .so(s)
 
that's what I'm saying
 
no, you were saying the other thing (which doesn't work) :D
 
root
|
+----lib
|       |
|       +-----PIL
|       |       |
|       |       |-----_imaging.cpython-35m-x86_64-linux-gnu.so
like that?
 
4:55 AM
yes and lib, not PIL, is in path.
 
ok, so link to lib/PIL/_imaging.cpython-35m-x86_64-linux-gnu.so and append lib/ to sys.path
right?
Sorry, I'm not trying to be annoying. Just want to get this straight once and for all.
 
ok
 
I'll do that right now.
Ok, I'm still getting the same error.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File " ... /embpython/stdlib.zip/PIL/Image.py", line 67, in <module>
ImportError: cannot import name '_imaging'
here's sys.path: "source.zip:stdlib.zip:stdlib.zip/plat-x86_64-linux-gnu:lib"
 
5:01 AM
ok, then, try running strace yourexe
see what files it is trying to access
 
@AnttiHaapala pastebin.com/2PGPmFZg
 
you have the PIL in path or wrong working directory too?
 
What do you mean?
 
open("/home/jovito/ClionProjects/embpython/lib/PIL/tls/x86_64/libpython3.5m.so.1‌​.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
it is searching this in lib/PIL
 
I don't know why, sys.path is exactly ""source.zip:stdlib.zip:stdlib.zip/plat-x86_64-linux-gnu:lib"
should I put all other .so files inside lib?
 
5:06 AM
yes you should
 
libpython3.5m.so and _tkinter.cpython-35m-x86_64-linux-gnu.so
ok
 
I am testing here...
 
they didn't give me any problems though
_tkinter.so loaded fine from root
ok, so should I put _tkinter.so in a tkinter dir inside lib or it doesn't matter
 
wait something strange
 
.
├── libpython3.5m.so
├── PIL
│   └── _imaging.cpython-35m-x86_64-linux-gnu.so
└── tkinter
    └── _tkinter.cpython-35m-x86_64-linux-gnu.so
that's lib
 
5:10 AM
hmm
I did some testing, moving the pil .so's to another directory
it didn't work even if they were in sys.path...
 
there's something else
if I run from the IDE I get:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jovito/ClionProjects/embpython/stdlib.zip/PIL/Image.py", line 67, in <module>
ImportError: cannot import name '_imaging'
but when I run from terminal I get:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'Image'
 
yeah
I am trying to abuse these: python.org/dev/peps/pep-0420
but obviously it seems it doesn't work like that :d
I guess you need to do a path hack within the PIL module itself
 
this is Pillow btw
what do you think is the problem?
 
of course it is, you can't use PIL on 3
ok this is ugly
 
I know, I'm just being overly descriptive to avoid mistakes as much as possible.
 
5:18 AM
but you can do:
import PIL
PIL.__path__.append('/path/to/lib/PIL')
import PIL.Image
gets further (then it starts complaining about missing jpeg libraries and whatnot, they're in PIL/.libs')
 
let me try
@AnttiHaapala yeah, it worked here
where would those libraries go?
lib/PIL/ ?
or lib/PIL/.libs/ ?
Why does this even happen?
 
if you've got the manylinux wheel, it has bundled those libraries in it
 
Ok, now tkinter failed.
Same problem.
 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "src/py/run.py", line 1, in <module>
    import tkinter as tk
  File "/home/jovito/ClionProjects/embpython/stdlib.zip/tkinter/__init__.py", line 38, in <module>
 
5:31 AM
same solution :D
because it is in a package
except...
does it wrok :?
damn
 
it worked before though
lib is already in sys.path
import PIL
PIL.__path__.append('/path/to/lib/PIL')
import PIL.Image
do I need to do that for any compiled extension?
 
well you can try that whichever worked before for tkinter
no, that is a hack for packages (where the extension is in Foo._bar, not just _bar)
 
I'm linking to _tkinter which is on lib/tkinter
lib is on sys.path
 
hmmhm
then perhaps let it be in the root if you're linking against it
if it worked, for tkinter
 
this is so confusing
ok
I'll do that
@AnttiHaapala same thing
something I did while fixing the path for PIL messed around with tkinter.so path.
 
5:43 AM
stackoverflow.com/questions/40520301/… OP already asked this question several hours ago, and asked again. Dupe, and what they want to do is not possible, and I addressed it in the comments.
 
futex(0x7f95606839d0, FUTEX_WAIT, 5692, NULLTraceback (most recent call last):
  File "/home/jovito/ClionProjects/embpython/build/Debug/stdlib.zip/tkinter/__init__.py", line 36, in <module>
ImportError: No module named '_tkinter'
Fixed it!
 
ok so now you officially know more of this than me :D
 
@AnttiHaapala Ok, so just in case this happen again (it probably will)
how do I know which compiled extensions to import with the namespace trick and which not?
 
6:08 AM
@tristan I don't care about all the Trump business, I am moving in
 
cbg
what's SE written in btw?
 
@Jovito idk, you know more of it than me :D
 
You know I don't.
 
whenever I've embedded python, a) I did link only against the shared python lib, b) I didn't even use any extensions, ever, c) I didn't try to make it installable.
so you're ahead already
(gaah I HATE PIL (the original))
 
6:11 AM
@AnttiHaapala are you on linux?
 
what's PIL
 
Python Imaging Library
 
is it GIL but with P
 
6:11 AM
or something like that
 
image processing is really interesting
 
last release in 2009, "python 3 support will come later on"
 
so is natural language processing
 
@AnttiHaapala maybe you could test the program, see if if it works there
 
6:12 AM
its API is horrible,
 
that would be the ultimate test
 
they've also reserved the PIL name....
 
Ladies and Gentlemen, Antti is writing Python 2.
Remember this day
 
now everyone needs to know that they need to install Pillow instead
(no hint in PyPI)
 
@AnttiHaapala do you have virtual box installed?
 
6:18 AM
no and I don't have time to test atm
 
that's ok, you already helped lot
thanks man
 
7:16 AM
"You are a programmer right?"
"Yes"
"can you crack a facebook account?"
had this tiny conversation lots of times
or "What do you study?"
"Computer science"
"You mean programming?"
"Yes, programming :/"
 
7:35 AM
Cabbage
@Will You asked: "isn't a list comprehension supposed to be a bit more efficient or something tho?". Yes, a list comp can be slightly more efficient than equivalent code using a "traditional" for loop because it uses a special LIST_APPEND operator to grow the list instead of using the list.append method call, as mentioned in this article: Efficiency of list comprehensions.
However, that article is a few years old and focuses on Python 2. The list comp has changed in Python 3: a list comp now creates its own scope to prevent "leakage" of loop variables into the surrounding code, and that adds a little overhead.
 
user5639219
7:51 AM
Hello everyone
 

« first day (2217 days earlier)      last day (2747 days later) »