Re: [Tutor] Retrieve data from log file
Abe Miranda wrote: > Hi there, > > I'm sorry to ask this, I tried and example that was posted in 2009 but I > couldn't make it work. I'm trying to parse a log file and retrieve what I > just need. > > Hope you can help me with this, this is part of the log file: > It repeats itself for every transaction and I need to extract from this > lines: > > [2011-10-12 21:02:43:383] DEBUG [BaseQualitasDaoWS: 86] > [http-80-1][clientThread-Thread-3] -wscall - hours:0.0 minutes:0.0 > seconds:3.0 & > [2011-10-12 21:02:43:462] DEBUG [RestController : 81] > [http-80-1][clientThread-Thread-3] - hours:0.0 minutes:0.0 seconds:16.0& > > this information: > > 2011-10-12 21:02:43:383 clientThread-Thread-3 hours:0.0 minutes:0.0 > seconds:3.0 > 2011-10-12 21:02:43:462 clientThread-Thread-3 hours:0.0 minutes:0.0 > seconds:16.0 > > Can this be done? I'd start with a few simple tests like with open("test.log") as instream: for line in instream: if line.startswith("["): parts = line.replace("[", "]").split("]") duration = parts[8].strip("& \n") if "hours" in duration and "minutes" in duration: duration = duration[duration.index("hours"):] time = parts[1] thread = parts[7] print "%s\t%s\t%s" % (time, thread, duration) and see if you get false positives/negatives. Refine as necessary. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] map one file and print it out following the sequence
> I think your final version of sortfile() might look something like: > > def sortfile(infilename=**INFILENAME, outfilename=OUTFILENAME): >infile = open(infilename, "r") >intext = infile.readlines() >outfile = open(OUTFILENAME, "w") >for chainid in CHAINID: >print("chain id = ",chainid) > sortoneblock(chainid, intext, outfile) >infile.close() >outfile.close() > $ python3 map-to-itp.py {'O4': '2', 'C19': '3', 'C21': '1'} C Traceback (most recent call last): File "map-to-itp.py", line 55, in sortfile() File "map-to-itp.py", line 17, in sortfile sortoneblock(chainid,intext,OUTFILENAME) File "map-to-itp.py", line 29, in sortoneblock f.write(line[1].strip() for line in temp) TypeError: must be str, not generator I don't know how to fix the writing issue. can I write the different chainID one into the same OUTFILE? Thanks, I attached the code I used below: #!/usr/bin/python3 import os.path LINESTOSKIP=0 CHAINID="CDEFGHI" INFILENAME="pdbone.pdb" OUTFILENAME="sortedone.pdb" DICTIONARYFILE="itpone.itp" mapping={} valuefromdict={} def sortfile(): intext=fetchonefiledata(INFILENAME) for chainid in CHAINID: print(chainid) sortoneblock(chainid,intext,OUTFILENAME) def sortoneblock(cID,TEXT,OUTFILE): temp = [] for line in TEXT: blocks=line.strip().split() if len(blocks)== 11 and blocks[3] == "CUR" and blocks[4] == cID and blocks[2] in mapping.keys(): temp.append((mapping[blocks[2]],line)) temp.sort() with open(OUTFILE,"w") as f: f.write(line[1].strip() for line in temp) def generatedictionary(dictfilename): text=fetchonefiledata(DICTIONARYFILE) for line in text: parts=line.strip().split() if len(parts)==8: mapping[parts[4]]=parts[0] print(mapping) def fetchonefiledata(infilename): text=open(infilename).readlines() if os.path.splitext(infilename)[1]==".itp": return text if os.path.splitext(infilename)[1]==".pdb": return text[LINESTOSKIP:] infilename.close() if __name__=="__main__": generatedictionary(DICTIONARYFILE) sortfile() > > > -- > > DaveA > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] problem with using set
i have two questions- 1.>>> removeLetter("hello", "l") >>>'heo' To tackle this problem i am using set so that i can remove duplicates. def removeLetter(word,letter) set(word).remove(letter) return ''.join(set(word)) I am not getting right answer.I think i am not using sets correctly.please help!!! Approach:- >>> a='hello' >>> set(a) set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i join the string, i will get the desired output. 2. >>> a='microsoft' >>> set(a) set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> print ''.join(set(a)) cfimosrt When i print "Hello", i get the output as "helo"(in same sequence) but when i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the outcome of set(a)?? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem with using set
What exactly do you intend to get as an output? Sent from my BlackBerry wireless device from MTN -Original Message- From: Praveen Singh Sender: tutor-bounces+delegbede=dudupay@python.org Date: Thu, 13 Oct 2011 10:44:53 To: Subject: [Tutor] problem with using set ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] map one file and print it out following the sequence
On 2011-10-13 15:09, lina wrote: $ python3 map-to-itp.py {'O4': '2', 'C19': '3', 'C21': '1'} C Traceback (most recent call last): File "map-to-itp.py", line 55, in sortfile() File "map-to-itp.py", line 17, in sortfile sortoneblock(chainid,intext,OUTFILENAME) File "map-to-itp.py", line 29, in sortoneblock f.write(line[1].strip() for line in temp) TypeError: must be str, not generator I don't know how to fix the writing issue. You should start to learn how to read the error messages :-). "write" just writes strings into files ("must be str") but you are calling it with an generator. I guess you wanted to use a list comprehension, but this is surrounded by square brackets: f.write([line[1].strip() for line in temp]) But list comprehensions create lists so you would have to convert the list to a string: f.write(str([line[1].strip() for line in temp])) But this would convert the whole list into one single string which you probably don't want (try it for yourself). IMHO it would be easier to iterate through "temp" and write each line separately: for line in temp: f.write(line[1]) "line[1]" is already a string including the newline ("\n"), so str() and strip() aren't necessary (remeber: "write" writes without automatic newlines). Is that what you want? can I write the different chainID one into the same OUTFILE? I'm not sure what you mean. Do you want something like: C D xxx xxx ... ("xxx" meaning the different lines)? Then you just have to write the corresponding chainID before the for-loop: f.write(cID + "\n") And you have to open the file in mode "a" (to append to an existing file) because otherwise you will overwrite the file with every new chainID you are processing: with open(OUTFILE, "a") as f: def sortoneblock(cID,TEXT,OUTFILE): Just a stylistic remark: It's better to use just lowercase for variable names and parameters. Uppercase names are usually just used for constants. Thus it's easier to distinguish them while reading the code. Bye, Andreas ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem with using set
Approach:- >>> a='hello' >>> set(a) set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i join the string, i will get the desired output. 2. >>> a='microsoft' >>> set(a) set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> print ''.join(set(a)) cfimosrt When i print "Hello", i get the output as "helo"(in same sequence) but when i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the outcome of set(a)?? = Are you required to use set? If you are not, I think the following will be easier. >>> 'hello'.replace( 'l', '' ) 'heo' >>> 'microsoft'.replace( 'o', '' ) 'micrsft' If you require set, you can do: >>> s = set("microsoft") >>> s set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> s.remove('o') >>> string = [] >>> for letter in 'microsoft': ... if letter in s: ... string.append( letter ) ... >>> ''.join( string ) 'micrsft' Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem with using set
+1 Ramit. Sent from my BlackBerry wireless device from MTN -Original Message- From: "Prasad, Ramit" Sender: tutor-bounces+delegbede=dudupay@python.org Date: Thu, 13 Oct 2011 11:09:24 To: tutor@python.org Subject: Re: [Tutor] problem with using set Approach:- >>> a='hello' >>> set(a) set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i join the string, i will get the desired output. 2. >>> a='microsoft' >>> set(a) set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> print ''.join(set(a)) cfimosrt When i print "Hello", i get the output as "helo"(in same sequence) but when i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the outcome of set(a)?? = Are you required to use set? If you are not, I think the following will be easier. >>> 'hello'.replace( 'l', '' ) 'heo' >>> 'microsoft'.replace( 'o', '' ) 'micrsft' If you require set, you can do: >>> s = set("microsoft") >>> s set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> s.remove('o') >>> string = [] >>> for letter in 'microsoft': ... if letter in s: ... string.append( letter ) ... >>> ''.join( string ) 'micrsft' Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] map one file and print it out following the sequence
On 10/13/2011 09:09 AM, lina wrote: I think your final version of sortfile() might look something like: def sortfile(infilename=**INFILENAME, outfilename=OUTFILENAME): infile = open(infilename, "r") intext = infile.readlines() outfile = open(OUTFILENAME, "w") for chainid in CHAINID: print("chain id = ",chainid) sortoneblock(chainid, intext, outfile) infile.close() outfile.close() $ python3 map-to-itp.py {'O4': '2', 'C19': '3', 'C21': '1'} C Traceback (most recent call last): File "map-to-itp.py", line 55, in sortfile() File "map-to-itp.py", line 17, in sortfile sortoneblock(chainid,intext,OUTFILENAME) File "map-to-itp.py", line 29, in sortoneblock f.write(line[1].strip() for line in temp) TypeError: must be str, not generator When you see an error message that describes a generator, it means you usually have a for-expression used as a value. At your stage of learning you probably be ignoring generators and list comprehensions, and just write simple for loops. So you should replace the f.write with a loop. for item in temp: f.write(something + "\n") One advantage is that you can easily stuff print() functions into the loop, to debug what's really happening. After you're sure it's right, it might be appropriate to use either a generator or a list comprehension. I don't know how to fix the writing issue. can I write the different chainID one into the same OUTFILE? Thanks, I attached the code I used below: #!/usr/bin/python3 import os.path LINESTOSKIP=0 CHAINID="CDEFGHI" INFILENAME="pdbone.pdb" OUTFILENAME="sortedone.pdb" DICTIONARYFILE="itpone.itp" mapping={} valuefromdict={} def sortfile(): intext=fetchonefiledata(INFILENAME) for chainid in CHAINID: print(chainid) sortoneblock(chainid,intext,OUTFILENAME) One way to get all the output into one file is to create the file in sortfile(), and pass the file object. Look again at what I suggested for sortfile(). If you can open the file once, here, you won't have the overhead of constantly opening the same file that nobody closed, and you'll have the side benefit that the old contents of the file will be overwritten. Andreas' suggestion of using append would make more sense if you wanted the output to accumulate over multiple runs of the program. If you don't want the output file to be the history of all the runs, then you'll need to do one open(name, "w"), probably in sortfile(), and then you might as well pass the file object as I suggested. def sortoneblock(cID,TEXT,OUTFILE): If you followed my suggestions for sortfile(), then the last paramter to this function would be outfile., and you could use outfile.write(). As Andreas says, don't use uppercase for non-constants. temp = [] #this writes the cID to the output file, once per cID outfile.write(cID + "\n") for line in TEXT: blocks=line.strip().split() if len(blocks)== 11 and blocks[3] == "CUR" and blocks[4] == cID and blocks[2] in mapping.keys(): if (len(blocks)== 11 and blocks[3] == "CUR" and blocks[4] == cID and blocks[2] in mapping ): Having the .keys() in that test is redundant and slows execution down quite a bit. "in" already knows how to look things up efficiently in a dictionary, so there's no use in converting to a slow list before doing the slow lookup. Also, if you put parentheses around the whole if clause, you can span it across multiple lines without doing anything special. temp.append((mapping[blocks[2]],line)) temp.sort() with open(OUTFILE,"w") as f: f.write(line[1].strip() for line in temp) See comment above for splitting this write into a loop. You also are going to have to decide what to write, as you have tuple containing both an index number and a string in each item of temp. Probably you want to write the second item of the tuple. Combining these changes, you would have for index, line in temp: outfile.write(line + "\n") Note that the following are equivalent: for item in temp: index, line = item outfile.write(line + "\n") for item in temp: outfile.write(item[1] + "\n") But I like the first form, since it makes it clear what's been stored in temp. That sort of thing is important if you ever change it. def generatedictionary(dictfilename): text=fetchonefiledata(DICTIONARYFILE) for line in text: parts=line.strip().split() if len(parts)==8: mapping[parts[4]]=parts[0] print(mapping) def fetchonefiledata(infilename): text=open(infilename).readlines() if os.path.splitext(infilename)[1]==".itp": return text if os.path.splitext(infilename)[1]==".pdb": return text[LINESTOSKIP:] infilename.close() if __name__=="__main__": generatedicti
Re: [Tutor] problem with using set
On 10/13/2011 10:44 AM, Praveen Singh wrote: 2. a='microsoft' set(a) set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) print ''.join(set(a)) cfimosrt When i print "Hello", i get the output as "helo"(in same sequence) but when i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the outcome of set(a)?? The set() function converts its input into a set. A set is not ordered in the usual way, but in such a way as to rapidly find whether a particular item exists already in the set, and insert it if not. Inserting a new item might totally rearrange the existing ones, set doesn't promise anything at all about the order. (Dictionaries are similar, but while set has only a key, dict has both key and value) A set has no value to the assignment as stated. Stick to lists. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem with using set
Original Message- From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of Prasad, Ramit Sent: Thursday, October 13, 2011 10:09 AM To: tutor@python.org Subject: Re: [Tutor] problem with using set Approach:- >>> a='hello' >>> set(a) set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i join the string, i will get the desired output. 2. >>> a='microsoft' >>> set(a) set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> print ''.join(set(a)) cfimosrt When i print "Hello", i get the output as "helo"(in same sequence) but when i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the outcome of set(a)?? = Are you required to use set? If you are not, I think the following will be easier. >>> 'hello'.replace( 'l', '' ) 'heo' >>> 'microsoft'.replace( 'o', '' ) 'micrsft' If you require set, you can do: >>> s = set("microsoft") >>> s set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) >>> s.remove('o') >>> string = [] >>> for letter in 'microsoft': ... if letter in s: ... string.append( letter ) ... >>> ''.join( string ) 'micrsft' == After further thought, I think you might want to keep one of each character and not remove them all. If so, see below. >>> string = 'microsoft' >>> dct = {} >>> for letter in string: ... dct[ letter ] = string.count( letter ) ... >>> for letter, count in dct.iteritems(): ... reversed_string = string[::-1] # reverse string to leave first occurrence ... reversed_string = reversed_string.replace( letter, '', count-1 ) ... string = reversed_string[::-1] # return it to normal ... >>> string 'microsft' If you do not care which duplicate character is left you can skip the lines with [::-1] and it will leave the last one in the string. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] ctypes and arrays of pointers
Hi, I have a question about ctypes. I am trying to call a C function but I am not able to construct the arguments in ctypes. I need to construct two pointers. Each is a pointer to an array of pointers to character values. I did it like this (I tried numerous ways; this seemed the cleanest way): >>> MAXSIZE = 10 >>> valueArrayPtr = ctypes.POINTER(ctypes.c_char_p) * MAXSIZE >>> valueArrayPtr >>> valueArrayPtrPtr = ctypes.POINTER(valueArrayPtr) >>> valueArrayPtrPtr >>> But this yields an error: : Don't know how to convert parameter .. Any idea what I am doing wrong? Below is more complete code. And once it works, can I simply use the ctypes as an iterable to retrieve the values? Thanks in advance! Albert-Jan import ctypes def getValueLabels(self, varName): MAXSIZE = 10 # Pointer to array of pointers to values valueArrayPtr = ctypes.POINTER(ctypes.c_char_p) * MAXSIZE valueArrayPtrPtr = ctypes.POINTER(valueArrayPtr) # Pointer to array of pointers to labels labelArrayPtr = ctypes.POINTER(ctypes.c_char_p) * MAXSIZE labelArrayPtrPtr = ctypes.POINTER(labelArrayPtr) # Pointer to number of values or labels numLabels = ctypes.c_int() numLabelsPtr = ctypes.byref(numLabels) # call C function with the following prototype: # int GetValueLabels(int handle, const char *varName, char ***values, char ***labels, int *numLabels) retcode = self.theLib.GetValueLabels(self.fh, varName, valueArrayPtrPtr, labelArrayPtrPtr, numLabelsPtr) # yields ArgumentError: argument 3: : Don't know how to convert parameter 3 Description This function gets the set of labeled values and associated labels for a short string variable. The number of values is returned as *numLabels. Values are stored into an array of *numLabels pointers, each pointing to a char string containing a nullterminated value, and *values is set to point to the first element of the array. Each value string is as long as the variable. The corresponding labels are structured as an array of *numLabels pointers, each pointing to a char string containing a null-terminated label, and *labels is set to point to the first element of the array. Parameter Description handle Handle to the data file varName Variable name values Pointer to array of pointers to values labels Pointer to array of pointers to labels numLabels Pointer to number of values or labels Cheers!! Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Pyinstaller Database
Hi guys: Im a beginner in coding and wanted to distribute some of my code to friends on linux distros. Pyinstaller works well enough. Theres a situation where I use pickle module to save data to an external file. The file is not a py file and when I use pyinstaller, it does nt compile the file too. Is there anyway I can make a none *.py file or use a databse file s that it is compiled too? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Pyinstaller Database
Hi guys: Im a beginner in coding and wanted to distribute some of my code to friends on linux distros. Pyinstaller works well enough. Theres a situation where I use pickle module to save data to an external file. The file is not a py file and when I use pyinstaller, it does nt compile the file too. Is there anyway I can make a none *.py file or use a databse file s that it is compiled too? On 13/10/2011, tutor-requ...@python.org wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > >1. Re: problem with using set (delegb...@dudupay.com) >2. Re: map one file and print it out following the sequence > (Dave Angel) >3. Re: problem with using set (Dave Angel) >4. Re: problem with using set (Prasad, Ramit) > > > -- > > Message: 1 > Date: Thu, 13 Oct 2011 15:18:24 + > From: delegb...@dudupay.com > To: "tutor@python.org" > Subject: Re: [Tutor] problem with using set > Message-ID: > > <263695032-1318519103-cardhu_decombobulator_blackberry.rim.net-1700908878-@b18.c12.bise7.blackberry> > > Content-Type: text/plain > > +1 Ramit. > Sent from my BlackBerry wireless device from MTN > > -Original Message- > From: "Prasad, Ramit" > Sender: tutor-bounces+delegbede=dudupay@python.org > Date: Thu, 13 Oct 2011 11:09:24 > To: tutor@python.org > Subject: Re: [Tutor] problem with using set > > Approach:- a='hello' set(a) > set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i > join the string, i will get the desired output. > > 2. a='microsoft' set(a) > set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) print ''.join(set(a)) > cfimosrt > > When i print "Hello", i get the output as "helo"(in same sequence) but when > i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the > outcome of set(a)?? > = > > Are you required to use set? If you are not, I think the following will be > easier. 'hello'.replace( 'l', '' ) > 'heo' 'microsoft'.replace( 'o', '' ) > 'micrsft' > > If you require set, you can do: > s = set("microsoft") s > set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't']) s.remove('o') string = [] for letter in 'microsoft': > ... if letter in s: > ... string.append( letter ) > ... ''.join( string ) > 'micrsft' > > > Ramit > > > Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology > 712 Main Street | Houston, TX 77002 > work phone: 713 - 216 - 5423 > > > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- > > Message: 2 > Date: Thu, 13 Oct 2011 11:43:15 -0400 > From: Dave Angel > To: lina > Cc: tutor@python.org > Subject: Re: [Tutor] map one file and print it out following the > sequence > Message-ID: <4e970713.6020...@davea.name> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 10/13/2011 09:09 AM, lina wrote: >> >> >>> I think your final version of sortfile() might look something like: >>> >>> def sortfile(infilename=**INFILENAME, outfilename=OUTFILENAME): >>> infile = open(infilename, "r") >>> intext = infile.readlines() >>> outfile = open(OUTFILENAME, "w") >>> for chainid in CHAINID: >>> print("chain id = ",chainid) >>> sortoneblock(chainid, intext, outfile) >>> infile.close() >>> outfile.close() >>> >> >> $ python3 map-to-itp.py >> {'O4': '2', 'C19': '3', 'C21': '1'} >> C >> Traceback (most recent call last): >>File "map-to-itp.py", line 55, in >> sortfile() >>File "map-to-itp.py", line 17, in sortfile >> sortoneblock(chainid,intext,OUTFILENAME) >>File "map-to-itp.py", line 29, in sortoneblock >> f.write(line[1].strip() for line in temp) >> TypeError: must be str, not generator >> >> > > When you see an error message that describes a generator, it means you > usually have a for-expression used as a value. > > At your stage of learning you probably be ignoring generators and list > comprehensi
Re: [Tutor] Pyinstaller Database
>Hi guys: >Im a beginner in coding and wanted to distribute some of my code to >friends on linux distros. Pyinstaller works well enough. Theres a >situation where I use pickle module to save data to an external file. >The file is not a py file and when I use pyinstaller, it does nt >compile the file too. Is there anyway I can make a none *.py file or >use a databse file s that it is compiled too? You can send them your entire source directory and it should work as long as they use a compatible Python version. Unless you have you need to ship/install libraries or complicated project, I see no reason to create an installer. That way you can send your pickled files without any issues. I know some projects (e.g. Sickbeard) do this; you just download from svn/github and run. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Job Scheduling package
Has anyone seen a python job scheduling framework that could provide the following features - Add/remove job from the queue - View job list - check job status - Run concurrent jobs. I am looking for something similar to coalition( http://code.google.com/p/coalition/) -- Harry ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Job Scheduling package
You could take a peak at these. Both work without external dependencies http://packages.python.org/APScheduler/#features http://pypi.python.org/pypi/TGScheduler/1.6.2 VInce On Thu, Oct 13, 2011 at 3:53 AM, harish bansal wrote: > Has anyone seen a python job scheduling framework that could provide the > following features > > Add/remove job from the queue > View job list > check job status > Run concurrent jobs. > > I am looking for something similar to > coalition(http://code.google.com/p/coalition/) > -- > Harry > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vince Spicer ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor