Python

#slider
#adsense

Python - Yahoo News Search Results

Python Challenge will return to Florida Everglades in 2016

Florida is bringing back a public hunt for invasive Burmese pythons in the Everglades.  The Florida Fish and Wildlife Conservation Commission plans to hold the next Python Challenge early next year. Registration opens in October. About 1,600 people participated in 2013 during the first month-long python hunt on state lands. Most of the 68 pythons collected were caught by experienced hunters ...

Stephen Hawking sings Monty Python

'Monty Python': Where are they now? 7 photos From left, Graham Chapman, Eric Idle, Michael Palin, Terry Jones, John Cleese and Terry Gilliam (foreground) in 1975's "Monty Python and the Holy Grail."

Stephen Hawking sings Python song

Famed cosmologist Stephen Hawking has proved his comedy chops on shows like "The Big Bang Theory," and now he's trying his hand at musicals.

Stephen Hawking Covers Monty Python Classic

Last year he appeared on film during Monty Python's live shows, but now Professor Stephen Hawking can be heard covering one of the comedy troupe's classic songs. The physicist sings the famous Galaxy Song, which is being released digitally this week and will be available on vinyl this weekend as part of Record Store Day 2015. In the video, the A Brief History Of Time author can be seen whizzing ...

How Monty Python and the Holy Grail Influenced Film by Satirizing It

Any writer, comic or otherwise, can attest that beginnings are the hardest part, but Monty Python never seemed to have that problem. Television was still chintzy and cheerful when Monty Python first aired in 1969, so to satirize it, the show had to be as dramatic as possible. The trappings of film are inherently epic, particularly in 1975, and in scraping together the funds to make Holy Grail ...

Delicious/tag/Python

recent bookmarks tagged Python

Why is Python used for high-performance/scientific computing (but Ruby isn't)? - Programmers

Posted on 18 January 2038

www.tutorialsavvy.com

Posted on 3 April 2015

www.checkio.org

Posted on 3 April 2015

flit.readthedocs.org

Posted on 3 April 2015

Notebook Gallery

Posted on 3 April 2015

Python Programming Resources - TUXAR.uk

Posted on 2 April 2015

Here's a big list of Python Programming resources : learnpython

Posted on 2 April 2015

Valued Lessons: python

Posted on 2 April 2015

Python - 十分鐘入門 « I try | MarsW

Posted on 2 April 2015

Talks and Presentations

Posted on 1 April 2015

Top Answers About Python (programming language) on Quora

Top Answers About Python (programming language) on Quora

With the increase of the processors speeds, will high level languages (like python) take over low level languages (like C/C++) since difference in execution speed will not differ that much?


I think this has already happened to a point, computers, generally are fast enough to run stuff like Python fast enough for 90% of tasks.
However, I don't see Python replacing languages like C or C++ (or Java, C#) etc. because it's dynamically typed, and therefore is a pain to use on big projects.
I use Java in preference to Python for just about everything, but it's not because Java is faster (it tends to be), it's because of the features of Java like Interfaces, static typing, multi-threading etc. That Java is faster, well, honestly, I don't care.
For me, Python's problems are not it's speed, it's the dynamic types, and I can't say I'm crazy about the whitespace syntax either.


See Questions On Quora

Posted on 13 January 2016

How is Python used for Raspberry Pi? I thought the embedded programmings are done with C.


You can program in any language you like, for just about any purpose, and C is commonly used for embedded systems because C has a few attributes:
1) It's small and fast.
2) More importantly perhaps, programs written in C do not necessarily need an Operating System to run.
The Raspberry Pi isn't really an embedded system in the true sense, it's basically a very small desktop computer, which runs regular Operating Systems and software.
An embedded system is like the chip which runs your dishwasher, probably no OS at all, and tiny amounts of memory, think around 32k, not 256MB like a Raspberry Pi.
A Raspberry Pi is actually more like a small version of this:
It looks like a regular PC, but's not, it's an Iyonix, which  is an ARM powered desktop computer, which can run RISC OS and Linux. The Raspberry Pi is basically compatible, and similar in specification to that Iyonix, it's a small desktop computer (and a great one), it's not really an embedded computer, in the true spirit.
So Python works fine on the Raspberry Pi, because basically, the Raspberry Pi is a desktop computer.


See Questions On Quora

Posted on 12 January 2016

Why is Python called "a scripting language"?


Mostly a perception thing.
It's very frequently used for scripting, automating tasks, etc. (technically you could use pretty much anything for that, but Python is a goto for it). It's also often to primarily interpreted which is enables and feeds into this very nicely as you can type it and go.
It's usage has morphed into other areas over time (data science and academia for example) though. JS used to only be considered a scripting language, and it's come a very long ways in terms of perception in a relatively short period of time.


See Questions On Quora

Posted on 9 January 2016

Is programming just not for me?


Maybe it's not for you. But maybe you're just going about it the wrong way, with the wrong focus.
I'm just taking a guess here, but it sounds like you're trying to "learn to code". Don't do that. Don't do the whole "I will learn to code" thing. Where you follow instructions and make boring little classes and run boring little programs for the sake of demonstrating properties and useful things to know.
That's the boring way to learn. You may have to go through some of that at the very beginning just to understand what the hell is going on, but try to get away from that as soon as you can.
Instead, focus on making things. Look at what you know, and the ideas you've read but maybe don't fully understand on the edges of your understanding, then come up with something to make. Something that you have chosen. Something that works and does a thing.
Then make that. It's a good idea to keep learning, keep reading etc. but keep trying to drag new things into your own projects, and only when they're a good fit. Even if you don't fully understand how to use them yet, if something seems good, bring it in. If you find yourself managing a dozen different arrays of data that all work together, maybe it's time to try OOP and make objects to hold that data instead, that sort of thing.
Focus on making things. Maybe it's a text based RPG, or a complicated todo list, or a virtual assistant. You can find fun stuff to make no matter what you know, even if you can only develop in the command line. Google everything. There are tutorials out there for a lot of small projects, but try to make stuff yourself if you can manage it.
Then when you've made something, or while you're making it, keep your eyes open and learn something new. Maybe it's from a book, or maybe it's something you came across while learning how to build your thing. Maybe you stumbled onto threading and barely used it, but it just blows your mind that you can do stuff in the background and have it ready when a user asks for it, so you do something with that.
Not only will this teach you programming, it will do it in a fun, interesting way and will give you holistic development experience, pretty much regardless of your skill level.


See Questions On Quora

Posted on 4 January 2016

Are C and C++ considered the most reliable programming languages as far as crashes or malfunctioning?


C lets you crash in ways you never could in Java.  In C for many embedded systems you can write directly, by accident or on purpose, to the stack or to machine registers that control memory mapping, CPU speed, resetting the processor, starting or stopping a motor, etc.
You don't use C for reliability, you use it because you want low-level control of exactly how the underlying resources are used.  In doing this you take on personal responsibility for writing code that doesn't accidentally kill anyone or melt the hardware.


See Questions On Quora

Posted on 12 December 2015

Should I learn algorithms and data structures with Python or Java?


You don't need any particular programming language to learn algorithms and data structures.  But if you're going to implement them and you have to choose either Python or Java, I'd go with Java.  You will almost certainly want to take advantage of object-oriented programming to implement data structures.  I like teaching Python in our introductory course at Dartmouth, but I do not care for Python as an object-oriented language.  I implemented the data structures in the second edition of Introduction to Algorithms in Java, and it worked pretty well.

See Questions On Quora

Posted on 6 December 2015

If I had to choose between learning Java and Python, what should I choose to learn first?


If you've never programmed before, I'd generally recommend Java as a first language. Python is a great language, but in its attempt to make things easier, I think it actually makes some things harder for a new programmer. Python hides too much and that makes things confusing for a new programmer.

Consider, for example, Python code like this:
x = 5
y = 2
z = x / y
print z


That will print 2 instead of 2.5.

To an experienced programmer, that makes perfect sense. The variables x and y are integers, so z becomes an integer, and thus it gets truncated to 2.

But Python hides this stuff. It all looks like magic.

In Java, it's more explicit what the types of variables are. There's much less "magic" that happens.
int x = 5;
int y = 2;
int z = x / y;
System.out.println(z);


See Questions On Quora

Posted on 20 November 2015

Is there an equivalent of Python "dir" instruction in C++?


There is no concept of a "module" in C++ yet, although work is being done on a standardized module system. But even if C++ had modules already, the answer would be "no". C++ does not have this form of reflection yet, either at compile time or runtime, and there is no reflection proposal that has majority support. There is a long way to go, since a great deal would have to be added to the language just so this question could be sensibly formulated; for example, how would you even pass a module to a function or metafunction? What would
dir
even return?


See Questions On Quora

Posted on 10 November 2015

What are some mistakes when using Python dicts?


Here are a few common pitfalls of using dicts in Python 3.

Using dicts

Dict values are typically checked using
key in d
, accessed using
d[key]
and updated using
d[key] = value
. However, sometimes there are better ways:
  • d.get(key, default=None)
    returns a default value rather a KeyError when the key is missing.
  • d.update(key=value)
    can be used in lambdas and to add multiple values at once (atomically).
  • d.setdefault(key, value)
    updates only if the value is missing (and returns the current value).
  • d.setdefault(key1, {})[key2] = value
    updates d[key1][key2] even if key1 is missing (though see defaultdict below).

Copying dicts

Like for lists, there are three ways to copy a dict:
  • e = d
    makes e refer to the same object as d, meaning that updating one will update the other.
  • e = dict(d)
    and
    e = d.copy()
    both perform a shallow copy, meaning that updating d will not update e but that any values in d will be copied by reference.
  • e = copy.deepcopy(d)
    performs a deep copy, meaning that any values in d will themselves be deep copied.

Looping over dicts

There are multiple ways to loop over a dict:
  • for k in d:
    and
    for k in d.keys():
    both loop over the keys
  • for k, v in d.items():
    loops over keys and values
  • for k in d.values():
    loops over the values
Note that the results are returned in an arbitrary (but non-random) order. Python does not implement a key-ordered map structure (collections.OrderedDict orders by insertion order not keys). The simplest way to loop in order is therefore to loop over
sorted(d)
or
sorted(d.items())
.

When not to use dicts

Dicts are useful but they're not the only associative array structure in Python. Often there is a more specialised container type that is better:
  • set: a collection of hashable objects (equivalent to a dict with Boolean values).
  • Class or named tuple: for fixed attributes these are usually better (Classes allow constructors and methods, named tuples are unpackable).
  • collections.defaultdict: a dict with default values for when 'missing value' doesn't make sense (useful for generic attributes or nested dicts).
  • collections.Counter: counts of hashable objects (equivalent to a defaultdict with count values).

Other gotchas
  • None
    is a perfectly valid dict value, and should not be confused for a missing key.
  • Only hashable values can be used as keys. Mutable structures such as lists, dicts and sets are not hashable (by default). Use frozensets or tuples instead.
  • Numeric values with different types can be equal (e.g. 1 == 1.0), in which case they represent the same key.
  • For dicts with case-insensitive string keys, you can import
    requests.structures.CaseInsensitiveDict
    or implement your own as per kennethreitz/requests.
  • The clearest way to reverse a dict is using dict comprehension:
    {v:k for k,v in d.items()}
    .


See Questions On Quora

Posted on 14 September 2015

What is the rationale behind using the tab indentation to specify blocks in Python?


The basic idea is that the indentation amount makes it obvious to the reader how the code flows, especially with nested stuff.

Besides, only a crazy person wouldn't indent code in languages where it doesn't matter (like C).

You're going to indent anyway. Might as well use the indentation for something.

Not sure why you'd think it would be more difficult for the parser.

Edit:

I'll add some examples. Which code do you find easier to read?

#python
for x in range(SIZE_X):
    for y in range(SIZE_Y):
        val = GetValue(x, y)
        if val > 5.0:
            SetValue(x, y, 5.0)

//c
for (int x=0; x<SIZE_X; ++x) {
    for (int y=0; y<SIZE_Y; ++y) {
        float val = GetValue(x, y);
        if (val > 5.0f)
            SetValue(x, y, 5.0f);
    }
}

//c without indentation
for (int x=0; x<SIZE_X; ++x) {
for (int y=0; y<SIZE_Y; ++y) {
float val = GetValue(x, y);
if (val > 5.0f)
SetValue(x, y, 5.0f);
}
}


Silly examples, sure, but they basically do the same. The first two read about as well, though the Python code is definitely easier on the eyes. The third one is a right mess, however! Without the indentation, the C code becomes very hard to read. Also, Here's a fun exercise! What happens if we add an early return point to the if statement, so the function returns when it finds a value greater than five?

for (int x=0; x<SIZE_X; x++) {
    for (int y=0; y<SIZE_Y; y++) {
        float val = GetValue(x, y);
        if (val > 5.0f)
            SetValue(x, y, 5.0f);
            return val;
    }
}

for x in range(SIZE_X):
    for y in range(SIZE_Y):
        val = GetValue(x, y)
        if val > 5.0:
            SetValue(x, y, 5.0)
            return val


The interesting thing is that these no longer do the same thing! In Python, the "return" statement is a part of the "if", but in the C example, it's not. The C code will always return on the first iteration! Looking carefully at the code, it's obvious to anyone who knows a C-like syntax. A single "if" without brackets will only be for the immediately following statement.

In Python, because the indentation determines the logic, this works right because it looks right. Unless you mix tabs and spaces, of course, but those people are heretics.


See Questions On Quora

Posted on 5 September 2015

Before Python, what used to be the first programming language taught to freshmen at MIT?


I entered MIT in the fall of 1969. There was no introductory Freshman computer science class. (We were supposed to focus on passing the General Institute Requirements, after all). I already knew FORTRAN, COBOL, IITRAN (resembled a simplified PL/I), and a little BAL. I was advised not to take the most popular CS class as a first-term freshman, as the instructors were supposedly of the mind that their class was aimed at older students. So I waited until second semester. This class was 6.251, and was taught by John Donovan and Stuart Madnick, and was all about compilers and linkers and the like. Our first problem set had to be written in IBM 360 BAL. We had just 3 batch runs under the control of the grading program. Note that this means we had only two chances to correct bugs. I got it right. Later in the class, we wrote a parser and then an interpreter for simple programming language. I got the parser right and ran into trouble with the interpreter PS. But Nixon invaded Cambodia and the last 2 weeks of classes were cancelled, so I didn't have to finish the interpreter PS. Those projects also were graded by batch runs with a similar limit on the number of attempts. Computer time was expensive back then and time-sharing systems were still quite new and primitive. The Professors had to pay for the computer time that their students used. During the course of my studies at MIT, I had to learn BAL, APL, LISP, PL/I, SNOBOL, BCPL, ALM, and a language whose name I've forgotten but was used by Art Evans in his class and was something like lisp. I hated it because I couldn't figure it out. Sorry, Dr. Evans. Learning all of those languages was a wonderful education; they all had something to offer.

See Questions On Quora

Posted on 30 August 2015

What are some mistakes when using Python dicts?


The biggest mistake I see developers doing is not using .get().

When you request information from your dictionary do not use the following
>>> my_dict = {'one': 1, 'two':2}
>>> my_dict['one']
1

Instead use the .get()
>>> my_dict = {'one': 1, 'two':2}
>>> my_dict.get('one', 'Not found')
1

This is much safer, and you can also pass in a default value if .get() cannot find the identifier you requested for instance:
>>> my_dict = {'one': 1, 'two':2}
>>> my_dict.get('three', 'Not found')
'Not found'
>>>

This can save you from having Exceptions thrown all throughout your code.


See Questions On Quora

Posted on 29 August 2015

Why would Quora choose the Mean stack over the Python stack?


Quora isn't using the MEAN stack



As far as I can gather, Quora is still using the same Python stack they started with:

QUORA.COM Technology Profiler on BuiltWith

Quora's Tech Stack | StackShare

I examined their JavaScript and couldn't find any trace of AngularJS (the A in MEAN stack). I think they are just getting a lot of mileage out of jQuery on the client side (never underestimate jQuery!).

This article is 4 years old, but it does a great job of exploring Quora's tech stack: Quora’s Technology Examined


See Questions On Quora

Posted on 13 July 2015

What are some of the drawbacks of Python?


In my opinion, the biggest drawback of python is that it does close to no compile-time checking of your code.   Even if you have grossly mis-spelled a function name, until you actually try to run that call, you won't hear a complaint from Python.

This makes it vitally important to have test cases that thoroughly exercise your code.  Guido defends this by saying that if you aren't thoroughly exercising your code and are depending on your compiler to tell you where you have errors in your code,, then you are living in a fool's paradise.  So this  drawback has both pros and cons to it.  Be careful out there.


See Questions On Quora

Posted on 8 July 2015

Isn't dynamic programming much simpler coding in languages like Python (and others) rather than Java (C/C++)?


It can indeed be simpler. The main reason is that (as opposed to Java and C++) Python can actually do the memoization for you automatically.

from functools import lru_cache

@lru_cache(200)
def fib(n):
    if n <= 1: return n
    return fib(n-1) + fib(n-2)

print('F(100) = {}'.format(fib(100)))


This code prints "F(100) = 354224848179261915075" in a matter of milliseconds.

Still, note that there are hidden constant factors both in the time complexity and in the memory consumption of this implementation. Only use it if you have enough of both these resources. Usually you'll run out of memory first. If that happens, you'll have to switch to a language that gives you more control. Or buy more memory :)


See Questions On Quora

Posted on 31 May 2015

Which is better, Perl or Python?


Though I may get flamed for it, I will put it even more bluntly than others have: Python is better than Perl. Python's syntax is cleaner, its object-oriented type system is more modern and consistent, and its libraries are more consistent. (EDIT: As Christian Walde points out in the comments, my criticism of Perl OOP is out-of-date with respect to the current de facto standard of Moo/se. I do believe that Perl's utility is still encumbered by historical baggage in this area and others.)

I have used both languages extensively for both professional work and personal projects (Perl mainly in 1999-2007, Python mainly since), in domains ranging from number crunching (both PDL and NumPy are excellent) to web-based programming (mainly with Embperl and Flask) to good ol' munging text files and database CRUD.

Both Python and Perl have large user communities including many programmers who are far more skilled and experienced than I could ever hope to be. One of the best things about Python is that the community generally espouses this aspect of "The Zen of Python":
Python's philosophy rejects the Perl "there is more than one way to do it" approach to language design in favor of "there should be one—and preferably only one—obvious way to do it".

... while this principle might seem stultifying or constraining at first, in practice it means that most good Python programmers think about the principle of least surprise and make it easier for others to read and interface with their code.

In part as a consequence of this discipline, and definitely because of Python's strong typing, and arguably because of its "cleaner" syntax, Python code is considerably easier to read than Perl code. One of the main events that motivated me to switch was the experience of writing code to automate lab equipment in grad school. I realized I couldn't read Perl code I'd written several months prior, despite the fact that I consider myself a careful and consistent programmer when it comes to coding style (Dunning–Kruger effect, perhaps? :-P).

One of the only things I still use Perl for occasionally is writing quick-and-dirty code to manipulate text strings with regular expressions; Sai Janani Ganesan's pointed out Perl's value for this as well. Perl has a lot of nice syntactic sugar and command line options for munging text quickly*, and in fact there's one regex idiom I used a lot in Perl and for which I've never found a totally satisfying substitute in Python.


*  For example, the one-liner
perl -i.bak -pe 's/foo/bar/g' *.txt 
will go through a bunch of text files and replace
foo
with
bar
everywhere while making backup files with the
.bak
extension.


See Questions On Quora

Posted on 27 May 2015

How does a language like Python efficiently calculate a huge number like [math]2^{50000}[/math]?


[math]2^{50000}[/math] is really tiny as far as computers are concerned. Python uses exponentiation by squaring with Karatsuba multiplication to compute it in under 200 microseconds. The hard part happens after that computation: the result needs to be converted from binary to decimal for display. Python actually does this part much more slowly than it could with better conversion algorithms.

