« first day (2170 days earlier)      last day (2779 days later) » 

Too late
 
this question gave me anxiety from the amount of detail: stackoverflow.com/questions/39669569/…
 
if it's calcsizing to the right number, it should be sending the right number... but it's not
 
6:19 PM
hi
 
hello
 
I need idea for developing this website
qweb.ir
what's your idea about that
and do u know such website
i just want to get idea
to implement it well
 
Do you want to use Python? If it's HTML/CSS/JS then there's a room for that too!
 
python is my second step
 
What's your first?
 
6:24 PM
@BhargavRao good man, give him something to sink his teeth into
 
developing UI
 
Aha, There there. You need to visit the HTML/CSS room for that, Not this! :)
 
yes
i'll go there but no body survive lol
all of them die :D
 
@RobertGrant Nah, I ain't give any ideas :D
 
Surely they aren't dead! Probably just drained.
 
6:27 PM
really, did they bombard by Atamic bomb?
 
Nope, By the PHP bomb
 
:D of course
 
user6568562
Congrats on your new home @RobertGrant, btw [ : Those life check-boxes are getting validated like crazy : D
 
Haha yeah
 
Congrats Bobby :)
 
6:31 PM
Thanks guys
We went there today to try keys - barely remembered what the place looked like!
 
user6568562
I can imagine that ! When's the final move and settle planned ?
 
When's the house warming? I need to set my affairs in order.
 
Hi
 
hello
 
@randomhopeful got 2 weeks of $stuff to be done to the house (damp, ceiling replace, decorating, etc) and then just sometime after that!
 
6:35 PM
Can somebody help me to add a condition to a simple function?
 
@idjaw hate to break it to you over chat but we've decided to stop allowing you to have affairs at our place :-(
 
@linuscl Ask directly! See our room rules here sopython.com/chatroom
 
@RobertGrant It was ONE time...ONE!....fine....
 
user6568562
@RobertGrant Nice ! Really really almost there, like 99% there
 
@BhargavRao thanks: This is the function: def closest(possiblities, target):
'''Modified from http://stackoverflow.com/questions/445782/finding-closest-match-in-collection-of-numbers/445824#445824'''
return min((abs(target - total), (o_list, total))
for o_list, total in possiblities)[1]
 
user6568562
6:37 PM
@idjaw I'm not sure "borrowing"* all the floor tile count as one time, idjaw !
 
add condition total higher or equal target
 
@linuscl 1. Use separate lines for your messages 2. indent code with 4 spacess
 
@idjaw however we'll probably put the place on airbnb over december; no moral judgment then!
 
def closest(possiblities, target):
'''Modified from stackoverflow.com/questions/…'''
return min((abs(target - total), (o_list, total))
for o_list, total in possiblities)[1]
 
@RobertGrant \o/
@linuscl I have absolutely no idea what it is you are trying to do. Can you please formulate a proper explanation of what you are trying to achieve and show a better representation of the code you are working on?
 
user6568562
6:39 PM
I'm sorry, I misread the scenario. I'm horrible at group improv
 
@idjaw I want to find the closest match in a list with integers, and the found one should be higher or equal to the target
@idjaw hope you've understood me
 
@linuscl Even in a chat room, we need a MCVE like on the main site :)
 
This is the MCVE (the function): f=lambda a,l:min(l,key=lambda x:abs(x-a))
 
user6568562
-"To be or not to be, that is the question."
-“thus with a kiss I die”
Goddammit, random !
 
@linuscl Can you put it in pastebin and link it here? That'd be easier for everyone.
 
6:45 PM
@BhargavRao This is/was my try to achieve it. pastebin.com/L2Fy311B
I have a list (possiblities) and a target value. Then I'm saving the differing value of every list value - target value in a list.
Then I'm calculating the closest value by using min() and look at the index of this value in the aux-list.
 
@linuscl That's a nice piece. Now, we know your aim, code and algo. The only thing that you need to inform is, "What's the error"!
 
Hi people
Can somebody help me please?
 
