3,386 Posted Topics
Here is experiment of how VM and Swing UI manage the sort test posted previously, instead of CPython and Tkinter. The timing is not so sweet, but at least no Java required! [CODE]K:\jython2.5.2>java -jar jython.jar swing_test.py 256000 words generated in 10.93 s Sorted in 1.68 s List prepared in 22.71 … | |
Re: What [B]how[/B] have you tried to do it? Post your code and we can see what is your problem Tony | |
Re: I proved the first pieces of code in Lazarus environment for comparison. I made the Buttons to show the finishing times after execution of the function finished. | |
Here is code to execute these printing commands from file: [CODE]talk("How Are You") bark("I am fine") bark("...and how are you") snarl("...sorry I asked") [/CODE] from file INPUT, do printing of results to screen without tags and to file with tags, and open the html output with webbrowser. | |
Re: I have feeling that you are better of reverse engeneering the code from scratch from description of what the code does. That is higher level and you produce more idiomatic and clear Python code. You could find that you can accomplish everything with minimal clue code by using 0ython standard … | |
Re: I think nobody understand what you want. Tell input and expected result. | |
I got a look one huge Java code suggestion from one [URL="http://www.daniweb.com/software-development/python/threads/86608/1525822#post1525822"]newbie high jacker of old thread[/URL], so I had to write this code. [url]http://oeis.org/A001235[/url] (for values with [B]minimum [/B]2 ways, first difference is 87539319 with three ways. You can of course change the if part of the print to … | |
I did this code to compare to Delphi code in Delphi forum [URL="http://www.daniweb.com/software-development/pascal-and-delphi/threads/357771"]TListBox and sorting[/URL] which ran in my computer compiled in free Lazarus environment at time 7,235 s for generate and insert to listbox, 13,265 s sorting the listbox. | |
Re: Are you not allowed to use dict or int? You have names in capital letters but I do not see any class definitions (Capitals are reserved by convention for defining classes). Could you explain how lines 85...90 (Python ranges are not including the last number ;)) work? I would not … | |
Re: Small nit pick, vegaseat. Because your use of os.path.join at line 10, looks like path[B]s[/B] variable is scalar and should be better named in singular, path, to not to be misleading. | |
Re: Give example data so we can discuss best data structure for it. Often dictionary does the job. Usong numpy arrays is possible but you must be carefull not to do too much conversions between numpy and normal lists. Often it is better to do calculations in numpy form but return … | |
Re: Do the command first from command line. I think you should have each line of code quoted or alternatively pass the name of script file. I also do not see much benefit from this compared to saving the paths to configuration file as you are giving anyway long absolute path … | |
Re: Also you can do above process for [url]http://pypi.python.org/packages/source/d/distribute/distribute-0.6.15.tar.gz#md5=ea52e1412e7ff560c290266ed400e216[/url] run the distribute_setup.py with python32, after you can run easy_install: [CODE]C:\Python32>Scripts\easy_install.exe pep8 Creating c:\python32\lib\site-packages\site.py Searching for pep8 Reading http://pypi.python.org/simple/pep8/ Reading http://github.com/cburroughs/pep8.py/tree/master Reading http://github.com/jcrocholl/pep8 Best match: pep8 0.6.1 Downloading http://pypi.python.org/packages/source/p/pep8/pep8-0.6.1.tar.gz#md5= 49380cdf6ba2e222e8630cb0afe29d66 Processing pep8-0.6.1.tar.gz Running pep8-0.6.1\setup.py -q bdist_egg --dist-dir c:\docume~1\veijal~1.yks\loc als~1\temp\easy_install-r4nmr_\pep8-0.6.1\egg-dist-tmp-r0zvr6 Adding pep8 0.6.1 … | |
Re: It is used for bitwise exclusive or. So 1 ^ 1 = 0 and 0 ^ 0 = 0 and 1 ^ 0 = 1 and 0 ^ 1 = 1. | |
Re: Why do not use the function you defined by having parameters and return value instead of print? int is better (safer) than eval on user input. | |
Re: You can put zip file (egg file is also one with aggreed structure, but that is not acceptable for package) to PATH or PYTHONPATH and import package or module normally from Python interpreter without unpacking. .egg file is also zip file with fixed format for scripts and can also be … | |
Re: You are not likely to get answer without informing us about your special environment (link to it) and some code of your own efforts and error messages. | |
Re: Maybe it would help if you could for examle compare your requirements with what pySnack offers [url]http://www.speech.kth.se/snack/[/url] | |
Re: [http://en.wikipedia.org/wiki/Pythagorean_triple](http://en.wikipedia.org/wiki/Pythagorean_triple) and [http://mathworld.wolfram.com/PythagoreanTriple.html](http://mathworld.wolfram.com/PythagoreanTriple.html) are excellent references. You just make your code and ask any question of possible stumbling blocks (with code-tags). | |
Re: It is unlikely that the words have only one translation so you are likely to need to deepen the definition value to list of lists or tuple. Also translation part is likely to need quoting or alternatively I find it convenient to use semicolon as separator in text file so … | |
Here version of TicTacToe demo [URL="http://www.daniweb.com/software-development/python/threads/357974/1526474#post1526474"]code by wooeee[/URL] with packing style, which is more familiar for me. Also fixed indents and made it run also with Python 3. | |
Re: You of curse start a new file in the IDLE editor window for the permanent code? Command line is for experiments and testing only. Finally you should run your code directly from command line to test the real behaviour of the program. Also the speed the program runs directly without … | |
Re: This seems to get there, but I do not know if it is the most beautiful method: [CODE]# explore the tix.ComboBox() # the Tix (Tk Interface Extension) module comes with the # Python27 and Python31+ installation try: import Tix as tix # Python27 except ImportError: import tkinter.tix as tix # … | |
Re: I am not going to give you ready answer, but if you are able to learn this my different style code for information: [CODE]from __future__ import print_function first_move, second_move = 2,1 place = (3, 7) legal_moves = tuple((place[0] + adiff, place[1] + bdiff) for adiff, bdiff in ((first_move, second_move), (second_move, … | |
Re: What you can then tell about the biggest possible [B]smallest[/B] factor, when you know that we are dealing only with integers? Give some effort first yourself. | |
Re: This list .jpg .JPG, .jpeg etc file in current folder: [CODE]import os exts = '.jpg', '.jpeg' files = os.listdir(os.curdir) print([filename for filename in files if filename.lower().endswith(exts)])[/CODE] | |
Re: I do not see connection of the rest of the text with the beginning of your description. If you have one value per pixel, then 300x300 = 90000 divide 10x10 = 100 boxes of 30x30 = 900. Pixel in coordinates x,y belongs to box x // 30, y // 30. … | |
Re: Nice work wooeee! Few nit pits though: The [] has automatic line continuation and so the ugly \ are not needed at line 60-61 and you have accidentaly dropped first letter of your code ([ICODE]from [/ICODE]became [ICODE]rom[/ICODE]). Maybe also to name BT as bt as it is an instance variable... … | |
Re: [CODE]for line in open('myfile.csv'): for word in line.split(','): # 0 tells that integer has base style Python style print "%s," % int(word, 0), print """ Output: 77, 21109, 923822080, 2210, 2466, 77, 21109, 923618816, 2210, 2466, 77, 21109, 923822080, 2210, 2466, 77, 21109, 923618816, 2210, 2466, """[/CODE] | |
Re: Do not high jack dead and buried threads, this is by the way Python not Java forum. Refer to by Python function I made for it today: [url]http://www.daniweb.com/software-development/python/code/358014/1526449#post1526449[/url], It is "slightly shorter" than "your" Java version. | |
Re: Except if you really want faster code with [URL="http://psyco.sourceforge.net/"]psyco[/URL], which requires Python 2.6.6. So I have 2.6, 2.7 and 3.2 in my computer. | |
Re: I once posted simple stack class as toy project to improve to code snippets. Recently I had one interesting experience replacing a stack class in real code as I had not that part of the code. i posted it as last reply of that thread. I hope it could be … | |
Re: I do not understand what you mean that you declared globally variables, which usually is not good idea for your information. You have not a single assignment in your main code only three function calls and print statements. Also you have not any global declarations. Your naming of functions and … | |
Re: [URL="http://docs.python.org/library/functions.html#filter"]filter [/URL]is built in function. | |
Re: In last code you are also putting value to matmod which is never used. | |
Re: Lost documentation? [url]http://ozark.hendrix.edu/~burch/cs/150/graphics-doc/#node13[/url] | |
Re: I understand that x86 is part of PC architecture and Pentium 4 is one example of computer hardware (the parts of computer you can not attach to email:) ) | |
Re: It seems to have return character from input in: [CODE]C:\Python32>python Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> name = input('Hello what is your name: ') Hello what is your name: Bob >>> … | |
Re: Difficult help because others have not same problem. I can do without problem: [CODE]>>> ysisoft = ftplib.FTP('ftp.ysisoft.com', user,password) >>> ysisoft.storbinary('STOR PyScripter-v2.4.1-Setup.exe',open("k:/Lataukset/PyScripter-v2.4.1-Setup.exe")) '226 Transfer complete' >>> [/CODE] After checking actually it did not transfer all. [CODE]ysisoft.dir('PyS*') -rw-r--r-- 1 ******** ftpusers 114110 Mar 28 01:18 PyScripter-v2.4.1-Setup.exe[/CODE] I forgot to include 'rb' for … | |
Re: I do not know exactly what you are after but on the page link of which you posted there is link list of available third party modules, which are comonly used fot web development like Django, TurboGears, CherryPy etc. If you want to do one simple cgi script, you can … | |
Re: Consider how could you do it with [URL="http://docs.python.org/library/functions.html#max"]key argument[/URL] There is one built in function, which puts numbers in same order as square, so even you do not need lambda or def. | |
Re: String has count method, but it is enough to split from hyphens and check the result length is three. You have still plenty of places for loops if int(day)+21>28. Assuming using datetime module is not allowed. Remember to mark your thread solved when you found your answer. | |
Re: Maybe you could check how they did it [url]http://libgmail.sourceforge.net/[/url] | |
[URL="http://www.pyside.org/"]PySide[/URL]: Python for Qt 1.0 released! The PySide team is thrilled to announce the release of PySide: Python for Qt version 1.0.0. In addition to the source code release, project community packagers have already released binary packages [developer.qt.nokia.com] for all major Linux distributions, Microsoft Windows, Mac OS X, and Nokia’s … | |
Re: [CODE]def sumall(*items): return sum(sum(item) if item.hasattr('__iter__') else item for item in items)[/CODE] To do deep sum. Unfortunately unable to test in my mobile. [CODE]sum((10, 29, 59)) # or define def sumall(*seq): return sum(seq)[/CODE] Maybe simpler to do what you did. | |
Re: Maybe this helps: [url]http://bytes.com/topic/python/answers/666061-can-python-access-windows-clipboard[/url] In linux I think you can write to /dev/clipboard | |
Re: They where just set at line 3 and 4 and displayed. What is your logic? Those lines look to be wrong place for me as you are inputing them before the menu. Could you present your plan (pseudo code) for the program. If you want to show drawn plan, it … |
The End.