Re: [Tutor] how to compile python3.0
that worked for me,too :) thanks to all the peopel helping me 2009/4/24 Dayo Adewunmi > Shaofeng NIu wrote: > >> I tried to compile and install python3.0 from source,but after "make",it >> shows: >> >> Python build finished, but the necessary bits to build these modules were >> not found: >> _dbm _gdbm _hashlib _sqlite3 >> _ssl _tkinter bz2readline >>To find the necessary bits, look in setup.py in detect_modules() >> for the module's name. >> >> Could anybody tell me how to install these modules?Thank you! >> My OS is Ubuntu 8.10 >> >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >> > > This worked for me on Ubuntu 8.04: > > $ sudo apt-get install build-essential libncursesw5-dev libreadline5-dev > libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev g++ gcc > > Solution for _dbm > $ wget -c http://bugs.python.org/file12234/dbm.diff > $ patch -p0 < dbm.diff > > $ sudo apt-get build-dep python2.5 > $ make > $ sudo make install > > Regards > > Dayo > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python help
cart = {"apple":2.00, "orange":2.50, "banana":1.75} print cart apple = 2 orange = 2.5 banana = 1.75 totalprice = 0 totalprice = apple + orange + banana print "your subtotal is 'totalprice'" taxedprice = (totalprice *.07) + totalprice print "your final price is 'taxedprice'" prompt = raw_input("are you a student?") if yes ('taxedprice' / 10) + taxed price = student print "your student price is 'student' else print "have a nice day" Robert Berman-2 wrote: > > Yes. > > Show us your solution and perhaps we can help you make it a tad more > efficient. > > Robert Berman > > IT_ForMe wrote: >> Anyone know how to program this using Python >> >> Add up the prices for items in a shopping cart. Some items are taxable >> and >> some items are not. You may assume a 7% tax rate for all taxable items. >> Apply a 10% discount if the customer is a student. (hint, instead of >> asking >> the user to input items, set them up as an associative array in the code) >> > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- View this message in context: http://www.nabble.com/Python-help-tp23175541p23227229.html Sent from the Python - tutor mailing list archive at Nabble.com. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Threading...
"Spencer Parker" wrote in message news:c7a040fa0904241426h70a0c82bhf95e476fe5ed0...@mail.gmail.com... I have a script that I want to test MySQL sonnections with. The way I have the script working is to just create connections, but I realized that it is going to wait for the first one to stop before starting a new connection. I want to throw a ton of open connections at it to see what the connection limit is and how it reacts when it hits that shelf. Would the best route for this be threading? or is there another way to go about it? Yes threading is probably the way to go but remember that each thread will take up CPU resource so the limits on performance could be the client computer rather than the server. Also the network connection between client and server will have a strong impact on connectivity, and not just bandwidth, you really need to account for queue latency on the ports. Ideally you should be using multiple network connections, multiple ports per connection and multiple clients if you really want a feel for how a server will respond under load. Finally, make sure you aren't just repeating the same data request for each hit otherwise locking tests etc will slow things down too. Its a good idea to have as many rows as you want to run tests and have alternate queries hit opposite ends of the table, or better still have several similar tables and round-robin the queries. Just some common gotchas with database performance testing. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Pyparsing question: marking matches in Pyparsing
Le Fri, 24 Apr 2009 16:20:02 -0400, Emad Nawfal (عماد نوفل) s'exprima ainsi: > Hello Tutors, > I've used Pyparsing to write a Noun Phrase Extractor that extracts noun > phrases from a Part-of-Speech tagged file. My question is: how can I mark, > instead of extract, the phrases. For example, In the sentence: > > The DET big ADJ woman NOUN saw VERB and CONJ greeted VERB the DET green > ADJ man NOUN > > both "The big woman" and "the green man" are noun phrases. > I need the results to look like this: > > The big woman saw and greeted the green man [...] Paul MacGuire may have a better solution, but I would use what in pyparsing is called (I guess) a post-parse action. I don't remember the exact syntax, sorry, anyway the method is simply to define a func that will transform the parse result (node) produced by a pattern, then set it on the pattern. For instance: NOUN_PHRASE = def markNounPhrase(result): NOUN_PHRASE.setParseAction(markNounPhrase) !!! Not sure of the syntax. !!! Beware of the internal structure of the result (possibly the actual value you need to catch is one or more levels nested in the result produced by the pattern). You'd better print it before writing the func. Denis -- la vita e estrany ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Threading...
I have a script that I want to test MySQL sonnections with. The way I have the script working is to just create connections, but I realized that it is going to wait for the first one to stop before starting a new connection. I want to throw a ton of open connections at it to see what the connection limit is and how it reacts when it hits that shelf. Would the best route for this be threading? or is there another way to go about it? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Pyparsing question: marking matches in Pyparsing
Hello Tutors, I've used Pyparsing to write a Noun Phrase Extractor that extracts noun phrases from a Part-of-Speech tagged file. My question is: how can I mark, instead of extract, the phrases. For example, In the sentence: The DET big ADJ woman NOUN saw VERB and CONJ greeted VERB the DET green ADJ man NOUN both "The big woman" and "the green man" are noun phrases. I need the results to look like this: The big woman saw and greeted the green man # This script is far from complete. It works only with Arabic # This is a parser for NP chunks # This depends on non-vocalized texts and tags. from pyparsing import * CASE = oneOf("CASE_INDEF_ACC CASE_INDEF_GEN CASE_INDEF_NOM") DEMONSTRATIVE = oneOf("DE DEM_PRON_F DEM_PRON_FD DEM_PRON_FS DEM_PRON_MD DEM_PRON_MP DEM_PRON_MS") NOUN_SUFFIX = oneOf("NSUFF_FEM_DU_ACC NSUFF_FEM_DU_GEN NSUFF_FEM_DU_NOM NSUFF_FEM_PL NSUFF_FEM_SG NSUFF_MASC_DU_ACC NSUFF_MASC_DU_GEN NSUFF_MASC_DU_NOM NSUFF_MASC_PL_ACC NSUFF_MASC_PL_GEN NSUFF_MASC_PL_NOM") NOUN_SUFFIX_IDAFA = oneOf("NSUFF_FEM_DU_ACC_POSS NSUFF_FEM_DU_GEN_POSS NSUFF_FEM_DU_NOM_POSS NSUFF_MASC_DU_ACC_POSS NSUFF_MASC_DU_GEN_POSS NSUFF_MASC_DU_NOM_POSS NSUFF_MASC_PL_ACC_POSS NSUFF_MASC_PL_GEN_POSS NSUFF_MASC_PL_NOM_POSS") POSSESSIVE_PRONOUN = oneOf("POSS_PRON_1P POSS_PRON_1S POSS_PRON_2FS POSS_PRON_2MP POSS_PRON_2MS POSS_PRON_3D POSS_PRON_3FP POSS_PRON_3FS POSS_PRON_3MP POSS_PRON_3MS") PRONOUN = oneOf("PRON_1P PRON_1S PRON_2FS PRON_2MP PRON_2MS PRON_3D PRON_3FP PRON_3FS" "PRON_3MP PRON_3MS") lexical = Word(alphas+"$"+"<"+">"+"|"+"}"+"{") NOUN = Literal("NOUN") DET = Literal("DET") ADJ = Literal("ADJ") NOMINAL = lexical + NOUN + Optional(lexical + NOUN_SUFFIX) import sys infile = open(sys.argv[1]).read() # This is for the definite NP made up of a noun + an adjective # An example is Alrjl AlmHtrm AL = Literal("Al") DEFINITE_NOUN = AL + DET + lexical + NOUN + Optional(NOUN_SUFFIX) DEFINITE_ADJECTIVE = AL + DET + lexical + ADJ + Optional(NOUN_SUFFIX) NOUN_ADJ = DEFINITE_NOUN + ZeroOrMore(DEFINITE_ADJECTIVE) DEMON_NOUN_ADJ = Optional(DEMONSTRATIVE) + NOUN_ADJ # Now for the indefinite NP # Example: rjl mHtrm INDEFINITE_NOUN = lexical + NOUN + Optional(NOUN_SUFFIX) INDEFINITE_ADJECTIVE = lexical + ADJ + Optional(NOUN_SUFFIX) INDEF_NOUN_ADJ = INDEFINITE_NOUN + ZeroOrMore(DEFINITE_ADJECTIVE) pattern3 = OneOrMore(NOMINAL) + lexical + DET + NOMINAL #pattern2 = NP = pattern3 | DEMON_NOUN_ADJ | INDEF_NOUN_ADJ # get the file import sys infile = open(sys.argv[1]).read() tokens = NP.scanString(infile) for x in tokens: for i,v in enumerate(x[0]): if i%2 == 0: print v, print "\n" -- لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد الغزالي "No victim has ever been more repressed and alienated than the truth" Emad Soliman Nawfal Indiana University, Bloomington ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sorting algorithim
"tonyon boyo" wrote i know how to print for bubble sort in python, is there a way to print each pass in the sort so i can see what happens at each step? thanks Yes add a print statement inside the looop that prints the list being sorted. def bubblesort(list): for passes in range(len(list)-1, 0, -1): You could use list slicing here: for passes in list[-2::-1]: But you might find using a while loop is easier than a for loop for bubble sort -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to compile python3.0
Shaofeng NIu wrote: I tried to compile and install python3.0 from source,but after "make",it shows: Python build finished, but the necessary bits to build these modules were not found: _dbm _gdbm _hashlib _sqlite3 _ssl _tkinter bz2readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. Could anybody tell me how to install these modules?Thank you! My OS is Ubuntu 8.10 In Python 2.X, modules are skipped when you do not have the necessary libraries and headers installed. Assuming the same happens with Python 3.0, the solution would be to install the libraries and headers needed by the above modules before compiling Python 3.0. These libraries and headers are available as seperate "XYZ-devel" packages for your OS. W.r.t. what libraries/packages you really need, some of them are guessable, bz2 eg will probably need a bz2-devel or a bzip2-devel package, etc. Others may be more difficult to guess For those, you may want to examine the function mentioned in the output to understand what libraries/headers it is missing. Note that different linuces use slightly different names to refer to some library, so the names may not match exactly. Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to compile python3.0
Shaofeng NIu wrote: I tried to compile and install python3.0 from source,but after "make",it shows: Python build finished, but the necessary bits to build these modules were not found: _dbm _gdbm _hashlib _sqlite3 _ssl _tkinter bz2readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. Could anybody tell me how to install these modules?Thank you! My OS is Ubuntu 8.10 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor This worked for me on Ubuntu 8.04: $ sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev g++ gcc Solution for _dbm $ wget -c http://bugs.python.org/file12234/dbm.diff $ patch -p0 < dbm.diff $ sudo apt-get build-dep python2.5 $ make $ sudo make install Regards Dayo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] how to compile python3.0
I tried to compile and install python3.0 from source,but after "make",it shows: Python build finished, but the necessary bits to build these modules were not found: _dbm _gdbm _hashlib _sqlite3 _ssl _tkinter bz2readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. Could anybody tell me how to install these modules?Thank you! My OS is Ubuntu 8.10 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor