How great is Python? Can you give me some tricks?

Python is pretty great. It starts off easy, as does any language, with the hello world program.

>>> print("Hello, world!")
Hello, world!

Then, you dive deeper. You learn about the data structures built into Python, lists, strings, integers, floats, dictionaries (Python's cute name for maps), tuples, etc. You discover some tricks, like the fact that strings and lists are really similar in some ways - you can slice strings, for example:

>>> x = 'i want to select this'
>>> x[:6] + x[-5:]
'i want this'

Oh yeah, Python also supports negative indexing for strings and lists. But you can't assign a certain index in a string like you can a list!

Then, you come across a string like ‘1122334455', and you only want ‘12345'. Lucky for you, Python slicing also allows you to skip stuff too!

>>> x = '1122334455'
>>> x[::2]
'12345'

What if you had a list of numbers and you only wanted the even ones? Use a list comprehension:

>>> x = [1,2,3,4,5,6,7,8]
>>> [i for i in x if i%2==0]
[2,4,6,8]

And then there's set comprehensions and dictionary comprehensions. And nested comprehensions, which can get confusing fast.

You learn about generators, a memory efficient function that calculates results lazily.

def up_to_million():
	i = 0
	while i < 1000000:
		yield i
		i += 1

Each time you call next on this generator, it will return the next number. But you don't have to store a million numbers in memory anywhere - it stores only one number at a time.

Then you learn all the libraries out there, including Django, which makes it really really easy to make a web server, or pandas, to do some tough number crunching and data analysis, or networkx, to analyze graphs and connections, or scikit-learn, for machine learning, or pygame, to make a game, and using this myriad of libraries, you can create anything you really want to with Python.

And then, someone says "well, Python is great, but it's slow, and you have the GIL." But you're a Python expert. Python is slow (so it's not used for low-latency systems like trading platforms), but really, Python isn't thaaaat slow. As for the GIL, which limits your programs from using all of the processing power of your computer, stunting the utility of threads/threading, you can now use asynchronous programming as of Python3.5 (asyncio).


Is it OK to go to the gym in the morning without breakfast?

Sympler, Your Health Buddy says,The main advantage to exercising on an empty stomach: the potential to burn more fat. Your muscles don't have much sugar to draw from so you are more likely to tap into your stored energy, which means releasing

Why is Victoria's Secret going downhill?

A2AIt is bit of brand strategy problems.What they should have done while in back was split brands into 3–4 and having separate shops.You really can not have it all in one brand shops when some of VS try to sell bras for $200, and yet right next to it there are bargain bin bras for $20–30.It is silly, you