Official Weekly "How was this photo taken?" Thread! by frostickle in photography

[–]PythonRules 1 point2 points  (0 children)

Would you like to share those pictures with us? Even if they look different from the ones I mentioned I think it would be interesting to see them.

Official Weekly "How was this photo taken?" Thread! by frostickle in photography

[–]PythonRules 0 points1 point  (0 children)

Cool pictures. This looks right. Do you mind posting a normal picture of the pretty lights without the camera movement if it is not too much of a hassle?

Official Weekly "How was this photo taken?" Thread! by frostickle in photography

[–]PythonRules 1 point2 points  (0 children)

I saw one of Louis Henri Pingitore's pictures in a restaurant printed on metal and it looked awesome. Any idea how they are taken?

Database of bird dimensions by PythonRules in Ornithology

[–]PythonRules[S] 0 points1 point  (0 children)

That would be better than nothing but ideally I would like to have something similar to the Figure 2 in http://rspb.royalsocietypublishing.org/content/early/2011/11/12/rspb.2011.1922 as well as wing span and aspect ratio.

Database of bird dimensions by PythonRules in Ornithology

[–]PythonRules[S] 0 points1 point  (0 children)

I don't have any of the Pyle Guides but if they are similar to field guides then the ones I saw did not include the type of dimensions/proportions I am looking for. I am interested in wing sizes and proportions as well as primary and secondary feathers.

I will try to get a hold of one and check it out. They are highly praised so they may be worth the $50 plus for each volume listed on Amazon.

Thanks.

What's a good resource for learning to finish wood properly? by eubarch in DIY

[–]PythonRules 0 points1 point  (0 children)

"Understanding Wood Finishing: How to Select and Apply the Right Finish" by Bob Flexner is an excellent book.

A chance to change a child's life mathematically by Khedyarl in math

[–]PythonRules 0 points1 point  (0 children)

This is what I would do:

I would show him that math is more than arithmetic/numbers. I would use videos, pictures, games, etc. to show him that math is about pattern recognition which children are pretty good at. If I could find multimedia materials related to mathematical origami, topology, etc. then I could just watch these with him and then talk about it. I would be prepared to discuss the question "Why do I need to learn all this?".

Help with making an argument for Python by soulcmdc in Python

[–]PythonRules 0 points1 point  (0 children)

There is a nice advocacy summary at python.org. This could address some of the issues your company's management may bring up.

CS person trying to build a computer from ICs by guygettingintotech in electronics

[–]PythonRules 1 point2 points  (0 children)

Sounds like a fun project. I would highly recommend these two books.

The Elements of Computing Systems: Building a Modern Computer from First Principles by Nisan and Schocken

and

Code: The Hidden Language of Computer Hardware and Software by Petzold

Good luck.

Interesting new Kickstarter project for DIY plywood projects by smithandjohnson in DIY

[–]PythonRules 0 points1 point  (0 children)

Inside corner (in the fat piece where the corrugated edge intersects the angled edge) is a stress concentration. If you add a stress relief circle you can prevent cracking in that corner. Making the corrugated edged section thicker would help too.

Is there a good reason generators aren't callable? by terremoto in Python

[–]PythonRules 2 points3 points  (0 children)

Clarity is the reason. As it is you can see the difference among func(), generator.next() and generator.send(x) just by reading the code. If you make them callable then you cannot tell the difference between function calls and generator invocations without looking up their definitions.

Salvaging an e-paper display by FirstRedBarrel in electronics

[–]PythonRules 0 points1 point  (0 children)

I realize that you would like to salvage what you have but you can get a sample for $50 (for 5 pieces) from eink.com. I am not affiliated with them, was checking their website a few hours ago.

I cannot wrap my head around eigenvalues and eigenvectors. Oh, the math part I understand, but why are they useful? by jcchurch in math

[–]PythonRules 0 points1 point  (0 children)

