• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

New py_tools repo

Leitz

SOC-14 1K
Admin Award
Baron
Given the Python popularity in the Poll, I've created a Makhidkarun repo "py_tools" for those small snippets that may not need a full repo of their own. First up are a simple roller that takes an int for number of times to roll 2d6, and a random ship weapon generator that takes an int for number of weapons to generate. The latter produces a sorted list with count.

As always, feel free to copy, clone, and commit improvements.
 
Update the repo. There's now the start of a general NPC generator with name, gender, terms, career, age. Added a Crew generator with intentions of using it for groups like ship crews and mercenary units. Currently just have the mercenary unit working. Check the front page which has the README.md on it.

Both the single and crew generators should work for Python 2 and 3.
 
Added very basic skills to the output.

While there's a lot left to do I'm faced with a decision point; pick one version of Python or move to a different language? Even with this simple code I've already hit two issues between Python 2 and 3 that I had to code around. Not sure if I'll be able to code around new challenges as things get more complex.

While Python 3 is "cool" the machines I work on require Python 2.

Thoughts?
 
Can you do it at home or on another machine?

If you're working on a mac, you could run up Linux or Windows in a VM and build on that.
 
Can you do it at home or on another machine?

If you're working on a mac, you could run up Linux or Windows in a VM and build on that.

I have root on my Linux desktop, I can do anything! However, it's a "want to". Python 3 is nearly another language if I have to do a bunch of testing and figuring out stuff. Not seeing any real reason to support Python 3.
 
I prefer to use Python 2.5 because it is the closest to Python's vision for design. Python 3 has turned into a kitchen sink version of itself. It wants to be popular with all the other programmers out there. The language has changed too much. But I can understand why it's changed. I just don't use Python for those situations. Maybe in the future, I will switch over if there is something I absolutely need that 2.5 has no way of doing.
 
Meanwhile all of your 2.5 code is 100% usable by anyone like me on Python 2.7, so I've got no beef with that.

For me the main reason to stay on 2.x is that I have several projects with significant code bases on 2.x, several of which I'm actively working on. I don't have the time to convert them to 3.x and don't relish the idea of working on new projects in one flavour and current ones in a different flavour.

Simon Hibbs
 
I prefer to use Python 2.5 because it is the closest to Python's vision for design. Python 3 has turned into a kitchen sink version of itself. It wants to be popular with all the other programmers out there. The language has changed too much. But I can understand why it's changed. I just don't use Python for those situations. Maybe in the future, I will switch over if there is something I absolutely need that 2.5 has no way of doing.

Hey Shawn, how do you feel about 2.6 and 2.7?
 
Started breaking things into modules and added some unit testing.

Would appreciate anyone finding issues as I'm sure there are plenty.
 
Meanwhile all of your 2.5 code is 100% usable by anyone like me on Python 2.7, so I've got no beef with that.

If I write all my Print statements as Print functions, my 2.5 main code will run without any editing for 2.7. But then there are the libraries. They all have changed since 2.5. So editing there.

Hey Shawn, how do you feel about 2.6 and 2.7?
They're changed enough to where I still prefer using 2.5. I have 3D modeling apps that have 2.7 and 2.8 built in them, so I'll use those versions from time to time because no choice. If I had an Apple computer, I'd probably use the version its Linux comes with. I don't think Python is pushing down 3.4+ to any systems yet that I know of. Even they realize that there is a lot of change between 3.4 and 3.5. Python has lost control of its Zen.

Started breaking things into modules and added some unit testing.

Would appreciate anyone finding issues as I'm sure there are plenty.
When you tell Character.py to use terms and career, it will use them no matter their values. No biggy though. I haven't looked at your latest update yet.
 
Last edited:
When you tell Character.py to use terms and career, it will use them no matter their values. No biggy though. I haven't looked at your latest update yet.

Yup. I use high terms to test math. I figure people can use anagathics or whatever. The career lets you name it whatever you want as long as you want skills from: "['Blade', 'GunCbt', 'Admin', 'Streetwise']" :coffeesip:

When I was doing this is Ruby I broke each career into a separate mixin. The idea was that folks could come up with their own careers and I tried to make the format easy to replicate. Even had some tests that could be added. :)

Let me know what it needs or what you'd like it to have. I'm going to build a ship crew generator in the near future. The idea is that you give it a ship size and it builds the minimum crew required.
 
