Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Generate String Only Unique to That Platform
#1
Hi all,

Could someone enlighten me,
How can I get a piece of string , say 6 characters mix of alpha & numbers,
only unique to that platform ?

Or at least some concept how can I do that?

I need to auto-generate a hostname,
in which even after multiple reboots,
Or re-installation of software,
this piece of code shouldn't generate a new name.

Generating out of MAC address is 1 way,
but it gets complicated especially in Python 2.7 getting to know which network card is active and so on so forth.

Looking for something easy and straight-forward.
Quote
#2
Can use uuid.
It provides the uniqueness as it generates ids on the basis of time,Computer hardware (MAC etc.).
>>> import uuid
>>> 
>>> str(uuid.uuid4())[:6]
'5a7fce'
Quote:especially in Python 2.7
Then stop using Python 2.7 Hand
Quote
#3
(Sep-10-2019, 03:33 PM)snippsat Wrote: Can use uuid.
It provides the uniqueness as it generates ids on the basis of time,Computer hardware (MAC etc.).
>>> import uuid
>>> 
>>> str(uuid.uuid4())[:6]
'5a7fce'
Quote:especially in Python 2.7
Then stop using Python 2.7 Hand

Yes but UUID is different everytime u run it.
I need the same I'd to be generated everytime for the same platform.

About py2.7 I wish u could come n tell those people chg to py3 !
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  AttributeError: module 'platform' has no attribute 'python_implementation' davidpluseipi 3 423 May-01-2020, 11:47 PM
Last Post: Larz60+
  Generate unique random numbers from different lists Takeshio 5 638 May-24-2019, 07:29 PM
Last Post: ichabod801
  turtle moving platform chappie 1 1,110 Dec-06-2017, 10:52 PM
Last Post: chappie
  Recommendation for Python IDE (with debugger, Windows platform) vadim_datascience 6 3,324 May-21-2017, 06:42 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)