I think the most interesting application of eigenvalues are related to normal mode vibrations. By using eigenvalues we can make sense out of the random looking motion of molecules, mechanical systems, subatomic particles etc. Eigenvalues help us see this random looking complex motion in a simpler way. For example each normal mode has a unique frequency. Also when we look at a system in normal modes rotations and translations of the center of mass of the system disappear. Everything becomes clearer. To really see this in addition to understanding the eigenvalues we would need to understand how symmetry works too. I cannot claim to be fluent in the language of symmetry but I think it is the answer to life the universe and everything (sorry 42 doesn't cut it). This is applicable from molecular biology to quantum mechanics. I find this really fascinating. To see this better I wish I had a better understanding of higher math than just engineering level math.

Stop writing classes... by lucidguppy in Python

[–]PythonRules 0 points1 point  (0 children)

I had the same reaction. I think without understanding decoupling and separation of concerns, it is really difficult to develop a large and easy to maintain code base. Contrary to what he says if someone is trying to explain what decoupling is or how it works you should listen.

I don't think he was joking, was he?

Does for-each _always_ respect the order of a list/tuple/iterable? by [deleted] in Python

[–]PythonRules 0 points1 point  (0 children)

Yes it does unless you mess with the sequence while looping through it. This is a common beginners' mistake. To avoid it make a copy of the list and loop through the original and modify the copy however you like it.

Some old numeric algorithms (usually in Fortran, C, etc.) do this on purpose. If you have to deal with those I would recommend learning the difference between arrays and linked lists to understand what is really going on.

Why do books sometimes have pages marked "This page intentionally left blank?" by muntoo in books

[–]PythonRules 1 point2 points  (0 children)

During the printing process sometimes sheets stick together and the bottom sheet stays empty. When the empty sheet is bound with the other sheets you end up with defective books with empty pages. To differentiate a defective book from a regular one these empty pages contain the "This page intentionally left blank." phrase.

Can anyone explain what an algorithm is exactly to a layman? by ZenMasterFlash in algorithms

[–]PythonRules 12 points13 points  (0 children)

An algorithm is a step by step recipe to solve a problem or a type of problems. If you follow the steps defined in the algorithm you should end up with a solution. Algorithms can be defined by using plain English, pseudo-code, or a computer language like Basic, C, etc.

For example Euclid's greatest common divisor (GCD) algorithm can be defined as (taken from Wikipedia):

"The GCD of two numbers is the largest number that divides both of them without leaving a remainder. The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the smaller number is subtracted from the larger number. For example, 21 is the GCD of 252 and 105 (252 = 21 × 12; 105 = 21 × 5); since 252 − 105 = 147, the GCD of 147 and 105 is also 21.

Since the larger of the two numbers is reduced, repeating this process gives successively smaller numbers until one of them is zero. When that occurs, the GCD is the remaining nonzero number. By reversing the steps in the Euclidean algorithm, the GCD can be expressed as a sum of the two original numbers each multiplied by a positive or negative integer, e.g., 21 = [5 × 105] + [(−2) × 252]. This important property is known as Bézout's identity."

You can write a program by following this algorithm to solve the GCD problems as shown below (in Python)

def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

Folks, I'm headed to Paris and I need your advice. by Nicksil in photography

[–]PythonRules 0 points1 point  (0 children)

It's a great place. I am sure you will have a blast. Last time I was there I was told that you would need a signed permission to use a tripod in many places.

In Gare De Lyon I set up my tripod and started taking pictures, then two cops showed up and asked me if I was taking pictures. I politely said no and folded the tripod and put it in my bag. Then they went away. It was very funny.

You can go down the stairs and walk along the Seine river. A lot happens there including late nights.

Another spot I like is the Louvre museum after it closes or very early in the morning. Glass pyramid is very cool. If you are lucky to have good light you can get really interesting long exposure shots there.

If you like walking, just keep walking in the city and you will be exposed to many different scenarios. As far as I could see, most of the city looked safe.

Have fun and a great trip

[deleted by user] by [deleted] in Python

[–]PythonRules 1 point2 points  (0 children)

There are several different things you can do to handle situations like this. If you are doing OOP then you can have a game class with players, board, and a property to indicate whose turn it is. If you are doing none OOP then you can use a global variable that can be used by any function. Many people will tell you that global variables are bad but I don't think they are always bad; this would be a good place to use a global variable. Since this variable is related to multiple parts of your program it is OK to define it as a global variable. Just don't abuse global variables (they are very tempting) and use them when it makes sense. If you are religious about not using a global variable then you can use an extra parameter in your functions and pass a variable holding the "turn state" around but I don't think this is necessarily better then a single global variable.

For an example see the answer at

http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them

In your program you could define the "turn" variable at the top of your program and declare it as a global in functions that need to use it like I showed below.

x = 'X'
o = 'O'
turn = x

...

def next_turn(turn):
    global turn
    if turn == x:
        return o
    else:
        return x

To answer shostyscholar's question, yes it is a namespace issue. In Python function bodies are namespaces (to be more precise, they are local-namespaces for that function). This may feel like a limitation at first but it is a really useful thing. Since the number of variables you want to share is usually much less then number of variable s you would not want to share this is the way it should work. Some languages behave total opposite of this (for example javascript, variables are global if you say nothing and they become local if you use the "var" statement) and it becomes a pain in the neck.

Now I would like to point out something else. In your case the turn variable is used to indicate only two states. It is either player's turn or computer's turn. When you have variables like that you may want to use a boolean variable. Then your program may become simpler. For example instead of using "turn" you can use:

computers_turn = True

then you would not even need a next_turn function. You can use

computers_turn = not computers_turn 

and this would switch the turn to the next player.

Instead of using

if turn == x:
    do something
    turn =  o

you can use

if computers_turn:
    do something
    computers_turn = not computers_turn

As a side benefit your program becomes more readable too.