While the maximum RAM limit for 32-bit Windows 7 editions is 4GB, when it comes to the 64-bit editions, the amount of memory that the OS can address depends on which edition you are running. Here are the upper RAM limits for the different editions of Windows 7:
petrichor (/'pe - tri - kor'/) is the familiar scent of rain on dry earth
this tech blog is the wafting fragrance of my geeky outpourings, one post at a time
Thursday, July 29, 2010
how much physical memory is supported by 64 bit editions of Windows 7?
Saturday, July 24, 2010
python: sharing global variables across modules
The canonical way to share information across modules within a single program is to create a special configuration module (often called config or cfg). Just import the configuration module in all modules of your application; the module then becomes available as a global name. Because there is only one instance of each module, any changes made to the module object get reflected everywhere.
For example:
File: config.py
File: mod.py
File: main.py
Module variables are also often used to implement the Singleton design pattern, for the same reason.
source
For example:
File: config.py
x = 0 # Default value of the 'x' configuration setting
File: mod.py
import config config.x = 1
File: main.py
import config import mod print config.x
Module variables are also often used to implement the Singleton design pattern, for the same reason.
source
python: local vs global scope
What are the rules for local and global variables in Python?
In Python, variables that are only referenced (and not assigned a value) inside a function are implicitly global.
If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be a local.
If a variable is ever assigned a new value inside the function, the variable is implicitly local, and you need to explicitly declare it with the "global" keyword if you want to use the global context.
python: if __name__ == "__main__"
This is a simple "trick" so that python files can be used as both importable/reusable modules and also as standalone python programs.
From another perspective, this answers the common interview question,
"What considerations do you take while writing a python module? Or do you just write a module like a regular python program and then import it blindly? Don't you have to take some extra care/precautions while writing a python module?"
See this link for a simple and illustrative example:
http://pyfaq.infogami.com/tutor-what-is-if-name-main-for
From another perspective, this answers the common interview question,
"What considerations do you take while writing a python module? Or do you just write a module like a regular python program and then import it blindly? Don't you have to take some extra care/precautions while writing a python module?"
See this link for a simple and illustrative example:
http://pyfaq.infogami.com/tutor-what-is-if-name-main-for
linux: my ~/.screenrc file
This is the .screenrc file that has evolved as my current favorite over time - both for cygwin and native linux shells.
# the default shell when creating a new screen window
# ~/.bashrc is invoked whenever creating a new screen window
# so all my bash aliases are available from within screen too
shell -${SHELL}
# The shelltitle specified is an auto-title that would expect the prompt and the typed command to look something like the following:
# $ fortune
# (it looks after the '$ ' for the command name). The window status would show the name "fortune" while the command was running, and revert to "bash" upon completion.
shelltitle "$ |bash"
#avoid startup message
startup_message off
hardstatus alwayslastline
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
# Use the function keys to immediately switch to corresponding windows
# (instead of having to press ^a0, ^a1 etc - which also still work, btw)
bindkey -k k1 select 1
bindkey -k k2 select 2
bindkey -k k3 select 3
bindkey -k k4 select 4
bindkey -k k5 select 5
bindkey -k k6 select 6
bindkey -k k7 select 7
bindkey -k k8 select 8
bindkey -k k9 select 9
bindkey -k k; select 10
bindkey -k F1 select 11
bindkey -k F2 select 12
# go to next/previous window using ctrl+ right and left arrows
# this interferes with word-back and word-ahead on ubuntu, hence disabled:
# bindkey ^[[1;5D prev
# bindkey ^[[1;5C next
# set the scrollback buffer to hold the last 5000 lines
defscrollback 5000
sources: Friday, July 23, 2010
python: getting the size (length) of a list - just use len() !
>>> print a [1, 2, 3, 4] >>> len (a) 4
Thursday, July 22, 2010
python: how to get size of an object
use sys.getsizeof:
source
>>> import sys
>>> x = 2
>>> sys.getsizeof(x)
14
>>> sys.getsizeof(sys.getsizeof)
32
>>> sys.getsizeof('this')
38
>>> sys.getsizeof('this also')
48
source
Subscribe to:
Posts (Atom)