What I'd miss in Py 2.5 is mainly context managers (with statement), json support, OrderedDict and argparse. Set and Dictionary comprehensions look cool but I've not got round to using them yet. I think I have used multiprocessing as well but it's been a long time. Actually the bin() function proved very hands when I was working on some binary data last year.

Some of that stuff is actually available in 2.5 using a from __future__ import.

Simon Hibbs
 
I do JSON in 2.5 (I like it way better than XML), and I will import from the future if I really have to use something. I grew up without With, and I prefer using the regular Python method. If I download something with With in it, I'll quickly change it over if I think about it.

I like to write code. The new Python has less for me to code, because everything comes in LIB now as a function. There's a Python function for just about everything now. And I'm not a Functional Programming. Never want to be one. I'm a Procedural Programmer. I like using loops, and iterate things, and count things, and point at things, and sort things. Python 3.4+ can do all that for me, reducing me to just a scripter and not a programmer. Most people call themselves Developers these days.

Maybe one day, I'm go for all the shortcuts that Python offers. But someone else's code is doing all the work for me. It's bad enough, when I think about it, that Python (CPython) is really just code written in C that I'm making calls to. So someone else did all the heavy lighting already for me, so I can just plunk down a .py script to run their code with.
 
Last edited:
I understand your concern about losing control of the code you're using, while loving all the power libraries give you. I'd hate to have to write my own library just to be able to read a JSON file. Something like that really has to be heavily standardised because different programs written by different people all have to work the same way, reliably, for an interchange format like that to be reliable. Still, writing my own bin() function would have been neat, it's just that at the time I was under extreme time pressure. It was for a programming test for a job application* so anything pre-existing that I could use and rely on was a godsend.

One thing that worries me a little bit is that nowadays kids learning to program are several layers of code away from the hardware. Back in the BASIC days even though it was a simple language that tried to make things easy for you, you could still POKE a value to a memory address and see a character appear on the screen, or the colour of all the text on the screen change. You had total control of the machine.

Its not really a bad thing that we lost that. I don't miss the fact that some random program could crash my entire computer at any time, on a daily basis. Still, it was an exciting feeling at the time.

* This was last Autumn. The job was at KCG and I didn't get it. However I just hired a contractor into my team at the job I did get. Turns out this guy worked at KCG and is contracting because the whole London office was just shut down. Just as well I didn't get that job then!

Simon Hibbs
 
...
One thing that worries me a little bit is that nowadays kids learning to program are several layers of code away from the hardware. Back in the BASIC days even though it was a simple language that tried to make things easy for you, you could still POKE a value to a memory address and see a character appear on the screen, or the colour of all the text on the screen change. You had total control of the machine....

As a programmer for 30+ years, and seeing the boot camp graduates who only know that 1 framework and consider themselves developers, I can't agree more. There are probably close to 100,000 javascript frameworks out there just so people don't have to write basic javascript (don't get me started on javascript either!). Same for pretty much everything - everyone uses frameworks and have no idea what it is actually doing.

However, if you DO know how things work, then using libraries and all that can be quite beneficial. No need to recreate the wheel. But you have to live within the limits of those libraries and frameworks. I've been with companies that were really breaking the framework to get things done - it would have been a bit slower to not use the framework but it would not have been such a hindrance later.

As an example, I am writing a UWP (Universal Windows Program) that uses the TravellerMap API. It returns JSON (or XML if you ask). Rather than manually parsing that, I simply generated a class for the data, and using a library convert the list of sectors that come in as a big JSON string into a list of typed data I can deal with. Without the library, it would have taken me a few days to figure do what I wanted versus the 15 minutes I spent generating the class and API handler.

And...get off my lawn!
 
I understand your concern about losing control of the code you're using, while loving all the power libraries give you. I'd hate to have to write my own library just to be able to read a JSON file.
I'm just importing a JSON library. I wouldn't want to write my own either. Just started playing with Pandas for the first time. Something to feed Numpy and Matplotlib for plotting my generated Traveller data that I've been wanting to do videos of.
 
Last edited:
Added a function to pull data from a file into a list and one to give a random item from a list. Need error checking for the file operation.

This will allow users to generate their own lists to be used for various bits. For example, skin tone, species, attitudes, etc. I have some files to populate this with.
 
Added the names.db file and set the scripts to use it. Lots more names possible now.
 
Back
Top