3,386 Posted Topics
Re: You should add as first condition [CODE]MIO_outports1[i] in map_dict1[/CODE] to only access the other part if i is not in the dictionary. Actually thinking about what you want to accomplish, you just want to do: [CODE]test = any(d[int(MIO_outports1[i])] == int(Exp_map_inport[i]) for d in (map_dict1, map_dict2) if MIO_outports1[i] in d)[/CODE] Propably … | |
Re: os.environ should work normally in Jython: [url]http://www.jython.org/jythonbook/en/1.0/InputOutput.html[/url] | |
Re: Use dictionary or (defaultdict or Counter) from collections module if you are using recent version of Python. Post your code with code-tags and error messages for further advice. | |
This is hopefully example of properly tested code snippet (fingers crossed). | |
Re: you should pass it as parameter or read from stringvar | |
[I]This is one idea for thread of some lessons learned with experience about asking wrong question and answers 'thinking out of box'. If there is need to have sticky, I suggest that this thread become sticky development thread and moderator can move the upvoted suggestions for next part in new … | |
Re: There is possible to use file as output in print statement, but it becomes cumbersome with many prints. Maybe something like this? [CODE]with open("testfile.txt","w") as myfile: myfile.write("""\ line 1 line 2 line 3 """) with open("testfile.txt") as myfile: print(myfile.read()) with open("testfile2.txt","w") as myfile: for line in ("line 1", "line 2", … | |
Re: Could you explain your logic for deleteRear as the argument passed to it looks like NULL and if it was passed correct last node it's next pointer would be NULL, so how you are updating the second last node which actualy is needed? Of course after this helper function works, … | |
This is inspired for recent poster, who asked to check multiple strings in multiple files. | |
Re: Did you try to remove that file? ([Error 183] Cannot create a file when that file already exists: 'C:\\Windows\\system32\\config\\systemprofile') | |
Re: Or without modules: [CODE]def callable(f): try: f() return True except AttributeError: return False except TypeError: return False [/CODE] Or you can try to call it and catch exception in your code. But there is the collections.Callable, like vegaseat said. | |
Re: Line 8 should basically be same as [CODE]if number_entered[/CODE] if number_entered is actually string (as there would be mix up between 0 and False if it were actually number). Notice that something, like generator does not need to be empty, but can produce values, even it has not length. So … | |
Re: You typed wrong, but the way you typed in your message is correct, try again! IDLE 2.6.6 >>> ["ma%d" % n for n in range(2, 5)] ['ma2', 'ma3', 'ma4'] >>> (If you copy code to message push first (CODE) or paint the code and push it afterwards.) You are expecting … | |
Re: Are you not letting to take care of that? That is whole point of using StringVar. Of course you can slice out the char at insert point. You have read the code of vegaseat and me from code snippets and sticky messages, haven't you? See the advice linked in my … | |
Re: Could you give it another try. Your formatting is complitly mixed up. Also variables and functions have capitalized names normally recerved for object classes. Try to change names more descriptive and follow Python PEP8 standard when possible if you want help. Otherwise the helper should recode the program to understand … | |
Re: Your code is OK, but still I am impressed with this [URL="http://code.google.com/p/mpmath/"]mpmath module[/URL] included in Sympy, which you use for comparison. | |
To be more clear, I post this 'unnecessary optimization' of Vegaseat's code in new thread instead of end of old one. Just to show that this is even simpler than [URL="http://www.daniweb.com/software-development/python/code/363346/1554115#post1554115"]checking if given day is first weekday of the month[/URL]. | |
Little clean up of vegaseat's code for generating pi decimals. Added number of decimals desired and string type return for easy use with ''.join() | |
Re: I can not reproduce the problem, it must be somewhere else: [CODE]list1 = range(6) list2 = range(10,15) adict = dict(zip(list1,list2)) print(adict) """ Output in Python 2.7.1 and 3.2 {0: 10, 1: 11, 2: 12, 3: 13, 4: 14} """ [/CODE] | |
Re: And reason of the program and conversion? If you happened to study c++ and haven't learned it yet, there is only one correct answer: start to study it like you should. Others can not study for you. Also you do not give attribution of the original code, so if somebody … | |
Re: See decimal package: [CODE]>>> from decimal import * >>> getcontext().prec = 100 >>> Decimal(1).exp() Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427') >>> Decimal(1).exp()**34 Decimal('583461742527454.8814029027346103910190036592389411081057829421204316676742119505811471038583648840548') >>> [/CODE] It is missing trig functions however. | |
Re: Which documents you are using? According [URL="http://effbot.org/tkinterbook/entry.htm"]this documentation[/URL] the key is 'disabledbackground': [QUOTE]disabledbackground= Background to use when the widget is disabled. If omitted or blank, the standard background is used instead. (disabledBackground/DisabledBackground)[/QUOTE] | |
Re: Look here for number formatting: [url]http://www.delphibasics.co.uk/RTL.asp?Name=WriteLn[/url] [QUOTE]After each expression, you can add formatting options: :width Field width for strings + numbers :precision Decimal digits for numbers [/QUOTE] | |
Re: You could implement the [URL="http://en.wikipedia.org/wiki/Rotation_%28mathematics%29"]turtle movements[/URL] using complex number support in Python. | |
Re: I would also use printf format string properly (for example "%30s") instead of gotoxy. | |
Re: ... and the fly-weight pattern? | |
Re: How stable and random is the distribution of information you want to hash? Generally it is better idea to test random sample of real data and trying to find what could be the worst case in all input, and could the input change to be even worse fitting than that. … | |
Re: [COLOR="Red"]DaniWeb voluntaries help you with 10% of the effort that you show us (and 10% of 0% is not much!) ![/COLOR] | |
Re: How about finding directory of argv[0]? | |
Re: My algorithm would be something like this: 1) generate primes until 100 (100 * 100 = 10000), remove 2 (odd sum with other primes) 2) do double loop marking sums of two integers not marked before until 5000 marked (or just mark all sums 3) check that there was 5000 … | |
Re: You could try to click the button to restore the default association or reinstall the Python, it does not take long. Reinstall also reinstalls the Idle to right click menu. | |
Re: Looks normal graph minimal distance probability coloring the edges. | |
Re: Worked for me I just changed the name of image to one of minds and defind my_menu as simple print message. The message was printed OK. | |
Here is function to count the number of elementary events for sum of multiple throws of n-faced dice. | |
Re: Maybe somebody can help when sees your efforts (code or at least pseudo code) | |
Re: You are changing list, not tuple [CODE]>>> my_tuple (1, 2, 3, [4, 5, 6]) >>> type(my_tuple[3]) <class 'list'> >>> id(my_tuple[3]) 14727328 >>> my_tuple[3][2]=7 >>> id(my_tuple[3]) 14727328[/CODE] | |
Re: There is lots of info in Internet just google or check wikipedia. If you want to experiment (best way), read a tutorial and do stuff with [URL="http://sourceforge.net/projects/lazarus/"]Lazarus IDE for Free Pascal Compiler (FPC)[/URL] | |
Re: You Assign the file only if choice=1, so choice=2 crashes. It should be more obvious how many books must enter and which number is now. No need to limit program to ten books. Better to search by title than ask number of book. Program should repeat until user wants to … | |
Re: You have control statement with comparison and casts in your code! Also modulus was not allowed! | |
Re: How about while or for loop? | |
Re: I do not want to give out solution code to you but the counts of different outcomes from my correct solution (I am tonyjv in projecteuler also, 131 solved problems) are for debugging: Draws 865512042, pwins 7009890480, cwins 4355187942 pwins means Pete wins. And no extra modules were needed for … | |
Re: Could you tell how you tested each function during writing the code? We need proof that you did the code, so give us brief pseudo code or add plenty of comments. Surely it is pure chance that [url]http://www.daniweb.com/software-development/c/threads/331884/1417642#post1417642[/url] looks quite similar to your code. You seemed to have forgotten the … | |
Re: If you would multiply all values by constant, say 1000000, and divide solution accordingly, maybe it could work out to transform the problem to integer realm. | |
Re: (Default)Dictionary accessed by the first value could be good place to collet the values... Go ahead and show us your code. | |
Re: I do not see requirement of writing your own sum, min and max; so you better concentrate finding better system of taking any number of user input. Do not worry about maths if you are really allowed to use standard functions, but input values to list by apppend method. You … | |
Re: My C is bit rusty but in pseudo code (max_of_random - min_of__random)/(wanted_max-wanted_min)*random_value +wanted_min | |
Re: One thing you did not have is code-tags. Push the button and then paste your code. You are then more likely to get help as your code is enormously more understandable and faster to read. #include<iostream> #include<string> #include<fstream> #include<vector> using namespace std; void encrypt( char userinput[ ] ); // prototypes … | |
Re: Recomended free IDE seems to be however Code::Blocks for cross platform or Microsoft's free for testing VC Express. |
The End.