Not being aware of the contents of the data in python

Abstract I will write what I felt about being unaware of the contents in Python, C, and C ++.

Not being aware of the type

For C and C ++ int a=8; How often do you declare variables? In this case, it is an integer type, so I think I will write it while thinking that "a number can be entered". On the other hand, with Python a=8 That's ok. "For the time being, create a variable to put numbers in." It's very easy, isn't it?

merit

Consider displaying a value with a simple example. If C printf("%d",a);

-output- 8 It will come out. "I have to be aware that some numbers will come out ..."

To you!

Good news!

With python print(a) -output- 8 Is coming out. It's convenient for debugging for the time being.

In C ++

std::cout<<a;


 -output-
```8```
 is.
 It may be the trend of the times that you don't have to be aware of the type.

## Demerit
 It's okay when something goes wrong, but when displaying in octal (I'm talking about such a scene?)
 In python
~~a=0o8~~
 -Additional part-
 Excuse me. It's an octal number, so it's 10.
 @shiracamus Thank you for pointing out.
 -So far-

```py
a = 0o10
print('%o' % a)

Must be written.

In C ~~printf("%x",a);~~ -Additional part- Excuse me. It was a hexadecimal number. @shiracamus Thank you for pointing out. -So far-

int a = 010;
printf("%o", a);

In C ++

int a = 010;
std::cout << std::oct <<  a;

It is ok if you write.

~~ Like this ~~ -Additional part- The example was not good, so I will cancel it. -So far- When the python in advance or to write any program policy is not determined exactly I got the impression that it was quite difficult to rewrite. On the other hand, I think it's easy to write when the policy is decided.

Conclusion

There are advantages and disadvantages to not being aware of the contents of the data. The merit is that the system does it without being aware of troublesome number conversion. The disadvantage is that you don't know what the contents are because you are not aware of it. I wonder if there are advantages and disadvantages.

Python is convenient if the policy is decided, but it may be difficult to write if there is a specification change.

It may be easier to understand if you cover it with variable naming.

"If you devise this way, the contents will be easy to understand from the variable name." If you have any questions such as "Isn't the writing style bad in the first place?", Please comment.

Recommended Posts

Not being aware of the contents of the data in python
The story of reading HSPICE data in Python
Let's use the open data of "Mamebus" in Python
Try scraping the data of COVID-19 in Tokyo with Python
[Homology] Count the number of holes in data with Python
[Data science memorandum] Confirmation of the contents of DataFrame type [python]
Check the behavior of destructor in Python
Output the contents of ~ .xlsx in the folder to HTML with Python
The result of installing python in Anaconda
The basics of running NoxPlayer in Python
In search of the fastest FizzBuzz in Python
Get the key for the second layer migration of JSON data in python
Get the contents of git diff from python
Output the number of CPU cores in Python
[Python] Sort the list of pathlib.Path in natural sort
The contents of the Python tutorial (Chapter 5) are itemized.
The contents of the Python tutorial (Chapter 4) are itemized.
The contents of the Python tutorial (Chapter 2) are itemized.
Get the caller of a function in Python
Match the distribution of each group in Python
View the result of geometry processing in Python
The contents of the Python tutorial (Chapter 8) are itemized.
The contents of the Python tutorial (Chapter 1) are itemized.
Make a copy of the list in Python
Real-time visualization of thermography AMG8833 data in Python
Find the divisor of the value entered in python
Find the solution of the nth-order equation in python
[Note] About the role of underscore "_" in Python
About the behavior of Model.get_or_create () of peewee in Python
Solving the equation of motion in Python (odeint)
Output in the form of a python array
The contents of the Python tutorial (Chapter 6) are itemized.
The contents of the Python tutorial (Chapter 3) are itemized.
A well-prepared record of data analysis in Python
the zen of Python
Let's automatically display the lyrics of the song being played on iTunes in Python
Experience the good calculation efficiency of vectorization in Python
Summary of tools needed to analyze data in Python
Full-width and half-width processing of CSV data in Python
Template of python script to read the contents of the file
How to get the number of digits in Python
Power BI visualization of Salesforce data entirely in Python
About the inefficiency of data transfer in luigi on-memory
Learn the design pattern "Chain of Responsibility" in Python
Implement the solution of Riccati algebraic equations in Python
List of Python code used in big data analysis
Reproduce the execution example of Chapter 4 of Hajipata in Python
Implemented the algorithm of "Algorithm Picture Book" in Python3 (Heapsort)
[Python] Outputs all combinations of elements in the list
[Maya Python] Crush the contents of the script 2 ~ list Notes
Understand the status of data loss --Python vs. R
Get the URL of the HTTP redirect destination in Python
A reminder about the implementation of recommendations in Python
Reproduce the execution example of Chapter 5 of Hajipata in Python
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
Extract the band information of raster data with python
Check the asymptotic nature of the probability distribution in Python
What to do if the progress bar is not displayed in tqdm of python
Handle Ambient data in Python
Towards the retirement of Python2
Download the file in Python