« first day (1590 days earlier)      last day (3375 days later) » 

12:02 AM
Would someone upvote this (if they agree with it) so I can use it as a dupe target: stackoverflow.com/a/27779413/400617
 
Hello, I have a Django model field <is_active = models.BooleanField(default=True)> but when I create a record using model form, the field in the db is False. any idea why it's behaving so?
 
Well, my first guess (and this might be obvious), is that the value was set to False...
 
where could that have happened and I have default=True?
 
I don't know, I'm not a remote debugger. Step through your code and examine the data as it comes from the client and goes to the database.
Is the default for the form True? Does some process set it to True before you commit the data?
 
12:19 AM
yes, I have initial=True in the form
 
Take everywhere I said "True" in the previous sentences and substitute "False". :-/
 
Can anyone tell why a post to this page using requests or hurl.it fails (page responds as if I did not fill the form) but when use the browser there are no issues ?
tried making sure the I use the same cookes and also the user agent but no luck -_-
 
You mean this chat room?
 
lol ma bad forgot to drop the url
here
im setting the parameter for lastName = "James"
Im guessing some sort of server validation is happening to block the request
But from the look of the website, i don't think its that sophisticated
 
12:48 AM
@Fuchida after playing around with it in the Firefox console, I figured it out
 
cbg
 
you need to send a value for every form field, even the ones that are empty strings
it doesn't care about cookies or headers at all
 
do you need some asparagus?
 
no, I'm good
 
@davidism wow -_- i should have set my standards even lower
 
12:51 AM
do you need some asparagus?
Is it for python tho?
 
Thanks for the assist
 
+25 COINS: ASSIST
laurel
 
Are you alright?
 
@davidism look at my username
cbg....?
@davidism are you still here?
 
 
4 hours later…
4:47 AM
django or flask
??
 
 
2 hours later…
6:54 AM
stackoverflow.com/questions/28655275/… too broad :P that is basically everything what my dayjob has been doing for a year
@Spycomb pyramid :P
 
7:07 AM
@Spycomb it always depends on what you're doing
 
7:21 AM
someone is stackoverflowing drunk maybe :P
 
Done!
 
7:32 AM
@AnttiHaapala done.
gone.
What is BeautifulStoneSoup?
-3
A: Why does BeautifulSoup reformat my XML?

7stud1) For xml parsing, you should use BeautifulStoneSoup(). 2) But BeautifulStoneSoup() still produces the same xml. I believe BeautifulStroneSoup's parser works on a simple rule: when an open tag is encountered while another tag is still open, it closes the first tag.

is this really exists?
 
@AvinashRaj nope, the guy is drunk or the account was hijacked
 
ah there is
but bs3
UserWarning: The BeautifulStoneSoup class is deprecated. Instead of using it, pass features="xml" into the BeautifulSoup constructor.
@AvinashRaj so you can remove the comment
there was beautifulstonesoup in bs3
aha now I undertstand :D
 
oh, sorry.
without xml param, it adds an extra html , body tags.
is that possible to write try except block in one liner? I have to fed this into python -c command.
 
@AvinashRaj not really ...
you need to do some \ns
 
7:47 AM
oh, thanks. I'll try.
 
@thefourtheye haha
the thing is OP had installed BeautifulSoup 3
and I read it that it was BeautifulSoup4
since I didn't even remember we have such thing as the original beautifulsoup
 
so I wrote my example which used bs4 and it worked
along with the explicit import there
and he is right about the BeautifulStoneSoup not parsing correctly :D
but it does not help a bit the OP :D
Note that you're using the obsolete package, BeautifulSoup Hurray! Hurray! 3 upvotes for being completely wrong before that edit. If someone asks a question about how BeautifulSoup3 works, and you post an answer about bs4 works, that isn't very helpful. For the correct answer, read my post. — 7stud 3 mins ago
 
Actually I know nothing about BS. So, I could neither upvote yours nor downvote his answer. So I just flagged that rude comment :)
 
cbg
It's all BS to me. :)
 
7:53 AM
@PM2Ring lol, now that you mentioned it, I realize what I have done there... :D
 
anw the question is worth upvotes :D
 
could you provide any two external modules?
 
@AnttiHaapala The trust I have in you, earned the OP an upvote ;)
 
it is like one of the wtf moments anyway because of this beautifulsoup beautifulsoup4 confusion and wtf (since most of the ppl call beautifulsoup4 beautifulsoup and I was so stupid as to ignore what the path says).
 
stackoverflow.com/questions/28655110/… I'm not totally comfortable with that custom close comment, but I guess it fits. I was going to write a comment of "SO is not a code translation service", but I guess that's not much better.
 
7:56 AM
lol. Found this one in the JS room.
 
hoho :D
 
0
A: How do I check whether a module is installed or not in Python?

Avinash RajYou could put the code inside try, except block. $ python3 -c "\ try: import cow print('\nModule is installed') except ImportError: print('\nThere is no such module installed')" There is no such module installed $ python3 -c "\ try: import regex print('\nModule is inst...

 
7stud care to elaborate. Yes: three thoroughly ignorant people (part of your cheating gang?) upvoted your answer--even though it was incorrect. — 7stud 1 min ago
:D
:D:D
now I have a cheating gang
 
@AvinashRaj Wait... What now? There is a module called regex? :O
 
yep. there is a regex module..
 
7:59 AM
so the 7studs solution is: knowing that the user uses the deprecated BeautifulSoup 3 package, to tell that "BeautifulSoup is a HTML parser, BeautifulStoneSoup is an XML parser, BeautifulStoneSoup will still produce broken XML, no can do, Q.E.D."
 
@AnttiHaapala :whistles innocently:
 
Oh he commented on his own question, it seems he might have some regrets (maybe)
 
@thefourtheye the new regex module is currently on pip but will replace re in time probably
 
@AvinashRaj Cool, I didn't know about that. BTW, use heredocs, instead of single string.
 
@Ffisegydd really? I'm waiting for that.
 
8:03 AM
@Ffisegydd Yup, I slightly remember discussing that here, last year...
 
nope, I don't think it will ever replace the python re
ppl will complain that standard library is complete
 
I believe that is the point. Put it on pip to test things with it. Eventually put it directly into stdlib.
 
and contains all the important packages. like aifc module :D
like when I said on #python @freenode
that wish that ISO 8601 timestamp parsing be in standard library, then someone said that not all crap needs to go into standard library.
 
Also is I were in a grouchier mood I'd downvote that guys question for being whiny. As it stands, I don't know if either of you are correct so I'm staying away.
 
@Ffisegydd 7stud is correct
but also seems to be drunk and typoing whatever he writes
I am also correct :D
 
8:07 AM
@AvinashRaj Why bother with the try:...except if you just want to do a simple test in the shell? You can just do python -c "import cow" . You get an error message, and a testable return code. Eg
 
hello
 
python -c "import cow" && echo "exists" || echo "doesn't exist"
behaves as expected
 
yep, but this kind of solution is already mentioned.
strange.
 
@Ffisegydd IIRC, regex will enventually be a drop-in replacement for re with added extras (i.e. it will be backwards compatible).
 
$ python -c "import cow" && echo "exists" || echo "doesn't exist"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named cow
doesn't exist
$ python -c "import regex" && echo "exists" || echo "doesn't exist"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "regex.py", line 653, in <module>
    import copyreg as _copy_reg
ImportError: No module named copyreg
doesn't exist
where the copyreg comes from?
 
8:10 AM
@Ffisegydd the 7stud came when I gave a working code with bs4 and just said "why are the idiots upvoting you"
and I asked "care to elaborate" and marked the comment as offensive -> removed
and he didn't note that I didn't notice the user was using a deprecated package and "technically he was answering the right question"
but he didn't give a solution.
 
I don't know much about BeautifulSoup, but Antti did say he tested his code...
 
