« first day (1506 days earlier)      last day (3440 days later) » 

12:37 AM
Sorry had to go, did anyone figure out why my program freezes?
 
DSM
Why shouldn't your program freeze?
 
1:24 AM
The while loop just gets it to freeze
 
DSM
Well, yes. Your while loop can only be escaped if the length of number1 becomes 5, and it never will.
 
1:48 AM
why won't it?
I'm adding something to ti
 
DSM
Hint: add print repr(number1), len(number1) right before the while loop. Printing the variables out should usually be your first step in debugging.
 
2:15 AM
what's repr>
 
DSM
It shows you a representation of an object. Although it doesn't matter here -- print number1, len(number1) would work just as well -- it's handy for dealing with strings which don't quite look like what they are. (Again, there's nothing going on like that here; the problem is much simpler.)
 
Okay so I strip the string of one of their characters but it still says it is 6 lengths
 
DSM
That's because it's six characters long.
 
even though I strip it?
 
DSM
Python isn't trying to deceive you; if it says a string has length 6, it has length 6.
 
2:20 AM
print number1.replace("b","")
print number2.replace("b","")
print number3.replace("b","")
print number4.replace("b","")
print number5.replace("b","")
print repr(number1), len(number1)
print repr(number2), len(number2)
print repr(number3), len(number3)
print repr(number4), len(number4)
print repr(number5), len(number5)
 
strings are immutable, so you need to use the returned value
 
but I take the b out
 
DSM
I think you might benefit from just playing around at the console. Strings in Python are immutable.
>>> s = '0b1100'
>>> s
'0b1100'
>>> s.replace("b", "")
'01100'
>>> s
'0b1100'
 
so if I set number1 = number1.replace("b","")
would that work/
 
DSM
Well, it'll get rid of the b, although you'll still have the 0 at the left.
There are lots of ways to avoid having one:
>>> x = 12
>>> bin(x)
'0b1100'
>>> bin(x)[2:]
'1100'
>>> format(x, 'b')
'1100'
>>> '{:b}'.format(12)
'1100'
 
2:25 AM
I just did number1 = number1.replace("b","") it seemed to work
 
DSM
You should probably read up on lists and for loops. Your code is very repetitive, and that's what loops can help avoid.
Anyway, sounds like you're on your way. Good luck!
 
except its driving me insane!
also I don't know how to use loops to manipulate variable names
like how I use number1, number2, ...
for i in range(0,5)
I don't know how each loop uses a different variable
print repr(number1), len(number1)
print repr(number2), len(number2)
print repr(number3), len(number3)
print repr(number4), len(number4)
print repr(number5), len(number5)
number1 = "1" + number1
number5 = number5 + "1"
now my code locks up when I do this
string number1 is 6 in length so it should just skip over that while loop
the while loop keeps running even if the conditions aren't meant
 
2:59 AM
can someone help me make an encode function for this lh3.googleusercontent.com/-THpCu8u8vX0/VHkKRfNyvRI/AAAAAAAACBk/… I've tried it here is my code dpaste.com/25JCNYZ
 
 
2 hours later…
5:01 AM
My wife made a music video, a violin cover of All of Me, please share if you like it! youtu.be/riOPJoGLq5E
It was shot in downtown Brooklyn
 
 
1 hour later…
6:19 AM
Cbg
 
 
3 hours later…
8:49 AM
cbg
 
I think my wireless keyboard interfere with my WiFi :[
Sometimes
 
Umm... that doesn't sound an ideal scenario :)
 
9:22 AM
Cbg
 
Yeah, they're both on 2.4GHz frequency, but I read that they shouldn't interfere because they both will use different channels, so it's quite surprising
 
@Ffisegydd!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
10:47 AM
another quiet Sunday :)
 
*another quiet week
 
11:33 AM
Umm... why would commands run from manage.py but not elsewhere... confused
 
anyone here?
 
yes
 
+
 
I think I got the solution, but no sure, just check it with someone :x
intro to computer science lol xD
 
small design question, i have a module with a hardcded constant. I now want to have it as a value that i set once and forget about it. Is there another way than making it a class?
 
