3,386 Posted Topics
Re: wrong, check again [CODE]a = 'abc' print 'd' or 'e' in a print 'd' in a or 'a' in a print any(c in a for c in 'da') [/CODE] | |
Re: Wikipedia does not mention your terms:[url]http://en.wikipedia.org/wiki/Wiener_process[/url] Additionally this looks quite purely mathematics/physics question. | |
Re: I do not understand what you mean by (0, 17), I do not see anything like that in your code. You are suppose to update letter_g aren't you? | |
Re: How are you launching the program? python <scriptname> should be OK, in order to treat the script as executable in Linux you need to add shebang line in beginning of script and probably also chmod it executable. Also the script as you posted it is indented, which is not acceptable … | |
Re: You seem to have spaces between the parts of answer, probably answer should be direct concatenation of parts. | |
Re: That is curious request, usually that kind of role is only for classes not functions. You can treat any funcition as object (because they are) and you can add attributes to them, which are accessible from outside the function. Usually you use class or dictionary for that, though, except for … | |
Re: decimal module has suppport of very long and accurate numbers, but I am not sure if it is enough for such extreme case. Usually you can find ways to work on powers with modulo, standard python pow supports second argument for modulo. | |
Re: There is not something similar than wxLB_MULTIPLE for ListBox? | |
Re: I do not think I understand what is all this fuss but maybe something like: [CODE] def add_mark(self, predmet,mark): for p in self.predmety: #print p.nazov if p.nazov == predmet: p.add_znamka(mark) break else: raise ValueError("%s not taking course %s" % (self.name, predmet)) [/CODE] | |
Re: I do not understand why you set up iterator if you only use the first value anyway. | |
Re: This [url]www.gnu.org/software/octave/doc/interpreter/Simple-File-I_002fO.html[/url] seems to indicate that Octave can handle such files. One idea would be to use Sage environment, so you could use various tools in Python/matplolib, octave etc. Overkill for your needs maybe, but why not. | |
Re: See for example [url]http://www.oracle.com/technetwork/java/javame/javamobile/training/jmesdk/index.html[/url] | |
Re: Something along these lines? [CODE]>>> ctrl = 5 >>> k = 7 if ctrl == 5 else None >>> k 7 [/CODE] | |
Re: How about simply ziping the lists together: [CODE]import numpy as np spec_dtype = np.dtype([ ('wavelength', float), ('intensity', float) ]) wavelengths=[300.00, 200.00, 100.00] intensities=[23, 32, 43] mydata = np.array(zip(wavelengths, intensities), dtype=spec_dtype) print(mydata)[/CODE] | |
Re: [CODE]def count_data_types(a_list): answer = [0,0,0] for x in a_list: for ind, t in enumerate((int, float, str)): if t == type(x): answer[ind] += 1 return answer print(count_data_types(['v', 3.0,1, 'etc'])) [/CODE] | |
![]() | Re: Why so complicated? You could simply do like: [CODE]>>> d = {1:1, 2:4, 3:8, 4:16} >>> print[k for k in d if d[k]==8] [3] >>> [/CODE] |
Re: You can indent the announcement inside the loop. | |
Re: Yes convert the number to int or float and do not add result to string. | |
Re: num1 and num2 do not change inside the while loop so exit condition is never fullfilled. | |
Re: Python has not function Length, it does have len. You should post your code (do use the CODE tags) | |
Re: Why you are deleting instead of changing the size of rectangle? I do not see you changing the current tag anywhere, so all shapes will have it set. | |
Re: Correct indention would help a lot. You would learn by figuring it out yourself, here anyway minimal change version that works (raw_input if you use Python2 otherwise keep input): [CODE]def names(): name=raw_input("Please enter a full name with 3 names, separated by one space: ") space=name.find(" ") first=name[:space] last=name.rfind(" ") middle=name[space+1:last] … | |
Re: why not use os.chdir? | |
Re: What you have studied until now on subject? [url]http://www.blog.pythonlibrary.org/2010/07/16/python-and-microsoft-office-using-pywin32/[/url] and [url]http://code.activestate.com/recipes/279003-converting-word-documents-to-text/[/url] looks good places to start and do your experiments with your data and different way of processing. | |
Re: [CODE]def sentinel(s='!'): t = inp = raw_input('Enter some text: ') while inp != s: inp = raw_input('More text: ') t += inp return t if __name__ == '__main__': print(sentinel()) [/CODE] | |
Re: In order to help you without giving ready answer here is your code adapted to do math functions from textfile: [CODE]import math f = open("funcs.txt","r") for line in f: print line, line = line.strip() data = line.split(" ") if data[0] in dir(math) and len(data) == 2: print eval("math.%s(%s)" % tuple(data)) … | |
![]() | Re: Here seems to be code for linux using ldap and what it takes to install the necessary software: [url]http://marcitland.blogspot.com/2011/02/python-active-directory-linux.html[/url] I do not know if there is quality controlled of Python code available except of course if you hire reliable and knowledgable programmer to review the code. Here is one article … ![]() |
Re: Is it sure that the site is not using utf8, for example? This is printing ok in Python 2.7.2/Windows XP, both typed from keyboard and copied from this post in DaniWeb. [CODE]# -*- coding: cp1252 -*- print 'Viva España!' print 'español' [/CODE] | |
Re: You are printing inside loop instead of out of it, also you only keep the position of last occurance of vowel, use the setdefault method or defaultdict from collections module: [CODE]def duplicount(): import string word = raw_input('Please enter your word:') vowels = ['a','e','i','o','u'] count = {} for index,letter in enumerate(word): … | |
Re: What is your current knowledge of Hadoop? Compared for example with [url]http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/[/url] | |
Re: [CODE]os.path.splitext(os.path.splitext('Corn-Curl-Server_Backup_2002-02-23.tar.gz')[0])[0].split('_')[-1][/CODE] then use my snippet: [url]http://www.daniweb.com/software-development/python/code/277460/1196224#post1196224[/url] | |
Re: SOAPpy documentation guide.html seems to have description in second chapter (ZSI-2.1-a1/doc/guide.html#SECTION003000000000000000000) Also [url]http://www.xml.com/pub/a/ws/2002/06/12/soap.html[/url] refered in main documentation seems interesting for your intentions. | |
Re: More simply let's see what it would mean if the statement was true: 2 ^(2n) = O(2^n) 2 ^ n * 2 ^ n = c * 2 ^ n 2 ^ n = c which is obviously wrong as it means n is constant. | |
Re: Next time please push start a new thread button from the Python groups main list so your post will be better seen. I push this (code) here, that gives nice looking fixed width text and keeps the white space, which is so essential for Python. Use also that next time … | |
Re: You should connect the marks to student, not subject, each student have their own marks. | |
Re: [QUOTE=vegaseat;1254825]Thanks for pointing out the flaw. I worked on it for a while and also modified it to work with Python3. Here is the new working code, quite a bit faster too ... [/QUOTE] This new version does not seem as fast as this part of example codes from shedskin … | |
Re: Simply using rhe python [iCODE]del[/iCODE] command does not work? | |
Re: We have here code snippet by Gribouillis [url]http://www.daniweb.com/software-development/python/code/260268[/url] to restart running program, but usually you should be able to just exit from mainloop and restart by putting the call to mainloop in while loop. | |
Re: Nice ihatehippies, I only unified the with to produce lines to output immediately to avoid temporary list (if you do lot of processing it might still pay off to use one and output from that), changed the name aDirectory to follow PEP8 convetion of words joined by underscore and removed … | |
Re: Maybe [URL="http://www.jython.org/"]Jython[/URL] comes closest? With SWING GUI app, I mean. Or use web framwork for web app. | |
Re: I think, that we could include 0 as valid power, couldn't we? If the power has fraction the recursion goes to negative so we could simplify the power ignoring the posibility of complex values (comparision will raise automatic error for complex power) [CODE]def power(x,y): if y < 0: raise ValueError('Power … | |
Re: This came up recently and I wan to say that there is 99% chance that you are doing something stupid. Usually one would use dictionary, like [CODE]import string d = dict((a,c) for c,a in enumerate(string.lower, 1)) [/CODE] | |
Re: Yes, that's true Beautifullsoup can take regular expressions. I have not used it myself but there seems to be quite a lot documentation and examples around. Where you learned to use it? Maybe there is something to learn still, from for example [url]http://www.crummy.com/software/BeautifulSoup/download/2.x/documentation.html[/url] | |
Re: You have nothing such in your code posted. Are you sure you are not trying to run log of your interactive session, instead of script file? | |
Re: [CODE]>> my_globals = dict(a=1, b=2) >>> ranking = ['a', 'b'] >>> x = eval("%s + %s" %(ranking[0], ranking[1]), my_globals) >>> x 3 >>>[/CODE] I bet you are not using the correct approach in your code, what you are trying to do to do this kind of indirection? | |
Re: I would not consider this your style of declaration without declared parameters to be so high level, brings my mind mostly memory of MIXAL programming form university time (symbolic assembler). In proper programming language you would not get access for example the name inputed. | |
Re: Are you using numpy/scipy/matlab for yor data? | |
Re: [CODE] >>> print('3' in '13 12'.split()) False >>> print('3' in '13 12 333 453 2 3 433'.split()) True [/CODE] | |
Re: Small example showing your current level could be usefull to give you correct advice. What books, tutorials have you learned? You have experimented with example code in Python interpreter to really learn the things, have you not? What you think of the code in the code snippet section of Python … | |
Re: You should give one failed attempt with output and how you would like to change it. It is too unclear otherwise, as there is no reason to have difficulty. If using strings is clumsy, just remember that there is many choises, some should fit your use case: "string" delimited single … |
The End.