I defined a simple function in a .py file. This function uses a library, urllib.
 
@Victornez Hi! Please read the chat rules. In short, yes, please just ask your question. :)
 
6:51 PM
@AnttiHaapala cabbage
 
@idjaw why do you have to be so fast :d
 
cbg once again @AnttiHaapala
 
@ZachThompson this again is in the documentation
 
@AnttiHaapala give yourself more credit, You just popped back in to chat :P
 
Then, from ipython I imported the function, but i get an error when I am using it. It says that urllib is not defined.
I imported urllib previously from the ipython console... So I know that is there.
 
6:54 PM
@Victornez you did what :?
 
Fine then guys, I gotta leave. Rhubarb all
 
Let me try to explain better...
 
@BhargavRao ip yet?
 
I have a file... File1.py
 
@Victornez Show a pastebin of your code
to know how exactly you are trying to use urllib
 
6:54 PM
Yes I'm aware the issue is in the documentation but I'm not seeing much of a solution there.
 
and specify what version of python you are using
 
@BhargavRao: It gave me some wrong numbers
 
@Victornez and please paste its contents to a pastebin, say bpaste.net
 
@ZachThompson it is very much in the same section that explains about alignment.
 
6:55 PM
I'm using python 3.4
I have that code in a file
 
@Victornez and where are the imports...
 
with the pad bytes?
 
In the iPython Console
 
@ZachThompson ... alignment...
 
@Victornez what do your imports look like
 
6:56 PM
In the ipython console I have "from urllib.request import urlopen"
 
@Victornez please read the python tutorial on modules. you must have import statements within your File1.py
 
I tried that
 
@Victornez Can you show exactly what is in the python script you are using to try to run that code? Because if what you have in the pastebin is what you are trying to run, then you are not importing anything and the failure is expected.
 
I need them to be aligned in a specific order though.
It has to be 3 bytes followed by a 4 byte chunk.
 
Yes
 
6:58 PM
This:

>>> pack('ci', '*', 0x12131415)
'*\x00\x00\x00\x12\x13\x14\x15'
>>> pack('ic', 0x12131415, '*')
'\x12\x13\x14\x15*'
>>> calcsize('ci')
8
>>> calcsize('ic')
5
 
I have this :
 
"By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler)."
@ZachThompson please read and understand the above ^
"Alternatively, the first character of the format string can be used to indicate the byte order, size and alignment of the packed data, according to the following table:"
 
In console I'm doing this :
from file1.py import scrape_products
 
and then below, there is a table of characters that you can use as the first character in your format.
 
It works great
 
6:59 PM
=/
1 hour ago, by idjaw
> The ordering of format characters may have an impact on size since the padding needed to satisfy alignment requirements is different:
 
But when I use the function, I get the error about urlopen
 
@idjaw I know, I hit him in the head with the documentation ~12 hours ago already.
 
I'm using ! to indicate byte order.
 
@ZachThompson oh you are?
 
yes dude
 
7:01 PM
then where is that ! hidden in the code above^
 
in another file
calcsize('!bbbi') = 7 yes
 
after someone else said that, I checked and ran it in the python SHELL that I was running that code in prior
 
@idjaw do you remember my question? Did you notice it? :)
@idjaw Here comes the error
 
@Victornez OK. Let's try this a different way. Is this what is happening?
 
7:03 PM
so my issue is. it's dropping a byte along the network somehow. 24 should be '18000000' but it's '180000'
that i value, when it should have all 4 bytes supposedly
 
@idjaw Yeah
Exactly
In console I also imported the module.
 
great. As I and Antti mentioned, you actually have to properly import urllib inside your script!
as well as your import for beautifulsoup
 
@linuscl hey, you've defined an all function that does exactly that which the builtin all function does...
 
ack = pack('!bbbi', 7, incoming_data[1], errorCode, result)
 
@AnttiHaapala Nope, Not until October I guess. It is midway between my apartment and my office. Now I am staying at my parents place, So only once I get back to my apartment I will be able to go. :/
 
7:04 PM
Exactly like this?
 