11:45 AM
@Arden use CONSTANT_NAME = 'whatever' in your module to indicate it's a constant
 
@JonClements sorry question wasn't clear, i need to set this constant via a call from another module. I then want all other modules that access it to be able to see that value. This is easy with a class but i do not want to have to route all calls through the class just for that
 
@user1561559 it's also trolling somewhat if you're going to post the same thing into the lounge and here... please refrain from doing so?
5 messages moved to recycle bin
 
but i want to access to a wider range of population? :(
 
@Arden well, if you import module... then you can do module.CONSTANTNAME = 123... then to use it elsewhere do the same...?
@user1561559 it's not on topic for this room thanks :)
 
ok honey love u still bb <3
 
11:57 AM
@JonClements yes i can, i just thought there might be a cleaner way
 
That's about as good as it gets
(and don't forget it's not technically a constant - but the allcaps indicates anyone mucking about with it should accept it's on their own head be it)
 
all clear ^^
 
12:14 PM
rbrb in a bit
 
12:42 PM
Cabbage!
 
1:20 PM
cbg
 
1:56 PM
cbg cbg cbg
 
2:07 PM
cbg
 
2:31 PM
i had kimchi yesterday, which is fermented cbg
spicyyyyyy
 
Cbg
Guys does this exist: [item for item in lst if condition(item) else something_else(item)]
 
@Mirac7 what are you trying to express there?
Do you want:
[item for item in lst if condition(item) or something_else(item)]
?
 
Hello
 
2:48 PM
Hello
 
Hello
 
@BenjaminGruenbaum the same as this:
a = []
for item in lst:
    if condition(item):
        a.append(item)
    else:
        a.append(something_else(item))
 
> its for my childs homework and I don't have any experience or idea on the use of Python
That's something new
 
2:58 PM
Anyone got any experience setting up VirtualBox on Linux to boot from a live Windows 8.1 partition?
 
Cabbage.
 
Wow… my answer still hasn’t surpassed Martijn’s crappy one…
@RobertGrant (late reply is late) That other answer would be way superior to the accepted one iff Java had tail recursion optimization.
 
3:26 PM
@JonClements don't understand the question, your running vb from linux and something about windows
 
@Arden I have a dual boot Linux/Windows 8.1 machine... I have VB installed on Linux, I'd like to run the live Windows 8.1 in VB as a guest
 
@JonClements Is such a thing even theoretically possible?
 
This is not a node question if you ask.. a general HTTP request problem :/
 
@l0oky please don't bring your newly asked questions here
See sopython.com/chatroom for the chatroom rules
 
Roger i am out
 
3:30 PM
Especially don't bring them here if they have nothing to do with Python
 
@poke Not sure - don't see why not though...
 
I can make them do something with Python does that count?
 
1 message moved to Trash can
 
@JonClements Because usually virtual machines don’t run with the exact host hardware but with emulated hardware, and the live system is set up for the exact host hardware. Also the VM software would have to be able to read the original file system, although most of them use some partitioned file instead.
 
@poke ahh... I forgot windows gets the hump if it detects hardware changes...
Not important anyway...
 
3:34 PM
Linux doesn’t?
 
Not that I've ever noticed
 
hmm
I haven’t really worked with Linux apart from command-line only setups, so I can’t really tell otherwise. And I don’t think those care about hardware at all.. ^^
 
cbg all... :)
 
Linux doesn't - work with live usb sticks in different machines quite often
 
Cabbage :)
 
3:36 PM
Windows just bitches about hardware changes to prevent copying etc...
wb @rvraghav93
 
It doesn’t necessarily bitch, but it will update all its drivers on hardware changes.
 
