Showing posts with label map. Show all posts
Showing posts with label map. Show all posts

03 December 2022

Advantages of map function in Python

 Does Python still need the map() function?

 

In the following situation, i.e. working with multiple itarables (lists, etc.), using map function may be the best approach. It is both the most readable and the most efficient.

 ...

Above, we applied map() for a single iterable, but we can use as many of them. The function will use them based on their index, that is, first, it will call the callable for the first elements of the iterables (at index 0); then for the second; and so on.

A simple example for this:

>>> def sum_of_squares(x, y, z):
... return x**2 + y**2 + z**2
>>> x = range(5)
>>> y = [1, 1, 1, 2, 2]
>>> z = (10, 10, 5, 5, 5)
>>> SoS = map(sum_of_squares, x, y, z)
>>> list(SoS)
[101, 102, 30, 38, 45]
>>> list(map(sum_of_squares, x, x, x))
[0, 3, 12, 27, 48]
...

10 July 2018

Copy UNC network path (not drive letter) for paths on mapped drives from Windows Explorer

Copy UNC network path (not drive letter) for paths on mapped drives from Windows Explorer



  1. In Windows Explorer, hold the shift button down, r-click on the file, and select "Copy as path".
  2. Insert a Hyperlink in the email and paste in the address field of the Hyperlink dialogue box. (Shortcut: ctrl-K ctrl-V + OK). At this point, the link will display the mapped drive letter as the root (Q:\foo.doc).
  3. Now, r-click and select "Edit Hyperlink..." you will notice that the Address field has been translated back into the full UNC path (\\cartman\users\emueller\foo.doc). With your mouse in the Address field, hit ctrl-A and ctrl-C to copy the full path to your clipboard, then move your cursor to the top field ("Text to Display:") hit ctrl-A and ctrl-V to display it correctly in your email.

02 February 2015

Automatically Map Network Drives on Domain Login for All Users, Certain Users, or Certain Groups

Automatically Map Network Drives on Domain Login for All Users, Certain Users, or Certain Groups

https://tinyapps.org/docs/auto_map_network_drives.html

tinyapps.org / docs / Automatically Map Network Drives on Domain Login for All Users, Certain Users, or Certain Groups


As always, use the following instructions at your own risk (and joy). Please submit any corrections or comments if you feel so moved.
Auto map network drives on login for all users
  1. Save the following batch file to the domain controller's NETLOGON share as logon.bat:
    @echo off
    net use * /delete /yes
    net use x: \\server_name\shared_directory_name
  2. Active Directory Users and Computers
  3. Right click domain name at top left and click Properties > Group Policy > Edit > User Configuration > Windows Settings > Scripts (Logon/Logoff) > Logon > Add...
  4. Enter path to logon.bat (e.g., \\ACME.local\sysvol\ACME.local\scripts\logon.bat) and click OK three times
  5. Login from workstation. Drive x: should appear in My Computer.
Auto map network drives on login for certain users:
  1. Save the following batch file to the domain controller's NETLOGON share as logon.bat:
    @echo off
    net use * /delete /yes
    net use x: \\file_server_name\shared_directory_name
  2. Active Directory Users and Computers > Users > Double click user > Profile
  3. Enter "logon.bat" (no quotes) in the "Logon script" box and click OK
  4. Login from workstation as user modified in step 2. Drive x: should appear in My Computer.
Auto map network drives on login based on Group membership
  1. Get KiXtart
  2. Put WKIX32.EXE in both the domain controller's NETLOGON share and %SystemRoot% (normally C:\WINNT\).
  3. Save the following script as map_drive.kx to the NETLOGON share (be sure to change the group as needed - here we've used Domain Users):
    use "*" /DELETE
    if ingroup("Domain Users")
    use x: "\\server_name\share_name"
    endif
  4. Save the following batch file (which calls your KiXtart script) as login.bat to the domain controller's NETLOGON share:
    @echo off
    \\server_name\NETLOGON\WKIX32.EXE \\server_name\NETLOGON\map_drive.kx
  5. Active Directory Users and Computers
  6. Right click domain name at top left and click Properties > Group Policy > Edit > User Configuration > Windows Settings > Scripts (Logon/Logoff) > Logon > Add...
  7. Enter path to login.bat (e.g., \\ACME.local\sysvol\ACME.local\scripts\login.bat) and click OK three times
  8. Login from workstation as a user belonging to group designated in map_drive.kx. Drive x: should appear in My Computer.
  9. If x: does not appear, check the permissions of NETLOGON, WKIX32.EXE, your script files, etc. Also, make sure that the user or group has the necessary permissions on the shared folder you are mapping.
More KiXtart Examples
  1. Map drive if user is *not* a member of a certain group (in this case, "Students"):
    If InGroup("Students") = 0
       Use R: "\\server\records"
    EndIf
    
  2. Using Boolean operators:
    If InGroup("Teachers") Or InGroup("Office") Or InGroup("PTA")
       Use G: "\\server\Grownup_Files"
    EndIf
    
    If InGroup("2008 Class") And InGroup("Honors")
       Use S: "\\server\smart_kids"
    EndIf
    
  3. Using Select...EndSelect (stops processing on the first true Case)
    Select
       Case InGroup("Students")
          Use S: "\\server\student_storage"
       Case InGroup("Office")
          Use O: "\\server\office_docs"
          Use R: "\\server\records"
       Case InGroup("Teachers")
          Use O: "\\server\office_docs"
          Use S: "\\server\student_storage"
          Use T: "\\server\teaching_materials"
    EndSelect
    

last update: 2008.02.12