« first day (2290 days earlier)      last day (2652 days later) » 
00:00 - 23:0023:00 - 00:00

11:04 PM
If I'm trying to send simple e-mails between computers on my LAN, is postfix the right direction?
 
Hey guys, is there anything specific that _ does before variables?
 
If the variable is a class member, then such a member is considered "private" or "semi-private" by convention. In practice it just means that it (might) not show up in some IDEs. And you're supposed to consider it as not part of the public class interface.
I mean it won't show up in the autocomplete of the IDEs.
Like if you type
f = Foo()
f.<TAB>
Then the autocomplete (usually) skips the members that start with _.
 
I see, thanks.
 
If you need to guarantee privacy, to be 100% sure that another class cannot rely on that member, use two underscores __. In that caes, the Python interpreter applies so-called 'name mangling' to make sure no one else can access it.
 
11:23 PM
Oh, nice.
Is there are a way to make class instance without calling it?
 
11:33 PM
What do you mean?
@SimeonAleksov What are you trying to do?
 
I found an answer, but I don't understand, so I'll skip it.
Creating a class instance without invoking init
I am working in PyQt, created a class for a Ball that bounces, now I am trying to create more balls
 
I don't think you can do that, but even if you can, please don't
if you're straining to do something in python, you probably shouldn't be doing it in the first place
 
I don't know how. Couldn't you just modify your init with a parameter that tells it not to do it the normal way, e.g.
 
__init__ is meant to be called
 
Alright
 
11:36 PM
f = Foo() # Create a normal Foo
g = Foo(dont_init=True) # Create a Foo but skip initialization.
 
It's okay, I think I figured it out. Thanks, though.
Okay, I just realized typing main automatically adds if name == "main"...
 
It is popular to write the line
if __name__ == '__main__':
    ...
 
it's there so that if you import the file, that block doesn't get run
 
at the bottom of a module. What you're seeing may be an autocomplete feature of your IDE.
 
Yeah, I've seen it, but I don't understand why.
Oh.
 
11:39 PM
When you run your module with the interpreter, as in 'python foo.py', the __name__ symbol has the value '__main__', but when you run a module as in 'import foo', it doesn't, so that part gets skipped.
 
# worlddestructer.py
def destruct_world():
    del(world)

destruct_world() # now *when* I import worlddestructer, the world ends
 
Ah, I understand, thanks.
I feel like I should learn about decorators or is it advanced thing and I should wait, what do you think?
 
Start with the standard decorators when needed like @staticmethod. I don't think it is normally necessary to define your own decorators.
 
Oh, wow I didn't even know you can define your own decorators
 
user3854113
Hi !
 
user3854113
11:49 PM
Can someone help my with a python problem in linux ??
 
Maybe I can help you, I am newbie with linux, but shoot.
 
user3854113
I have a web hosted on godaddy (big mistake). For various reasons I set a virtual env to install python with django
 
user3854113
the problem is that now I want to upgrade django to a newer version but I cant because of a library, the linux dynamic linker
 
user3854113
I can reset its path by using LD_LIBRARY_PATH on python, but It doesnt seem to work
 
user3854113
Its like it cant find the file, but the file is there
 
11:52 PM
I am sorry, I don't know :D
 
Well, when you write the @staticmethod it is syntactically the same as writing 'staticmethod(...)' after that definition. Here is a short example:
def run(f):
    f()

def bye():
    print "Bye!"

@run
def hi():
    print "Hi!"

bye()
The output is "Hi!", then "Bye!" because the @run calls run(hi), which executes it first. Then the last line calls bye.
Notice run is just a name that I made up. It is the same with @staticmethod, except that staticmethod(f) is a built-in method.
 
I think that's a pretty confusing example
Decorators typically return a modified (wrapped) function
 
Thank you, I will read more tomorrow, I am going to bed now. Good night.
 
00:00 - 23:0023:00 - 00:00

« first day (2290 days earlier)      last day (2652 days later) »