Here we compare the running times using Python’s builtin arithmetic vs. using the GNU MP bignum library via the gmpy2 bindings. You can see that the former grows quadratically and the latter is closer to linear.

Python 3.4.3 (default, Mar 26 2015, 22:03:40) 
IPython 2.3.0 -- An enhanced Interactive Python.

In [1]: a, b = 2, 50000  # to prevent constant folding

In [2]: %timeit repr(a**b)
100 loops, best of 3: 7.64 ms per loop

In [3]: a, b = 2, 500000

In [4]: %timeit repr(a**b)
1 loops, best of 3: 753 ms per loop

In [5]: a, b = 2, 5000000

In [6]: %timeit repr(a**b)
1 loops, best of 3: 1min 15s per loop

In [7]: from gmpy2 import mpz

In [8]: a, b = mpz(2), mpz(50000)

In [9]: %timeit repr(a**b)
1000 loops, best of 3: 387 µs per loop

In [10]: a, b = mpz(2), mpz(500000)

In [11]: %timeit repr(a**b)
100 loops, best of 3: 13.6 ms per loop

In [12]: a, b = mpz(2), mpz(5000000)

In [13]: %timeit repr(a**b)
1 loops, best of 3: 325 ms per loop


See Questions On Quora

Posted on 26 May 2015

How does a language like Python efficiently calculate a huge number like [math]2^{50000}[/math]?


The source code for Python 2.7 clearly explains how they do it. This dated Stack Overflow question covers some more details, including implementation in C.

To put a long story short, the trick is exponentiation by squaring.

Let the exponent be [math]e[/math]. We can convert this to binary as so:


i.e. just expand it as a series of coefficients of increasing powers of 2. The [math]n[/math] is just the highest power of 2 that is above the exponent.

Then, the value [math]b^{e}[/math] is


So far so good? You're done.

The interesting part about this algorithm is that it runs in [math]O(log \;\mathrm{e})[/math] time. You can see intuitively that it takes significantly less time to compute the result compared to simply multiplying 2 repeatedly, which is an operation that's linear with time - you no longer have to multiply out so many digits, for one, and the powers to which each term is raised are themselves drastically smaller. Since Python is written in C, you can rest assured that the actual code is well-optimised for the machine themselves.

Specifically for [math]2^{50000}[/math], you can see that only 15 terms are needed in the multiplication, since [math]50000 < 2^{16}[/math]. Each of these fifteen terms have a relatively small footprint - you can just calculate [math]b^{2}[/math] first and then multiply with [math]b^{2}[/math] to get the next term in your series before raising it to a power. The last couple of [math]a_{i}[/math] tend to be much smaller (obviously), so the need for excessive multiplication decreases as you move down the chain. In other words, the sheer bulk of your calculation will take place with the first couple of terms, and then the tax on your system decreases as you move along the series.

All in all, the success of the method lies in the drastic reduction from having to multiply 50,000 terms to just 15. A recursive implementation of this algorithm (assuming you know a good way to convert to binary) would be pretty simple to write.


See Questions On Quora

Posted on 24 May 2015

Which is better, Perl or Python?


I like and use both,  few quick points:
  • Python is easier to learn, Perl takes a while to get used to and is not intuitive. Perl is great, if you already know it.
  • I use Perl to write quick scripts using regular expressions, to perform text/data manipulations. If there is anything Perl can do well, it is string manipulations.
  • I use Python for writing reusable code. I personally think OO in Perl is a little odd, and find Python to be more consistent. For example, I find it easier to create modules in Python.
  • Perl scripts are often messy (it takes me a while to understand my own scripts), whereas, Python is very clean.

I can't think of anything that you can do with Perl that you can't with Python. If I were you, I'd stick with Python.


See Questions On Quora

Posted on 20 May 2015

What are some interesting things to do with Python?


First of all, congratulations for learning Python. Now you should take the next steps and learn how to write 'pythonic' code. These links will help you in this endeavour.

Code Like a Pythonista: Idiomatic Python
The Hitchhiker's Guide to Python
Hidden features of Python

Install Jupyter and the future of IPython on your system. Its a great tool for python programmers. All you will be needing is a '?' to access the docs, once you install ipython. And if you write your code in vim then here is a handy plugin davidhalter/jedi-vim.

Next up, as the description says you want to learn Big Data and Machine Learning. Now the getting the data part is as important as learning the algorithms involved. So, the logical step would be to learn how to scrape data.

You should start off with this video tutorial.

https://www.youtube.com/watch?v=... 
Its pretty long but you will end up learning the standrd libraries involved in scraping data. You should also go through Scrapy and the Requests library. Both of them are pretty amazing.

A Fast and Powerful Scraping and Web Crawling Framework
Requests: HTTP for Humans

Here's a great course that you should go through

CS109 Data Science

Finally we come to the algorithms involved in machine learning.
Here's a great read to get you started

Programming Collective Intelligence: Building Smart Web 2.0 Applications: Toby Segaran: 9780596529321: Amazon.com: Books

This book will introduce you to all the major algorithms involved. There is no mathematics involved, but it serves as a great introductory book. It contains all the implemenatations in python. For advancing your knowledge you can take up these courses

CS1156x Course Info | edX
Page on coursera.org

Now you can use your gained prowess to create a web application that involves machine learning. The best way, according to me, will be to pick up Flask (A Python Microframework). Don't get confused by the 'Micro', you can create anything with flask. It has some great documentation along with a lot of terrific addons that will help you in creating the web app.

And when you are done, you can show the world your baby by hosting it on Host, run, and code Python in the cloud: PythonAnywhere.

Lastly, I would like to say, read as much docs as possible, as these are well managed and great source of information. And if you get stuck anywhere then just ask, python has a great community which will help you in every way possible.

Happy Coding.


See Questions On Quora

Posted on 20 May 2015

How important is it to learn Python?


If you're already proficient at C and/or Java then consider the cost/benefit analysis for learning Python.

The costs:

  • An hour or so for the syntax including all 31 keywords, seven core data types and their methods, a couple dozen commonly used functions (out of a total of 76 "built-ins" in the top-level name space and about 100 "magic" or "dunder" ("doubled underscore") methods) if:...elif:...else:, conditional structures for and while loops, try: ... except: handling, with context management (resource handling), and, of course the code organization and re-use with def, class, and import. (Yeah.  Only one or two hours to cover that, because they're basically the same, conceptually, as corresponding features in C and Java but with sorta mostly pseudo-code syntax).
  • Another few hours, perhaps a full day to learn more advanced syntax and semantics: list comprehensions, decorated, generators and generator expressions, iteration and context management protocols, set and dictionary generator expressions.
  • A week or so learning the most useful dozen or so of the 430 modules in the 2.7 standard libraries in 2.7 and 317 modules included with 3.4
  • A couple of months discovering the third party modules that are most useful for your needs.  There are over 10K listings on PyPI - the Python Package Index and this site: Python 3 Readiness tracks the "readiness" of the 360 most interesting packages for the transition from Python 2.x (legacy version which is still dominant in real world usage) to Python 3.x (which is the future and slowly gaining deployment ... currently at around 20%)
Those are, admittedly, rather optimistic estimates.  The depend quite a bit on just how proficient you are at programming (apart from your specific skills in any given language) and, especially, on how easily you pick up new language and how much focus you can achieve over the time spans I've estimated.

It's really easy to pick up the very basics of Python. Mastering its idioms takes as long as any other language.

What's the value proposition?  What are the benefits?

Mostly you get to work in a very high level language with about the broadest range of support for real world, practical stuff that can be found in computing.  For most APIs, file formats, and services, there are already modules available for Python, almost all free and mostly of reasonably good quality.  Search PyPI for almost anything you'd conceive of programming and there's a reasonably good chance that you can fetch and use, usually with only a dozen or so lines of code.  (As an example I wanted to find some numbers to intersperse in my estimates above ... and easily found: stdlib-list 0.2.1 which pulls the lists of standard libraries off the official documentation websites for any version of Python).

You get to work in a REPL (Read-Eval-Print-Loop) to explore you requirements and the behavior of code that you're writing, and especially the code that you're using ... that you're building your programs over.  In particular you get to use iPython which is the pre-eminent interactive shell for Python ... and to use iPython Notebooks to document and collaborate on your computations.

Also if you step out into the job market you'll find that many sites want practical skills in very high level scripting languages such as Python, Ruby, or Javascript.  Even if you're going to work in C or Java it's handy to be able to do prototyping, testing, and backend glue work in something that's more "RAD" (suited for rapid application development).


See Questions On Quora

Posted on 12 May 2015

Can an operating system be written completely in Java or Python? What are the difficulties associated with writing an OS in Java or Python?


An OS has to run on top of the hardware. High level languages like Java and Python run in a VM, and a VM runs on top of an OS. Technically, you cannot take a JVM and turn it into an OS.

If you do want to write an OS in Java/Python, you will have to first implement a compiler that takes Java/Python code and converts it into machine code. And that means you will have to implement a compiler for each kind of hardware that it will run on

Of course your Java/Python program needs access to the underlying hardware too right? But these programs are designed to work at a level of abstraction above the OS. For example, a FileOutputStream assumes that there is an OS that manages the file system. However, if you don't have an OS, you don't have a file system. Your OS has to provide the file system. This means that your code will need some way of sending commands to the disk. This means you need to provide API that can send commands to the disk.

Essentially, this means that you have to throw away all the APIs that are specified by Java/Python, and come up with a whole new native API that can access the hardware.

What you will end up with is a new language that is uses Java/Python syntax!


See Questions On Quora

Posted on 7 May 2015

How do you identify a good programmer?


Many engineers think that the quality of a programmer, is their comprehension of some complex thing. Their mastery of best practice. Their dominance of killer methodologies....  These are what I call "inputs". These are things programmers put into a project.

Artists don't see the world like this. Artists tend to judge other artists by their body of work.   They make a judgement, not on methodology but on output alone. They look at the outcomes.

In my view, the artists have this right.

We should judge good programmers by the outcomes:
 
Did the project ship?
Did it ship on time?
Was the program stable? - and so on. Because this is what matters more than the other stuff.

I can hear the engineers howling in protest. What about the quality of code? What about <insert fashionable technique> methodology?  Reusability, Unit tests etc.

The thing is, good programmers will indeed use those methodologies. Just as good artists will employ the right sort of brush technique.
But the truth is, so do bad programmers and bad artists.

Good programmers ship.  Bad programmers congratulate themselves about clever methodologies, while missing deadlines.

#controversial


See Questions On Quora

Posted on 24 January 2015

How many boring steps in programming were there for you, before it became exciting?


I got stuck playing Grand Theft Auto: San Andreas on my PC! I had to figure out a way to get rid of the update to unlock my old saves. I ended up messing with one piece of the source code that was open to modify, it was written in C (If I only had known what C is).

I went to buy this book (This exact copy) for $75. In North Iraq $75 is a lot of money:

My cousin, Misho, who was an actual Engineer at the time told me few things:

  1. First, that is C++, you wanted C, those are not that close. AND no the ++ doesn't mean a better version. (My logic back then :/ )
  2. Second, this is for someone who can understand at least College level English, wait do you even know what a TextBook is Yad?
  3. Third, why did you break the game again? It doesn't look like that you are going to be playing it anytime soon.


Hence, the journey started my friend! I went on an epic mission to fix the game back! Didn't know what was coming, it got dark really fast.



I ended up making a MOD on the game and never being able to fix it. I downloaded the free available 3D car models and added them to the game.
My first 101 programming project as a 16 years old (It was one of the most exciting things I have ever done in my life).

When I showed the game Mod to my friends, the reaction was something like this:

For those who are interested here is what the game ended up like:
Hitman: Blood Money MOD in GTA :):

I found a Forum that gave all the Car Models for free and I gave them my Mod for free. Back then startup tactics was such simple!

https://www.youtube.com/watch?v=...


See Questions On Quora

Posted on 14 January 2015

What are some interesting things to do with Python?


I always get beginners to write a program that crawls the internet and downloads every image that it finds. Get's the size (height and width) of the image, hash it MD5, SHA256 and delete the file. Save information in the database - don't download it again. Gather more information like country of origin etc

Run the program for a week. Without it crashing!

Then write a program to extract some statistics about what you have found. Where did you go in the crawl? How many files found? How many Unique? Average size of image? etc etc etc

It's fun, interesting and with so much information being online will stand you in good stead for writing data gathering applications in the future.


See Questions On Quora

Posted on 6 January 2015

Why do we return 0 to the OS when we exit with no errors, but boolean functions within the code generally return 1 (true) to indicate all is fine?


Because the exit code is answering the question "were there any problems?" as opposed to "was the program successful?".

Moreover, it's actually more than just a boolean: the number returned is a code that can specify what sort of error it was. Depending on the program, an exit code of 1 can be very different from 255.

The neat thing is that this approach works as both a boolean and a richer code, at least in C. By answering what is, in essence, a negative question, it elegantly covers two different use cases at once.


See Questions On Quora

Posted on 11 December 2014

How do I learn a programming language (Python) without a strong background in computer science? What strategies/materials do you use?


Getting Started with Python

So you wanna learn python eh? Well, what is python? Python is a general purpose programming language that is able to be used on any modern computer operating system. It may easily be used for processing text, numbers, images, scientific data, or anything else which one might save on a computer. It is used daily in the operations of the Google search engine, the video sharing web site YouTube, SpaceX, NASA, and the New York Stock Exchange. These are but a few of the places where Python plays important roles in the success of business, government, and non-profit organizations; there are many others.

Python is also an interpreted language. This means that it is not converted to computer-readable code before the program is run but at runtime. In days gone by, this type of language was called a scripting language, intimating its use for trivial or banal tasks. However, programming languages such as Python have forced a change in that nomenclature. Increasingly, large applications are written almost exclusively in Python. As mentioned above, in addition to being used by Google and NASA to complement other languages, Python is used almost exclusively for such applications as YouTube and the web-based transaction system of the New York Stock Exchange (NYSE).

You have the option of learning from front to back or jumping straight into a pretty damn good tutorial, made by Al Lukaszewski to get down and dirty. The choice is yours.

Table of Contents (whats covered below)
  1. An Introduction to Python
  2. Tutorial It Up
  3. The Pythonic Way

If you wanna dive straight into the programming and get your feet wet, dive into #1 Team Tree House's online interactive tool for learning. If you wanna start from scratch and work through the entire thing begin with #4 Learning Python from Scratch. If you're really a rebel, jump into #3, and do it like a boss, the hard way.


An Introduction to Python
  1. Python By Team Tree House | If you're new to Python, this is the place to start. In this course, you'll take a look at some of the most common and important bits of the language, how to use them, and then put them together into several different handy scripts. Finally, you'll build a small console game using all of the stuff you've learned!
  2. Code Academy | In this Codecademy course you will learn how to work with files, how to use loops and how they work, what are functions and what they’re good for. It’s all very basic, and very beginner friendly. There is community forums available for those who need help, but usually everything can be understood from within the dashboard you’re working with.
  3. Learn Python The Hard Way | The absolute easiest way of learning Python is by completing this book. You’ll be amazed at how easy it is to pickup the basics, and you get that sense of real learning process, acquiring new knowledge as you move forward.
  4. Learning Python from Scratch | This is going to teach you the ins and outs of Python development... from scratch. There's no need to worry if you don't have any ounce of Python experience.
  5. A Byte of Python | Very similar to Learn Python The Hard Way, but offers a slightly more in-depth introduction on how to get your perfect setup up and running, and how to take the first steps so you don’t overwhelm yourself. It has been recognized as one of the best beginner guides for those who want to learn Python, definitely check it out and see the first few chapters to figure out whether you like the style of writing.
  6. The New Boston | If you’re more like someone who likes to learn from video tutorials, I’m not sure there is anything as comprehensive as The New Boston video tutorial series for learning Python, and many other programming languages as can be seen on their YouTube channel. If you want some of their older python videos after you're done, check here
  7. Python + Coursera | This course is intended for people who have never programmed before. A knowledge of grade school mathematics is necessary: you need to be comfortable with simple mathematical equations, including operator precedence. You should also be comfortable working with simple functions, such as f(x) = x + 5.
  8. The Python Challenge | It might be a little tricky to get this one going, if you’ve never in your life programmed before, but it goes together well with the above book, and you should definitely give it a go. There are 33 levels (puzzles), which can be solved by using your Python programming skills.
  9. Google's Python Class | Google itself is powered by a lot of Python code, and so it only makes sense that they support the community and want to help others learn the language. This is one of my favorite guides / classes I’ve ever viewed, it’s really detailed and the videos are very beginner friendly and also entertaining to watch.
  10. Think Python | Think Python is an introduction to Python programming for beginners. It starts with basic concepts of programming, and is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression. Larger pieces, like recursion and object-oriented programming are divided into a sequence of smaller steps and introduced over the course of several chapters. You can even find some example code here
  11. Learning from the docs | This right here is the source. The official docs of the open source community that make up python.

 Straight Up Tutorial
This series of tutorials is intended to help anyone learn to program in Python. If you are new to computers, however, you may benefit from the absolute beginner's tutorial: How a Computer Looks at Your Program.
Once you have downloaded and installed Python for your platform or operating system, you will probably want to jump right into programming. Before you do, you should ensure that you are equipped with an editor you can live with and familiarize yourself with the basics of Python programming.

  1. Executing a Python Program: Shell or File? | Programming is pointless if you cannot run, or execute, the program you write. Executing a Python program tells the Python interpreter to convert the Python program into something the computer can read and act upon. There are two ways to do this: using a Python shell and calling the Python interpreter with a "bang" line.
  2. Choosing a Text Editor for Python Programming | To program Python, most any text editor will do. A text editor is a program that saves your files without formatting.
  3. Data Types | In order to program, you need to know the types of containers your program uses to hold your data. This tutorial will help you know when to use which kind.
  4. Operators | Before you can calculate anything, you should read this tutorial and learn which symbols mean what operation to Python.
  5. Controlling the Flow | Computer programs are all about choices: if low, buy; if high, sell. This tutorial covers the several ways of expressing decisions in Python.
  6. Putting it All Together With Syntax | In order for your commands to make any sense to the computer, they must follow a certain protocol, put certain pieces of information in certain places. This "putting together" is what syntax is all about (in fact, syntax comes from the Greek word which means 'put together'). This tutorial will teach you what should be put together with what.
  7. Exceptions, Errors, and Warnings | If your programs are going to live in the real world, they had better be able to crash softly. This tutorial tells you how to ensure that.
  8. Python's Encodings for Unicode and ASCII | Python's encoding functions offer a means of encoding ASCII in Unicode and vice versa. Any program that might be used on the internet someday will need to work with multiple character sets. Here is how.

Framework it up!
  1. Flask | A lightweight Python web framework based on Werkzeug and Jinja 2. Code, documentation, and community links are provided.
  2. Django | Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  3. CherryPy | CherryPy allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.

The Zen of Python
The Zen of Python is a guideline on how to write Pythonically. It was authored by Tim Peters. You can see this by running IDLE/ Python in your terminal and typing import this.

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!

All of this and more can be found here, HackerCollective/resources, made by myself and a few others across the interwebs!


See Questions On Quora

Posted on 8 December 2014

Which course materials such as books and other resources does Thomas Cormen recommend for the undergraduate course - Introduction to computer science using Python?


In the COSC 1 course that we teach at Dartmouth, we publish our own online lecture notes.  We point students to How to Think Like a Computer Scientist, but we do not assign reading from the book.  We have our own set of assignments, and we add new assignments into the mix every now and then.

See Questions On Quora

Posted on 25 November 2014

As a starting Python programmer I see a lot of praise for the Python language (and so far I can only agree). Isn't there anything bad to say about it? What is a real con?


Python s fantastic in many ways.  It's very clean in many ways, and the huge number of modules make it a snap to do electrical engineering, Fourier transforms, data plotting, reading/writing excel spreadsheets, doing 2D and 3D graphics, and much more, with a very few lines. 

But if there isn't a built-in feature or plug-in module and you have to write a complex and explicit loop to do something, it can be a bit slow.  What I do is google "How in Python can I swap rows and columns" and someone will very often have an answer of a built-in that will do the trick very quickly.

As an example of a success then a failure, I needed to parse a huge 33 gigabyte text data file and collate the data.   It only took about 60 lines of Python to do all the work.  However it took many minutes to run, and it eventually used all 4 gigabytes of memory and hung.

I had to rewrite the code in Delphi, and that program was more like 600 lines, but it ran about 10 times faster and used about 1/4 the memory.

So Python is very good in many ways, it's just not a solution for every problem.


See Questions On Quora

Posted on 29 October 2014

What does one mean by 'elegant' code?


It's very closely related to elegance in mathematics.

Elegant code is simple, gives you some new insight and is generally composable and modular. These qualities, although they may look almost arbitrary, are actually deeply related, practically different facets of the same underlying idea.

Simplicity

The biggest one, perhaps, is simplicity. But remember: simple is not the same thing as easy. Just because some code is very simple does not mean it is easy for you to understand. Easiness is relative; simplicity is absolute. 

This is especially relevant for Haskell: often, the most elegant Haskell code comes from simplifying a problem down to a well-known, universal abstraction, often borrowed from math. If you're not familiar with the abstraction, you might not understand the code. It might take a while to get it. But it is still simple.

Simple code like this is also often concise, but this is a matter of correlation, not causation. It goes in one direction: most elegant code is concise, but much concise code is not elegant.

One way of thinking about simplicity is that there are fewer "moving parts", fewer places to make mistakes. This is why many of Haskell's abstractions are so valuable—they restrict what you can possibly do, precluding common errors and shrinking the search space.

Consider the difference between mapping over a list and using a for-loop: with the loop, you could mess up the indexing, have an off-by-one error or even be doing something completely different like iterating over multiple lists at once or just repeating something n times. With a map, there's only one possible thing you can be doing: transforming a list. Much simpler! It leaves you with fewer places to make a mistake and code that's easier to read at a glance, since you immediately know the "shape" of the code when you see
map
.

In fact, that's probably my favorite test for simplicity: given that I'm familiar with the relevant abstractions and idioms, how easy is the code to read at a glance? Code is read more often than it's written, but it's skimmed even more often than it's read. That makes the ability to quickly get the gist of an expression—without having to understand all the details—incredibly useful.

Insight

Another thing that elegant code does is give you a new insight on its domain.

Sometimes, this is a surprising connection between two things that seemed disparate. Sometimes it's a new way of thinking about the problem. Sometimes its a neat idiom that captures a pattern that is normally awkward. Almost always, it's an idea that you can apply to other code or a common pattern you've already seen elsewhere.

Beyond the immediately practical reasons, mostly illustrated in the "simplicity" section, this is why I'm so drawn to elegant code:  it's the best way to learn new things. And these things, thanks to their simplicity and generality, tend to be pretty deep. Not just pointless details.

Elegant code also displays the essence of the problem its solving. It's a clear reflection of the deeper structure underlying either the solution or the problem space, not just something that happened to work. If your problem has some sort of symmetry, for example, elegant code will somehow show or take advantage of it. This is why that QuickSort example—which, unfortunately, has some problems of its own—gets trotted out so often. It does a marvellous job of reflecting the structure, and especially the symmetry, of QuickSort which the imperative version largely obscures in implementation detail. The key line
quicksort lesser ++ [p] ++ quicksort greater
reflects the shape of the resulting list.

Composability

The final characteristic of elegant code, especially elegant functional code, is composability and modularity. It does a great job of finding the natural stress lines in a problem and breaking it into multiple pieces. In some ways, this is just the same point all over: elegant code gets at the structure of what it's doing.

Really elegant code combines this with giving you a new insight and letting you split a problem into two parts that you thought inseparable. This is where laziness really shines, coincidentally.

A great such example is splitting certain algorithms into two phases: constructing a large data structure and then collapsing it. Just think of heapsort: build a heap then read elements out of it. That particular algorithm is elegant on its own, and is pretty easy to implement directly in two parts. For many other algorithms, the only way to separate them and maintain the same asymptotic bounds is to construct and fold the data structure lazily.

Conal Elliott has a great talk about this which is well worth a look. It includes some specific examples of splitting up algorithms that seem inseparable into a fold and an unfold—most of which only work lazily.

I think modularity is one of the best ways to avoid bugs and, to illustrate, I'm just going to reuse the same pictures. The first represents code that's less modular; the second represents code that's more modular. You can see why I'd find the second one more elegant!

Imagine these graphs to be parts of your code with actual, or potential, interconnections between them. If all your code is in one big ball, then every part could potentially depend on every other part; if you manage to split it into two modules with clear module boundaries, the total number of possible interconnections goes way down.
Not very modular, pretty complex—not very elegant.

Simpler and more elegant.

An Example

But that was all pretty abstract. So let me give you an example that captures all of these ideas and neatly illustrates elegance.

Lets say we have a bunch of records containing book metadata:
data Book = { author, title :: String
            , date :: Date
            {- ... -}
            }


We want to sort our book collection, first by author, then by title, then by date. Here's the really elegant way to do it:
sortBy (comparing author <> comparing title <> comparing date)

We can use
comparing
to turn each field into a comparison function of type
Book -> Book -> Ordering
and then use the monoid operator
<>
to combine these comparison functions.

It does exactly what you expect it to—but if you're not familiar with monoids and the
Ordering
type, you might not know why it does what you expect.

On the other hand, there is the really explicit version which replaces each
<>
with pattern-matching on
EQ
,
LT
and
GT
. To somebody who's not familiar with the relevant abstractions, this might be easier to read—but it's also more complex and noisy. Less elegant.

This example is simple because it neatly abstracts over all the plumbing needed to combine the comparison functions. It's very easy to tell, at a glance, exactly which fields we're sorting by and with what priorities.

It's insightful because it takes advantage of the natural way to combine
Ordering
values—the way they form a monoid. Moreover, going from the
Ordering
monoid to the
Book -> Book -> Ordering
monoid is actually also free—if we know how to combine any type
o
, we know how to combine functions
a -> o
. So the abstraction that hid the plumbing? We got most of that for free, from libraries that are not specific to Ordering at all!

Finally, this version is definitely more modular and composable than the alternatives. It's very easy to mix and match different comparison functions with this pattern. We can trivially extract parts of them to be their own functions. It's very easy to refactor. All good things.

Hopefully that's a nice illustration of what people mean by elegant and why it comes up often in languages like Haskell.


See Questions On Quora

Posted on 25 May 2014

Why are banks like JP Morgan and Bank of America Merrill Lynch using Python to replace historic legacy systems built in Java/C++?


They aren't.

People use C++ as a LEGO brick and then python as a glue language to paste C++ components together.  Python is very useful for this because it interfaces with C++ nicely through things like boost::python.  Also you have something like a C++ computational engine call pieces of python code for something that you want configurable.

No one is replacing java and c++ with python.  The systems that are being replaced are ad-hoc older systems, including one that was built on top of Excel plugins.


See Questions On Quora

Posted on 13 April 2014

Can a high-level language like Python be compiled thereby making it as fast as C?


Yes it can. In fact, many high-level languages are compiled like that including Common Lisp, Scheme, OCaml and Haskell.

But you have to keep something in mind: C is not all that fast. Rather, C is easy to optimize.

This is an important difference: if you just write naïve C code, it won't be fast. It won't be terribly slow--certainly not as slow as Python--but it won't be anywhere close to the speed of optimized C.

C doesn't magically make your code fast. Rather, C exposes enough low-level details to make optimizing possible. It takes an expert in performance--one who is constantly thinking about cache behavior, register blocking, memory layout and so on--to write truly fast C code. And C doesn't even help all that much; it just makes all this possible in the first place.

For example, you could just compile your high-level program to C directly. But just because you're outputting C does not mean you're anywhere near the speed C can offer. And, in fact, this is exactly what happens with compilers like CHICKEN Scheme: they turn high-level code into C, but the result isn't nearly as good as handwritten C can be.

To actually rival C, your compiler would have to not just compile down to assembly but also optimize really cleverly. You would have to compete with both the optimizations C compilers already perform and the hand-optimization of experts. And, right now, we don't have any systems that can really do this in the general case.

There have been research projects like Stalin Scheme (it brutally optimizes) which could beat even hand-written C in some cases. But this comes with significant compiler complexity, really long compile times and prevents separate compilation--enough problems to basically kill Stalin. There have also been projects that can generate really fast code for specific tasks or really short programs. But nothing general.

So: yes, you can compile high-level languages. And, in one sense, they would be as fast as C. But they will still not be as optimizable as C, so hand-written C will still trounce your high-level programs.


See Questions On Quora

Posted on 2 January 2014

What is the right age to start learning 'how to code'?


The right age to start learning anything is when it interests you. People learn best when they're interested, and two people are unlikely to become interested at exactly the same age. I've seen six-year-olds become fascinated by programming; I've seen others not get into it until they were older. Some people never show any interest in it.

Most kids are able to understand the concept of an instruction set at a very early age.


See Questions On Quora

Posted on 18 August 2013

What are some "practice problems" that everyone should work on in-order to get better at programming (in any programming language)?


Some great resources have already been mentioned (I visit Project Euler periodically, myself), but here's a gem no one seems to be aware of:
Timus Online Judge
This is an "archive of programming problems with automatic judging system". For any given problem, you submit your code, and the system compiles and runs it against a suite of example and edge cases. You can solve Project Euler problems by a fluke, with unresolved edge cases, or brute-force; not so with Timus Online Judge problems.


See Questions On Quora

Posted on 26 July 2013

Is Quora still running on PyPy?


No, currently we don't use PyPy, although there is working PyPy branch in our repository.

The main reason for not switching to PyPy is its performance: in our case CPython + Cython version is noticeably faster (at least currently). We spent pretty limited time on PyPy migration and performance analysis, so I admit this might be due to some issues on our side, i.e. this may not be related to PyPy itself.


See Questions On Quora

Posted on 6 July 2013