Well, you've made a good point - even if it's possible (I'm sure it must be) - it's not something I want to be doing... so I'll leave it
Umm... sounds like someone's vacuuming down stairs... but that's the sound of my laptop fan while compiling pandas... sighs
 
meeeh xD
 
3:54 PM
Is there a way to print class' qualified name on Python 2? I'm asking because I think I might have given a misleading answer..
 
4:07 PM
Earlier, I was actually about to comment “I can’t even think of a hacky way to solve this in Python 2”.
So I’d say no.
 
Umm... @poke haven't you tried something like this before?
(although yours was trying to divide in N many different buckets or something)
 
Yeah, my problem was different
 
Wow useful answer I'd never have gotten that as a solution
 
“If there are many such possibilities, find the first such partition.” Is it even possible to have multiple solutions? I don’t really get it.
 
11000011 could be split in 4 places I guess
 
4:18 PM
No, only in the middle
 
oh... misread it - number of zeroes in the other... not equal number of ones
ignore me :)
 
As the count of 1s in the first part needs to be equal to the count of 0s in the second part
That’s why I’m wondering if it’s even possible.
Assume we have a solution at the index i. Now if we were to move it one to the right we have two possibilities: Either lst[i+1] is a 1 then our left part is one too big, or it’s a 0, then our right part is one too small. So we can’t move it to the right. Similar reasoning when moving the boundary to the left.
 
umm... I'm trying to not think about it... trying to sort out my own problems at the moment :)
brb
 
@poke How about this one ?
def partition(a):
        t_ones = a.count(1)
        l = len(a)
        t_zeros = l - t_ones

        t = [0, t_zeros]

        for i in range(l):
            t[a[i]] -= 1

            if -t[0] == t[1]:
                return i + 1
Ah this is similar to your answer!
 
4:33 PM
Yeah, the -t[0] is so weird though xD
But it should be the same I think.
 
Thats because I didn't want to check if its 1 and increment and decrement if its 0... This just keeps decrementing... then invert the ones alone to check...
Not sure if that gives any specific advantage though :P
 
Probably not :P
I’d put the confusion as a disadvantage actually ^^
 
lol!!
 
:D
 
Hi, how do I skip an iteration in a list comprehension?
I have some text which I split into list of strings and some lists are of type [''] and I want to skip them but this code below is not working.

[p.split(" ") if (len(p) == 1 and p[0] != '') else continue for p in text.splitlines()]
 
4:40 PM
Why do you calculate the number of zeroes by substracting the length from the counted number of ones?
You could just count the zeroes directly :P
@Animesh In general, you can filter when you do list comprehensions: [expr for var in lst if someCondition(var)]
So in your case [p.split(' ') for p in text.splitlines() if len(p) == 1 and p[0] != '']
 
Ok! I get it now. Thanks
 
Maybe even: [p.split(' ') for p in text.splitlines() if any(p)] ?
 
well, even that is working correctly
 
@poke yeah :P I initially started off by counting both 1s and 0s... then realized that only 0 count is needed... so absentmindedly left that line there...
def partition(a):
    t = [0, a.count(0)]
    for i, no in enumerate(a):
        t[no] -= 1
        if t[1] - t[0]:
            return i + 1
this one takes 0.8 us only :D
 
Now that I think about it, the p.split(' ') doesn’t actually make much sense when len(p) == 1 is a requirement.
 
4:54 PM
oh that was my mistake
the actual thing was
[p.split(' ') for p in poem.splitlines() if len(p) > 1 and p[0] != '']
 
Ah
 
In this post here http://stackoverflow.com/a/952946/1461896

How does this solution work?

My thought: As per the functional programming concepts, it is a "fold" operation from left to right as in python two strings can be joined together using + operator.
 
+ concats two lists - so it reads as [] + list1 + list2 + list3
so [] + [1, 2, 3] + [4, 5, 6] gives you a flattened list
it's an abuse of sum though really
 
this clarifies my doubt but I still think it was a smart solution.
So is the first solution supposed to be the preferred one?
 
5:10 PM
@poke I imagine the hacky way to be (it's not the ideal solution, and needs some fixes, but anyway)
import inspect

def find_by_last(last, types=[]):
    if 'end' not in dir(find_by_last):
        find_by_last.end = (last, inspect.getsource(last))
    sequence = list(globals().items() if not types else vars(last).items())
    for name, ob in sequence:
        if inspect.isclass(ob):
            source = inspect.getsource(ob)
            if source and find_by_last.end[-1] in source:
                types.append(ob)
                if find_by_last.end[0] is ob:
                    return types
                for attr, val in vars(ob).items():
 
either chain.from_iterable or either a genexp or list-comp - sum and reduce are just abusive really :)
 
@vaultah ouch.
 
Yeah, but it gives the desired result
 
Not worth it imo xD
 
What the heck is that meant to be used for? :p
 
5:11 PM
2
Q: Why the unexpected naming of nested classes in Python? How to "fix"?

0xC0000022LPlease consider the following short Python 2.x script: #!/usr/bin/env python class A(object): class B(object): class C(object): pass def __init__(self): self.c = A.B.C() def __init__(self): self.b = A.B() def main(): a = A() print ...

 
I want to package a library so that the libary's user can import foo and then foo.Bar(). In other words, I want all of the classes defined by the library to live in a namespace "foo". Is that a good idea? And what are my search terms for learning how to do it?
 
@WayneConrad so foo is a module. Yes, that works.
 
@poke any thoughts on how wiki revisions should be handled?
 
@poke That's good. Thanks. My google searching keep leading me to things like "namespace packages", which to my novice eye don't seem like what I'm looking for.
 
@WayneConrad you can see how I set up a python package for sopython-site: github.com/sopython/sopython-site/blob/master/setup.py
 
5:14 PM
@davidism What exactly do you want to hear from me? :D
 
@davidism Looking... thanks!
I think I might be getting it. It looks as though modules in Python are created implicitly whenever you put some code into a file. They're not explicitly declared as in Ruby. Is that right?
 
@Wayne Yes, a file makes a module.
 
@poke not sure I guess :) I was thinking of doing it like stackoverflow, store the post as one object, the revisions as another list of objects, the latest revision is what gets displayed
 
And the light bulb start to flicker. This is good.
And if I want to put each class in its own file, then the module's file (foo.py) uses import statements to put those classes into the module's namespace?
 
and a package is a directory with an __init__.py file, other py files, and other packages
Python's not Java, you don't need one file for one class
but yes, you can do that
 
5:19 PM
@davidism Yeah, that’s what I was thinking too; it’s also what mediawiki does. You could even do it the Git way: Store page contents in a acyclic graph (pointers to parent revision), and have actual pages as “branches” that contain just a pointer to the revision they are showing.
 
make each of the files part of a package, have the imports in the __init__ file
yeah, that was the other way I was thinking, either it's a linked list or it's a collection
 
@davidism That did it. Brilliant, thanks!
I don't know if my Ruby addled brain would ever have figured that out on its own.
 
@WayneConrad there don't seem to be good tutorials on how to make python packages, and the docs are more technical, so I looked at how other projects like Flask and SQLAlchemy did it
 
