3,386 Posted Topics
Re: All your conditions are allways True as second part of or is not zero/False. Maybe you want case insensitive input? If so, use lower method to input and check only for small letters. BTW you where instructed to take numeric input which is in allowed values, not letters. | |
| |
Re: Are you really only interested files named "promptList"? Why use fnmatch then? | |
Re: We are glad to check your code, either push the (CODE) button right before doing paste or select the code you pasted and push the (CODE) button after. | |
Re: check itertools.groupby, use it with string.isalpha as the grouping function. | |
Re: ... Without word wrap?? This is word wrap. | |
Re: If you meant the words you wrote in your first post and want the function to modify the list values you can do it like this with full slice at left and generator producing value for each element on right side. Then you do not return value, but you print … | |
Re: You could do some help in developing the shedskin Python to C++ compiler or help to migrate major libraries to Python 3 (like numpy) | |
Re: Here idea of way: [CODE]>>> data = """132435 321350 35465162 6561516 546516 654613 65462133 6584652""".splitlines() >>> for line in data: line = [(-1)**ind*int(number) for ind, number in enumerate(line.split())] print line [/CODE] | |
Re: Yes, here I tested concept in Python, the weight does not put short words which start in alphabet later after the long ones with previous letters: [CODE=python]>>> def weight(word): return sum(ord(c)/float(ind1) for ind1, c in enumerate(word,1)) >>> sorted(('abc', 'aa', 'aac', 'acde','bed'), key = weight) ['aa', 'aac', 'abc', 'bed', 'acde'] >>> … | |
Re: [QUOTE=silvercats;1667713][CODE]http://en.wikipedia.org/wiki/Compiler Follow links; read.[/CODE] I've seen that article before.but looking for more detailed ones .[/QUOTE] You followed links, like [url]http://www.onyxbits.de/content/blog/patrick/introduction-compiler-construction-using-flex-and-yacc[/url] If you understand that example toy compiler, you should understand things quite deeply. | |
Re: [CODE]nt1 nt2 pred_effect pph2_class pph2_prob pph2_FPR pph2_TPR pph2_FDR G T prob_damaging deleterious 0.999 0.00692 0.111 0.0222 T A prob_damaging deleterious 0.999 0.00692 0.111 0.0222 A T prob_damaging deleterious 0.997 0.0208 0.332 0.0665 [/CODE] [QUOTE]I have shortened down the original file (which contains both more columns and rows). But the general … | |
Re: [QUOTE=pyguy62;1664981]Post code and ask specific questions, read forum rules and/or pytony's signature.[/QUOTE] Yes, show some effort. (Here you can click in my version of 'Daniweb for dummies' from my signature, if you wish) | |
Re: Use subprocess with Gribouillis Command class: [url]http://www.daniweb.com/software-development/python/code/257449[/url] For your extraction of last column I do not understand as you give no sample of output and what you want from that. The man page of Linux [url]http://linux.die.net/man/1/snmpwalk[/url] gives example output like this: sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m" sysObjectID.0 … | |
Re: How many Giga/Terabytes is this huge file? You need only to remove this specific lines, not certain element blocks? This code drops sections that are in discard_blocks set. [CODE]discard_blocks = {'*ELEMENT,TYPE=S4,ELSET=one' } with open('data.txt') as datain, open('data_out.txt', 'w') as dataout: writeout=True for line in datain: if line.rstrip() in discard_blocks: writeout … | |
Re: put your formula at line 4 instead of line and better to use int function instead of eval. Naming of your variables does not follow the Python conventions (PEP8). If you are free to choose, follow them, it produce more readable code. | |
Re: You are probably supposed to write out unicode characters not numbers in string format. See unichr function. | |
Re: You should post your code with `[CODE]` tags and exact error messages. It would also be nice if you told what you did to solve the problem. | |
Re: Why not inverst your time for real CPU instead of fancy hack? Or at least educational one like LC3: [url]http://www.daniweb.com/software-development/python/code/367871[/url] (and assembly forum is here: [url]http://www.daniweb.com/software-development/python/code/367871[/url]) | |
Here unsystematic play with linked list structure Object Oriented style. If you have performance critical code, please do not use this but use the superb faster than list [URL="http://pypi.python.org/pypi/blist/"]blist module[/URL] (including sorted versions of main data structures). As OO newbie (though with some 30 years of other programming), I wanted … | |
Re: import sys sys.path.append # does nothing from node import Node # ?? class None(length) #???????? class Node(object): ## if we had module node this overwrited Node | |
Re: Simply (and looks to me your original one should be same): [CODE]import itertools x = [['foo'], ['bar', 'baz'], ['quux'], ("tup_1", "tup_2"), {1:"one", 2:"two"}] print list(itertools.chain(*x)) print [element for sub in x for element in sub] [/CODE] Output: [CODE]['foo', 'bar', 'baz', 'quux', 'tup_1', 'tup_2', 1, 2] ['foo', 'bar', 'baz', 'quux', 'tup_1', … | |
Re: See my signarture linked post on some hints on using this forum, especially how to use code tags. [CODE]# phonebook dictionary phonebook={'francis':'francis@gmail.com','iris': 'iris@gmail.com','karen':'karen@gmail.com'} name=raw_input('what name you want to check :') # what you are checking print(phonebook.items()) # check if the name is in the dictionary if name in phonebook.items() : … | |
Re: What is purpose of ord at line 8? You only want to sort single characters? Shouldn't you pass theList as parameter to function? | |
Re: Shouldn't the word loop be inside line loop? You have not the asked parameters. | |
Re: Here two ways: [CODE]import random stuff = random.sample(range(10,1000,10), 20) print 'data: ', stuff print 'groups' for end in range(7, len(stuff)): print stuff[end-7:end] print 'more efficient' seven = stuff[:7] for end in range(7, len(stuff)): print seven del seven[0] seven.append(stuff[end]) [/CODE] | |
Re: Gives me syntax error at line update mydict2 After commenting it out it says it needs file to read, so I can not reproduce the problem. Next time push the CODE button right before pasting to get the tags right. | |
Re: You can not take len of integer values, wouldn't you need to check letters in word? You also forgot CODE tags. | |
![]() | Re: Are you sure that the function should print words, not return them. It seems strange that you overwrite the value of parameter at line 4 without using the original value. Also line 6 does nothing so you can remove that. words.txt does not look like list for me but more … |
Re: Does the friend [B]list[/B] bring anything to mind? | |
Re: If not that, try def search(self, event, val): | |
Re: I slightly pyTonysed the code, I got same as bro pyguy62 from your version. [CODE]#Python 2 compatibility from __future__ import print_function try: input = raw_input except: pass # valid 10 x 10 square cordinates valid = {a+str(b) for a in 'abcdefghij' for b in range(10)} combination = {'a1','b1','c3','c4','f7'} hits = … | |
Re: What part is tested and which function are you now testing? You should indicate the location of your bug or give only part of the program you work with which manifest the bug with hard coded state, input to produce bug, output you are getting, output you should get, what … | |
Re: [QUOTE=mbox_96;1663521]Hi, I got the solution I need...thanks [CODE]try: mySer.flushInput() s = "".join(["%2x" %(ord(c)) for c in list(mySer.readline())]) print int(s, 16) finally: print 'Close' mySer.close() [/CODE] regards, mbox_96[/QUOTE] Looks like you are doing something like: [CODE]try: s = [ord(c) for c in mySer.readline()] print s finally: print 'Close' [/CODE] in obfuscated … | |
Re: I myself have not used DOS for a long while, as now everything runs in Windows or Linux. I did find that old 2.4 version exist: [url]www.caddit.net/pythond/[/url] | |
Re: Thanks for sharing your knowledge, our dear brother wooeee (even you do not accept friendship requests). However I do not like those \ line continuations. They are not needed when you have parenthesis available, which have automatic continuation. Don't like those separarator comments so much either. Also I think that … | |
Re: row and column values set in get_integers are never used. | |
Re: Did you read recent posts in this forum? | |
Here is capital letter style caesar crypted message. We can simply try all possible shifts for first few words (ignoring punctuations, which is left as is). If both first words succeed we assume we cracked it. You could also use Vigenère encryption, but keeping non-letters is less simple, our Vigenère … | |
Re: You should return value from function, not print. | |
Re: Could be that that module you want would work with IronPython or what you say IronPython gurus? Or the program could be complied to library (dll in Windows) and used as Python library with [URL="http://docs.python.org/library/ctypes.html"]ctypes[/URL]. Or you could see if [URL="http://code.google.com/p/shedskin/"]shedskin[/URL] could manage to turn all your code to C++ … | |
Re: > start quote: >>> word3='' >>> for letter in word[::-1]: #which could also be "for letter in reversed(word):" word3+=letter >>>word3 'olleh' > end quote. This does not make much sence as you are building another copy of `word[::-1]`, which is allready the answer: word = 'Hello' print word[::-1] Professor probably … | |
Re: If you have not set, you can set dictionary used with that key to value and use in dictionary test or dictionary.haskey. Even for such short stuff simple list implementation should be enough. Here simple start: [CODE]from __future__ import generators class Set(dict): def __init__(self, *args): dict.__init__(self) self.update((v, True) for v … | |
Re: You are using after timer events as demonstrated in by color changing label demo snippet? | |
Re: Post your code and the error messages | |
Re: You basically look like doing nothing only outputting simple range to file. What is purpose of those import statements in begining, I see no reference to any module. | |
Re: I do not understand your use of l (and it is not only global variable, which is very rarely good practise, but also poor choice of variable name). |
The End.