3,386 Posted Topics

Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
0
506
Member Avatar for tony75
Member Avatar for TrustyTony
0
268
Member Avatar for Morten Brendefu

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.

Member Avatar for TrustyTony
0
2K
Member Avatar for TrustyTony

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.

0
311
Member Avatar for stan_l

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 …

Member Avatar for TrustyTony
0
299
Member Avatar for tky
Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
0
4K
Member Avatar for TrustyTony

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.

0
585
Member Avatar for diniboi

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 …

Member Avatar for diniboi
0
199
Member Avatar for parijat24

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.

Member Avatar for TrustyTony
0
202
Member Avatar for magnetpest2k5

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for stan_l

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 …

Member Avatar for stan_l
0
146
Member Avatar for e-papa

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 …

Member Avatar for e-papa
0
730
Member Avatar for Thropian

It is used for bitwise exclusive or. So 1 ^ 1 = 0 and 0 ^ 0 = 0 and 1 ^ 0 = 1 and 0 ^ 1 = 1.

Member Avatar for TrustyTony
0
91
Member Avatar for animanga

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.

Member Avatar for animanga
0
761
Member Avatar for G_S

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 …

Member Avatar for G_S
0
8K
Member Avatar for nightrev

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.

Member Avatar for TrustyTony
0
65
Member Avatar for SgtMe

Maybe it would help if you could for examle compare your requirements with what pySnack offers [url]http://www.speech.kth.se/snack/[/url]

Member Avatar for SgtMe
0
372
Member Avatar for brixton d

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

Member Avatar for TrustyTony
0
113
Member Avatar for dobleseis

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 …

Member Avatar for TrustyTony
0
233
Member Avatar for brixton d
Member Avatar for TrustyTony

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.

Member Avatar for e-papa
0
759
Member Avatar for TwistedVelocity

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 …

Member Avatar for richieking
0
145
Member Avatar for Lardmeister

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

Member Avatar for Lardmeister
0
1K
Member Avatar for jarograv

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

Member Avatar for TrustyTony
0
1K
Member Avatar for brixton d

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.

Member Avatar for TrustyTony
0
130
Member Avatar for debasishgang7

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]

Member Avatar for TrustyTony
0
109
Member Avatar for StevoLord

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

Member Avatar for TrustyTony
0
179
Member Avatar for levic22

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

Member Avatar for vegaseat
0
837
Member Avatar for blacknred

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

Member Avatar for e-papa
0
182
Member Avatar for ram.patil

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.

Member Avatar for TrustyTony
0
2K
Member Avatar for falgunpatel
Member Avatar for TrustyTony
0
106
Member Avatar for kacieh80

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.

Member Avatar for e-papa
0
407
Member Avatar for e-papa

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 …

Member Avatar for e-papa
0
359
Member Avatar for dare599z

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 …

Member Avatar for dare599z
0
187
Member Avatar for Emred_Skye

[URL="http://docs.python.org/library/functions.html#filter"]filter [/URL]is built in function.

Member Avatar for Emred_Skye
0
189
Member Avatar for Zaffron
Member Avatar for woooee
0
462
Member Avatar for avinash_545

Lost documentation? [url]http://ozark.hendrix.edu/~burch/cs/150/graphics-doc/#node13[/url]

Member Avatar for TrustyTony
0
104
Member Avatar for Wajed

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

Member Avatar for rubberman
0
12K
Member Avatar for Rockpile

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

Member Avatar for vegaseat
2
448
Member Avatar for rssk

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 …

Member Avatar for rssk
0
886
Member Avatar for Voidz

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 …

Member Avatar for TrustyTony
0
1K
Member Avatar for pink_872

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.

Member Avatar for TrustyTony
0
89
Member Avatar for xxhellothere

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.

Member Avatar for jice
0
163
Member Avatar for group256
Member Avatar for group256
0
174
Member Avatar for TrustyTony

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

Member Avatar for e-papa
2
420
Member Avatar for e-papa

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

Member Avatar for e-papa
0
511
Member Avatar for Bazal

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

Member Avatar for Bazal
0
273
Member Avatar for MUFC4life
Member Avatar for Atistus

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 …

Member Avatar for TrustyTony
0
140

The End.