« first day (1499 days earlier)      last day (3436 days later) » 
01:00 - 14:0014:00 - 22:00

1:01 AM
@corvid I see you got a rasp pi, I've always thought it'd be awesome, where'd you get it from?
 
@M0dem Micro Center
 
ok :)
 
 
2 hours later…
2:46 AM
 
lets say I had a lastrecordedtime = 2014-11-22 18:51:08 and I wanted to do an if statement that says, if currenttime > lastrecordedtime:
then do whatever
when I say > I really mean newer
 
make it a datetime object. Datetime objects are comparable
 
3:07 AM
thanks! .strftime('%Y-%m-%d %H:%M:%S')
 
 
2 hours later…
j0h
5:05 AM
I have a build error in python3.4
http://pastebin.com/dn0FmjMy
some russian site cannot load
 
user559633
5:16 AM
brace yourself, the "why does my homework answer not work correctly" questions are coming
 
user559633
@j0h that seems like a legitimate error: испытание => "xn--80akhbyknj4f"
 
user559633
and испытание.python.org doesn't seem to exist
 
user559633
hg.python.org/cpython/rev/c16e047965a2 and the "test" subdomain for .ru got moved
 
Guys, why is the following code valid?
class Celsius:
def __init__(self, temperature = 0):
self._temperature = temperature

def to_fahrenheit(self):
return (self.temperature * 1.8) + 32

@property
def temperature(self):
print("Getting value")
return self._temperature

@temperature.setter
def temperature(self, value):
if value < -273:
raise ValueError("Temperature below -273 is not possible")
print("Setting value")
self._temperature = value
I know that this piece of code demonstrates how to use properties instead of getters/setters. But what I don't understand is how is it possible to have two functions with the same name (i.e. temperature) in the same scope?
I know how decorators work, but shouldn't this cause a conflict?
 
user559633
see sidebar about formatting code
 
user559633
5:29 AM
and it's valid because of how decorators work
 
From what I understand, decorator is syntactic sugar for
temperature = decroator(temperature)
There are two definitions for temperature
How do the decorators know which definition of temperature to use?
 
user559633
because* signatures
 
>>> def overload(a, b):
... return a + b
...
>>> def overload(a):
... return a
...
>>> overload(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: overload() takes exactly 1 argument (2 given)
So, of course, signatures can't be it
 
user559633
:) you know best
 
Could someone who knows more than me here please help me? :)
@tristan - Thanks for trying to help :)
 
user559633
5:36 AM
Hah, I was pointing you in the right direction but hey
 
user559633
If you want it more directly fed to you, consider why you type @property vs @something.setter
 
is there a better way to strip html tags than this stackoverflow.com/a/925630/2698552
 
That is because, I first create a property object with a getter and then create another property object which additionally adds a setter
 
user559633
properties are more than getters and setters
 
Yes, there is also fdel. But that is going away from my original doubt :(
How does Python know which temperature function object to pass to the decorators?
 
user559633
5:42 AM
Do you know how decorators work?
 
user559633
so again, @property vs @something.setter.
 
If your argument about signatures is correct, why am I not allowed to define two functions with the same name but different signatures?
 
user559633
You're allowed to call def temperature() twice because the resolution isn't the same
 
What do you mean by resolution? :)
 
user559633
5:47 AM
your experiment with the repl showed you that you were redefining overload, yes?
 
@Ffisegydd @JonClements writing a simple parser for html processing. let me know if i need to refactor code github.com/ChillarAnand/nidaba/commit/…
 
user559633
but when you used the property decorator, you seemed to be able to define temperature() twice, yes?
 
ah, so it is because we redefine the function and so the previous definition doesn't hold any more?
 
user559633
uh, no.
 
5:49 AM
then? :O
 
user559633
what do you think @temperature.setter is doing?
 
temperature = temperature.setter(temperature)
I assume it is the syntactic sugar for the above?
 
user559633
why do you think that?
 
So, this is wrong? :O
Sorry, I didn't understand your question :(
 
user559633
meh, it's not fun if i just give you the answer
 
