if set_dir != None (wrong!)

In the source code of wx/lib/imagebrowser.py under the ImageDialog’s init method there’s this code:
if set_dir != None
which should be
if set_dir is not None

Please fix this. Thanks.

I think there are far more important things in wxpython to consider than this.

···

On 19/04/2014 19:12, Boštjan Mejak wrote:

In the source code of wx/lib/imagebrowser.py under the ImageDialog's
__init__ method there's this code:
if set_dir != None
which should be
if set_dir is not None

Please fix this. Thanks.

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.

Bostjan, submit a patch, most of the patch will be header stuff. Also context, data type of set_dir?

Any __eq__ method, so forth?

Mark, it depends - what if this causes someone some weird bug that they never realise is caused by this line? If you have to get a truth table and compare the results for the two things.

This is not a part of wxPython I'm familiar with, so I'm not sure about the types in play. It is worth noting that (as I have above) __eq__ may be used, for example this set_dir could be in some sort of "null" state, representing no dir, but it is not null itself. In that case Bostjan is wrong.

Alec

···

On 19/04/14 19:58, Mark Lawrence wrote:

On 19/04/2014 19:12, Boštjan Mejak wrote:

In the source code of wx/lib/imagebrowser.py under the ImageDialog's
__init__ method there's this code:
if set_dir != None
which should be
if set_dir is not None

Please fix this. Thanks.

I think there are far more important things in wxpython to consider than this.

Boštjan Mejak wrote:

In the source code of wx/lib/imagebrowser.py under the ImageDialog's
__init__ method there's this code:
if set_dir != None
which should be
if set_dir is not None

Please fix this. Thanks.

It's not wrong, just different. And a few nanoseconds less efficient.

  >>> NUM = 1000000
  >>> t1 = timeit.timeit('foo != None', 'foo = 123', number=NUM)
  >>> t2 = timeit.timeit('foo is not None', 'foo = 123', number=NUM)
  >>>
  >>> print t1/NUM - t2/NUM
  1.1265039444e-08

···

--
Robin Dunn
Software Craftsman

Python experts/gurus teach us to always use the “is” or “is not” keyword when comparing an object to None, and not “==” or “!=”.

Boštjan,
After reading your post, I am reminded of the following quote from Donald Knuth on optimization:
“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil”
Hopefully you realize that PEP8 only recommends using “is” or “is not”.
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
There is no “shall be done with”.

In my opinion, readability and maintainability trump code optimization.

Bruce

Boštjan,
After reading your post, I am reminded of the following quote from Donald Knuth on optimization:
“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil”
Hopefully you realize that PEP8 only recommends using “is” or “is not”.
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
There is no “shall be done with”.

In my opinion, readability and maintainability trump code optimization.

Bruce

@ Boštjan
Basically, what is being said here is that everyone has a trade.
97% are Carpenter/Doctors/Farmers/etc…
the other 3% are ComputerSpecialists/Programmers/Optimizers.
While anyone of a particular trade can spot something that maight be better written/worded…
…it isn’t for the faint of heart.

As far as python goes, we all know that PEP8 isn’t the stone tablet.
The real guideline here is this.
if you don’t know what this is, then import it.
while bruce’s opinion is “readability and maintainability trump code optimization.”, I agree that this is a very good start, but falls short of this.
the reason being is that when dealing with images, optimization is crucial to performance, and while readability counts,
if an application is dirt slow, then you might as well throw your readability along with your userbase right out the window.

In a nutshell, zen = balance.
so while others may prefer certain picked lines out of the zen above others, when in doubt consider balance as a whole, then proceed from there as to what needs more attention than other points.

Ok, so lets look at what we are dealing with here…

if set_dir != None:
What we start out with is a line of python. if True: proceed()
if set_dir happens to be 0, None, ‘’, , {}, NoneType, etc…
…then pythons truth checking will fail. Ok. working fine.
so basically to answer as optimized:
if set_dir:
or basically to answer as readable and more precise:
if set_dir is not None:

…there are many other ways the code could be mangled/written,etc…
as Mark Lawrence suggests, your time with imagebrowser.py and wxPython could be spent better.
I agree that while readability counts, making a mail about it isn’t going to do much other than having someone suggesting you make a readability patch and submit it, which IMO won’t be very high on the food chain.

…Now note this Boštjan:
Most coders focus on progressing a project and all have their own readable standards.
If you ever intend to get some recognized attention on the matter, besides locally on your own HHD within a decent amount of time, then you have to provide something
that everyone will be interested in. Ex: a bug fix of some sort would be nice to get/have. or maybe a addon/improvement.
Think of it like politics. You are a Politician with your own views and think that a law on the books, could have been better worded without changing the meaning of said law.
So you might gather support for a oversight in part of it and present a amended/extension of that law. While doing so you tack on your readability fixes, so that common folk can understand what you are really doing/trying to change.

… So what you need here might be a little help finding a bug to fix…
Well, I have one just right up your alley.
THE BUG: (Image in attachment)
Load a image into the image browser. when it is scaled down all the way(Think resize the window to zero(and hence drawing of the image)), It throws a traceback.
This traceback has to do with dc and rescaling of an image.
THE BUGFIX:
The traceback itself has all the information you will need to fix this bug(the checking algorithm that will happen when it gets to the C++ level) funny enough, so this should be fairly straight-forward fix for you to implement.

Then when you have fixed and made a patch, consider fixing readability and tacking that on also.
Or send as a pull request to Robins github.
I’ve done about a dozen of these type fixes, so I will let you gain a little exp for this one. So, no don’t ask for the answer.

Moral of the story:
You will gain more optimization experience and become closer to being considered a good optimizer by fixing bugs rather than just pointing cosmetic changes out that otherwise would not change the functionality.

good luck:)

···

On Saturday, April 19, 2014 7:54:20 PM UTC-5, bruce g wrote:

The wxPython Phoenix source code is a big pile of mess. There is no order in it and no consistency. No one cares if the code is not tidy. For example, somewhere the comments end with a dot, somewhere else they don’t; somewhere there’s “== None” or “!= None”, and somewhere there’s “is None” or “is not None”. You just don’t give a fuck, do you?

There is a simple solution to your issue,write your own language.

···

On Sun, Apr 20, 2014 at 10:57 AM, Boštjan Mejak bostjan.galaxy@gmail.com wrote:

The wxPython Phoenix source code is a big pile of mess. There is no order in it and no consistency. No one cares if the code is not tidy. For example, somewhere the comments end with a dot, somewhere else they don’t; somewhere there’s “== None” or “!= None”, and somewhere there’s “is None” or “is not None”. You just don’t give a fuck, do you?

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

https://xkcd.com/386/

Lighten up, please.

Cheers,

Scott.

···

On Sun, Apr 20, 2014 at 10:57 AM, Boštjan Mejak bostjan.galaxy@gmail.com wrote:

The wxPython Phoenix source code is a big pile of mess. There is no order in it and no consistency. No one cares if the code is not tidy. For example, somewhere the comments end with a dot, somewhere else they don’t; somewhere there’s “== None” or “!= None”, and somewhere there’s “is None” or “is not None”. You just don’t give a fuck, do you?

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sure, we all give a ****! some more, some less.
And I believe the others do more also to a certain degree, Otherwise they would have not posted. Learn from it. Knowledge is power.
We are not here to fight with each other, but help each other(users and devs alike), further wxPython, and at times to come up with a solution that the majority agrees with for the better of all.

Well… code consistency is hard sometimes. This is a given for a community project such as wxWidget/wxPython.
You must remember you are working with many other people on this.
I’m not perfect, nor is anyone else posting here. We all make mistakes at times, and are inconsistent in our own code writings.
Python as a language is like a book. I find that book to be a dictionary that has many words in it that are similar in nature, but wonder why sometimes the dictionary has many different variations for a word.
That is why python is beautiful and elegant and powerful. Because it speaks to people of all different styles and problems.

a little story about focus.
Back when I first started coding I often times wouldn’t know where to start or what to work on,
so what I did after asking some fellow coders about how they handled the subject
was make me a list of my priorities and also a level of importance to those priorities.

What I then did was use a wxPython CalendarCtrl to randomly pick a goal/theme priority from the list based on the week and day of the week.
So when I started coding that day/night, if I feel stumped as to what to work on, I would just look to the calendar.

Today is Sunday, a day for hunting the priorities calendar says. What I am hunting for should be simple… An easter egg. Other things it suggests is Documentation(this could be reading, fixing readability, or writing)
Tomorrow is Monday, the priorities calendar list will pop up probably “Organization” activities, since it is the beginning of the work week.
Etc, Etc…

Also a good tip is not to use what some folks consider derogatory language in a post. It helps when priests and old ladies and kids come across this.
The best we can do is try our best everyday, even on our worst days. Just keep the end goal in mind, don’t quit(keep plugging away at your goal in little bits) and you will eventually get it done.
Happy Easter :slight_smile:

···

On Sunday, April 20, 2014 9:57:32 AM UTC-5, Boštjan Mejak wrote:

The wxPython Phoenix source code is a big pile of mess. There is no order in it and no consistency. No one cares if the code is not tidy. For example, somewhere the comments end with a dot, somewhere else they don’t; somewhere there’s “== None” or “!= None”, and somewhere there’s “is None” or “is not None”. You just don’t give a ****, do you?

I look forward to seeing all of the patches that you will provide to tidy up the mess, as you clearly care so much.

···

On 20/04/2014 15:57, Boštjan Mejak wrote:

The wxPython Phoenix source code is a big pile of mess. There is no
order in it and no consistency. No one cares if the code is not tidy.
For example, somewhere the comments end with a dot, somewhere else they
don't; somewhere there's "== None" or "!= None", and somewhere there's
"is None" or "is not None". You just don't give a fuck, do you?

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.

Please use reply-all, some of us have clients that explicitly mark list messages addressed to us (rather than putting them right into a folder)

The wxPython Phoenix source code is a big pile of mess. There is no
order in it and no consistency. No one cares if the code is not tidy.
For example, somewhere the comments end with a dot, somewhere else they
don't; somewhere there's "== None" or "!= None", and somewhere there's
"is None" or "is not None". You just don't give a fuck, do you?

I look forward to seeing all of the patches that you will provide to tidy up the mess, as you clearly care so much.

This shouldn't read in a way that presents you as childishly as it does. I do admit that given it doesn't matter Bostjan is taking it way to seriously. BUT if he submits tidy-up patches that isn't a bad thing.

The comments ending with a dot thing is a bit insane though. Regardless Mark if he wants to patch it let him, don't devalue "tidy" patches.

Bostjan, calm down there's no need to harm others or yourself over this, take some deep breaths and relax, I'd feel awful if I didn't say this and 3 days from now read a news article that ended with "and then he turned the gun on himself"

If you do want to tidy, don't just "fix" (because ... they work, I must confess I use both, I tend to use == when I might explicitly assign to it, and "is" where I am testing a return say....) the null thing. Tidy code is good, but you are focusing on such a small, trivial and unimportant thing.

I'm really trying to defend you here, stop swearing. Mark ... be constructive and not childish please. This subject ought not have had so many messages, lets try not to extend it beyond its utility.

Alec

···

On 20/04/14 19:01, Mark Lawrence wrote:

On 20/04/2014 15:57, Boštjan Mejak wrote:

I was being serious. Put up or shut up are your (plural) options if you wish to complain about the code base.

···

On 20/04/2014 20:50, Alec Teal wrote:

On 20/04/14 19:01, Mark Lawrence wrote:

Mark ... be constructive and not childish please.

Alec

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.

Shut the fuck up all of you, stupid monkeys!

Hi Boštjan,

A product use of all our time would have been if you had provided a PR making imagebrowser comply with PEP 8, but I am now convinced that you have no interest in helping wxPython progress.

Have a nice day!
Werner

I did provide a PR in the near past for the wxPython Phoenix project. I made a branch named polish and had polished a lot of modules in the lib package and commited to that branch. My commits were not merged with the master branch, because no one cares about polished code. You are all a bunch of untidy, disorganized, messy, scruffy mother fuckers. Have some order in your life first, then your code will resemble that.

I didn’t find your ‘polish’ branch PR but found at least one PR from
you which Robin merged. There were others where he made comments
and you never acted on them, so no they don’t get merged.
Some PR’s from you Robin didn’t apply because your code was buggy,
maybe organized and tidy but that is not enough.
I submitted a few PR’s some got committed, some others didn’t get
committed, either Robin had no time to review them or for other
reasons - so what that is open source live.
Hopefully you will start changing your attitude you show on this
list, because you won’t get any where in live if you don’t change.
Werner

···

Hi Boštjan,

  On 4/21/2014 14:45, Boštjan Mejak wrote:
      I did provide a PR in the near past for the

wxPython Phoenix project. I made a branch named polish and had
polished a lot of modules in the lib package and commited to
that branch. My commits were not merged with the master
branch,

Shut up with the spiritual shit (like I gotta change). I saw your code, Bruhin, and it’s very ugly. Who’s code is ugly, has an ugly soul as well (take that as a spiritual smack in the face).

Shut up with the spiritual shit (like I gotta change). I saw your code, Bruhin, and it’s very ugly. Whos code is ugly, has an ugly soul as well (take that as a spiritual smack in the face).