<div dir="ltr"><span style="font-size:large">"</span><span style="font-size:large">That's really interesting.  I've used "</span><i style="font-size:large">map</i><span style="font-size:large">" before, but never used "</span><i style="font-size:large">map.get( )</i><span style="font-size:large">" before.  What does "</span><i style="font-size:large"><b>map.get( )</b></i><span style="font-size:large">" do?  Thanks for the feedback!"</span><div><span style="font-size:large"><br></span></div><div><br></div><div>I think you're confusing the 'map' function with the '(hash)map' data type (also known as dictionary).</div><div><br></div><div>If you create a dictionary like so:</div><div><br></div><div>foo = {"bar": "baz"}</div><div><br></div><div>You can retrieve the value using either foo['bar'] for foo.get('bar'). Now if you tried to retrieve a value that didn't exist such like foo['qux'] you would get a KeyError. To avoid running into that key error you can use the get method and call something like foo.get('qux'), which would return null because the 'qux' key is not in the dictionary. If you wanted any failed look up to return something non-null you can provide the default as a second argument to the get method. eg foo.get('qux', 'my_default').</div><div><br></div><div>In the ruby world this is the same as using the '.fetch' method on a Hash.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 9:00 AM, Hector Rios <span dir="ltr"><<a href="mailto:labeledloser@gmail.com" target="_blank">labeledloser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Douglas,<div><br></div><div>I've been alternating between Ruby and Python for some time now and I can just say this: each language is great in it's own way. </div><div><br></div><div>My personal preference is Ruby, though. Ruby makes more "sense" to me. The syntax, the philosophy, the testing -- everything just makes more sense to me.</div><div><br></div><div>Python is simple in a sense that you can do something one way, where as Ruby has many ways of doing things. However, I believe that things can be accomplished in a variety of different ways, which is why Ruby feels more natural to me.</div><div><br></div><div>That said, Python is a beautiful language with many great things going for it. I believe that it is a great language for everyone to use, and I encourage people to learn it.</div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><span style="font-family:courier new,monospace"><br>{<br>    "name": "Hector Rios",<br>    "title": "Software Developer",<br>    "contact": {<br>            "linkedin": "hrios10",<br>            "gmail": "labeledloser",<br></span></div><span style="font-family:courier new,monospace">            "site": "<a href="http://hectron.github.io/" target="_blank">http://hectron.github.io/</a>"<br></span><div><span style="font-family:courier new,monospace">    }<br>}</span><span style="font-family:arial,helvetica,sans-serif"><br></span><div><span style="font-family:arial,helvetica,sans-serif"><br><span style="color:rgb(204,204,204)"><font size="1"><i>No trees were killed to send this message, but a large number of electrons were terribly inconvenienced.</i></font></span></span></div></div></div></div></div><div><div class="h5">
<br><div class="gmail_quote">On Tue, Jun 16, 2015 at 7:18 AM, Lewit, Douglas <span dir="ltr"><<a href="mailto:d-lewit@neiu.edu" target="_blank">d-lewit@neiu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font size="4">Hi William,</font><div><font size="4"><br></font></div><div><font size="4">That's really interesting.  I've used "<i>map</i>" before, but never used "<i>map.get( )</i>" before.  What does "<i><b>map.get( )</b></i>" do?  Thanks for the feedback!</font></div><div><font size="4"><br></font></div><div><font size="4">Doug.</font></div><div><font size="4"><br></font></div><div><font size="4">P.S.  I agree about those comprehensions.  They are definitely very nice!  But I think Python programmers should be cautious when using them.  If you overdo the comprehensions, then the code becomes really obscure and difficult to trace through.  That's just my humble opinion.  Your mileage may vary.</font></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 11:29 PM, William E. S. Clemens <span dir="ltr"><<a href="mailto:wesclemens@gmail.com" target="_blank">wesclemens@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Although Python does lack some classic control flows notably do-while and switch-case, it offers plenty of other uniq control flows. I often use a else statement with a for loop. Python also offers list and dictionary comprehension.<div><br></div><div><a href="https://docs.python.org/3.5/tutorial/controlflow.html" target="_blank">https://docs.python.org/3.5/tutorial/controlflow.html</a> </div><div><a href="https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions" target="_blank">https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions</a><br></div><div><br></div><div>I would also suggest that you can easily implement a do-while like such:</div><div><br></div><div>while True:</div><div>    pass # Do Stuff</div><div><br></div><div>    if condition: break # Our do statement</div><div><br></div><div><br></div><div>Switch-cases are a little tricky. Most the time a if ... elif ... else works just fine, although this is a bit limiting if you want to use a fall through condition. A neat trick that you can do with python is use a dictionary as a switch-case.</div><div><br></div><div>def foo():</div><div>   print("foo")</div><div><br></div><div>def bar():</div><div>   print("bar")</div><div><br></div><div>def baz():</div><div>   print("default baz")</div><div><br></div><div>map = {</div><div>    "Blue": foo,</div><div>    "Red": bar</div><div>}</div><div><br></div><div>map.get("Red", baz)() # bar</div><div>map.get("Yellow", baz)() # default baz</div><div><br></div><div>This has the added advantage that you can dynamically build out the dictionary map.</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div>--<br>William Clemens<br>Phone: <a href="tel:847.485.9455" value="+18474859455" target="_blank">847.485.9455</a><br>E-mail: <a href="mailto:wesclemens@gmail.com" target="_blank">wesclemens@gmail.com</a><br></div></div>
<br><div class="gmail_quote"><div><div>On Mon, Jun 15, 2015 at 10:55 PM, Lewit, Douglas <span dir="ltr"><<a href="mailto:d-lewit@neiu.edu" target="_blank">d-lewit@neiu.edu</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><font size="4">if __name__ = "__main__":</font><div><font size="4">       etc.</font></div><div><font size="4">       etc.</font></div><div><font size="4">       etc.<br></font><div><br></div><div><font size="4">Now I get it.  Do you want to just import the methods from your .py file?  Or do you want to actually run the program directly?  Cool stuff!</font></div><div><font size="4"><br></font></div><div><font size="4">Best,</font></div><div><font size="4"><br></font></div><div><font size="4">Douglas.</font></div><div><font size="4"><br></font></div><div><font size="4">P.S.  Any thoughts on Ruby guys?  I've been messing around with it lately.  Sort of Python-like, but it actually offers more constructs than Python.  For example, Ruby has a do-while loop and Ruby offers two different ways to represent ranges, one with the upper limit included and the other with the upper limit excluded--as in Python.  But Ruby has a very "Pythonic" feel to it.</font></div></div></div>
<br></div></div>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>