A small improvement code (common.py)

Suggestions and discussion of future versions
Post Reply
shakaran

A small improvement code (common.py)

Post by shakaran »

Hello, I'm an apprentice Python and user Deluge. I download the source code to learn from it and I would suggest a small improvement:

In the source code file src/common.py line 149 (in function get_logo)

Code: Select all

    if windows_check(): 
        return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.png"), \
            size, size)
    else:
        return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.svg"), \
            size, size)

Code: Select all

    return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge."+ \
        ('svg','png')[windows_check()]), size, size)
Only shortens the code using a compact and the abridged condition if.
I hope it will be useful.

Greetings.
Gasten
Member
Member
Posts: 11
Joined: Fri Dec 14, 2007 2:36 pm

Re: A small improvement code (common.py)

Post by Gasten »

It works, and it looks elegant from a c/perl programmers point of view, but it's cluttered and unreadable in python world. However, I'm not a deluge developer and not the one who judge.

Hope to see further improvements!
shakaran

Re: A small improvement code (common.py)

Post by shakaran »

Yes, Gasten that's why said it is only a suggestion.

The code, it is something more elegant, but also complicated. But if you look is just getting used to seeing him in that way.

It is just something like:

Code: Select all

If:
     True text + Condition
else
     text + False Condition
to

Code: Select all

text (false, true) [condition]
It is just another way of looking at things, but as you say, developers are the ones who tried.

I await your response.

Greetings.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: A small improvement code (common.py)

Post by johnnyg »

well deluge is open source so you can change your code however whether or not the developers will commit it is another thing all together.
I think the general rule is if it works don't fix it :P so I'm not sure what your odds are.
but thanks anyway for posting, I actually learnt something new about python! :D
loki
Moderator
Moderator
Posts: 787
Joined: Tue Dec 04, 2007 3:27 pm
Location: MI, USA

Re: A small improvement code (common.py)

Post by loki »

I would think it's probably easier to read one way for some people than others, everyone has their own style in coding don't they?
Post Reply