Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
5 Cards in this Set
- Front
- Back
What does this mean?
import gio |
This tells Python to use the GIO (Gnome Input Output) module.
|
|
What's the difference between the three methods if importing a module:
import [module] from [module] import * __import__ |
import [module] imports the module and and creates a reference to it in the current namespace. You can use module.name to refer to things defined in the module.
from [module] import * imports all public objects (not beginning like _this) from the module. You can refer to these by their own name, and don't have to use module.name X = __import__(‘module’) works like "import [module]" but you can assign it a name. |
|
How would you figure out which OS you were running Python on?
|
import os
youros = os.name switch(youros) { case nt: printf("Windows.\n"); break; case dos: printf("DOS.\n"); break; case os2: printf("OS\/2.\n"); break; case mac: printf("Mac OS.\n"); break; case ce: printf("Windows CE.\n"); break; case posix: printf("Unix or Linux.\n"); break; |
|
What is the difference between a "set" and a "frozenset"
|
A set is an unordered collection of objects that can be modified after creation. A frozenset cannot be modified.
|
|
How would you mount SMB shares using 'gio'?
|
import gio
def mount(f): op = gio.MountOperation() op.connect('ask-password', ask_password_cb) f.mount_enclosing_volume(op, mount_done_cb) def ask_password_cb(op, message, default_user, default_domain, flags): op.set_username(USERNAME) op.set_domain(DOMAIN) op.set_password(PASSWORD) op.reply(gio.MOUNT_OPERATION_HANDLED) def mount_done_cb(obj, res): obj.mount_enclosing_volume_finish(res) |