[14] python (realistic) IV #misc

CV claims — “used py for sys automation”

Q: optimize – how did you optimize perf?
A: I didn’t need to for my scripts.

Q: try/catch + ….?
Q: immutable – what data types are mutable/immutable?
Q: threading – global interpreter lock?
A: never really needed threading
Q: xml – what xml parser did you use? ess477
Q: debugger? A: I didn’t need it

Q: read a config file?

Q: logging?
Q: DB access?
Q: command line arguments stored where? A: sys.argv?
Q78: exit normally? A: sys.exit()
Q78b: normally, “raise Exception” would print to stderr stream, but how do you direct that to a log file instead?
A: set sys.stderr stream. dive205 i.e. [[dive into python]]

Q: how do you handle newline diff between OS? ess114
Q: truth table? e68 (i.e. [[essentialRef]])
Q: how do you edit on windows and deply to linux?
A: samba, ftp. See also the post in pearl
— sys admin
Q: how do you pass input files to your py script? cook539
A: fileinput module is convenient.

Q: how is PYTHONPATH used with sys.path?

Q: another py — how do you execute another py script? Ess89 (i.e. [[essentialRef]])
Q: what command line options do you use often?

Q5: how do you launch an external program?
Q5b: how do you capture its output? c546 [[cookbook]] has a slightly advanced solution
Q5c: how do you call a unix shell command?
A: shutil module meets some of your needs

Q: exit with an error msg? cook540
A: raise SystemExit (‘msg’)

— data structures
Q: diff between listcomp and genexp? How would you choose?
Q: convert between list and tuple? cvc
Q: convert a list of objects to string and concat? see post in recrec
Q: split a string on multiple delimiters? cook37 explains re.split()
Q: iterating in reverse? cook119
==coding IV
Q: how do you print to a file rather than stdout?
A: e115 — print >> anOpenFile, ‘whatever’ # using the print KEYWORD
A: c144 — print (‘whatever’, file=anOpenFile) # using the print() function
Q: concat 2 lists?
Q: initialize a dict
Q: initialize a 2D array? m52 (i.e. [[perl to python migration]])
Q: walk a directory
Q: use a dict as a “seen”
Q: iterate a dict? mig87
Q: iterate a file
Q: interpolate into a string? ess115. c61 i.e. [[cookbook]]
Q: date/time usage (datetime module is OO;  time module is procedural?)
Q: trim both ends of a string? strip()

Advertisements

##9dataStruct(+..)for TIMED c++cod`IV

  1. generate a range from 1 to 9 — xrange() for py
  2. vector (more useful than array), std::string (more useful than cStr). Many string operations are still unfamiliar
    1. Array-based data structures are required in 80% of my coding tests.
    2. More than 50% of all my coding tests require nothing but arrays.
    3. Most of my toughest coding tests are presented in arrays but may need maps as helpers
  3. basics of map lookup
  4. sorting, operator<(), upper_bound, binary search … on containers
  5. sorted data structure (like std::multimap)
  6. [w] stringstream — ECT to improve

Very few NY interviewers would test you on graph or DP. Here are other less important constructs:

  1. [w] binary tree is common and simple, but they can ask very tough questions on it!
  2. [w] double pointer is trickier and my advantage
  3. [w] Node class in a linked data structure.
  4. [w] stack, queue.
  5. [w] grid or matrix
  6. file I/O? only for IDE tests, not pure algo or take-home tests
  7. [w] basic syntax for pointer arithmetic.
  8. [w] dtor, copier, op=? only for design questions, not algo questions.
  9. [w] shared_ptr? Only for design questions, never needed in algo questions!
  10. [w] ref variable only as function I/O.
  11. stl algo? Only Citadel array-shrink
  12. never exception
  13. never template
  14. no (very, very seldom) threading in coding Q
  15. adv: pointer to function
  16. adv: circular buffer
  17. [w = no weakness]

 

(Revisit) senior manager IV: what they watch out for