@linuscl Sorry...at first someone else seemed like they were looking at it, and I did not go back to it. I am actually not too sure.
 
Or what I'm doing differently?
 
@AnttiHaapala oh, really, maybe that's the problem. Thank you, I'll change and try
 
@linuscl Oops, I gotta leave. Don't worry, you're in safe hands when you are in this room. You'll get help, I'll assure you :)
 
@linuscl no it is not, but I'd not hire someone who writes their own all function :D
 
7:05 PM
Rbrb guys \o
 
where result is result = int(incoming_data[4] + incoming_data[5])
 
@BhargavRao rbrb
 
no real need for the int type casting it doesn't do anything. but incoming_data[4] and [5] have format characters h
 
@Victornez I just copy pasted your latest pastebin and it runs without error now.
@BhargavRao rbrb
 
@linuscl one thing more, why do you mix '' and numbers abs(target - valor) in the same list?
 
7:08 PM
@AnttiHaapala Yes,you're right, changed
 
@idjaw You are right, I was doing the import again but it didn't work.
I close ipython and opened again
 
@AnttiHaapala That's because I need the index
 
and it works
Thanks a lot for your help!
 
cheers
 
@Victornez that is because the imports are cached.
 
7:09 PM
Oh
I get it
@AnttiHaapala Thanks
 
@AnttiHaapala also if the input value is not higher than the target value, it stay the same index
 
@Victornez sorry couldn't find any better than: docs.python.org/3/reference/import.html#the-module-cache
@linuscl you must be using Python 2 here.
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
>>> max([0, ''])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() > int()
or perhaps you didn't meet this problem yet...
 
@AnttiHaapala Thanks a lot for the link, now I understand. Thank you.
 
@linuscl also, in python 2, '' is greater than any number.
python 2:
>>> max([100000000000000000000000000, ''])
''
in conclusion: never mix numbers, strings in a list and then expect to do anything sensible with min, max, sort...
 
@AnttiHaapala pastebin.com/vYkLATRj
it's towards the bottom when I'm packing it in my while loop that it's fucking up.
 
7:18 PM
@AnttiHaapala what should I do, if I want to keep my indexes?
 
@linuscl I do not know what you actually want to do
you've just got an XY problem here, what is this function supposed to do?
"I want to find the closest match in a list with integers, and the found one should be higher or equal to the target"
right?
 
This is/was my try to achieve it. pastebin.com/L2Fy311B
I have a list (possiblities) and a target value. Then I'm saving the differing value of every list value - target value in a list.
Then I'm calculating the closest value by using min() and look at the index of this value in the aux-list. ((old post))
 
no, I asked what do you want to achieve.
 
Find closest or matching number that is higher then the target value
 
also, you do not want the value, you want the index?
 
7:21 PM
That's the way to print the value stored in the tuple "possiblities"
If you know another way, just tell me :)
 
why are you re-implementing all?
 
^ I've changed that in the past, that's not the problem @idjaw
 
I know it's not the problem. Just asking
 