*sigh* Another answer that gets accepted in favor of one that actually explains what’s going on :(
 
5:28 PM
I'm in a happy spot. Now I can stop worrying about how to put classes in a module, and carry on with some oopifying.
 
arhghgh... need to change some settings in windows else I can't mount the NTFS partition in write mode - bloody thing
rbrb in a sec
 
I don’t get the review system.
On this review item, four users reviewed it to close; if I go to the question directly, there are two close votes…
 
5:44 PM
That question is a bit of a mess. It is just a jumble of varying levels of detail with no theme.
 
@poke expired votes?
(or flagged to close)
 
Two of those reviewers did not appear in the close message.
 
@poke both of which are under 3k to actually have a close vote
 
Ahh
 
they get to review it, and it just adds weight to its position in the queue I think
actually... I think it's possible they've flagged it for closure
but then... umm...
I'm not sure now...
 
5:53 PM
Yah they can flag with the same reasons for closing, but it's not a binding vote
 
maybe that gives moderator attention?
 
Nope - it just puts it in the review queue... mods don't get notified of close flags
(and if even if they did - they wouldn't bother with 'em)
 
Yes, Bill closed it… :P
 
I think the rule is if it's blatantly crap, then they might... otherwise, if they're not sure, it's up to the community
 
6:15 PM
When documenting Ruby, we might refer to method bar in class Foo using the nomenclature Foo#bar. Does Python have a similar convention?
 
Just use . instead of #
Unless you state it's a static/class method/property or class/instance attribute, it's kind of assumed you mean it's an instance method
 
Excellent. Thanks.
 
Normally - you'd structure it something like: docs.python.org/2/library/stdtypes.html#dict
 
6:33 PM
That makes sense.
 
@Wayne if you're using sphinx to generate documentation, you can get it to "autodoc" stuff, if you construct your docstrings nicely
 
Oh, cool. That'll be good.
 
6:59 PM
Actually, if you start iterating from the middle rather than from one of the ends (see my answer below), you'll find solution faster in 3/4 of cases (assuming random distribution of the partition site). — striving_coder 41 mins ago
Timeit: Mine: 6.22858255730873, His: 10.917649050831361
xD
 
wow... my connection speed has dropped massively
 
@JonClements I have to vote as unclear because that feeling greatly overcomes the “do the work yourself”..
I don’t even understand the title
 
Well, the title's somewhat better than the body :)
omfg - netflix now works under linux... without having to WINE a browser - did the OS equivalent of silverlight get DRM at some point!?
 
Flash? :P
 
@Jon on Firefox, or still just on Chrome unstable build?
 
7:14 PM
using chrome stable
 
It's the only reason I have chrome installed right now. Not sure if Firefox will add the DRM or not.
 
umm... netflix have changed then... never use to be able to use it under linux
 
yeah, it was out on unstable builds a month or two ago, chrome added the drm that netflix requires
 
Excellent - only need winblows for games now then
So use to running firefox under wine with silverlight to get it to work - it's nice to just be able to not do that :)
 
I was using pipelight for a while, but it seems to break a lot lately
It runs just silverlight in wine, and embeds it like a normal plugin in firefox
 
7:38 PM
pipelight works fine for me
so, I just learned I am doing an interview for a company that is working with machine learning in python, maybe I can actually offer something to nidaba now other than pretty data renderings
 
@corvid that'd without doubt be appreciated - just focus on getting the job and doing what you'll be paid to do first though :p
 
I also have an interview with google :\ but I assume that won't go too far
 
If they dont' employ you - just threaten legal action under the grounds they're discriminating against you, because you're a crow
Or is it only because of race/gender/religion and sexuality.. umm...
 
"sir, why do you think they were discriminating against you?" "CAW. C-c... CAW!"
Crow is religion. Crow is life.
 
@corvid there ya go - ya got it! The job's in the bag :)
 
Also, crow is a sexuality. Crowmosexual
 
8:25 PM
Hello, someone could tell me how to link test foo with code bar then nosetests --with-coverage --cover-package=hello --verbosity=1 recognise where the foo and where the bar?
 
@madzohan Use the -m flag to understand the statements that are missed by your test(s)
Check this guide on how to use coverage...
 
@rvraghav93 anyway this don't recognise my tests, what I've missed apps/hello/tests 20 20 0% 1-25
 
8:48 PM
maybe I've wrote test in wrong way? or do I need some config file to link code with test? totally ... nothing is clear at all
 
1 message moved to Trash
@madzohan please do not post < 2 day old questions in chat, see sopython.com/chatroom
 
9:41 PM
cbg
 
10:03 PM
morning
 
That's a useful set of rules. The Ruby room needs something like that.
This is a good one: Especially don't use @username notification unless that user has already told you it's okay to ping them
 
@davidism sorry))
 
@WayneConrad if I'm not mistaken there was some intention of using this for other rooms as well
 
@Wayne if you want to take those as a base and modify them to suit ruby, feel free :)
 
it would kill sopython
 
10:18 PM
@Ffisegydd Thanks. I think I'll do that.
@AnttiHaapala What would kill sopython?
 
not pinging :D
 
I think the context of the rule is, "Don't ping someone with your question".
 
Yeah, we just don't like people coming in and picking someone to ping. When you have 3 conversations at once, it's necessary though.
 
I want that rule for the Ruby room. Since I hang out there a lot, people treat me as a magic help oracle.
Which would be less annoying if I were any good at it.
 
10:38 PM
Just came to know that js can be run as code snippets in SO Questions... We should also have such a feature!!!
 

« first day (1506 days earlier)      last day (3440 days later) »