Python Forum
Try Python without dots!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Try Python without dots!
#1
I uploaded a single-file module adddot.py here https://sourceforge.net/projects/adddot/. With it you can code in Python with optional dot operator. For example you would write
# coding: adddot

import xml dom minidom
result = xml dom minidom parse('spam.xml')
To install the file (manually), follow the docstring
""""Module adddot: an encoding to add missing dot operators in python

Usage:
    * put this file adddot.py on the Python path
    * in usercustomize.py add the lines
        import adddot
        adddot.register()
    * in utf8-encoded python programs, use the encoding line
            coding: adddot
    * Enjoy! you can now omit the dot operator in Python files
    
Requires:
    * module 'untokenize' from Pypi (install with pip)
    
Disclaimer:
    As of version 2021.05.24, this has been tested with very very
    few python (3.8) files.
"""
Thanks for comments and feedback!
Reply
#2
Uploaded a small bugfix. Tell me if you encounter any problem with this. You are my first users panel!
Reply
#3
I don't like it. Not sure if that's because I'm so used to using the dots, or because I'm used to dots syntax for C structures, but it makes me feel uncomfortable.
Reply
#4
I think it is a matter of habit. To me Python without dots is much more fluid and comfortable than ordinary Python. If you want to access the size of the wheel of the car, you simply write car wheel size. It cannot be simpler!

Let me remark that if you write a file without dots, you can use adddot.py to rewrite the file with the dots automatically, so you can safely program this way.
Reply
#5
Quote:Let me remark that if you write a file without dots, you can use adddot.py to rewrite the file with the dots automatically, so you can safely program this way.
If you never used it in the first place, you would never have to worry about this.

I think cwsize = len(car wheel size) looks awful.
Whereas cwsize = len(car.wheel.size) immediately indicates that size is an element of wheel which is an element of car,
so car.wheel.size should be able to be used without further processing.

Again this is just me, and my habits go back to when I started coding 54 years ago.
Reply
#6
I don't see why you would need further processing, you can just write
cwsize = car wheel size
and it works.

Larz60+ Wrote:If you never used it in the first place, you would never have to worry about this.
I agree with that but it's always like that when you start doing something new that nobody else does. It is not a sufficient argument to me.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to make complex shapes using swarm of dots......like chair,rocket and many more wisewizer 1 1,841 Apr-18-2019, 04:19 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020