Do you want to see the "whole" script (it's a subset sum algo)?
 
no. It's OK. Was just curious about that. I need to get going anyway.
 
7:25 PM
@linuscl first of all, you do not need to keep indexes
 
rbrb for now o/
 
@idjaw bye
 
you want to return a certain item, not know its index.
 
that's true
What do you think of? @AnttiHaapala
 
>>> differences = [(olist, valor, target - valor) for (olist, valor) in possibilities if valor > target]
>>> olist, valor, difference = min(differences, key=lambda item: item[2])
something like that,
and that'd be the returned item ^
perhaps there is a sign error, and it should've been valor < target or valor - target or something like that...
because I am not sure that I understood your description exactly,
 
7:28 PM
@AnttiHaapala my lab partner said my server works with her c++ client, why isn't it working for my c client?
I'm convinced my implementation is correct.
 
I am not
 
C also has alignment requirements.
 
yeah, I've done the ntohl thing? Isn't that what you're talking about?
 
no it is not.
pastebin is down, please use a sensible pastebin solution with syntax highlighting, such as bpaste.net
 
7:30 PM
Okay, so why does it work correctly when I do say
pack('!ibbb', stuff...) but when I do pack('!bbbi', stuff....) it drops a byte?
on the c client side, it's only storing 3 bytes for the result.
 
@ZachThompson get yourself a C book.
 
The C code works though. I've had it run with other servers.
The issue is on the python end.
 
Data structure alignment is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding. When a modern computer reads from or writes to a memory address, it will do this in word sized chunks (e.g. 4 byte chunks on a 32-bit system) or larger. Data alignment means putting the data at a memory address equal to some multiple of the word size, which increases the system's performance due to the way the CPU handles memory. To align the data, it may be necessary to insert some meaningless bytes between the end of the...
read and understand.
 
@AnttiHaapala I've got the solution: return min(((o_list, total) for o_list, total in possiblities if total >= target), key=lambda (o,t): t - target)
 
I already know that.
 
7:34 PM
@ZachThompson no you don't
 
@AnttiHaapala I'll test this further
 
the result, which should be passed along as a 4 byte chunk, is to be stored in a variable int32_t
except
when I read the int32_t it's stored with %x
it's only 3 bytes.
 
@ZachThompson and where is this C code of yours
 
hold on
 
just to note that you're wrong already, I just want to point exactly where you're wrong.
and you do not understand the data structure alignment.
 
7:37 PM
please excuse my quirkyness pastebin.com/ctNwXijf
 
@AnttiHaapala thanks for your help, bye
 
typedef struct {
        int8_t TML;
        int8_t reqID;
        int8_t errID;
        int32_t result;
} ACK;
there ^
 
now go to wikipedia and read and understand the article that I pasted to you ^
 
3 bytes followed by a 4 byte chunk.
:'(
 
7:38 PM
int32_t is aligned at 4 bytes.
86
Q: Structure padding and packing

ManuConsider: struct mystruct_A { char a; int b; char c; } x; struct mystruct_B { int b; char a; } y; The sizes of the structures are 12 and 8 respectively. Are these structures padded or packed? When does padding or packing take place?

 
that is kinda what I assumed. I'm reading the things you sent me though.
 
the only proper way to do it in C is to read 7 bytes into a char array,
then use
 uint32_t result;
 memcpy(&result, array + 3, 4);
but that's C, not python.
 
re-cbg all
 
7:54 PM
@ZachThompson there's also the C room
@MartijnPieters OP updated with input, exception, sigh... stackoverflow.com/questions/39675793/… ...
 
8:12 PM
hi
 
what does cbg mean ?
 
it means "cabbage", whose meaning is then explained in the room rules
 
cabbage is something to eat. am I right ?
 
did you read the rules? It's called salad language for a reason
 
8:16 PM
well, it means hello, and those orange words are a hyperlink...
 
rules website is not available for me.
 
hehe poor you
that's a very strange firewall whitelist that you have, allows chatting here, which is probably the worst waste of time imaginable, but not visit the sopython wiki.
 
in my country highest speed of internet is 4 MB, what about yours ?
 
@Uncle iran blocks sopython?
 
8:20 PM
I think we've made it if that's true
 
@AnttiHaapala no but its not available
 
very strange
could be internet routing error too
 
@JGreenwell thank you !
 
no problem
 
@AnttiHaapala I think the host provider of SOpython is blocked.
 
8:23 PM
that network belongs to
network:Organization;I:Swarma Limited
network:Street-Address:36a Denbigh Road
network:City:London
network:State:UK
network:Postal-Code:W13 8NH
network:Country-Code:GB
 
>>> whois.whois('http://sopython.com')
{u'updated_date': [datetime.datetime(2015, 12, 14, 0, 0), u'2015-12-13T20:16:42.00Z'], u'status': [u'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', u'clientTransferProhibited https://www.icann.org/epp#clientTransferProhibited'], u'name': u'WHOISGUARD PROTECTED', u'dnssec': u'unSigned', u'city': u'PANAMA', u'expiration_date': [datetime.datetime(2017, 2, 7, 0, 0), u'2017-02-07T18:27:00.00Z'], u'zipcode': u'00000', u'domain_name': u'SOPYTHON.COM', u'country': u'PA', u'whois_server': u'whois.enom.com', u'state': u'PANAMA', u'regi
yes hosting is blocked unfortunately
 
ah that is the proper host yes
 
hi
 
the IP network on which sopython.com runs, belongs to swarma limited.
host sopython.com
sopython.com has address 75.126.24.80
 
i just register a domain but i got a little confused. can i register an email just like Info@mydomain.com
 
8:28 PM
@Sandro yes, mainly it depends on your host provider, but 1 or 2 emails are free.
 
Am I the only one here who didn't realize you could do in python:
for obj.prop in collection:
<stuff>
?
 
you know i want to print my visit card and want to make sure can i register Info@mydomain.com
 
if you've now got mydomain.com, then you should find a hosting provider (or use the domain registrar),
@Sandro so why not get the mail working first.
before you even make any visit cards.
 
because the designer got angary at me
 
8:30 PM
@namey no you're not,
I had been using python for more than 10 years before I found that out
... and ... you shouldn't be using it anyway :D
the reason why it works is that that part is just another ordinary assignment statement.
 
best decision is to first register your email address then print your visit card
 
yes uncle
 
@namey could be useful in code golf though; also @MorganThrapp
one can set "variables" in list comprehensions, generator expressions
>>> a = []
>>> for a[:0] in [[1, 2],[3, 4], [5, 6]]:
...     pass
...
>>> a
[5, 6, 3, 4, 1, 2]
@namey ^
 
0
Q: Is this possible to modify python packages with python shell?

UncleLet’s say I have a python package like this : my-python-package/ __init__.py app.py __init__.py is empty and it is just for telling python that we have a python package. And app.py is this : FAVORITE_COLORS = ['blue', 'purple'] Here is the idea, I want to append another color to thi...

answer above question please
 
use pickle
 
8:42 PM
@Uncle no, the changes within the module at runtime are not reflected back to code.
 
is it possible without pickle ?
 
everything is possible but it doesn't mean that one'd use that...
 
why are you trying to modify a module within the shell?
 
@MattDMo I'm trying to build a web framework based on Django, it is fully-dynamic therefor sometimes I need to manipulate modules
 
If you want to modify something, make your module read a config file that the user can modify, and use the values therein.
Which, not surprisingly, is how Django does it.
Modules themselves should be thought of as immutable in Python - otherwise you can't trust how they'll behave. They should always have a default behavior that can be fallen back on.
 
8:52 PM
is there something like generator for classes ?
 
What do you mean?
 
what you want is somewhat achievable by using AST, parsers, lexers, etc.
it gets very complicated soon...
 
@MattDMo I mean modify a class based on another class (modify not inheritance)
 
do you mean "modify the source code"?
 
@AnttiHaapala yes, not overriding
 
8:55 PM
all these can be done for sure, but it is very complicated
 
also massive security hole if not done properly
 
and not recommended...
 
it would be the most complicated thing in your framework!
 
I still don't understand why you want to do this.
 
user6568562
Good night everyone [ :
 
8:57 PM
you know, in my opinion, way of doing things is more important than things !
 
When you play with the source code from within the program, you change how the program runs. A program (IMO) should run the same way with the same input every single time. If you're messing around with the source, that might not happen.
 
@MattDMo because I try to make flexible modules !
 
There are plenty of ways of being flexible without doing what you're suggesting...
 
@MattDMo my definition from flexibility is behave different in different situations. I don't mean working with different inputs
 
well, good luck with that
 
9:01 PM
مرسی
 
ah, so build an AI which uses back propagation, statistical learning, heuristics, or other means which changes based on a model and training sets
 
@JGreenwell I need to learn something before doing that
 
yes, but that is what you are asking for; been 2.75 years for me and I am still learning
 
yeah
 
9:14 PM
translationbot result مرسی => merci => thank you. do not respond please
 
@idjaw :|
 
@idjaw you're a translationbot?
 
@AnttiHaapala autoresponse that is correct.
 
Farsi -> French -> English -> Salad sounds like it is much more prone to translation errors than Google translations...
 
9:34 PM
@AnttiHaapala autoresponse do you question my skills bro?
 
I didn't know that I could be a brother to a translation machine... ah you mean metaphorically, right?
 
@AnttiHaapala autoresponse you programmed me
 
:D
 
9:55 PM
51
Q: Find the maximum of two numbers without using if-else or any other comparison operator

SuperManFind the maximum of two numbers. You should not use if-else or any other comparison operator. I found this question on online bulletin board, so i thought i should ask in StackOverflow EXAMPLE Input: 5, 10 Output: 10 I found this solution, can someone help me understand these lines of code int...

ewww
that is a closeworthy post really...
people do not even read the question but answer with their own algorithms
 
ew.....
 
so there is Java, JavaScript etc crap,
when the question is a) about C, and b) asks "how does this algorithm work"
c) the accepted answer explains how does it work, but even then it doesn't really tell that the algorithm actually doesn't work. (it is implementation defined at best).
 
I should answer it in COBOL just to show 'em
 
@JGreenwell I guess I downvoted every answer and the question itself there...
wouldn't hurt much to downvote yours as well.
@vaultah wrong dupe
 
maybe
 
10:05 PM
I'll reopen
the problem is that the check is prone to races
 
Hi, I have nginx and flask installed I am using Python Dev and already working in a virtual env. I have successfully created static graphs on my flask using matplotlib and numpy plus scipy.
At this point I want to collect real time data and plot it into an interactive graph. I have tried several approaches and I am getting the following Error in some of them:
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: no display name and no $DISPLAY environment variable
I would be happy if someone can check my code and see what I am doing wrong? Thanks
 
@AryeGuetta you're using tkinter inside a webserver, that's why.
that interactive graphing is using tkinter that creates a desktop application window, which naturally doesn't work in Flask.
 
So I can only have static graphs on a webserver? I can not able to have interactive graphs at all?
Thanks I didn't even realized that :) - That means I can NOT have interactive images on a Flask Webserver or any webserver at all?
 
@MartijnPieters thanks for carefully reading my comments on the question, oh no.
 
I wonder what percentage of my hammers get silently reopened
 
10:17 PM
martijn just rehammered it
dsaölkfsaölfdkfdsaasfd
 
lol that edit
 
@MartijnPieters I am going to bed but seriously, please read and think through what you wrote in that comment and which dupes you proposed and also what their accepted answers say?!
the current dupe target says, in its accepted answer that in 50/50 case, if should be used, depending on timing.
 
11:01 PM
@AryeGuetta use JavaScript. That's what it's there for.
 
11:31 PM
granted, I've used static graphs with drill-down links (for low-scale intranet application) but it wasn't scalable
 
11:42 PM
Thanks MattDMo - I will have a refresh JS code that will update the data for me and I will not use the animation of matplotlib at all, that is what you are telling me?
 
@AryeGuetta No, you can still use matplotlib to create animations on the server side and send them to the client. However, if you want interactivity, you'll need something like D3.js
 
How Can I make it move to the left - meaning popping out data when there is now need for it any more. If I will have the same draw and plot function refreshed on itself I will have the data pilled up and over draw the graph itself and I will have something that I can't use. Is there a way to have the PNG file refreshed and the data will be popped out ?
 
You should also check out bokeh. I haven't played around with it much, but I believe it outputs to an HTML5 canvas and allows for interactivity that way - the JavaScript is already built in.
 
So I will have the animation on the server side - the flask route that will bring me to anim.png and I will need to have D3.js running where? Can you please provide me with an example or a link of which I can learn that from Thanks
 
@AryeGuetta That's pretty straightforward with CSS and JS
 
11:50 PM
is bokeh can be installed using pip install on my virtual dev?
Virtual environment .
 

« first day (2170 days earlier)      last day (2779 days later) »