Dear all, this is my first post on the Forum, so hello everybody! :)
I am newby with Python (I have only 4 days experience), I have started to leanr because I will need to develop some software to the company I working in.

Currently I am developing a code (Windows Python25) to generate a pool of MAC Addresses based on Start (or source) MAC Address -entered by the user- and the Range of the pool -defined by the user too- and finally show "Start MAC Address", "Destination MAC Address" and "Pool Range".

I have the following questions:

1. Is it necesary to start every program with "#!/usr/bin/python"?
2. Based on the code below, how to asign HEX attribute to "macnum" variable and how to do the operation of "+" to get the "macdst" variable value?

One example of the wrong function is as follows:
From uservalue=00:02:00:00:F0:8A
I get macnum=00020000F08A

From macrange=448
I get rangehex=0x1c0

And get macdst=00020000F08A0x1c0

#---Program Begins---#
#!/usr/bin/python
#
print "\n" * 100
#
from easygui import *
import sys
#
uservalue = enterbox(message="Input start MAC", title='', argDefaultText='00:00:00:00:00:00')
macnum = (uservalue).replace(':',"")
maclong = len(macnum)
if maclong == 12:
   macrange = enterbox(message="Input MAC range", title='', argDefaultText='0')
   if macrange != 0:
      rangehex = hex(int(macrange))
      macdst = macnum + rangehex
      print macnum
      print macdst
      print rangehex
   sys.exit(0)
#---Program Ends---#

#!/usr/bin/python
is only needed for Linux computers.

print "\n" * 100
is a crude way to clear the cmd screen. Are you sure you need this at all?

Also, easygui is a subset wrapper for the Tkinter GUI toolkit. Very few people use it. I would switch to Tkinter that comes with most any Python installation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.