👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I have written the following Python code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, glob
path = "/home/my/path"
for infile in glob.glob( os.path.join(path, "*.png") ):
print infile
Now I get this:
/home/my/path/output0352.png
/home/my/path/output0005.png
/home/my/path/output0137.png
/home/my/path/output0202.png
/home/my/path/output0023.png
/home/my/path/output0048.png
/home/my/path/output0069.png
/home/my/path/output0246.png
/home/my/path/output0071.png
/home/my/path/output0402.png
/home/my/path/output0230.png
/home/my/path/output0182.png
/home/my/path/output0121.png
/home/my/path/output0104.png
/home/my/path/output0219.png
/home/my/path/output0226.png
/home/my/path/output0215.png
/home/my/path/output0266.png
/home/my/path/output0347.png
/home/my/path/output0295.png
/home/my/path/output0131.png
/home/my/path/output0208.png
/home/my/path/output0194.png
In which way is it ordered?
To clarify: I am not interested in ordering - I know sorted
. I want to know in which order it comes by default.
It might help you to get my ls -l output:
-rw-r--r-- 1 moose moose 627669 2011-07-17 17:26 output0005.png
-rw-r--r-- 1 moose moose 596417 2011-07-17 17:26 output0023.png
-rw-r--r-- 1 moose moose 543639 2011-07-17 17:26 output0048.png
-rw-r--r-- 1 moose moose 535384 2011-07-17 17:27 output0069.png
-rw-r--r-- 1 moose moose 543216 2011-07-17 17:27 output0071.png
-rw-r--r-- 1 moose moose 561776 2011-07-17 17:27 output0104.png
-rw-r--r-- 1 moose moose 501865 2011-07-17 17:27 output0121.png
-rw-r--r-- 1 moose moose 547144 2011-07-17 17:27 output0131.png
-rw-r--r-- 1 moose moose 530596 2011-07-17 17:27 output0137.png
-rw-r--r-- 1 moose moose 532567 2011-07-17 17:27 output0182.png
-rw-r--r-- 1 moose moose 553562 2011-07-17 17:27 output0194.png
-rw-r--r-- 1 moose moose 574065 2011-07-17 17:27 output0202.png
-rw-r--r-- 1 moose moose 552197 2011-07-17 17:27 output0208.png
-rw-r--r-- 1 moose moose 559809 2011-07-17 17:27 output0215.png
-rw-r--r-- 1 moose moose 549046 2011-07-17 17:27 output0219.png
-rw-r--r-- 1 moose moose 566661 2011-07-17 17:27 output0226.png
-rw-r--r-- 1 moose moose 561678 2011-07-17 17:27 output0246.png
-rw-r--r-- 1 moose moose 525550 2011-07-17 17:27 output0266.png
-rw-r--r-- 1 moose moose 565715 2011-07-17 17:27 output0295.png
-rw-r--r-- 1 moose moose 568381 2011-07-17 17:28 output0347.png
-rw-r--r-- 1 moose moose 532768 2011-07-17 17:28 output0352.png
-rw-r--r-- 1 moose moose 535818 2011-07-17 17:28 output0402.png
It is not ordered by filename or size.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from How is Python”s glob.glob ordered?, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano How is Python”s glob.glob ordered?
- Deutsch How is Python”s glob.glob ordered?
- Français How is Python”s glob.glob ordered?
- Español How is Python”s glob.glob ordered?
- Türk How is Python”s glob.glob ordered?
- Русский How is Python”s glob.glob ordered?
- Português How is Python”s glob.glob ordered?
- Polski How is Python”s glob.glob ordered?
- Nederlandse How is Python”s glob.glob ordered?
- 中文 How is Python”s glob.glob ordered?
- 한국어 How is Python”s glob.glob ordered?
- 日本語 How is Python”s glob.glob ordered?
- हिन्दी How is Python”s glob.glob ordered?
Munchen | 2023-03-22
I was preparing for my coding interview, thanks for clarifying this - How is Python”s glob.glob ordered? in Python is not the simplest one. Will use it in my bachelor thesis
Boston | 2023-03-22
Thanks for explaining! I was stuck with How is Python”s glob.glob ordered? for some hours, finally got it done 🤗. I am just not quite sure it is the best method
Abu Dhabi | 2023-03-22
Thanks for explaining! I was stuck with How is Python”s glob.glob ordered? for some hours, finally got it done 🤗. I just hope that will not emerge anymore