« first day (2646 days earlier)      last day (2285 days later) » 
00:00 - 22:0022:00 - 00:00

10:17 PM
How can I dynamically set SomeClass.__init__ in a way that it's called with self as the first argument?
 
what are you trying to solve?
 
SomeClass(object): pass

def init(self):
    self.func()

def func(self):
    print("Calling func()")

SomeClass.__init__ = init
SomeClass.func = func
 
hi
oops
x = SomeClass()
x.func()
I think
 
what is the problem you are actually trying to solve?
 
The function needs to be called init with 2 underscores on each side, not init
 
10:27 PM
@idjaw it's a bit complicated so that's why I'm trying to give you a simpler version of it
 
That just seems unintuitive
I don't understand the use case for this
 
For instance:
 
lol
I'm going to re-use that one
 
hi all, I have a super basic question
 
10:31 PM
@Jovito the reason he's asking is because this sounds very very very much like an XY problem, trying to solve the wrong problem in a very wrong way.
 
When I use an IDE (Spyder) and edit a function, how do I execute the modified version of the function?
 
@AndrasDeak I understand, I will try to explain it
 
monkey-patching a class you've just created is certainly not what you likely want to do
@Jonas if you're in a running interactive session, you need to reload the module that contains the function using importlib.reload (assuming python 3, and assuming I understand your scenario correctly)
 
I fixed a bug, but when I execute the function, it still throws the same error (but shows the edited and correct line). It can't be that I just have to restart Spyder everytime I fix a bug?
@AndrasDeak: ok will try
 
@idjaw I'm using peewee and I'm wrapping subclasses of peewee.Model in adapter classes which give me the interface I want. The thing is a lot of the code gets repeated in each of these "adapter" classes, so I wrote a class decorator that takes the subclass of peewee.Model as an argument and wraps the "adapter" class in Decorated class which hold a reference to the model that the adapter class adapts.
 
10:33 PM
there might or might not be a button in spyder that does this for you, I've never used it
> The thing is a lot of the code gets repeated in each of these "adapter" classes
 
It claims importlib is not defined - do I need to import that as well?
 
@Jovito sounds like you want to define a base class and its subclasses
 
I think this should work
 
@Jonas well, yes. But first we should establish that you're indeed working in an interactive shell
 
I think I am? I'm in an IPython console
 
10:34 PM
@Jonas then yes :)
 
@Jovito It seems like you need to take a step back and re-think your design. I'm confused by your explanation and if you are dealing with wrapping your "stuff" around some library, then you probably need to think, similar to what Andras specified, creating some base class yourself
 
and using 3.5
 
That's fine. You can either import importlib; importlib.reload(module_where_your_function_is), or specifically in ipython you can run reset which will clear your namespace and then you can run your script again with a clean slate
 
@AndrasDeak: ok, that works. Thanks!
 
no problem
 
10:37 PM
it does seem a bit cumbersome coming from Matlab :)
 
well, reset is basically clear all
but yeah, the fact that imports only import once is weird from matlab
 
yeah, but I may not want to clear all everytime I've fixed a bug... Each language has their own idiosyncracies, I guess
 
@Oqhax may I suggest the sandbox
 
What is the sandbox?
I keep wanting to indent the code...
 
10:39 PM
...
 
@Jonas well, on the other hand it's easy to trip yourself up with something left over from a previous iteration of your code in an interactive shell, so if you want to be sure it works you should run it in a clean session anyway
but of course I see where you're coming from, I "started" with MATLAB
 
VTC as no MCVE
Picture of code != MCVE
 
I know.
I deleted many comments because I could not indent the code and reply to someone.
It kept messing up.
 
@Oqhax To properly format code in these messages, just hit ctrl-k. However, you can just easily use pastebin
 
10:45 PM
Paste your code, and click on fixed width font on the right when it appears.
 
pictures of code are usually not helpful.
 
I also tried ctrl-k
 
I gave you two useful links
 
class Foo:
 def __init__(self, x):
  self.x = x
The above was done with just hitting ctrl-k
that's it
 
ironically, @PM2Ring's "don't post code as images" picture can't be easily located in the transcript because it is an image
 
10:46 PM
@AndrasDeak Could you not annoy me?
 
I know, but I also want to reply to someone.
 
coldspeed that isn't garlic
 
10:47 PM
"To recognize, deal with, or kick a help vampire."
 
yes
 
The number to reply to the person got mixed up with the code if I hit ctrl-k
 
yes and they are not being a help vampire, coldpeed
 
Oqhax is trying to answer a question of someone else
 
^^
 
10:47 PM
Then I've missed the context
 
Don't teach me rules you don't know. please.
 
indeed
 
I wasn't trying to teach you anything. I was only explaining things as I understood them.
So, relax.
 
ok bruh
 
Obviously I misunderstood something here, bruh.
 
10:49 PM
ok bruh
 
you clearly did :)
 
true, bruh
 
that was for cOLDsPEED
 
thanks, bruh
 
10:51 PM
troll
Anyway... Any other topic to talk about?
 
Snakes. Snakes on planes. Snakes in computers.
Pretty much snakes....
>>> from snake import snake
>>> snake.snake.Snake()
hiiiissssssss
 
Cool... Snakes in programming. Wonder what?
 
@AndrasDeak Seen this?
 
lol
 
Can someone help with tkinter scroll bars? I'm lost I must have seen three different ways of doing it.
So far I'm using this example but I don't want it to be possible to just write over it. Any ideas?
 
11:05 PM
It's not what you want to hear, but I'd migrate away from tkinter as soon as possible
 
It is what I want to hear actually but I've never found a good alternative
Pygtk is not really usable, can't get on with PyQt, Kivy won't run on my old machine, wxpython is all I could find
What do you use?
 
@cᴏʟᴅsᴘᴇᴇᴅ nope
 
well, pygtk is outdated. gtk3 works fine, though on windows it doesn't support python >3.4
I have used gtk for all my projects so far, but I'm also looking for something better.
 
Yeah but I bet your not under Windows
 
It's still leagues above tkinter though, needless to say
 
11:11 PM
I love gtk3 I just can't get pip on the 3.4 environment.
Just over a week ago I asked but there were no answers.
Also I have a feeling gtk3 apps are rather heavy to distribute.
 
true, on Windows they're quite a pain to package
 
70Mb the last GTK3 package I did in C I think
 
That's a lot O.o In my experience, gtk3 + python is around 10MB
 
!!!! Are you sure? Which OS?
 
Windows. I used cx_freeze
 
11:22 PM
How did you get it on there may I ask?
I mean cx_Freeze
 
this was my setup.py, if it helps
 
I see you found out about the DLLs. I had a hard time with those at first. What I meant is I used MSYS to get gtk3. No pip so how did you install cx_Freeze?
Now it runs under the MSYS environment.
 
I honestly can't remember, I guess I installed it with pip
 
Do you run it under the MSYS environment though? (nice setup script by the way)
If I can get something to install with or get pip I'm off tkinter and onto gtk3 for sure.
 
Nope, I didn't use msys or cygwin or anything of the sort. Python, PyGObject for Windows, cx_freeze.
 
11:32 PM
So you installed a 3.4 environment and got it that way?
 
Yeah.
 
And naturally that has pip installed and everything else. Thank you so much you are a lifesaver, You would not believe how long I've been struggling with this.
MSYS is such a tomato pain.
 
I'll take your word for that and steer clear of it :p
 
I must say I'm speechless. Yes if you can, it's a project to get Linux calls on Windows and it's rather horrible at times. : )
GOOD BYE TKINTER HELLO FREEDOM (gtk3) : ) : D
 
00:00 - 22:0022:00 - 00:00

« first day (2646 days earlier)      last day (2285 days later) »