2

I've written about a 40-50 line block in Python for a very specific task: scrubbing Japanese addresses based on certain criteria. Most of my SO questions are short but this one would be notably longer.

I have specific criteria for the addresses, such as replacing "丁目" with a dash unless it appears at the end of the address, then make it blank (there are about 15-20 conditions). My script works but I know it could be improved so I wanted to ask SO users but I thought my code might be too long.

  • Is 40-50 lines of code too long? If not,
  • Can I ask a question for something that has very specific environmental parameters? (Mostly reading addresses in Japanese).

Thank you.

1
  • 4
    If you code is working and you seek improvement and optimization consider asking your question on CodeReview. Make sure your question is on topic there by getting yourself familiar with the CR Help Centre page
    – user2140173
    Commented Aug 19, 2014 at 9:40

2 Answers 2

10

Questions should contain all the code needed to reproduce the problem. Fiddle links, while useful as a back up and to show the code in context, can be useless if the link goes dark or the fiddle site is down - which happens far too often.

If you're posting lots of code then you should be looking at reducing it down to the barest minimum. People don't want to have to wade through pages of code to find your problem - that's your job.

However, you state:

My script works but I know it could be improved so I wanted to ask SO users but I thought my code might be too long.

In that case you should ask your question on CodeReview

2
  • Thanks for an insightful comment, I'll try to post it on CodeReview. What are Fiddle links? (Sorry, I'm new to this)
    – Tensigh
    Commented Aug 19, 2014 at 9:20
  • @Tensigh - Fiddle links refers to one of many online services that allow you to upload code and show people it working (or not) online without them having to download and run the code locally.
    – ChrisF Mod
    Commented Aug 19, 2014 at 9:26
0

Yes, you are allowed. 40-50 lines of code is not a big deal in Stack Overflow. However it would be more helpful if you provide a working Python Fiddle with your code in it and then point out/add the exact code block(your struggle part) in your question.

In case if you want to improve your code, I would suggest you to take your question to Code Review Community.

4
  • 5
    The question should contain all the code needed to reproduce the problem. Fiddle links are annoying at best and useless when the link goes dark - as is often the case.
    – ChrisF Mod
    Commented Aug 19, 2014 at 8:56
  • @ChrisF Fiddle helps to reproduce the exact problem easily, thereby we don't need to do it locally. However I agree with your point on chances of links getting dark.
    – Praveen
    Commented Aug 19, 2014 at 9:05
  • Thanks, gnat. I'm new to this - is PythonFiddle like a repository for sharing code? I'm a little lost - should I post the code there or on SO?
    – Tensigh
    Commented Aug 19, 2014 at 9:21
  • @Tensigh yes it is like a repo for sharing code. As ChrisF suggested, you have to paste to whole code in your question in SO.
    – Praveen
    Commented Aug 19, 2014 at 10:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .