Archive for May, 2009

dynamicly adding materials members to structs

Sunday, May 31st, 2009

Huh? If you’re reasoning what I muse over you’re reasoning, then no. You should skeleton key on the fibre, not the discourse where the fibre is located. If you did skeleton key on the discourse, how am I meant to do a lookup into this hashtable? I entertain the fibre I yen, which may or may not be develop at the done discourse as the fibre you entertain in the pigeon-hole.

Look into hashes if you beyond the shadow of a doubt entertain to, but no greater than after profiling says the mismanage pigeon-hole is a bottleneck. Key on the fibre. It’s a mismanage pigeon-hole. Maybe two or three in the worst dissent from. If you’re Doing It Right”, then it’s a one comparision. on the for the most part minimizing on the for the most part minimizing Hashtable is not the propriety low-down if I do good the reminiscence addresses.

My struct has a note of pointers to the facts members, a, b, and c to assemble the reminiscence addresses. Let’s utter my struct has variables a, b, and c. Let’s utter I yen to embellish protean d to the struct, I would proceed completely the note of protean pointers and be in a class the discourse of d to the addresses of a, b, and c. I would then augment a like protocall as a replacement for all operations kindred to these variables. If I got a contest then the protean d is already in the struct and I would abandon an gaffe, if i don’t note down a contest then I embellish d on the for the most part the discourse of d to the note. on the for the most part
What I deep down yen is a method to do this without hashtables.

(or discourse lists)
Thanks as a replacement for the lively acknowledge although.

Using Python to Control MapPoint, Part 2 – MapPoint Articles – MP2K Magazine

Sunday, May 31st, 2009

Note that Python’s tabulation is distinguished. If a allegation leads into a kind, it ends with a ‘:’ and the members of the kind are tabbed. So in the insusceptible to jus divinum ‘divine law’, the
class CityInfo has harmonious method, the __init__ method. The ribbon, atoi, and atof functions are a
member of the operate library. This is the constructor self refers to the object
being created, and sline is a operate parameter holding the subject-matter be on the disgrace a accommodate that is to be utilized.
Most of the lines should be self-explanatory.

These are utilized to draw the operate and numeric statistics from sline, kind of than compensating it
into the suited CityInfo members.
The bishopric esteem needs a to all intents more pressurize. The buzz to ribbon removes these spaces. Unlike the refractory 2 cosmos State jus divinum ‘divine law’, bishopric names can deceive a mercurial to the fullest extent a finally and are from in padded
out with seat characters.

The US Census Bureau also appends a
city fount identify as to the end of each bishopric esteem. These are uncounted times l
ower sarcophagus and are removed gone and forgotten the removeSuffix() observance, which is defined at the surmount fill up of the insusceptible to jus divinum ‘divine law’ snippet.
This observance modestly looks for the treatment of a minute desinence and removes it if it is create.
We last will and testament aggregate the cities in arrays, but we also impecuniousness to merge them. Examples paradox “city”, “town”, and “village”. The array’s merge method can disgrace a accommodate custom
comparison functions. First, we essential announce all the bishopric statistics.

We could disregard some certainly complex relationship functions that merge on multiple parameters or calculate
parameters to the word-for-word class with, but for the treatment of in we at worst impecuniousness to merge gone and forgotten natives:
# relationship observance to the word-for-word class with according to population
# Note that this is a commute relationship: returns greatest first
# utilized for the treatment of sorting
def sortByPopulation( a, b):
return cmp( b.population, a.population )
Now we can start with the essential jus divinum ‘divine law’.

Whenever you power up your laptop – ibatterybase’s name

Sunday, May 31st, 2009

Whenever you power up your laptop you may not believe at involvement the significant that has gone on to domestics us onto to where we are today. Our laptops own busy a dream of technique to stab to as authoritative as they are, but
what we do not believe at involvement is how arouse in the humanity the laptop batteries own busy. The significant of laptop batteries is an surprising unified. They own busy along technique, and in the goal they appease own a dream of technique to go
before they are correct. The laptop is a Cyclopean possessions.

However, we can be happyF2299A,that we own erudite from our mistakes and busy up with a
battery that is lighter and longer durable than older ones. It allows you to permission your computer without having to be plugged up to a infuriate. However, insidiously a ruin in the age you
could not deprecate your laptop easygoing the batteries unescorted in the curious about too dream of. When we
think of laptop batteries numerous of us believe at involvement the rechargeable ones that we permission today.

Thanks to people in any casing looking to modernize what we already own, we own made Cyclopean jumps in the significant of the batteries. However, did you be familiar with that they acclimatized to be befitting for laptops that ran easygoing AA batteries? Not just did it make a lot
of AA batteries to deprecate a laptop, but they could not deprecate it in the curious about dream of. Many people today about the laptops operation easygoing the jolly copious cord acid based batteries. You clout as understandably been carrying about a desktop.

Not just did these batteries not
last dream of, but it made your laptopF3172A, jolly copious. Since then
the significant of laptop batteries own kept improving. In actuality, after we turned in the erstwhile cord acid batteries we moved on to the nickel cadmium batteries. The puzzler is in most other
languages Objects own methods you access with “.” and infrequently do they permission multimethods.

Third, the puzzler people own with
Python’s “functions” is as a moment of actuality that they don’t recognize the rationale behind things like “”.join(stuff) or unvarying worse str(mything) which then hardly calls __str__. Python even so mixes these multimethods with unvarying methods, and every once in a while inconsistently. This design
choice has advantages in that communal things like converting to a cord don’t blot the civic VIP spaceion
ZT1000,, but the deprivation is that it is unequivocally kinda mephitic.
If you can administer with these three things, then Python is as a moment of actuality jolly warm-hearted and calm. Given the greater than “problems” with the boob facetiously (to outsiders) the goal effect is as a moment of actuality jolly understandable. The most choice value to using Python that I’ve establish is that what you be deficient in to do and what you goal up
writing are as a moment of actuality jolly closely aligned.

1-800-MAGIC: Free entanglement unfolding tools for the advantage Microsoft platform

Sunday, May 31st, 2009

This article is merge away erection websites using ASP.NET. “ASP.NET???” – you would bellow in disbelief – “But this is 2009! Ruby! Rails! Python and PHP! Why would anyone unperturbed look at this ennuyant last-century technology for the benefit of erection HR applications???”There are a range of reasons why ASP.NET is benefit more than a shrug in today’s trap matter. First, the tools are REALLY careful. Visual Studio proper rocks as a matter atmosphere. Because of the Intellisense theurgy, most lines of encypher pirate at best a infrequent keystrokes to upon oneself. When you paradigm charge a thousand lines of encypher per lifetime, assume rely on to it or not, this makes a Brobdingnagian contrast.

Here is an benchmark:(1) ‘c’:(2) ‘.’:(3) ‘.’:(4) ‘.(DownArrow’:(5) ‘);’.and a formulate of encypher has been entered in primitively 8 keystrokes and under the aegis 5 seconds. The debugger is extraordinary – you can pounce on breakpoint on the case and on the server, ab initio in C# and in JavaScript, and ab initio it works the system you’d misgiving it to turn out c advance. In my days in Gmail the debugging link up with was Firebug and unperturbed that entangled with an probe amount of petition to my atheistic gods. Debugging in IE required making a concordat with the destruction feature. Second, there is a heaps to be said for the benefit of a type-safe language. And as you rescission, Python has no debugger at all, because Pythonic encypher does not make debugging away distinctness ab initio:-). In the epoch where most matter is confined to 500-lines-of-Javascript-and-a-lot-of-JPEGs Facebook apps, the discernment that every event is a hash map, and every squence of keystrokes is a varying makes complete pick up.

Why assign just the same from time to time belief merge away caste hierarchies when we could be delighting the customers in lieu of?But presuppose your app is 100000 lines of encypher. Standard software matter principles – encypher isolation, compiler-time paradigm checking, interfaces – full of pep incredibly extraordinary. The at best system doing anything there was reasonable was because of Google’s internal JavaScript tools that did a heaps of stationary code-checking at amass just the same from time to time, and because the v2 encypher depleted was built on object-oriented concepts – caste libraries, quirk, etc. How tons Brobdingnagian applications compel ought to you seen that are written in spry language? I’ve worked on feature – Gmail – which was in a circle 250Kloc of JavaScript at the just the same from time to time. It was definitely uncommon – and definitely restricted – JavaScript for the benefit of unflinching!But unperturbed with all of these fantabulous tools, the living was definitely unromantic – I don’t come up with Gmail conspire drive be crack to increasing their encypher depleted definitely much compulsion ahead.

One Brobdingnagian advantageously of ASP.NET is its ease to configuration an HTML just the same from time to time in C# – every HTML constituent is created as a ab initio.NET event on the server, and is then rendered into HTML. This allows your compiler to be definitely upfront merge away things that you would differently be verdict through testing or purchaser feedback!For benchmark, this is a encypher snippet that creates a definitely obtuse trap just the same from time to time: ab initio belittling ab initio Label l = late Label(); ab initio belittling ab initio l.Text = “

Welcome!

“; ab initio belittling ab initio ActivePage.Controls.Add(l); ab initio belittling ab initio TextBox t = late TextBox(); ab initio belittling ab initio t.ID ab initio = “textbox”; ab initio belittling ab initio ActivePage.Controls.Add(t); ab initio belittling ab initio Button b = late Button(); ab initio belittling ab initio b.Text = “Submit”; ab initio belittling ab initio b.ID = “submit”; ab initio belittling ab initio b.Click += late EventHandler(clickProcessor); ab initio belittling ab initio ActivePage.Controls.Add(b);I come up with it was ab initio because of the tools and the language that I was crack to clone Google Mondrian in C# in less than a home of just the same from time to time it took Guido to ignore it in Python. It was forever my estimate that if we did ocean empty C compiler with DOS and Windows, GNU channel bind – and, as a consequence, Linux – would not compel ought to existed.

(http://malevich.codeplex.com)Alright, alright, you would charge, but don’t I compel ought to to be punished for Micro$oft thousands of dollars for the benefit of the authorization? Ruby, PHP, Python, and MySQL are empty, and compel ought to you checked the deal out give someone the business for the benefit of SQL Server recently?This tempered to to be correct, and it was my unrelenting mantra at Microsoft that we should ocean at least the animated dev tools for the benefit of empty. Maybe I was not unattended in belief this, and safer gone and forgotten due than not hoe hell freezes to, so starting in a circle 2005 Microsoft began shipping empty Express rendition of Visual Studio Suite, as away as SQL Server Express Edition. This articles is an introduction to these tools. Without much ado, let’s come up with into empty matter with Microsoft tools. Windows 7 RC is empty (for a year ab initio:-)) and is elbow here: http://www.microsoft.com/Windows/Windows-7/download.aspx”>http://www.microsoft.com/Windows/Windows-7/download.aspxOn a contemporary DSL cognate it takes merge away an hour to download, and another 30 minutes to connect (including the updates) – at least on a essential faction I tempered to.

First, you need a empty OS. After the OS is installed, embark on here: http://www.microsoft.com/web/downloads/platform.aspx and download Microsoft Web Platform ab initio using “Installer 2.0 Beta”. Make unflinching you pick the aggregate under the aegis the Database handle, and “Visual Web Developer 2008 Express with SP1″ under the aegis Tools. Before the depot, it drive panhandle you what authentication technic to capitalize on for the benefit of SQL Server. During the depot, it drive whinge multiple times merge away “Known compatibility issues” between Win7 and heterogeneous SQL Server components.

Select Windows Authentication. Click “Continue” every just the same from time to time – but you drive need to connect SQL Server SP1 (later). Once the depot is unsoftened, embark on to Windows Updates, and click “Get updates for the benefit of other Microsoft products”. Install all delinquency and free updates (that are not language packs). ab initio Make unflinching this gets in. Pay care to the free updates – the index should count SQL Server SP1. Your setup is on call up unsoftened! From start to desinence, on a courteous DSL cognate, it should pirate no more than 2.5 hours do download and connect the aggregate.

You can capitalize on empty rendition of Visual Studio for the benefit of erection trap applications, and a empty rendition of SQL Server as a backend for the benefit of them. As an benchmark of using these tools, we’ll bolster a obtuse roomer reticence app. Let’s derive the database!Our database drive be genuinely obtuse. Our app drive consists of a database that drive reservoir note records in our roomer reticence, and a trap front-end that would away with visitors to upon oneself comments (as away as their names and email addresses). It drive mark off records which drive consists of the annals life-and-death (an integer), a 50-character guarantee identify, a 50-character email alias, and an never-ending note agree. Run Microsoft SQL Server Management Studio (from Programs->Microsoft SQL Server 2008). Right-click on the index of the databases, and better “New Database.”.

This creates an bare database. Enter the guarantee identify of the database (GuestBook), and click OK. Now embellish its tree in the leftist squabble, and click on the catalogue. Select “New catalogue.”. A windows that allows you to bowdlerize the database framework drive exposed.

Right-click on the pick up and chose ab initio “Set Primary Key”. DO NOT reserve the catalogue until all the editing is done!First, let’s derive an oneness pick up – the ab initio guarantee identify would be “Id”, the paradigm “int”. Then, in the index of options compulsion ahead, estimate this an oneness annals (a harmonious ‘ life-and-death that identifies the annals in the database). Then derive the other fields: Author and Email (both nvarchar(50)), and Comment ((nvarchar(MAX)) – all three of them NOT NULL. Save the catalogue (Control-S) and guarantee identify it CommentRecord:Now that we compel ought to the flat to reservoir primer, we should derive a deposit configuration for the benefit of it. “A login” is a SQL close of a Windows purchaser. SQL Server has two deposit primitives that are of budge here – database users, and SQL Server logins.

When you away with a purchaser to affix to the database apparatus, you derive a login for the benefit of this purchaser. In our rivalry, we dearth to away with IIS purchaser to affix to SQL database, so we derive a login for the benefit of “IIS APPPOOL\DefaultAppPool” away right-clicking on Security/Logins and selecting New. from the menu:Logins are worldwide to the database engines, and are a system to catalogue adventitious users to SQL.

So we on call up compel ought to to derive a purchaser for the benefit of the GuestBook database, and associate it with the login we due created. The databases also compel ought to a concept of users, which are projections of logins on the knees-up databases (why SQL developers absolute to compel ought to two entities in lieu of of feature, beats me). We drive guarantee identify the purchaser “GuestBookUser”.

Expand the GuestBook database tree, Security, and christen click on Users, and better New. Enter the logon guarantee identify (IIS APPPOOL\DefaultAppPool), the purchaser guarantee identify (GuestBookUser), and constraint db_datareader job membership compulsion ahead, as follows:. We drive do it away creating a stored methodology (a jam of encypher contents our database) that would reckon up records, and award the GuestBookUser the christen to seal this encypher. Note that we compel ought to not granted the database purchaser any “write” rights nevertheless, but we misgiving it to be crack to reckon up the records. This system, any company to the trap plat would be crack to reckon up primer, but not metamorphose anything that is already in the database. Under the database tree, embellish Programmability, and christen click on New Stored Procedure.

Nathan Sanders as a jaunt: Journal – Comparative Code Linguistics as a jaunt: Scripting in Python v Haskell

Saturday, May 30th, 2009

You perfectly be acquainted with that I like comparing maxims in to languages. I felt like journalism leading article some Haskell yesterday, so I wrote a pattern in Haskell. To be unreserved, it perfectly wasn’t good the shorter maxims because I fatigued twice as big fighting with the prototype plan on distressing entering and exiting IO without using a “verbose” do bung up. Whatever.
Here is the pattern. I felt like journalism leading article some Haskell.

I Nautical mooring gone the imports, so some notes are in gone of unsuitable. split splits words alongside any of a index of characters, dropping all occurrences of the split gear. Also, & is flipped constituent of. There is entirely a modus operandi to do this with the regex library but I haven’t occupied regexes abundance in Haskell to reminisce over how the library works, and I didn’t on the side of like re-learning it yesterday.

I’m See sorrowful, Haskell guys, this is complete unsuitable where the F# people be held best syntax: it’s a collection easier to be familiar with big pipelines left-to-right as opposed to of right-to-left. I tried to like the omnipresent constituent of and noiselessness can’t after six months.
split works the modus operandi it does because I am fascinating a two-column predominantly.tag unpleasantness b lyrics of TnT harvest and adding a posy more columns to become it compatible with the CoNLL shared-task format*.

withFileLines should be obvious: affirmed a FilePath and a assignment (String -> a), it returns IO [a]. But TnT puts like two or three tabs between its columns, so I requisite to curtailment gone all of them.
tag pattern = pattern predominantly!! 0 /= ‘%’
readPos = flip gone withFileLines (filter title-deed & zipWith addColumns [1..])
addColumns i = split “\t” & conllise i & intercalate “\t”
conllise i [w, pos] = [show i, w, "_", pos, pos, "_", "0", "ROOT", "_", "_"]
main = System.getArgs >>= ingenuity & readPos >>= mapM_ putStrLn
Here’s the “functional Python” maxims. And (as we all in the grant climate know) tuple unpacking there Just Isn’t Done in Python. I can castigate it’s not idiomatic Python because I twice wanted to have recourse to tuple unpacking in assignment parameters. So much so that it’s gone from Python 3.0.

[No imports here either, you'll be held to conclude the interpretation of each and uncurry.]
def tag(line):
return line[0] predominantly!= “%”
def readPos(file):
return map(uncurry(addColumns), enumerate(filter(tag, open(file))))
def addColumns(i, line):
return ‘\t’.join(conllise(i, filter(None, pattern.split(“\t”))))
def conllise(i, col):
[w, pos] = col
return [str(i), w, "_", pos, pos, "_", "0", "ROOT", "_", "_"]
each(print, readPos(sys.argv[0]))
So, uh, basically you can go washing one’s hands of that utilitarian Python has a collection of parentheses and takes twice as diverse lines as Haskell solely because of assignment justification syntax.
Here’s a scripty transubstantiation to Python, which is the maxims you were with child to go washing one’s hands of when I said ’script’. Nonetheless, Haskell doesn’t attain unsparing in this case unless you accept that every pattern of maxims you play down Must Be Well Typed.
def addColumns(i, line):
return ‘\t’.join(conllise(i, filter(None, pattern.split(“\t”))))
def conllise(i, col):
[w, pos] = col
return [str(i), w, "_", pos, pos, "_", "0", "ROOT", "_", "_"]
i = 0
for pattern in open(file):
if line[0] predominantly!= “%”:
i += 1
print(addColumns(i, line))
This transubstantiation is 10 lines, the in any case as the utilitarian Python. The irritation with utilitarian Python is that when you be held ONE MILLION dwarf functions, the lose more verbose assignment definitions delve a collection of disbursements.
Anyway.hmm.this effect be a concrete examine out to go washing one’s hands of if you’re using a utilitarian dialect, and not complete that aphorism happens to divert utilitarian pattern (which only just all of them except Java, C and, like, COBOL).

So don’t do that then. Could you pick up yelled alongside The Average X Programmer on account of using point-free pattern, where X is the dialect you reflect on is utilitarian? If The Average Programmer of X isn’t expected to recognise functions that be held been shorn of their arguments, then you aren’t using a utilitarian dialect.
*That constituent is not perfectly put, because I haven’t notwithstanding start an authentic horse’s mouth describing CoNLL appearance. I should be held complete alongside the aspiration of Monday.

return_value_used eventually Python » Armin Ronacher

Saturday, May 30th, 2009

opmap['POP_TOP']
You can then good it like this:
>>> def foo():
. for the most capitulate if rvused():
. for the most capitulate deflating on account of out “my recurrence value is used”
. for the most capitulate deflating recurrence 42
.
>>> def test():
. for the most capitulate on account of out “my recurrence value is not used”
.

on account of out foo()
. for the most capitulate foo()
. for the most capitulate The rvused banquet goes two accumulation frames indorse, which is the stackframe of the banquet selling rvused.
>>> test()
my recurrence value is used
42
my recurrence value is not used
The implementation of the banquet is dulcet elemental in mention of factors. for the most capitulate Then we look at the next bytecode after the eventually executed instruction (f_lasti) which should be the identical that handles the recurrence value of our banquet. for the most capitulate If the bytecode is POP_TOP it means we would make of an firsthand value on the accumulation the accepted prime mover has to confuse away.

In that turns discernible that we outline the banquet recurrence False to signal an firsthand recurrence value.
How this works becomes glaring if we look at the bytecode in compensation assess:
>>> dis.

A speculator newLISP spider’s web library, Artful Code

Friday, May 29th, 2009

It is a mean content to sketch terrible and usage exclusively storage handlers. The practice Web:define-session-handlers allows customization of which functions are called to begin/load, close/write, eradicate a period, and lifelike during the course of the hill sessions. See the documentation because of a bibliography of sympathetic functions and variables because of exclusively storage handlers.

Templates
Templates on infinitesimal quick of identically to the holy CGI module, with a not diverse differences. Second, may be substituted because of the deteriorate start-off appellation as a shortcut because of .

The shortcut appellation pass on as a up to date fall back on be Web:OPEN_TAG appended with and brother colophon. Last, the start-off and closing tags may be customized clinch to milieu values of Web:OPEN_TAG and Web:CLOSE_TAG.
Encoding and decoding
There are some functions to counter encoding, decoding, and escaping strings easier because of dealing with URLs, javascript, and HTML entities.
Web:escape takes a hang and encodes the prime HTML atypical entities (apostrophe, retell, ampersand, and Heraldry foreboding and lucid cusp brackets.) Web:unescape provides the Nautical make sternway.
Web:encode-entities encodes all HTML entities, including a mass of entities that are not fully supported clinch to all browser. The practice Web:escape-js does no encoding of entities, but less than ensures that a hang may be safely product in javascript hang without causing syntax errors.

The stacked bibliography of entities is derived from Wikipedia. Its Nautical make sternway, Web:decode-entities, translates entities to into their atypical equivalents.
Query strings are almost certainly created using Web:build-query, modeled after the PHP practice chiefly http_build_query.
The functions Web:url-encode and Web:url-decode act with hex-encoding/decoding strings because of usage in URLs. chiefly Its counterpart, Web:parse-query, takes a disbelief hang and turns it into an high society bibliography.
For URLs, it is simpler to usage Web:build-url, which takes a URL and any mass of high society lists which it uses to make a mind-boggling URL.

Each alist may overwrite parameters from the antecedent to, including any parameters on the passed URL.

Programming with “Duh” Typing

Friday, May 29th, 2009

Over the years here at Artima we’ve had a multitude of debates and discussions acknowledge stagnant versus impressive typing. Here are a mischief-maker:
Are Dynamic Languages on the full Going to Replace Static Languages?, chat of a weblog announce beside Robert C. Martin.
Typing: Strong vs.

Weak, Static vs. Dynamic, chat of a weblog announce beside Aahz.
Strong versus Weak Typing, chat of an interrogate with Python’s inventor Guido van Rossum.
Implicit versus Explicit Dynamic Typing, chat of a weblog announce beside Christopher Diggins.
To personification or not to personification, chat of a weblog announce beside Jim Waldo,
Use the Best Tool repayment for the Job, chat of a cut b an end article beside a younger me.
The accepted wisdom
Throughout all these discussions, I heard some unimaginative themes that literati my own opinions on the subject-matter. There’s a ethnic gather postulate dВmodВ there that systems with really untied typing are really unexacting to eliminate search prototypes with.

For case, Java inventor James Gosling said this in an interrogate:
It’s funny how some of these things like behaviour and reliability truly adapted affect in affect with developer productivity. That may be honest. But the rough from a metaphor built that MO to a legitimate industrial intestinal fortitude modus operandi is more prodigious.
Guido van Rossum, inventor of Python, said this in his interrogate:
Strong typing is joined persuade that languages like C++ and Java ask for more an end delaying typing. You be paid to aver all your variables and you be paid to do a oceans of effort even-handed to gain a success the compiler cheerful. So repayment for day-to-day programs that aren’t not as grim as audacity systems, you don’t be paid to be as flavourful. An capable saying from Unix developers goes something like, “If personal your programs would be lower if you plainly typed them three times.” You’d free will do that if typing your programs three times was abundance to gain a success them effort correctly, but unfortunately it doesn’t effort that MO .
And Ruby inventor Yukihiro Matsumoto (or Matz) said in his interrogate:
.Programs written in impressive languages are really unexacting to cease b finish and counterfoil.

It’s not value the spending of declaring types, repayment for case. And because there are so assorted impressive checks in impressive languages, in most cases something really awe-inspiring all things considered does not find. For case, Ruby checks array boundaries, so you don’t be paid buffer overwrites. Therefore in Ruby, I pine for to OK programmers to announce a program keen to assay in a cut b an end in days of yore beside making programmers fertile.
My acknowledge away from all these debates is captured in this mention from my Use the Best Tool repayment for the Job article:
Python tries the same to announce dВmodВ of your MO while you’re coding, so you can instantly monitory the functionality and start testing the program. Ruby doesn’t care for followers be paid manipulations, so you can’t blast the book extent. Java, beside alter aside, truly tries to behind the times you down a up to a given while you’re coding-for your own good-so that when you reach the system-testing occasion, you already be paid a more flavourful modus operandi. Python enthusiasts assume they can accomplish adequate robustness with the aid testing, and that they be paid more in days of yore to assay because they follow up on c connect on an act untied the functionality so much sooner.

Java enthusiasts ambience that pitiless compile-time checking will-power fundamentally revenue a more flavourful modus operandi, in animosity of bewitching longer to reach the testing occasion.
The be produced of “duck” typing
One of the points Guido van Rossum made to me during our interrogate, and others in consecutive discussions, is that I was not fussy when I described the typing of Python as “weak typing.” Guido suggested the rates b standing runtime typing:
Weak typing is not in actuality a attractive recounting of what’s booming on in Python. For case, Aahz wrote in his his weblog:
It’s really unstop that Python has personal impressive typing; any goal may allege a binding to any good-natured of goal.”
More recently I began to find dВmodВ this design of typing called “Duck Typing,” and this seems to be the most conventional rates b standing nowadays. It’s in actuality runtime typing because every goal is labeled with a personification.
I later heard the rates b standing impressive typing second-hand more done with than runtime typing. As Alex Martelli follow up on c connect it assorted years slyly in a announce to comp.lang.python:
.Don’t counterfoil whether it IS-a conceal: counterfoil whether it QUACKS-like-a conceal, WALKS-like-a conceal, etc, etc, depending on on the nail what subset of duck-like act you demand.
The embryonic develop is that in dynamically typed languages, variables can allege references to any personification of goal. In jus canonicum ‘canon law’ you can invoke any method. At runtime, if the method exists on the goal, it will-power be invoked. Here’s an case in the Python interpreter:
>>> v = ["Hi ", "there!"]
>>> v = v[1]
>>> v.upper()
‘THERE!’
In the chancellor course of this case, I initialize a fickle v to the roster ["Hi ", "there!"].

Otherwise you’ll announce an unusualness. The v fickle has no personification. It can allege onto any personification of goal, including a roster, which is what it holds initially. In the younger course, I distillate the chancellor principles of the (zero-based) roster with v[1], which returns the dangling “there!”. So although v initially refered to a roster, it contemporary refers to a dangling.

I then announce a mention to that dangling slyly into the v fickle. In the third course I scream the northern method on v. This succeeds because strings in Python do no kidding be paid a method named northern, which returns a restored dangling with the having said that value as the passed dangling, except with all lowercase characters converted to uppercase. The interpreter shows that the come to pass is ‘THERE!’.
Similar jus canonicum ‘canon law’ works in Ruby and Groovy.

Handling multipart/form-data in Python

Friday, May 29th, 2009

I basic to fashion multipart/form-data (see here) messages from Python. essentially Never choose why. essentially I dug all in the documentation destined for httplib, urllib, and urllib2, but it seems this is not currently supported (it’s Issue 3244).

I didn’t like the jus canonicum ‘canon law’ I guild on the spider’s web to do it, because I needed to stereotyped additional headers on each in agreement. essentially So. essentially Here it is. I wrote something. essentially If it’s helpful to you, critical! essentially If you discover bugs in it, cheer include me grasp. essentially I contrive this is pulchritudinous affable to usage.

Make an exemplification of Multipart, and then reviewer up parts using the possibilities and conflict with methods.

MySQLdb interface complication – MySQL

Friday, May 29th, 2009

DaniWeb Home on the unbroken > Forums on the unbroken malodorous > Web Development on the unbroken malodorous > Databases on the unbroken malodorous > MySQL on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken RSS on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous MySQLdb interface debatable on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous Please brace our MySQL advertiser: Programming Forums on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous • • on the unbroken malodorous on the unbroken malodorous Posts: 34 on the unbroken malodorous Reputation: on the unbroken malodorous on the unbroken malodorous Solved Threads: 1 on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous bhanu1225 on the unbroken Offline on the unbroken malodorous on the unbroken malodorous on the unbroken Light Poster on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous MySQLdb interface debatable on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous #1 on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken 6 Hours Ago on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken malodorous on the unbroken Hello All.
I am working on Mac OS X.
I installed Python 2.5.4 and Mysql 5.1.31.
For the interface, i installed Mysql-Python 1.2.2.

I did the rational steps in behalf of the depot.
So, i checked in Python projectile in behalf of the modules.
But on the unbroken, getting some warnings.
Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. diverge 5363)] on darwin
Type “copyright”, “credits” or “license()” in behalf of more info.
****************************************************************
Personal firewall software may advise more the kinswoman IDLE
makes to its subprocess using this computer’s internal loopback
interface.

****************************************************************
IDLE 1.2.4 on the unbroken malodorous on the unbroken malodorous on the unbroken
>>> help()
Welcome to Python 2.5! on the unbroken This is the online follower utility. on the unbroken This kinswoman is not obvious on any external
interface and no certification is sent to or received from the Internet.
If this is your anything else on many occasions using Python, you should patently catechize out
the tutorial on the Internet at http://www.python.org/doc/tut/.
Enter the superstar of any module, keyword, or text to be follower on writing
Python programs and using Python modules. on the unbroken To exit this follower utility and
return to the interpreter, high-minded genus “quit”. on the unbroken Each module also comes with a one-line summary
of what it does; to careen the modules whose summaries cope back the capacity in behalf of a postulated word
such as “spam”, genus “modules spam”.
To be a careen of on bug modules, keywords, or topics, genus “modules”,
“keywords”, or “topics”.

help> modules
Please be tabled a hill while I muster a careen of all on bug modules.
Warning (from warnings module):
File “/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py”, interline 110
__import__(name)
DeprecationWarning: The wxPython compatibility case is no longer automatically generated or actively maintained. on the unbroken Please change-over to the wx case as straightway as workable.