5:53 AM
I am grateful and very willing to try to take the hint if I can. So, please give more bread crumbs?
Or alternatively, give me the answer straightforward since that is my objective anyway :( :)
 
user559633
well, i don't work for you, so :)
 
This is why I said I am very grateful :)
There is nothing more I can do for you in return but to promise that I will help someone who is in my position and I am in yours :))
 
user559633
to_fahrenheitis a function. temperature is a property object.
 
temperature is a function when it is defined as
def temperature(...)
no?
 
user559633
if it was a function, i would have said it was a function.
 
user559633
5:57 AM
it's a property object.
 
Okay, now I am even more confused :( temperature is a property object as well. And there are two functions with the same name (at least from what I understand, maybe my understand is wrong).
 
user559633
Your understanding is incorrect.
 
Why is it not a function too?
 
user559633
Because you're making it a property.
 
user559633
With the @property decorator.
 
5:58 AM
But there are functions with the same name as well, isn't it so?
def temperature(self):
print("Getting value")
return self._temperature
Is this not in the function scope?
 
user559633
The two def temperatures don't result in overwriting a function, as we've established, correct?
 
I know my answer might be frustrating for you, but I cannot lie that I have understood how this is established.
 
user559633
Remember when I told you "type signatures?" here's the actual source code hg.python.org/cpython/file/tip/Objects/descrobject.c#l1207
 
My C knowledge is only just enough to understand the syntax. Could you please elaborate what _PyMethodWrapper_Type actually refers to?
 
user559633
you figured out that you can't redefine methods right before asking "Could someone who knows more than me here please help me? :)"
 
6:04 AM
yes, I know that if I redefine function, the previous definition doesn't hold anymore
 
user559633
and you claimed to understand what decorators do
 
okay, this is where the problem might be. I think I understand them.
 
user559633
you're right that decorators "wrap" a function and return it
 
user559633
and you're right, decorator() is a function that returns something
 
user559633
in this case, it's a property object.
 
user559633
6:06 AM
which means that @property and @temperature.setter are referring to different decorators that wrap some code and return it
 
But clearly, from the source code, two functions named temperature are defined as well. Are they not in the same scope?
 
user559633
so if redefine a function, the previous function is overwritten
 
That is the only way identifier conflicts won't arise (again, from my understanding).
 
user559633
so then your second function declaration doesn't replace the old one
 
I understand that they are different decorators
The functions that decorators wrap, are they still defined in the scope where the result of the decorator holds? Or are they not in the function scope?
 
user559633
6:09 AM
@property
def temperature(self):

@temperature.setter
def temperature(self, value):
 
user559633
so you have a) different signatures and b) different decorators.
 
If we don't use syntactic sugar, won't the source code go like?
def temperature(self):
temperature = property(temperature)
def temperature(self, value):
temperature = temperature.setter(temperature)
 
user559633
@property turns the bound function into a property class object
 
In REST, if I have orders mounted as /customers/orders, (orders of customer), should I also have a /orders URI to get all the orders of everyone?
Or is this usually done by the client by iterating through all customers and then joining their orders? Using Flask-RESTful if it matters
 
I do understand that, @tristan But if the function is also defined in the same scope, how does it not lead to overwriting?
I will be grateful if you could please explain how scoping works when working with decorators
 
user559633
6:17 AM
 
user559633
also because objects can have functions assigned to them
 
user559633
so if the @property decorator turns temperature into an object....
 
Was my code exapansion wrong?
I do not understand :(
 
user559633
have you thought about what property() does?
 
I know that it returns an object
 
user559633
6:25 AM
i mean, i've told you, but..
 
user559633
okay, can you assign methods to objects?
 
This is where I am confused
what do you mean by assigning methods to objects? A method is also an object (in my understanding). So, it's just assigning another reference to an identifier, isn't it?
 
user559633
reference to an identifier?
 
user559633
by "reference" do you mean an actual ref in memory?
 
user559633
6:28 AM
if @property is creating an object..
 
I understand the first two lines (if my code expansion is even correct).
This makes sense -
def temperature(self):
temperature = property(temperature)
 
user559633
and property(...) returns an object.
 
user559633
so then if temperature is an object, then you can have temperature.dogfart(), yes?
 
yes
I know how temperature.setter works, that is fine
 
user559633
6:30 AM
and temperature.getter
 
but how is temperature still pointing to the object and not to the temperature function (the second one)?
 
user559633
and when you just call temperature, your signature is just temperature(reference_to_bound_object)
 
Sorry, I didn't get the last statement
 
user559633
by the time you get to the second temperature method declaration, temperature is a special object and not just a method
 
>>> def overload(a, b):
... return a + b
...
>>> def overload(a):
... return a
...
>>> overload(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: overload() takes exactly 1 argument (2 given)
>>> overload = 1
>>> overload
1
>>> overload(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
>>>
 
user559633
6:32 AM
why are you pasting that crap again?
 
It's different
 
user559633
that's not equivalent to

    @property
    def temperature(self):

    @temperature.setter
    def temperature(self, value):
 
I tried to have a variable named overload
 
I don't think there's overloading in Python
 
And it does interfere with the overload function
 
user559633
6:33 AM
@quantumtremor there's overloading in c
 
user559633
where property is implemented
 
user559633
    @property
    def temperature(self):
        # yayyyyy now temperature is an object

    @temperature.setter  # call temperature object as a decorator
    def temperature(self, value):
        # i'm a method of with a signature of (self, value) on the above object
 
What do you mean by 'on the above object'?
 
user559633
temperature.
 
user559633
6:36 AM
which is then, again, a "property object "
 
That is fine, but what does 'on' mean?
What is the relation of the second temperature function to the property object?
 
user559633
the line after setter?
 
user559633
def temperature(self, value):
?
 
user559633
no offense, but going higher level than C
 
user559633
6:41 AM
it's associating the setter with the attribute
 
so, the second temperature function is not defined before the decorator call is executed?
 
user559633
if the first temperature function was just a function, your second call would overwrite it
 
So, these functions are defined in the outer scope at all?
 
user559633
the outer scope meaning?
 
user559633
the container object?
 
6:46 AM
the scope where the code was written :)
 
user559633
what
 
not inside either of the function definitions...the scope in which the @property call is written
 
user559633
this conversation is starting to repeat itself
 
#scope 1
@property
def temperature(self):
# yayyyyy now temperature is an object

@temperature.setter # call temperature object as a decorator
def temperature(self, value):
# i'm a method of with a signature of (self, value) on the above object
 
user559633
yes
 
6:48 AM
If decorators are syntactic sugar, how would you expand this piece of code?
 
user559633
property makes temperature a descriptor object. temperature is an object.
 
I think that is where the problem lies
 
user559633
temperature is now also capable of being a decorator
 
user559633
the setter then becomes a method on the temperature object.
 
Did someone say decorators are syntactic sugar?
 
6:50 AM
The below is not how it works?
def temperature(self):
temperature = property(temperature)
def temperature(self, value):
temperature = temperature.setter(temperature)
 
user559633
this might confuse you more, but i'm getting bored docs.python.org/2/reference/…
 
@RonaldMunodawafa I thought the @decorator was
 
user559633
why would you ask "how it works?" when you don't understand why property is doing
 
Okay, I don't know what other question to ask.
 
user559633
"how does property() work"
 
6:53 AM
temperature = property(temperature)
isn't it?
 
@ShubhamGoyal syntactic sugar for?
 
user559633
i feel as if you're copying that, but you dont understand what property() does
 
My question is not really about what property does :) What I don't understand is why there is no identifier conflict.
 
user559633
wow, i really have just wasted an hour and a half.
 
What are the benefits of using Jython over Python
 
user559633
6:54 AM
your question is about what property does.
 
Like concurrency wise
 
user559633
apples and oranges.
 
user559633
you mean jython v. cpython?
 
user559633
depends on your code. jython has JIT
 
6:55 AM
How about IronPython?
 
user559633
and i guess it has more java, so if you hate yourself, there's that
 
Does it offer any benefits over CPython
 
user559633
and ironpython is .net if you don't have enough microsoft in your life
 
Well, I am not antiMicrosoft because they cosponsor my uni
 
user559633
i don't care
 
6:56 AM
So, what does property do? :O
 
user559633
@ShubhamGoyal review what i typed above.
 
I don't know how to ask what I don't understand
 
user559633
i've explained it to you several times
 
it created a property object
assigned it to temperature
 
Politics aside are there any issues regarding using Jython or IronPython vs CPython
 
user559633
6:57 AM
@RonaldMunodawafa not talking politics. depends on your usecase
 
and we use setter method of the object to assign a setter to the object
 
I have to write for Windows
 
user559633
if your versions and modules are supported in whatever implementation, it comes down to if you need some feature
 
but why don't the second temperature function and the temperature property object cause a conflict?
 
user559633
cpython is likely a fine choice @RonaldMunodawafa
 
user559633
6:59 AM
@ShubhamGoyal re-read what i typed several times.
 
Thanks
So Python 3 it is
 
@tristan I just re-read it twice. I seriously don't get it.
I am trying hard to understand.
 
user559633
did you read the documentation i linked?
 
nope, let me read it.
 
user559633
and the source code to even skim?
 
7:01 AM
What is the question about the property thing
I keep seeing the question being mentioned over and over again
 
user559633
review back from 1.5 hours ago. stack chat supports loading history
 
Which source code? The C one?
 
Yes, I have read the entire chat over many times. I am more embarrassed to keep on bothering you but I can't get it.
 
Hello.. is there any best way to convert a Iron Python WPF application to exe?
 
user559633
7:04 AM
@ShubhamGoyal maybe my explanation, plus official documentation, plus link to source isn't going to help
 
user2511798 yes
 
I am reading the official documentation now
It is hard to understand for me.
 
But it depends on what you want. Do you want an IL file or you want a native file
 
I don't know yet what a descriptor is :O
 
@RonaldMunodawafa i have used pyc.pc thing... but copy every available dll into the project folder is not the best thing.. even if you create standalone its goes to 4MB! and if you use any of python standard lib in you need put them up too!... its too much work...
 
7:08 AM
You do know if you are on Windows double-clicking a .py file automatically starts running it
 
thats if you have python installed!
i am talking about deployment into client machine
without python thin
 
can you run .py file without python!
 
no
You were saying 4 MB is too much
 
yea.. for a smalll little app.. its too much
for a app which just read a text file.. its huge..
 
7:12 AM
But consider how complex a single abstract Python object is
Have you looked into how Pythons are actually implemented and what composes their data structures and types
Try digging into the magic and you will see it is not too much
 
your talking about a programmer perspective... but i am taking about end user :)
 
Cbg
 
user559633
cbg vaultah
 
Python is good if your creating apps for youself not for the end user!
 
Let us start from here
 
user559633
7:15 AM
must...not...troll
 
Python is fully object-oriented - encapsulation
Type annotations will be added in Python 3.5
Or 3.6
Because it is object-oriented, it is extremely late bound
An extremely late bound and dynamic application has a lot of magic behind it - so much people do not realise the how fast Python actually is
For the end user, your best shot would be to do what DropBox did/does - ship the Python interpreter along with the app
So your .exe file is basically an archive which when clicked calls the python interpreter to execute your app
 
user559633
or just write native if it really needs to be small
 
C# would be a good choice if you want a small app
 
hmm.. python is good for it is .. not for what its not!.. but people stretch it too much.. sayin you an do this and you can do that.. like python gui,python for andriod and stuff.. which simply doesn't work or you get into problem
 
-.-
 
user559633
7:21 AM
on a related note, i'm done with the internet and SO chat for a few days
 
Python is great as a language for scripting an application. You can easily expose an API via Python
What is your app doing anyway
 
user559633
poka poka
 
If we are to draw a space complexity graph as your app becomes more complex the size of the app becomes unimportant
Just as a sidenote, Python was born from a Unix culture where C is king. On Windows, C is king as well but I am yet to come across someone who actually enjoys working with the Win32 API
 