Common, non-trivial, perhaps hidden issues in a candidate, ranked:

  • twist and turn and not /candid/ about his past
  • not listening
    • jumping to conclusions
    • assuming too much
    • not waiting for a long-winded interviewer to finish, perhaps interrupting
    • jumping to the defensive, when deliberately provoked
  • desperate for the job and losing his perspective
  • opinionated
  • choosy on projects
  • conceited beyond “cool confidence”
  • —–secondary
  • impulsive answers ^ elusive, guarded answers
    • elusive answers? common
  • bad-mouth past managers
  • lack of humor? common
  • tensed up and not cool and calm, perhaps prone to workplace stress
  • exaggeration about his past? common
  • not articulate enough? common
  • poor eye contact? common

%% Q2interviewer #to improve further

As I get older, the soft interview is becoming more important more tricky. Part of the soft interview is my list of questions to interviewer.

Tip: If possible, ask “salesy” a question so you can highlight your memorable strengths. More importantly, ask smart, serious questions.

How about “truthful” question that show your real concern? I feel there’s very limited value in truthfulness here.

Some people (like me) don’t like [e]asy questions, but interviewer may find it too sensitive and blunt, though they can always dodge it.

  • [e] Q: between quality and speed, what’s more important?
  • Q: bottlenecks and what was/is done about each
  • [e] Q: what are your challenges?
    • resource?
    • people not communicating enough?
    • requirement changing too fast?
  • [e] Q: what design trade-offs have you made?
  • [e] Q: what user groups, and what challenges do each present?
  • [e] Q: what types of team player are needed here?
  • [e] Q: how is performance *measured*?
  • [e] Q: your management style?
  • [e] Q: median age among the developers?
  • Q: Are expectations any different on an older developer (say, my age)
  • Q: who is the most important (not necessarily biggest) competitor?
  • Q (only for the hiring manager): Based on what you have learned about me in this interview, do you have any questions or concerns about my ability (not suitability) to do this job?
    • Note This is a pretty aggressive question, but if there is a good rapport built during the interview, it can be useful. More assertive hiring managers like this as it shows the candidate is not shy about seeking feedback. This can also clear the air of any lingering concerns or possible miscommunications/misconceptions that are a subtext to the interview.

 

MSVS linker option -L vs -l #small L

Linker option –l (small ell) for the lib file name; -L for to specify the search path

———-

Finally, you must tell the linker where to find the library files. The ST-Developer Windows installation contains programming libraries built for use with Visual C++ 2005 (VC8) and 2008 (VC9) with the /MD flag, as well as versions that are link compatible with other compilers. These are kept in different subdirectories under the ST-Developer “lib” directory. The library directories available for Visual Studio 2005 and 2008 are as follows:

  • $(ROSE)/lib/i86_win32_vc8_md (2005, 32bit platform, /MD)
  • $(ROSE)/lib/x64_win64_vc8_md (2005, 64bit platform, /MD)
  • $(ROSE)/lib/i86_win32_vc9_md (2008, 32bit platform, /MD)
  • $(ROSE)/lib/x64_win64_vc9_md (2008, 64bit platform, /MD)

Select the Linker category of properties and, pick the General options under that. In the Additional Library Directories property, add the appropriate ST-Developer library directory.

 

I know more c++than c#(spent X years full time)

Action: spend enough (30?) hours revisiting my 1000+ cpp (including socket, stream..) blog posts and explore just a little beyond them.

(I blogged about exactly the same observation before …) Here’s a paradox — i spent 2 years in a full time c# job, arguably longer than my full time c++ experience. However, sometimes I feel I understand dotnet less than C++.

Reason? Many aspects of the languages are never used in-depth on work projects, so length of experience != depth of experience. We need spare time self-exploration to learn those aspects like:

– template meta programming
– custom operator new/delete
– memory tuning
– memory leak detection
– threading
– async communications
– pure virtual
– ++i vs i++

(… not a complete list by any measure.) Interviewers are notorious for testing these obscure or advanced, theoretical topics.

file/console input output ] python

Output typically uses “print”.

print >> myFileObject , arguments
print >> sys.stderr , arguments…

Quiz: so, in that case, how do you print to stdout?

Input from file is very common, so that's another quiz

Input from std input —

aLine = sys.stdin.readline()
all_the_Lines = myFileObject.readlines()

Some prefer the object-oriented way to output

myFileObject.write(arguments….)