As a Python developer, should someone apply at Facebook or not?


When I applied for an internship with Facebook, they told me I could use any language I wanted when solving the coding interview questions. (Although they warned me that I might run out of time if I picked Java, since it tends to be quite verbose.)

Every Facebook engineer I met was very smart and an excellent programmer, quite capable of picking up any language if necessary, or maybe just for fun. The interns came from various backgrounds. Some had worked almost exclusively with C++; some were quite proficient with JavaScript, some were fascinated by Haskell, and some extolled the virtues of LISP. As far as I could tell, most people had more trouble with Git than with the programming languages their teams used (typically PHP, or, rather, Facebook-flavoured PHP.).

Does this sound like you? Apply! It's am amazing place to work. You won't regret it.


See Questions On Quora

Posted on 3 May 2013

What did Dropbox offer to Guido Van Rossum?


Parts of Google's search engine was originally in Python, but the company has since moved on to Java on the front end, C++ on the back end, and Python has been relegated to glue code.

On the other hand, Dropbox has been using Python for its entire stack. I believe they made a few performance related contributions to CPython as well.

Guido is a great engineer (besides being a language designer), and still writes a lot of code. He would get more satisfaction working at a growing company where Python is a first class citizen rather than at Google.


See Questions On Quora

Posted on 7 December 2012

What explanation of the concept "functions may or may not return a value in python" will be intuitive and definitive enough for newbies to understand?


Actually, every Python function returns a value. If the function doesn’t have a
return
statement or if it has a
return
statement with no explicit value, then the return value is implicitly
None
.

So these three functions are equivalent:
def func1():
    print('Hello, world!')

def func2():
    print('Hello, world!')
    return

def func3():
    print('Hello, world!')
    return None


Perhaps you might object that
None
represents the absence of a value, but that’s as silly as saying that zero represents the absence of a number.
None
is a legitimate value (of type
NoneType
) that can be passed around and stored in variables like any other Python value.

None
behaves a little specially in the interactive Python interpreter, in that a result value of
None
is not shown by default. You can force it to be shown with, say,
print(func1())
.

See also Defining Functions in the Python tutorial.


See Questions On Quora

Posted on 22 July 2012

Why does + and += behave differently for python lists?


In general, the difference between
a += b
and
a = a + b
depends on whether
a
is mutable
:
  • For an immutable object
    a
    (such as an
    int
    ,
    str
    , or
    tuple
    ), they do the same thing.
  • But for a mutable object
    a
    (such as your
    list
    ), the difference is that
    a += b
    mutates
    a
    in place. This mutation will be observed by anyone with a reference to the same object
    a
    .

Why? The Python
a += b
operator works roughly* by invoking the first of whichever of three methods are defined and does not return
NotImplemented
:
  1. a = a.__iadd__(b)
    . Typically this mutates
    a
    in place and returns
    a
    .
  2. a = a.__add__(b)
    . Typically this creates a new object and modifies neither the original
    a
    nor
    b
    .
  3. a = b.__radd__(a)
    . Typically this creates a new object and modifies neither the original
    a
    nor
    b
    .
On the other hand,
a = a + b
only tries the last two of these.

(* The full story is somewhat more complicated.)


See Questions On Quora

Posted on 23 June 2012

What is the fastest scripting language on the server side?


Javascript (or more precisely ECMAScript). And it's a lot faster than the others. Surprised?

When in 2009 I heard about Node.js, I though that people had lost their mind to use Javascript on the server side.But I had to change my mind.

Node.js is lighting fast. Why? First of all because it is async but with V8, the open source engine of Google Chrome, even the Javascript language itself become incredibly fast. The war of the browsers brought us iper-optimized Javascript interpreters/compilers.

In intensive computational algorithms, it is more than one order of magnitude faster than PHP (programming language), Ruby, and Python. In fact with V8 (http://code.google.com/p/v8/ ), Javascript became the fastest scripting language on earth.

Does it sound too bold? Look at the benchmarks: http://shootout.alioth.debian.org/

Note: with regular expressions, V8 is even faster than C and C++! Impossible? The reason is that V8 compiles native machine code ad-hoc for the specific regular expressions (see http://blog.chromium.org/2009/02... )

If you are interested, you can learn how to use node: http://www.readwriteweb.com/hack... :-)

Regarding the language Javascript is not the most elegant language but it is definitely a lot better than what some people may think. The current version of Javascript (or better ECMAScript as specified in ECMA-262 5th edition) is good. If you adopt "use strict",  some strange and unwanted behaviors of the language are eliminated. Harmony, the codename for a future version, is going to be even better and add some extra syntactical sugar similar to some Python's constructs. 

If you want to learn Javascript (not just server side), the best book is Professional Javascript for Web Developers by Nicholas C. Zakas. But if you are cheap, you can still get a lot from http://eloquentjavascript.net/ and http://addyosmani.com/resources/...

Does Javascript still sound too archaic? Try Coffeescript (from the same author of Backbone.js) that compiles to Javascript. Coffescript makes cleaner, easier and more concise programming on environments that use Javascript (i.e. the browser and Node.js). It's a relatively new language that is not perfect yet but it is getting better: http://coffeescript.org/


See Questions On Quora

Posted on 10 May 2012

What are some cool Python tricks?


List comprehensions and generator expressions

Instead of building a list with a loop:
b = []
for x in a:
    b.append(10 * x)
foo(b)

you can often build it much more concisely with a list comprehension:
foo([10 * x for x in a])

or, if
foo
accepts an arbitrarily iterable (which it usually will), a generator expression:
foo(10 * x for x in a)

Python 2.7 supports dict and set comprehensions, too:
>>> {x: 10 * x for x in range(5)}
{0: 0, 1: 10, 2: 20, 3: 30, 4: 40}
>>> {10 * x for x in range(5)}
set([0, 40, 10, 20, 30])


Fun tricks with
zip

Transposing a matrix:
>>> l = [[1, 2, 3], [4, 5, 6]]
>>> zip(*l)
[(1, 4), (2, 5), (3, 6)]

Dividing a list into groups of
n
:
>>> l = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8]
>>> zip(*[iter(l)] * 3)
[(3, 1, 4), (1, 5, 9), (2, 6, 5), (3, 5, 8)]


import this

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!


See Questions On Quora

Posted on 1 December 2011

How can I learn to write idiomatic Python?


No, no, no. You start by reading Python. Python source. As in, the code.
  • Not a book. When I was in China, one of my friends showed me an English proficiency test she had to take to get qual'd. It was hard as balls; even I had no idea what some of the answers to the questions were, and I'm a native speaker. She did know the answers, though. All of them. And the result is that she knew a lot about English. In spite of this though she could not speak it.

    Programming is more or less the same. It's a community event: you are operating in a system with other people, and the shorthand, the hacks, the abbreviations, are all part of this system. If you want to learn these things, you need to be a part of this system. You need to read Python.
  • Not PEPs. When I learned Chinese, I picked up a book called Making Out In Chinese. It was great, full of idioms. It explained where they came from, and why they were idioms. But it did not teach me idiomatic Chinese. It just taught me Chinese idioms. This is a subtle but crucial difference: imagine someone who clearly does not know English at all walks up to you and says (in a heavy accent), "What's up?" This is not the same thing as when I say this to my friends. This person has just used an English idiom, but they are not speaking English idiomatically.

    In the real world, idiomatic English (just like idiomatic Python) requires good judgement and understanding of context[1]. I'd say this is actually more important in programming since one big component of these systems is that they need to be correct. And at the end of the day, this is something that you can't really get without being a part of the dialogue. You need to read Python.

Caveat: This is not to say that these aren't great resources. For learning about Python. Learning about Python will help you to be a better programmer, and I say this from experience. But it will only get you so far. So roll up your sleeves and get out there.

If you're looking for projects to look at, I like the source of Brubeck framework[2] and Mercurial[3]. Per Shashwat Anand's (correct) suggestion, standard library stuff like heapq and shutil are also worth looking into.


I'M NEW HERE. Please leave me any criticisms that might be helpful as I slowly learn to be a better writer!


[1] Also, it's easy to make mistakes when judging idioms. Do you know the best way to create a 2-D List of
0
's? A quick perusal of the internet might lead you to believe it's
[[0]*n]*m
, but this is very very wrong, and in order to understand why, you need to have spent time with it.
[2] http://brubeck.io
[3] http://mercurial.selenic.com/


See Questions On Quora

Posted on 19 August 2011

What are common uses of Python decorators?


I've found the following memoization decorator useful on a number of occasions:

def memo(fn):
    cache = {}
    miss = object()

    def wrapper(*args):
        result = cache.get(args, miss)
        if result is miss:
            result = fn(*args)
            cache[args] = result
        return result

    return wrapper


With this little tool in your toolchain, you can write functions in a naive, mathematically elegant style, and get away with it:

@memo
def fib(n):
    if n < 2:
        return n
    return fib(n - 1) + fib(n - 2)


Goodbye, exponential time.  Hello, linear time.

Of course, the original function must be pure, and the arguments must all be hashable, but python does a great job synthesizing a hash function for the
args
tuple, provided those assumptions hold.


See Questions On Quora

Posted on 19 May 2010

What are common uses of Python decorators?


Decorators are convenient for factoring out common prologue, epilogue, and/or exception-handling code in similar functions (much like context managers and the "with" statement), such as:
  • Acquiring and releasing locks (e.g. a "@with_lock(x)" decorator)
  • Entering a database transaction (and committing if successful, or rolling back upon encountering an unhandled exception)
  • Asserting pre- or post-conditions (e.g. "@returns(int)")
  • Parsing arguments or enforcing authentication (especially in web application servers like Pylons where there's a global request and/or cookies object that might accompany formal parameters to a function)
  • Instrumentation, timing or logging, e.g. tracing every time a function runs
They are also used as shorthand to define class methods (@classmethod) and static methods (@staticmethod) in Python classes.


See Questions On Quora

Posted on 19 January 2010

reddit.com: search results

[Meta] Can we take "Learn Python the Hard Way" off the sidebar? It's old and teaches, "I repeat, do not use Python 3. Python 3 is not used very much... you'll still have to learn Python 2 to get anything done. Just learn Python 2 and ignore people saying Python 3 is the future."

There was a conversation on /r/learnpython yesterday about whether someone should learn Python 2 instead of Python 3 due to this advice by LPTHW's author:

A programmer may try to get you to install Python 3 and learn that. Say, "When all of the Python code on your computer is Python 3, then I'll try to learn it." That should keep them busy for about 10 years. I repeat, do not use Python 3. Python 3 is not used very much, and if you learn Python 2 you can easily learn Python 3 when you need it. If you learn Python 3 then you'll still have to learn Python 2 to get anything done. Just learn Python 2 and ignore people saying Python 3 is the future.

At the same time, Automate the Boring Stuff with Python is a great book that brings many new people to Python using Python 3, and it's not in the sidebar yet. The consensus of the conversation was that LPTHW should be replaced with AtBS in programmer's recommendation repertoire, what do you all think?

Edit: Thanks /r/Python for making this /r/Python's top thread of all time!

submitted by /u/CATHOLIC_EXTREMIST to /r/Python
[link] [comments]

Posted on 13 January 2016

Signup for "Automate the Boring Stuff with Python" Udemy course is free until New Year's Day with code RESOLVE_TO_CODE_2016

Hi Reddit, I'm making my Python course free to register for. Here's the link: https://www.udemy.com/automate/?couponCode=RESOLVE_TO_CODE_2016

EDIT: Whoa! I only made 10,000 coupons and didn't realize how popular this would be. If the above code doesn't work, use this one instead: https://www.udemy.com/automate/?couponCode=RESOLVE_TO_CODE2_2016

This discount code will work until New Year's Day and give you lifetime access, so you can sign up now and take the course later when you have free time. The course follows my book Automate the Boring Stuff with Python, which is also free to read online under a Creative Commons license.

The course covers the same material in the book, which is aimed at total beginners. The material is especially those who don't necessarily want to become software developers but want to automate computer tasks with simple scripts: updating Excel spreadsheets, reading PDFs, web scraping, etc. It's also nice for experienced developers who want to learn about some really practical Python modules.

(Side note for those reading this post after New Year's Day: The last time I posted a free code, I still gave out free codes to people who messaged me after the deadline. But I'm going to have to tighten down on that this time around. You can always use the code HALF_OFF to bring the price from $60 to $30: https://www.udemy.com/automate/?couponCode=HALF_OFF )

submitted by /u/AlSweigart to /r/Python
[link] [comments]

Posted on 28 December 2015

How do you use Python in your job?

I'm going to be running through the 'Learn Python the hard way' course but I'm trying to make the leap from "I want to learn Python programming" to "I can use Python to do x in my job".

I work with Linux a lot, mostly basic Sysadmin stuff and even this is just using polished knowledge I already had. It's mostly reading logs files, working with API, restarting services and whatnot. How would someone who does this kind of thing apply Python to their day to day job? Even as far as using VMware exclusively?

I know I can use Python but how and why is the part I'm struggling with.

submitted by /u/MoifMurphy to /r/Python
[link] [comments]

Posted on 7 December 2015

Everyone who encounters it seems to love Python. Everyone seems to bitch about languages like Java and C++. Why isn't Python more widely used in Enterprise and will it ever be?

I was reading this thread on /r/Programming about how Oracle has lost interest in Java. One of the comments says

Objective-C / Swift live on Apple island, C# lives on Microsoft island. That leaves going back to C++ or surrender oneself to the Python version schizophrenia (sounds most fun of all other options).

I started learning code with Python and I love it. I write it for fun. Now I'm having to learn Java for college and it sucks. There's so much more code to write to do simple things and you can make so many silly little syntax mistakes so easily that it makes it harder to actuallly write functioning code. A lot of people in my class are completely new to programming and they are so lost.

I understand that because of the JVM, Java is super duper portable and a lot of existing code is written in Java. Is that the only reason it continues to be used? Would a startup or a company building something from the ground up completly avoid Java? Is Java the only language we can use for Android dev?

C++ seems to be universally hated on with C# being the best alternative but leaving you tied to a MS plaform.

Then behind all of this there's Python. Python is a dream to read and write. Has a bunch of amazing libraries to do all kinds of cool shit. There's tools like Flask, Django, Kivy and others that allow you to use Python for WebDev and Mobile Dev.

Even if you look at this sub there are 111,085 readers. /r/Java has 46,788 readers and /r/cpp and /r/csharp have around 30k readers. If everyone loves Python so much why is it not being used more? What am I missing here?

EDIT: Too many responses to reply to but thanks everyone for your input. Some good points were made about how I'm srill very new to this and will see the benefit of Java's constraints when working with other devs. Also the fact that Python just cant compete for speed in some situations.

It seems to me that Python is an excellent tool to have on your utilitiy belt. Great for automating things and supplementing other tools (As well as being perfectly capable, most of the time, of building full size projects). However those other languages might not be that scary and have their own advantages over Python.

In my opinion though Python is an amazing educational tool. I think it could reasonable be introduced in Primary education without too much hassle while I wouldn;t say the same about Java.

submitted by /u/looneymicheal to /r/Python
[link] [comments]

Posted on 30 September 2015

I recently released "Intermediate Python", a free and open source Python book. After receiving a LOT of positive feedback and support it is in Beta stage now!

Hi guys! You might already know that I released a free and open source book on Intermediate Python. The name of the book itself is also intermediate Python. After my last post the book received a lot of patches and it is in a whole lot better shape now. It also received a LOT of positive response from the community. It remained on the front page of Hacker News and /r/Python. It is currently a trending project on GitHub under the Python tab. I am happy to say that it has entered beta stage now. This is the best time to take a look if you haven't already.

Moreover, if you want to add anything to the book or just want to polish it further then you are more than welcome to submit a Pull request on GitHub.

I just wanted to write a quick note that a lot of people asked me last time whether I accept donations. I wasn't accepting donations untill recently. I have uploaded the latest build of the book on Gumroad so if you feel like tipping me then you can buy the donation version of the book from Gumroad. It would mean a lot to me and would help me to continue writing free quality content.

Links:

submitted by /u/yasoob_python to /r/Python
[link] [comments]

Posted on 23 August 2015

I just released alpha version of "Intermediate Python", my first and free E-Book.

Hi guys! After a lot of hard-work and sheer determination I have mostly completed my book, "Intermediate Python". It will receive updates over time :)

It has a couple of issues related to grammar and technical info in it. I am working on ironing them out one by one.

I was a bit lazy so didn't upload it earlier but here it is now.

I have decided to distribute it for free! I wanted to give back to this awesome community so this is what I have to offer for now. I am sure that it would help those who really want to be helped. Best of luck!

Here are the links:

If you like this book then a simple tweet and a personal email <yasoob DOT khld AT gmail DOT com> would mean a lot to me!

P.S: The book is open-source so if you find typo or technical error or just want to expand it's contents with your own knowledge then just send over a pull request :) Moreover, if you want to give me any tip then kindly pm me your email and I would let you know once I setup a tip-collection system.

Note: This is not related with that paid "intermediate Python" book in any way. I became aware of it today. I had been using this name internally for a couple of months. If the author of paid "Intermediate Python" has any issue with this I would be more than happy to change the name of my book because he definitely beated me to the finish line. :)


Edit:

Hey guys! All those of you who are going to use this book can really help me and motivate me by letting me know how this book supplements your day to day learning and if you are a Teacher, Assistant Professor or something of that sort then kindly let me know if you would be willing to offer this book to your students or not. :)

You already have my email address or if you want to tweet about it then you can do so at @yasoobkhalid.

Moreover, I really can't thank this community enough. This community has helped me a LOT over the years. If you see my Reddit profile then you can easily guess that this is the only community (/r/python) where I spend most of my time.


Edit:

You guys can donate me if you want to by buying the donation version of Intermediate Python from @gumroad :)

It is only for $10 but if you want to pay less then kindly let me know (pm) and I can give you a custom link.

Cheers!

submitted by /u/yasoob_python to /r/Python
[link] [comments]

Posted on 17 August 2015

Experienced Python Users: what's the most recent new thing you learned about the language?

I ask this because I just learned something new that I feel like I should have known for a long time... if you define a class with a __len__() and a __getitem__() method, it automatically becomes iterable! e.g.

class Foo(object): def __len__(self): return 10 def __getitem__(self, i): if i > len(self): raise IndexError return i for i in Foo(): print(i) 

What's the most recent new Python feature you have learned?

submitted by /u/jakevdp to /r/Python
[link] [comments]

Posted on 17 April 2015

When do you *NOT* use python?

Hi everyone,

We're all python fans here, and to be fair I may use it a bit more than I should. I'd like to hear other people's thoughts on which tasks they want to solve in a non-python language and which one they'd choose for that job.

Thanks in advance...

submitted by /u/RealityShowAddict to /r/Python
[link] [comments]

Posted on 16 February 2015

python.org should stop steering web visitors away from v3 docs

$ curl --head https://docs.python.org/library/string.html HTTP/1.1 301 Moved Permanently Date: Fri, 06 Feb 2015 23:22:21 GMT Server: nginx Content-Type: text/html Location: https://docs.python.org/2/library/string.html 

This is another contributing factor to why v3 adoption is slow, and new users are confused. This configuration affects everything from StackOverflow links (how I first noticed it) to Google pagerank.

It's why Python3 docs don't often show up in search results.

docs.python.org should default to v3. Or, at the very least, display a disambiguation page, a la Wikipedia.

submitted by /u/caninestrychnine to /r/Python
[link] [comments]

Posted on 6 February 2015

What do you *not* like using Python for?

Maybe sounds like a silly question, but here's the context: Been programming for ~10 years, professionally for the past 7. Matlab, C#, C++ (in decreasing order of proficiency). Per management, it looks like I'll now be getting into some Python for an upcoming project... which is cool, as with how prevalent Python seems to be, I've wanted to get my feet wet for a while.

Obviously all languages have their bounds... or at least things they do better than others. So - as I'm getting my feet wet here, does anything stand out as far as areas where Python is weak and there may be better alternatives?

submitted by /u/therealjerseytom to /r/Python
[link] [comments]

Posted on 18 October 2014

What are the top 10 built-in Python modules that a new Python programmer needs to know in detail?

I'm fairly new to Python but not to Programming. With the programming languages that I've learned in the past I always see a recurring pattern — some libraries (modules) are more often used than others.

It's like the Pareto Principle (80/20 rule), which states that 80 of the outputs (or source code) will come from 20 of the inputs (language constructs/libraries).

That being said, I would like to ask the skilled Python veterans here on what they think are the top 10 most used built-in modules in a typical Python program, which a beginner Python programmer like me would benefit to know in detail?

EDIT:

Thanks to all that have replied :)

I found a site where I can study most of the modules that you suggested:

(Python Module of the Week)

Contents: http://pymotw.com/2/contents.html

Index: http://pymotw.com/2/py-modindex.html

Of course, there is no substitute for the official documentation when it comes to detailed information:

Python 2.7.*: https://docs.python.org/2/library/index.html

Python 3.4.*: https://docs.python.org/3.4/library/index.html

submitted by /u/ribbon_tornado to /r/Python
[link] [comments]

Posted on 24 June 2014

Python

Русскоязычная группа посвященная языку Python.

Posted on 18 May 2014

Learning python earned me a 50% raise, and it's about to again.

(Sorry for the throwaway, but I wanted to be able to answer questions honestly without any hesitation.)

I've been in IT since I was 17 in 1999. I started off at a help desk, and worked my way up to a Systems Administrator where I was making 60k USD/yr. (I currently have only an associates degree with no plans to go back to school.) I was primarily a Windows domain/ network admin, with a few *nix boxes spread throughout. I had known windows batch scripting, and way back in the day had programmed in BASIC before the world was.

I had tossed around the idea of learning a programming language before, but when asked I'd often say "Developers' brains just work differently than mine. I'm not a coder." Programming seemed so abstract and I couldn't really wrap my head around it. I finally decided though, to try something.

It was 2010 and I had heard a lot of Ruby on Rails and thought that Ruby would be a great language to learn. I ran through the tutorial of making a polls app at least 5 times, but I just couldn't wrap my head around it. So I gave up.

One year later I heard about python. Despite all the negative talk about python while googling for "python vs ruby vs php vs ..." (GIL, speed, whitespace, duck typing, (not that I knew what ANY of that meant anyway)) I decided that I really wanted to give it a shot. I started out with codeacademy to get my feet wet, I'd tinker with idle while my wife and I would watch netflix after the kids went to bed. Then I started dreaming in code.

Have you ever had "work dreams"? The kind you have for about 2 weeks after starting a new job that's really hard? That was python for me. Being primarily in a Windows environment it was hard to find anything for python to do initially at work. My boss didn't program, and really didn't see the value in it. Then one day I found myself needing to compare a list of files. I needed to find all the files that were in one column but not in the other. I had them in excel and after working through a formula I had my answer, but I hated it. All I wanted to do was write something like--

select name from column1 where name not in (select name from column2); 

Enter python and sqlite. It probably took me about 3 hours to figure it out, but I imported a csv into a sqlite table in python so I could query it. BAM! I was hooked from then on.

Every night I would tinker, read, and play. I found tons of things to automate at work, making my time so much more effective. I loved it. I became a python evangelist. I'd like to say that my boss was impressed, but really he never came around, and it frustrated me. Fast forward a year.

I had heard about the DevOps movement and though I didn't understand it completely at the time I thought that being a Developer and Systems Admin mutant sounded like a lot of fun, and something I could really be good at.

After having a rough time with my boss one day I decided to check the local classifieds. I saw an ad for a DevOps Admin. Basically this guy needed to know hardware, networking, provisioning, something called puppet, and one of three scripting languages- ruby, bash, or python.

I looked at puppet, and after having learned about booleans and strings and syntax from python, picking it up wasn't a problem. I got hired on the spot for $90k USD. A clean 50% raise. I use python every single day. I write scripts to check if databases back up properly, if services are up, if all 1000 of my physical servers are getting their updates, to provision RAIDs, you name it. I integrate what I write into puppet, fabric, and a host of other tools that I've learned along the way.

After doing that for a little over a year now, I'm about to hire 2 guys under me as we expand and I'm moving up to $120k USD. I'm learning django for fun and am just starting into machine learning. I check out /r/python every day, you guys have been so helpful to me along my way. And if I can learn python, anybody can!!!

TL;DR I learned python in a year and got a 50% raise. 1 year later I got another 25% raise, all from python!

edit: percentages, oh math...

submitted by /u/self_made_sysad to /r/Python
[link] [comments]

Posted on 6 May 2014

What is the best part of python you wish people knew about?

I just quit my job at a major software company to be with a startup in downtown seattle and it looks like our stack is Python based. I'm new to Python but I want to learn fast; So please, let me what you like the most (or hate the most?) about python, other python developers code, etc so I can take all the good and not use the bad as I learn this new language.

Who knows, maybe you will need to maintain my code someday, so you could only be helping yourself!

Thanks in advance!

submitted by /u/honestduane to /r/Python
[link] [comments]

Posted on 16 December 2013

Eric Idle here. I've brought John Cleese, Terry Gilliam, Terry Jones and Michael Palin with me. We are Monty Python. AUA.

Hello everybody. I had so much fun last November doing my previous reddit AMA that I decided to return. I'm sure you've seen the exciting news, but here we are to confirm it, officially: Monty Python is reunited. Today is the big day and as you can imagine it's a bit of a circus round here, but we'll be on reddit from 9am for ninety minutes or so to take your questions. We'll be alternating who's answering, but everyone will be here!:

  • J0hnCleese
  • Terry_Gilliam
  • TerryJonesHere
  • _MichaelPalin

Proof: https://twitter.com/EricIdle/status/403525056740851714

Update: We're running a little late but will be with you 10-15 minutes!

Update 2: The url for tickets - http://www.montypythonlive.com - available Monday

Update 3: Thank you for all the questions. We tried to answer as many as we could. Thanks everyone!

submitted by /u/ericidle to /r/IAmA
[link] [comments]

Posted on 21 November 2013

What you do not like in Python?

I'm a big fun of Python! I use it every day! But there are things which are annoying, strange and so forth in Python (you really don't like it). If any, please, share your thoughts. For example:

  • built-in set type has method like symmetric_difference_update. I don't like so long methods in built-in types.
submitted by /u/krasoffski to /r/Python
[link] [comments]

Posted on 18 September 2013

Python interview questions

I'm about to go to my first Python interview and I'm compiling a list of all possible interview questions. Based on resources that I've found here, here and here I noted down the following common questions, what else should I add?

easy/intermediate

  • What are Python decorators and how would you use them?
  • How would you setup many projects where each one uses different versions of Python and third party libraries?
  • What is PEP8 and do you follow its guidelines when you're coding?
  • How are arguments passed – by reference of by value? (easy, but not that easy, I'm not sure if I can answer this clearly)
  • Do you know what list and dict comprehensions are? Can you give an example?
  • Show me three different ways of fetching every third item in the list
  • Do you know what is the difference between lists and tuples? Can you give me an example for their usage?
  • Do you know the difference between range and xrange?
  • Tell me a few differences between Python 2.x and 3.x?
  • The with statement and its usage.
  • How to avoid cyclical imports without having to resort to imports in functions?
  • what's wrong with import all?
  • Why is the GIL important? (This actually puzzles me, don't know the answer)
  • What are "special" methods (<foo>), how they work, etc
  • can you manipulate functions as first-class objects?
  • the difference between "class Foo" and "class Foo(object)"

tricky, smart ones

  • how to read a 8GB file in python?
  • what don't you like about Python?
  • can you convert ascii characters to an integer without using built in methods like string.atoi or int()? curious one

subjective ones

  • do you use tabs or spaces, which ones are better?

Ok, so should I add something else or is the list comprehensive?

submitted by /u/dante9999 to /r/Python
[link] [comments]

Posted on 19 August 2013

What is Python not a good language for?

I am moving from writing one-off code and scripts to developing tools which are going to be used by a larger group. I am having trouble deciding if Python is the right tool for the jobs.

For example I am responsible for process a 1gb text file into some numerical results. Python was the obvious choice for reading the text file but I am wondering if Python is fast enough for production code.

Edit: Thanks for the all responses. I will continue to learn and develop in Python.

submitted by /u/Hopemonster to /r/Python
[link] [comments]

Posted on 6 May 2013

Are there any things about Python that you do *not* like, or that you wish were done differently, or that you flat out think are wrong?

I lightheartedly joked in another thread that if the person had agreed with my point (that Python 3 seems very slightly harder to code in than Python 2.x - also a lighthearted, almost completely unfounded critique), that it would be the first time I'd ever seen any Python user online agree with any criticism of any part of the language. In this last bit I'm not really joking.

I had many newbie critiques a few years ago - 'self', the fact that you can't join a string list with myList.join(', '), something about slicing that I forget now, that it was confusing which things worked in-place, and which worked on a copy, etc. - and in a forum (not reddit) where I posted up my lengthy list (mostly to see what people thought of these things), I was met with a wall of responses, all strongly in favor of every last part of all of it, and even of things I hadn't mentioned. In 3 years I realize now I have never once seen anyone critique any part of the language and not be met with all manner of deep, philosophical justifications as to why that thing or those things must be that way.

It's the perfect language, I guess.

So my new question is just straight up: IS there anything about Python you don't like? I mean, it is moving to 3, and there are changes, so clearly 2.x had room for improvement, so let's hear it. Be prepared for a battle on all fronts from everyone else in here, though, whatever you say :) I'd love to hear from the real experts, the people who usually wield seemingly powerful reasoning and long strings of computer science words in their arguments.

This itself isn't a critique, nor even a jab, but just another attempt to learn more.

submitted by /u/gfixler to /r/Python
[link] [comments]

Posted on 16 November 2011

Python Education

Subreddit for posting content, questions, and asking for general advice about learning the Python programming language.

Posted on 2 October 2009

Python

news about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python

Posted on 24 January 2008