Live data from Hacker News

Reworder – A tale of learning Python and launching an app in five days.

sahillavingia.com

21–30 of 37 posts

Re: Reworder – A tale of learning Python and launching an app in five days.

#21
post #10

Earlier quoted context omitted.

Ah yes, I randomly generate a permalink on load of the page, so it uses the old permalink, hence why it loads the first submission. Any ideas on how to change this?

I guess just generate the permalink in the action and redirect to that instead of having it in the form itself. Something like: Form: /reworder/generate Action: Generates text, creates permalink and then redirects user to that permalink. In the web world this pattern is common, called redirect-after-post. I'm not sure if thats much help, I've only used python in the context of the Pylons framework (and have only a fe…

Of course not, I love criticisms. How else do I improve? I'll implement that ASAP.

Re: Reworder – A tale of learning Python and launching an app in five days.

#24
post #11

"App engine is fast and awesome, right now. However, if your site gets really popular, you may consider moving off of it." Perhaps you can explain why you believe this to be true? I thought that the strength of App Engine is that you can stay on it no matter how popular your app gets.

App engine doesn't allow certain features, like subdomains for each user, and non-www. URLs. Some other things too, that I probably don't even know about yet.

While I agree that there are limitations with App Engine, I disagree with your two examples; not only are these possible, I think they have a nice solution on App Engine.

1. Wildcard subdomains and multi-tenancy seem to be a nice solution to "subdomains for each user".

2. Unless by "non-www. URLs" you mean naked domains, that is also possible; both explicitly defined and with wildcard subdomains.

Maybe I'm misinterpreting you though.

Re: Reworder – A tale of learning Python and launching an app in five days.

#25
post #2

make sure you use tabs to format all of your Python code I disagree. Idiomatic Python uses 4 spaces per indent. Either solely use tabs or solely use spaces, they don’t work well together, at least in my experience Mixing tabs and spaces is indeed very unwise. You can run Python with the -tt option to make sure you're consistent. Read Style Guide for Python Code for more advice on this front I agree ;-) The author pro…

Could not agree more!!!! If you're a vimmy, be sure to add this friendly helper into your .vimrc :set tabstop=4 :set shiftwidth=4 :set expandtab

Or, if you only want to use these settings for python files, create a ~/.vim/ftplugin/python.vim file. Mine looks like this:

  setlocal tabstop=4
  setlocal softtabstop=4
  setlocal shiftwidth=4
  setlocal textwidth=80
  setlocal smarttab
  setlocal expandtab
  setlocal smartindent

Re: Reworder – A tale of learning Python and launching an app in five days.

#28

He said he wanted to learn a functional language, and then listed Python and Ruby. Weird.

There's a joke here I don't get. Care to explain? :D

Python and Ruby aren't functional languages.

You can write code in them in a functional manner, but for anything more than toy programs you _likely_ wouldn't.

They're heavily Object-Oriented, but could probably safely be called multi-paradigm. Not just "functional", though.

Functional languages are Haskell, ML, others, where you express computation by composing functions (in the mathematical sense). You make lots of copies and you don't modify state directly like procedural and OO languages do where you modify state a lot.

Re: Reworder – A tale of learning Python and launching an app in five days.

#29

Earlier quoted context omitted.

There's a joke here I don't get. Care to explain? :D

Python and Ruby aren't functional languages. You can write code in them in a functional manner, but for anything more than toy programs you _likely_ wouldn't. They're heavily Object-Oriented, but could probably safely be called multi-paradigm. Not just "functional", though. Functional languages are Haskell, ML, others, where you express computation by composing functions (in the mathematical sense). You make lots of…

I remember it took me a dozen times of carefully reading explanations like this before I finally got what "functional" meant... I'll try to provide an explanation my former self would have easily got.

  lambda x: x+1 
If you only program with lambda's like these, your program is functional.

  def dosomething(x):
      y = x + 3 # y is a global variable
      return x + 1
As soon as you have a function like this, your program is no longer 100% functional.

The dosomething function modified `state` when it changed a global variable. Another function that modifies state is "print()". Generally any function that returns nothing is almost certainly going to modify state outside of it. (Otherwise what is the function for?)

State is memory that is not `local` to the function itself.

  def dosomething(x):
      y = x + 3 # y is a local variable
      return x + 1
The dosomething function here is functional, because the only `state` it modified was local to the function.

There you have it.

Re: Reworder – A tale of learning Python and launching an app in five days.

#30

He said he wanted to learn a functional language, and then listed Python and Ruby. Weird.

It's an easy mistake to make - when you come from a Java or C# background one of the most striking things about Python and Ruby code is the use of first-class functions.

Not everybody knows that there's more to a functional language than first-class functions.

Post reply on HN