3,386 Posted Topics

Member Avatar for arindam31

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]

Member Avatar for TrustyTony
0
219
Member Avatar for kolibrizas

Wikipedia does not mention your terms:[url]http://en.wikipedia.org/wiki/Wiener_process[/url] Additionally this looks quite purely mathematics/physics question.

Member Avatar for kolibrizas
0
217
Member Avatar for Kitty17

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?

Member Avatar for Lucaci Andrew
0
696
Member Avatar for Fitchie

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 …

Member Avatar for Fitchie
0
295
Member Avatar for pwolf

You seem to have spaces between the parts of answer, probably answer should be direct concatenation of parts.

Member Avatar for TrustyTony
0
1K
Member Avatar for straylight

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 …

Member Avatar for TrustyTony
0
166
Member Avatar for weIIet

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.

Member Avatar for Thisisnotanid
0
2K
Member Avatar for floatingshed
Member Avatar for floatingshed
0
103
Member Avatar for vlady

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]

Member Avatar for vlady
0
123
Member Avatar for ljvasil
Member Avatar for ljvasil
0
177
Member Avatar for DavidB

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.

Member Avatar for TrustyTony
0
272
Member Avatar for jemz

See for example [url]http://www.oracle.com/technetwork/java/javame/javamobile/training/jmesdk/index.html[/url]

Member Avatar for jemz
0
209
Member Avatar for Thisisnotanid

Something along these lines? [CODE]>>> ctrl = 5 >>> k = 7 if ctrl == 5 else None >>> k 7 [/CODE]

Member Avatar for Thisisnotanid
0
181
Member Avatar for hughesadam_87

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]

Member Avatar for hughesadam_87
0
245
Member Avatar for unigrad101

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

Member Avatar for bumsfeld
0
137
Member Avatar for apeiron27

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]

Member Avatar for TrustyTony
0
41
Member Avatar for oberlin1988
Member Avatar for fishsticks1907
Member Avatar for woooee
0
109
Member Avatar for layneb131

num1 and num2 do not change inside the while loop so exit condition is never fullfilled.

Member Avatar for woooee
0
1K
Member Avatar for vimtojoe

Python has not function Length, it does have len. You should post your code (do use the CODE tags)

Member Avatar for ihatehippies
0
207
Member Avatar for Thropian

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.

Member Avatar for Thropian
0
177
Member Avatar for PythonIsCool

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

Member Avatar for TrustyTony
0
170
Member Avatar for Lucaci Andrew
Member Avatar for DJ-DOO

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.

Member Avatar for TrustyTony
0
145
Member Avatar for layneb131

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

Member Avatar for TrustyTony
0
1K
Member Avatar for scott_liddle

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

Member Avatar for Lucaci Andrew
0
174
Member Avatar for MarcusMaximus

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 …

Member Avatar for MarcusMaximus
0
286
Member Avatar for hokeysmoke

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]

Member Avatar for hokeysmoke
0
3K
Member Avatar for winnar

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

Member Avatar for woooee
0
238
Member Avatar for philipalex

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]

Member Avatar for philipalex
0
233
Member Avatar for wolf29

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

Member Avatar for TrustyTony
0
166
Member Avatar for hasanatkazmi

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.

Member Avatar for TrustyTony
0
890
Member Avatar for hystaspes

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.

Member Avatar for Rashakil Fol
0
31K
Member Avatar for jobs

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 …

Member Avatar for cementovoz
0
865
Member Avatar for vlady

You should connect the marks to student, not subject, each student have their own marks.

Member Avatar for vlady
0
120
Member Avatar for vegaseat

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

Member Avatar for Mavericks
1
3K
Member Avatar for arindam31
Member Avatar for arindam31
0
307
Member Avatar for Vkitor

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.

Member Avatar for woooee
0
14K
Member Avatar for pxalpine

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 …

Member Avatar for ihatehippies
0
168
Member Avatar for oiwah

Maybe [URL="http://www.jython.org/"]Jython[/URL] comes closest? With SWING GUI app, I mean. Or use web framwork for web app.

Member Avatar for TrustyTony
0
190
Member Avatar for pwolf

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 …

Member Avatar for TrustyTony
0
214
Member Avatar for ron126

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]

Member Avatar for snippsat
0
241
Member Avatar for Aung Myat

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]

Member Avatar for tomstratton
0
4K
Member Avatar for MBPFAN

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?

Member Avatar for MBPFAN
0
1K
Member Avatar for ron126

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

Member Avatar for ron126
0
240
Member Avatar for bodymassacre

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.

Member Avatar for TrustyTony
0
196
Member Avatar for manisha
Member Avatar for hamidvosugh

[CODE] >>> print('3' in '13 12'.split()) False >>> print('3' in '13 12 333 453 2 3 433'.split()) True [/CODE]

Member Avatar for Gribouillis
0
160
Member Avatar for Thisisnotanid

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 …

Member Avatar for Thisisnotanid
0
384
Member Avatar for floatingshed

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 …

Member Avatar for NewbieXcellence
0
2K

The End.