3,386 Posted Topics

Member Avatar for PlUmPaSsChIcKeN

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.

Member Avatar for PlUmPaSsChIcKeN
0
238
Member Avatar for peste19
Member Avatar for Y DIY

Are you really only interested files named "promptList"? Why use fnmatch then?

Member Avatar for Y DIY
0
71
Member Avatar for radiumc

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.

Member Avatar for radiumc
0
146
Member Avatar for peste19
Member Avatar for TrustyTony
0
179
Member Avatar for pythondaniweb
Member Avatar for jonjacob_33_0

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 …

Member Avatar for TrustyTony
0
2K
Member Avatar for bonyjohn

You could do some help in developing the shedskin Python to C++ compiler or help to migrate major libraries to Python 3 (like numpy)

Member Avatar for TrustyTony
-1
150
Member Avatar for giancan

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]

Member Avatar for giancan
0
141
Member Avatar for Joe Shmoe

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'] >>> …

Member Avatar for Taywin
0
220
Member Avatar for silvercats

[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.

Member Avatar for TrustyTony
0
123
Member Avatar for sofia85

[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 …

Member Avatar for JoshuaBurleson
0
4K
Member Avatar for Y DIY

[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)

Member Avatar for Y DIY
0
3K
Member Avatar for felix001

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 …

Member Avatar for felix001
0
391
Member Avatar for kaskoraja

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 …

Member Avatar for TrustyTony
0
155
Member Avatar for Tourbillion

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.

Member Avatar for TrustyTony
0
132
Member Avatar for Tourbillion

You are probably supposed to write out unicode characters not numbers in string format. See unichr function.

Member Avatar for TrustyTony
0
265
Member Avatar for Jburton881

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.

Member Avatar for TrustyTony
0
109
Member Avatar for Zssffssz

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])

Member Avatar for Zssffssz
0
233
Member Avatar for TrustyTony

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 …

0
216
Member Avatar for nw240x

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

Member Avatar for nw240x
0
425
Member Avatar for Khodz

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', …

Member Avatar for Khodz
0
3K
Member Avatar for francisgan9

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() : …

Member Avatar for JoshuaBurleson
0
1K
Member Avatar for Joe Shmoe

What is purpose of ord at line 8? You only want to sort single characters? Shouldn't you pass theList as parameter to function?

Member Avatar for JoshuaBurleson
0
116
Member Avatar for sjgood

Shouldn't the word loop be inside line loop? You have not the asked parameters.

Member Avatar for JoshuaBurleson
0
330
Member Avatar for bsh6wc

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]

Member Avatar for TrustyTony
0
138
Member Avatar for ljvasil

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.

Member Avatar for TrustyTony
0
175
Member Avatar for xploxstriker

You can not take len of integer values, wouldn't you need to check letters in word? You also forgot CODE tags.

Member Avatar for snippsat
0
592
Member Avatar for Lomholdt

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 …

Member Avatar for JoshuaBurleson
0
154
Member Avatar for JoshuaBurleson
Member Avatar for JoshuaBurleson
Member Avatar for huntin4hitters
Member Avatar for adrain91

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 = …

Member Avatar for adrain91
0
110
Member Avatar for programing

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 …

Member Avatar for trin12345
0
178
Member Avatar for mbox_96

[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 …

Member Avatar for TrustyTony
0
151
Member Avatar for josko91

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]

Member Avatar for josko91
0
300
Member Avatar for woooee

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 …

Member Avatar for TrustyTony
5
568
Member Avatar for syjytg
Member Avatar for Tyler212
Member Avatar for asong
Member Avatar for Riteman
Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
1
937
Member Avatar for davehe
Member Avatar for Tcll

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++ …

Member Avatar for JoshuaBurleson
0
2K
Member Avatar for bigredaltoid

> 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 …

Member Avatar for TrustyTony
0
405
Member Avatar for M.S.

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 …

Member Avatar for M.S.
0
6K
Member Avatar for JoshuaBurleson
Member Avatar for JoshuaBurleson
0
217
Member Avatar for rohitshukla
Member Avatar for henky2011

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.

Member Avatar for TrustyTony
0
589
Member Avatar for jagan605

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).

Member Avatar for TrustyTony
0
197

The End.