its not a app at all.. its just a simple thing.. i thought of gettin into the IronPython thing.. so created a small WPF application with IP... with a button and a textbox .. and just user as to select the file and display its content .. too much simple stuff.... i am actually planning something bigger.. but i just tested it...
 
So you prototyped it in Python
Now write it in C#
You have the code so it is mere coding
icsharpcode.net/OpenSource/SD also have you heard of Boo? Check it out. And SharpDevelop allows you to "compile" your Python scripts to .exe
 
7:29 AM
yea. checked that thing.... they are mostly shippping python dll or something of that kind..
 
anyway... thx for talk! will go with c# for desktop app, andrioda nd iOS(xamarin) ,windows phone.. and will go with python for personal use!
 
Which is the way to go
Don't forget if you come to Linux or OS X you can easily deploy your Python scripts
 
@ShubhamGoyal @tristan this explains how decorators work and why the "same" method name is allowed - stackoverflow.com/questions/12730191/…
 
@CalvinCheng sir, you rock! Exactly what I needed :D
Thanks :)
 
7:51 AM
Do you know of any chat service which runs in the terminal
 
You meant probably
 
Hmm:D no..that is a link to what you asked for.. if I am not incorrect.
 
Oh sorry
Thanks
 
no worries.. cabbage!
 
@Chillar I'm not sure how we're going to do the code stuff because we're going to effectively have a Question object yes? I thought about separating code and text when creating that. So you effectively have 3 variables body, text, and code, which hold the whole lot, the text only, and the code only, respectively.
I literally only just woke up though, so let me think about it some more.
@tristan we will miss you ;_;
 
8:36 AM
Always remember to prefer composition to subtyping
 
Sorry, what?
 
8:53 AM
Prefer interfaces to inheritance
 
Are you just going to continue to speak random snippets of 'wisdom'?
 
No. I m going to breakfast
 
Good.
@Chillar I've added you to the sopython team on GH. This way you can branch things in sopython/nidaba, rather than having to fork them to your own repo.
I'd still ask that, when you've done something, you PR it though.
It also means that we can comment on the work, etc, if its in sopython git
 
I am done eating
Why do we inherit?
Why do we compose
 
9:31 AM
Sorry, what?
I really don't understand what you're saying or trying to get at, you're just saying seemingly random questions.
 
@Ffisegydd I guess the question was: why are using classes, and inheriting one class from another, instead of using separate interfaces (or traits) and data where you add the interfaces together and "assign" them to objects/structs/whatever
if that was the question, I think it is an interesting one
as it is a different OO approach
and quite popular these days (Go, Rust, etc.)
 
9:58 AM
@Peter my challenge to it came from his previous questions where they had seemingly nothing to do with anything and the author didn't provide anything more, literally just dribbling out randomness.
 
I see..
 
10:15 AM
Back at home now :D
 
hey
how can i add python command to bin/bash ?
 
@odaialghamdi you mean like you have a python file at /home/yourname/docs/myfile.py and you want to run this?
you can add an alias into your ~/.bash_profile, something like this:
alias my_command = "python /home/yourname/docs/myfile.py"
and then you can run it, like:
$ my_command
(where $ symbol indicates the command prompt)
cbg @JonClements
 
10:30 AM
cbg @Peter - just lurking - getting some reports done...
 
yeah.. same old, lovely, calm sunday as always.
 
lol - I'd rather be doing nothing, but oh well...
 
anyway.. I wonder why ints don't have a separate __repr__ implemented..
>>> '{!r}'.format(1)
'1'
I expected to get something like:
"'1'"
ofc I can pass str(1) but still..
 
@PeterVaro repr is supposedly used to return a string that can be used to regenerate the original object
int("'1'") is an invalid int :)
 
ahh.. I did not know, it has such an expectation (regenerate object)
although.. if that was true.. most of the __repr__ returns are invalid
 
10:42 AM
Well... within the stdlib that's what it's "supposed" to be
 
>>> map(lambda: None, [])
<map object at 0x10cd126a0>
 
(if it's practical anyway)
 
I cannot regenerate it :P
so basically it is limited to "primitives"
 
yeah... so stuff like ints/floats/complex/strings/tuples/namedtuple's etc...
 
like bool, str, int and float, tuple, list, dict.. and probably that's all
yeah..
@JonClements but we also have a __str__
 
10:44 AM
Where possible, it should be that eval(repr(obj)) == obj
 
and at least (1).__str__() could return "'1'"
although for me
this is totally not intuitive
 
why? the string representation of the number 1 is 1
 
I want repr to return something with quotes
@JonClements exactly => this is what I have asked a few lines above (my original question) :
12 mins ago, by Peter Varo
anyway.. I wonder why ints don't have a separate __repr__ implemented..
why __str__ and __repr__ are the same
ofc you provided an answer
 
because eval(repr(obj)) will return a single letter string - not the original int :)
 
with the eval(repr(obj)) == obj
yeah.. but I don't like this answer :)
 
10:47 AM
tough - that't the way it is buddy :p
 
why not: eval(str(obj)) == obj
@JonClements yeah, yeah.. I know..
 
Because I might want the __str__ to be a "friendly version"...
so if i had a named tuple of firstname, surname, then I might want to print it as Jon Clements (it's __str__)
 
>>> str(1)
one
:P
@JonClements okay.. that kinda makes sense.. but still a limited niche where I can use it
and it doesn't have a real meaning in my case: ints
 
While I may want its repr to be "Name(first='Jon', last='Clements')"
hence eval(repr(obj)) == obj again
 
I won't say you convinced me, but meh.. I kinda accept it :)
I want candy.. jelly belly to be precise..
 
10:55 AM
I'd better get back to what I was trying to focus on - rbrb for now
 
11:31 AM
@JonClements how would you call the property which has two values: "private" and "public"?
 
schizo?
Nope.... I'd call it "Alfred" I think
 
hehehee..
then I call it: "come here"
but seriously, what is the generic phrase for that?
 
I'm lousy with names/stuff.... I'm not familiar with a suitable term...
Useful error message: Error:SMTP Error: The following recipients failed:
Ha, with a button that says undefined which I assume is the "OK"/"Close" button :)
"Warning: selecting this will over-write any information already present in the body of the message: " 50/50 chance here I guess....
 
12:30 PM
I posted a correct solution as a comment, a user created a community-wiki answer, linked to my comment and to my profile. Wow.
 
@vaultah that's sportsmanship :)
 
1:07 PM
hi
i working on a django 1.6.5 project with mod_wsgi, mysql and apache ,when i click to my site url my server throw error (-1, 'server not initialized')
i already set host :"localhost"
port : "3306"
anybody have solution
 
why port 3306? That's normally used for MySQL server
 
for mysql
 
Maybe it's his mysql server..
Whoa, I was right :D
 
@lalit tried googling "mysql server not initialised" ?
 
when i set localhost and port then it working ,otherwise it always throw this error
after setting , when first click it throw error after it working
 
1:18 PM
@lalit afraid that's not enough info. for someone to assist in debugging...
 
InternalError at /

(-1, 'server not initialized')

Request Method: GET
Request URL: http://example.com/
Django Version: 1.6.5
Exception Type: InternalError
Exception Value:

(-1, 'server not initialized')

Exception Location: /home/mysite/public_html/food/lib/python2.6/site-packages/MySQLdb/connections.py in __init__, line 182
Python Executable: /usr/bin/python
Python Version: 2.6.6
this is my error
 
Well - I have no idea - did you try googling that error?
 
i did it
 
@vaultah stop talking and start answering then? :p
Another 187 answers, and 5000 rep to go... hurry up :)
 
I continued answering yesterday after the long period of idling
Ffisegydd has 7.3k already :[
 
1:32 PM
But that's good :)... we want Stewie to get to 10k!
oh wait - Stewie no longer exists.... :(
 
I mean I need to work hard to overtake him in rep
 
1:50 PM
 
I got past him for ~1 day.
 
cbg
 
01:00 - 14:0014:00 - 22:00

« first day (1499 days earlier)      last day (3436 days later) »