thus wholly not constructive
he is right
there was BeautifulStoneSoup in BeautifulSoup 3 and it too produces broken XML
the solution is to install beautifulsoup4
1) For xml parsing, you should use BeautifulStoneSoup().
NO
 
Why is it called beautifulsoup?
 
for XML parsing you should install beautifulsoup 4
tagsoup
 
@AnttiHaapala I guess it might be diplomatic to post a comment saying you originally didn't notice that the code was for bs3, since bs3 is so ancient, and people really shouldn't be using it.
 
8:14 AM
google gives haskell package or something
 
I just looked at a meta post by him. My advice as a lawyer and spiritus guide is to walk away. The guy seems generally argumentative.
 
FWIW, Stone Soup Stone Soup is an old folk story in which hungry strangers trick the local people of a town to share their food: a good confidence trick that benefits the group from combining their individual resources. The story is usually told as a lesson in cooperation, especially amid scarcity.
 
I'm still unsure about the name choice
 
@AnttiHaapala, It's evident from the first line of the code. Now delete your answer. — 7stud 24 secs ago
@PM2Ring I think this has nothing to do with diplomacy :d
 
@AnttiHaapala Sounds like you guys are having a brawl
 
8:23 AM
ping a mod..
 
I'd just walk away.
 
Should I delete a git remote branch if I no longer need it?
Docs say yes
 
@Vader yeah sure. As long as you don't need it.
 
@AnttiHaapala Fair comment. And he's just getting uglier. I agree with Ffisegydd: just walk away.
 
BeautifulSoup 3 contained some XML parsing features (the BeautifulStoneSoup) that really did not understand the same tag being nested again (as noted by 7stud in his answer; thus for all XML parsing needs it should be totally and utterly considered replaced by BeautifulSoup 4. Note that these projects can coexist even within an application - BeautifulSoup.BeautifulSoup for BS3, and bs4.BeautifulSoup for BS4.
now noodle for breakfast yummy
 
8:43 AM
3
Q: Still struggling with class scope

HusarI am still not fully understanding the scope of classes very well. I have read up on this and and I have been trying to do different things to lean with some success but this one has me scratching my head. I am playing around with this code. I think Bryan Oakley may have written this example bu...

accepted :P
 
9:06 AM
cbg
 
9:27 AM
cbg
 
@jonrsharpe Look sir, I am purely doing this code for my own benefit. What suggests that I am doing it for any qualification??? I do apologise but I feel offended. I have only been looking at other people's projects on SO to help develop my own program with my own understanding. Please do not suggest that I am plagiarising my own work as this undermines my own intentions. — Delbert J. Nava 4 mins ago
And the comeback
"What suggests that I am doing it for any qualification???" - the fact that it's a GCSE Computing programming task (see reddit.com/r/Python/comments/2gawvg/…). "do not suggest that I am plagiarising my own work" - I'm not (indeed that would make no sense). I apologise if you are genuinely not cheating, but note that this is still not a good question for SO, see stackoverflow.com/help/how-to-ask. — jonrsharpe 1 min ago
 
9:40 AM
i installed pycharm on my Ubuntu 14.04. I don't know what's the actal command to start pycharm from terminal.
 
Navigate to the dir that contains the executable
 
@there is a .sh file
 
chmod the file
then run it ./bla
I am not on linux atm, so I am unsure of the specifcs
 
bin/pycharm.sh
 
but it ask me to accept the license agreement once again.
 
9:43 AM
0
Q: How can I have autocomplete for python libraries in sublime

makkasiCurrently when I import some code, for example: from datetime import datetime I can't see what methods it has. How could I know that there is utcnow() for example. It would be great if there is some plugin for sublime so that I have this functionality , as it is in eclipse with cntr+space for ...

@AvinashRaj then accept
 
10:00 AM
@AnttiHaapala Thank you :-)
I meant to say Melons :D
 
now to the HV problem
this guy just edited in code with python 2 print
and running python 3, clearly been just copy pasting the code without any understadning
can we do something about it?
if you look in the history this is about the 10th question about the same fscking problem
 
Most of the HV questions would fall under the "too broad" category
 
this is not too broad
because it has been divided into 10 qusetions by now :D
this should be closed as "Lacks minimal understanding" and it wouldn't be too rude in this case
 
Well, we can mention that in Custom Comment in CV reason, right?
 
this does not have any point in being on a programming enthusiasts forum
 
10:04 AM
It's been the suggested that the user is being dishonest. He could be cheating for seme test
Not that that would make it a CV, but it would explain the 10 questions
 
sjfakölsdfasdklfjasdöfjkasdjf
 
Headbanging again?
 
I want that kind of behaviour to stop
the comment thread just keeps growing longer
and no one is getting any benefit there...
 
Well don't engage in it.
 
I don't
I stopped now
but I spent 2 minutes on it
hmmm I think I really should write a browser plugin
that when I have seen 1 question being bad, I could flag it for myself, so I will not reread it
also flag HVs :d
so if I see a bad question, I can also see that the user has a HV flag, and can pass
 
10:09 AM
Last comment: Looks like the user may not know python all too well.
 
ofc not
just been copy pasting everything there
I read the questions on the Python tag
and most of them I shoudl just comment "don't do it"
"i want to write a concurrent program and share some objects" - "don't do it"
"I want to parse '.' as an int" - "don't do it"
"I want to use virtualenv -p with a python from another virtualenv" - "don't do it"
 
Delbert may lack core coding skill, but you have to admit that he's polite, enthusiastic and persistent. :)
 
re-cbg
 
But yeah, at this stage he's a classic cargo-cult programmer.
 
0
A: How to reinitialize a variable in Python?

Antti HaapalaYes, you just re-execute the same statement: av = "Core/" + cuname + ">> " again.

 
10:23 AM
It's depressing that using Tableau I can make plots with a few clicks that would take me 5-10 minutes of coding in Python >.<
Never mind. Python allows scripting. But Tableau might be nice for exploration.
 
@AnttiHaapala Let me guess. He's creating a new local av so it's not updating his original av
 
Is it bed time yet?
 
@thefourtheye asdfjasdiflasdölfasdfjasdfjkasdfkljs grace time edits
need to have a close reason "Exceeds my clairvoyance abilities" :D
 
@AnttiHaapala Uh, I don't know why... But OP liked my answer.
 
we really should cv all those answers and refuse to answer them
but too bad there are no good python questions either
 
10:31 AM
@thefourtheye Why on earth did you just add a setter to that class???
 
@PM2Ring Oopsie, sorry... I was trying something locally and forgot to remove that during the PEP-8 formatting.
 
okay...
@AnttiHaapala "Insufficient code to reproduce" covers it.
 
there is no sign of any quesiton
half the top 10 programming tags under it
and python mentioned in the last paragraph
 
@AnttiHaapala I have answer answer for that if he want the 1st 8 elements of each line
But I am not too sure if that what he wants
 
@Vader I just said there: lines[0:8]?
there was print lines [0:9] that prints 9 first elements...
 
10:38 AM
Doesn't he have to use readlines()?
nvm he is
 
Well, they've had more than enough time to elaborate
 
@AnttiHaapala That's what I am thinking
 
-1
Q: Python rotating logs without creating logger

MightyPorkCurrently I log like this: logging.basicConfig( format='%(asctime)s %(levelname)s : %(message)s', datefmt='%Y-%m-%d, %H:%M:%S', level=logging.INFO, filename='example.log') logging.info('Writing some stuff') I want to add log rotating or limit the log length, because it grow...

yet anotehr
this morning not a single decent thoughtful or researched questions
 
@Vader a better method would be lines = list(islice(file, 8)) if they don't want all lines for something else
 
@thefourtheye used clairvoyance there to get the answer right without seeing any code.
 
10:41 AM
@AnttiHaapala I was totally shooting in the dark there :(
 
Please don’t cv-pls during the first 10 minutes of a question’s existence - same for ?
 
@clemos24 Ya we could, but we don't actually know what the OP's problem is :( — thefourtheye 8 mins ago
 
@61612 there is no
 
Well, I used it quite a few times here when I was unsure about a question, that's why I'm asking
 
can anyone guide me to a simple function that can be used to encode ints, string, floats to raw binary ?
 
I need to send (u32|s|u32|u8|u32|s) byte stream in socket
 
yay 1 question deleted
 
I am trying to use struct.pack which doesn't seem to work
 
@Neel "which doesn't seem to work" isn't particularly useful :)
 
Could you elaborate? How do switch do the interpreter I want, and why isn't what I was trying to do not correct? — Luken 2 mins ago
anyone else want to answer that?
I have run out of politeness juice
 
10:49 AM
@JonClements buffer = struct.pack('IsIBIs', address_size, address, time, 0x0, signature_size, signature)
This is what I am trying to do
 
Okay... and you're setting address_size to be len(address) ?
 
yes
and this is what I am getting \x0b\x00\x00\x001\x00\x00\x00@\xa9\xe9T\x00\x00\x00\x00\x11\x00\x00\x00\x0
B is the one byte combination of flags that I kept 0x0 for now
 
Okay... you also need to specify a width to the ss
 
How ?
 
Like 32s
 
10:51 AM
struct.pack('I8sIBI12s', ...)
 
ahh also
 
Yeah, but put in the size according to the strings
 
you didn't specify the byte order
 
Also double check you've got endianess right
 
@NeelBasu what protocol is this?
 
10:52 AM
@AnttiHaapala Hmm how do I specify that ?
@AnttiHaapala Homebrew
 
@Neel it's in the docs... :)
 
your own?
 
@JonClements yes, written the server in C++ working. just need a demo client for presentation
 
hmmmm
ok so why don't you show how you read in C++
why didn't you say
 
@AnttiHaapala sorry I didn't understand
 
10:54 AM
by default uses native alignment, which means that it is never what you'd expect EXCEPT if your C++ expects to get a struct
 
I C++ I read the byte stream buffer, and reinterpret cast is
 
ok, that is the wrong way
ah ok that is slightly better...
 
Yes But I don't have time to write so many structs
 
I mean:
this does not work correctly, it is actually an incorrect C++ program in that it uses unaligned access
 
and I cannot use boost serialize or anything like that as client programs will be written on sensor's micro controller
 
10:57 AM
there is no guarantee this is at all portable
 
@AnttiHaapala What you suggest in C++ side ?
 
@Vader: There's a more efficient way to do line.split(' ')[:8]. The str.split() method takes an optional maxsplits argument. Also, to split on whitespace it's generally better to not supply a sep argument. See the docs for details & examples.
 
C++ does not make guarantees that you can do reinterpret cast at any arbitrary pointer and get a correct value, not at al.
 
Yeah, I deleted it anyway. He is using python 2.7
also maxsplit doesn't give you what you think it does
I tried that :D
 
maxsplits = 9 then splice 8
though it is still slow
 
10:59 AM
@AnttiHaapala Yes but what is the other way out then ?
 
I must admit that do not know what is the best C++ way
 
It will just return the rest of the entire line in the last element
 
just trying to help you understand that your code most probably won't ever work :D, except by accident
 
@AnttiHaapala end of the day it is an arbitrary byte stream server may expect and check endian ness. but what more it can do ?
 
which one of these qwas in microcontroller? the C++? (obviously)
 
11:02 AM
@AnttiHaapala The client will go in microcontroller.
right now I am arranging the demo with a simple python client on raspberry pi
 
generally you'd want to do a binary protocol so that it uses network byte ordering (or the embedded byte ordering) and no padding.
but then you need to be prepared to read it in C++
 
@AnttiHaapala Yes I think you meant strictly specify byte order
 
yes, but the C++ code does not even work in the special case:
 
@Vader Sure. So you throw that last element away if you don't want it.
 
['This', 'is', 'the first line with a few words on it\n']
 
11:07 AM
you know if you have uint32_t followed by string of 3 bytes, then uint32_t, you cannot safely reinterpret_cast that 2nd char* to uint32_t anymore
 
Oh I see what you mean now
We can just throw the last one away
 
@AnttiHaapala Sorry I didn't understand why ?
 
because you can't
 
@Vader Or maybe get that last element and feed it into something else.
 
on ARM you can have unaligned access which can crash the processor or return wrong bytes
some C compilers round the addresses etc...
 
11:09 AM
@AnttiHaapala If I know the string is 3 bytes only I'll forward the iterator 3 bytes only
Oh! I didn't know
@AnttiHaapala Hmm that requires padding then
 
9
Q: Any real example of reinterpret_cast changing a pointer value?

sharptoothAccording to C++ Standard, a reinterpret_cast of a pointer T* to some other type pointer Q* can change or not change the pointer value depending on implementation. I'm very interested - it there any real example of a C++ implementation where casting a pointer to some other pointer type with rein...

nope
instead you should use something that reads byte at a time
wait
found a deleted answer that could be of help
(and this is why I hate C++, it is 100 times more complicated than C, yet you still have all the gotchas of C)
 
@PM2Ring why? It will not be needed anyway
 
Hmm it should be there on the microcontroller side ? right ?
 
11:14 AM
I am not doing that
I am doing the server side only
 
ahha :d
then you have a problem :D
 
I just need to show the demo on how the server program works
 
so in that case you just assume this is a packed struct,
 
NO no it is a demo protocol
 
in the microcontroller's byteordering
 
11:16 AM
yes. or I need to specify the byte order
 
no, what I mean, is that you need to assume how the microcontroller works
but the code on microcontroller is broken, it is not valid C++ :D
 
well I just need to demonstarate how my server program works (which actually create pts and does various traffic forwarding and mux'ing)
for that I've written a dummy protocol, a dummy mitrocontroller board (which is a raspberry pi)
I am supposed to demmonstrate how the server program works with these dummy setups
and just to show various types of people that both client and server can be written in various languages I am trying to limit the client in a simple python program
 
thus you'd do a function u32_to_bytes: struct.pack('<I', value); and u8_to_bytes: struct.pack('<c', value)
 
I hope I am able to make you understand
 
it is best then just to paste these together:
u32_to_bytes(address_size) + address + u32_to_bytes(time) + u8_to_bytes(0x0) + u32_to_bytes(signature_size) + u32_to_bytes(signature)
or better make the str_to_bytes() which will do the length + bytes after that
the struct.pack really is for fixed size structs so I wouldn't even care to do variable length formatting for it (struct.pack('<I%ds'. % len(string)), string))
bc it just looks plain ugly
and if the byte ordering is wrong then you'd have to use '>' there
address_size, address, time, 0x0, signature_size, signature)
 
11:29 AM
will the bytes() function work as str_to_bytes
 
@Vader Sure, in this particular case we don't need the end of the string, so we can just throw it away. But str.split() behaves the way it does to make it convenient when you need to parse a string that requires different splitting rules on different sections of the string.
 
@NeelBasu python 2 or 3? what are we talking about here?
what are you converitng to bytes
 
user1804599
Other bytes.
 
python 2
apart from anything I don't understand how comes @ in this struct.pack output \x0b\x00\x00\x00192.168.0.4@\xa9\xe9T\x00\x11\x00\x00\x00Dummy Device Inc.
 
11:45 AM
cbg @Martijn
 
This is what I am trying buffer = struct.pack('<I%dsIBI%ds' % (address_size, signature_size), address_size, address, time, 0x0, signature_size, signature)
 
@NeelBasu yeah would work but as I said, I wouldn't squeeze that into 1 struct pack
@\xa9\xe9T
is the time
>>> struct.unpack('<I', '@\xa9\xe9T')
(1424599360,)
 
@AnttiHaapala Yes this is time
But why @ ?
 
because it is a printable ascii character
thats how the str works in python 2
 

« first day (1590 days earlier)      last day (3375 days later) »