How do I properly start creating a programming language in python? [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I've been thinking to make a programming language written in python but I have no idea where to start, and I really don't know the steps creating it.

You would probably start by first planning out your language. That should take a lot of time. Then in Python... you would write a parser that can understand the syntax of your language, and an interpreter that can take the results of the parser and perform the actions of the program.
Your language that is written in Python with Python in-turn being written in C is practically guaranteed to be very slow and will not succeed, but this could be a really fun thing to do as a learning or education experience.

You will likely want to look at Abstract Syntax Trees. This is the underlying structure that python is built on. Take a look here at the documentation: https://docs.python.org/2/library/ast.html
Using ASTs you can at least define the syntax of your language. You will still need to solve the problem of how to interpret it on a platform to get your code to execute.

Related

Python docx documenation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am looking for resources that help me interpret python documentation effectivley. In particular, I am reading through the pythondocx module documentation, but am finding it hard to understand some sections.
As an example, when I read the Style Objects Section
, I am confused by lines such as class docx.styles.styles.Styles and what it is actually saying.
Any ideas on what I can do the to interpret documentation better?
I honestly think reading pythondocx module documentation is a bit of overkill.
The hard part of reading python documentation is understanding the specific logic of how objects and builtin's are organized in python. The best place to start, IMHO, is the index Python 3.8.1 documentation together with standard library and collections.
Even if you had studied other common languages before, like Java and C#, their API's are laid out in a different style. Each takes its own time for the reader to get used to. The python docs were written to be self-explanatory and after an initial learning curve that isn't especially steep the docs start making lots of sense.

User-Defined Functions and Learning to Think Like a Computer Scientist with Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am brand new to coding / programming and am starting with the foundations of Python. I've used a few different resources (Codecademy, Automate the Boring Stuff, and most recently, How to Think Like a Computer Scientist by Using Python).
So far my education has been good, albeit a bit slow to start (not used to thinking in computer terms quite yet!). But I've run into a problem with one of the lessons that I cannot replicate in my IDE. Please see the code below:
def printTwice(bruce):
print('bruce')
print('bruce')
The lesson states the output should be 'Bruce, Bruce' which makes sense logically. However, when I go to run the code I get the following:
===RESTART: /Users/owner/Documents/bruce.py======
So essentially just another line to start a new code from. I am writing this code in a new file and just cannot figure out what I'm doing wrong.
Any help is appreciated.
Thanks!
Add printTwice('bruce') on a new line after the function, with no indentation like so:
def printTwice(bruce):
print('bruce')
print('bruce')
printTwice('bruce')
This line will call your printTwice function, passing the value 'bruce' to the variable bruce, which is not used.

Should I learn C++ before I advance too much further in Python? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
First, to give you a slight bit of background on me:
Perl is technically the first language I was introduced to, but I quickly migrated to Python when I found how clean and easy it is to write. I've now been working in Python for about 8 months, and I feel that I'm reaching an 'intermediate' stage. I have the language syntax, data-structures, and memory usage principles pretty much down, and now I'm starting to get into things such as algorithmic design and some of the slightly deeper topics like function closures.
I'm teaching myself C++ on the side, and I'll be honest, it feels tedious and extremely obtuse to me. It might be how new I am too it still, but I have to force myself to practice C++ whereas I can barely get enough coding in Python. I've heard people say it's good to learn to give you a baseline knowledge about computers and memory management, so my question is if I should "catch-up" in C++ to where I'm at in Python before continuing? I think the convenience of Python is making it hard to learn C++ as a second language.
I feel you should try to fully master one language before advancing to another. If you juggle too many at the same time you will just mix up their syntax and spend a lot of time becoming a jack of all trade and a master of non.

Is there a limit to how large a function can be? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
New programmer here!
I'm creating my first script on my own, and I have a particular function that is quite large, as in 50 lines.
I understand that theoretically a function can be as large as you need it to be, but etiquette-wise, where is a good place to stay under?
I'm using Python 2.something if that makes a difference.
A good rule of thumb (and it's more a guideline of thumb really) is that you should be able to view the entire function on one screen.
That makes it a lot easier to see the control flow without having to scroll all over the place in whatever editor you're using.
If you can't understand fully what a function does at first glance, it's probably a good idea to refactor chunks of code so that the more detailed steps are placed in their own, well-named, separate function and just called from this one.
However, it's not a hard-and-fast rule, you'll adapt your approach depending on your level of expertise and how complex the code actually is.

what language do I need to write macros in LIbre Office Calc? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've written a bunch of VBA code for various things in Excel. I'm looking at migrating to libreOffice. Under Tool->Macros->Organize Macros: the two choices are LibreOffice Basic and Python.
Should I learn one of those, both, or something else. Am I wasting my time altogether? Any suggestions appreciated.
Python is the way to go.
Start here: http://wiki.python.org/moin/BeginnersGuide
And no, you're not wasting time.
You'll look back and say, why didn't I do it sooner.
Python's a great skill to learn - I use it for everything. It's the glue language for virtually every tool out there (you can even use it with .Net).
Documentation for Python + LibreOffice is however a bit sketchy currently, although I don't have much experience with Calc.
There is some work-in-progress documentation at http://documenthacker.wordpress.com (or soon www.documenthacker.com). It has examples for working with Writer, rather than Calc, but you might still find it useful.

Categories