3,386 Posted Topics
Re: I think it is because Python import command do npt take extension of the file name and so the extension must be one which Python looks for. It is also quite simple to wrap dll calling like this [url]http://www.knowledgetantra.com/component/content/article/2-python/1-call-dll-function-in-python.html[/url] | |
Re: [QUOTE]repr(object)ΒΆ Return a string containing a printable representation of an object. For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval(), otherwise the representation is a string enclosed in angle brackets that contains the name … | |
Re: And what have you tried? Do not forget the CODE-tags. I do not get your second example. I coded the thing and this is what my program managed to produce from the two words. n n a a m e e s s p p l l a a c … | |
Re: Tested with PySide, worked by only changing PyQT4 to PySide. It did not like IDLE though, giving nothing more serious than crash reports, but directly running from command line was OK. | |
Re: Your function fails, please test your code before sending as code snippet (ask advice in normal thread first, when everything is tested, post it as snippet): [CODE]from __future__ import print_function, division """ADEGOKE OBASA, adegokeobasa@yahoo.com""" """this functions solves Quadratic equations using the quadratic formula""" from cmath import * delta = 1e-9 … | |
Re: There is code snippet here in Daniweb by Gribouillis if you really want what your title says: [url]http://www.daniweb.com/software-development/python/code/260268[/url] This statement is always True (same as 1) [CODE]>>> not 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 True >>> not … | |
Re: Difficult to help as you give only scrambled data. I do not know if I recovered the data scrambled correctly. What you would like to ask? [CODE]>>> fileOut = open('output.csv', 'w') >>> import csv >>> for row in data.items(): print row ('customername', 'bzip') ('aaddr2', 'bzip') ('invoicelatefeepct', 'bzip') ('aaddr1', 'bzip') ('aphone', … | |
Re: Something like this? [CODE]a = """>BIG_CLUSTER96 ENSTNIP00000002777 TETRAODON8 1 105 136 Ank NGCTPLHYAASKDRYEIALMLLENGADPNATD >BIG_CLUSTER96 ENSTNIP00000002777 TETRAODON8 1 141 169 Ank TPLHRASAKGNYRLIQLLLRQSASTNIQD >BIG_CLUSTER96 ENSTNIP00000002777 TETRAODON8 1 172 202 Ank GNTPLHLACDEERVEAAKLLVEHGASIYIEN >BIG_CLUSTER96 ENSTNIP00000002777 TETRAODON8 1 40 71 Ank RRTALHWACSAGHTDIVEFLLDVGAEVNLQDD >BIG_CLUSTER96 ENSTNIP00000002777 TETRAODON8 1 74 103 Ank WTPLHIAASAGREDIVRALISKGAQLNSVN """ data = [line.split() for … | |
Re: Maybe you understand from this interactive session by 'no comments' style: [CODE] >>> from math import * >>> sqrt(-1) Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> sqrt(-1) ValueError: math domain error >>> sqrt(-1+0j) Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> sqrt(-1+0j) TypeError: … | |
Re: Generally you give solutions in code snippets not do discussions. Of course sometimes some bugs are hiding in the code even you try to debug it well before posting as code snippet solution. Anyway here another section of my Project Euler utilities, actually the combination code is from wikipedia, it … | |
Re: First step for installlation is to get [URL="http://pypi.python.org/pypi/setuptools#files"]setup tools[/URL]. Then you just do [CODE]easy_install numpy[/CODE] or what ever. | |
Re: I assume you have source package as binary you can only run and be done with. If you are running Linux command line or similar with tar command you can issue command [CODE]tar xvzf package_name.tar.gz[/CODE] Then you cd to directory created and issue [ICODE]python setup.py install[/ICODE] | |
Re: [CODE]>>> histogram(([1,56],[2,67])) Histogram: No. Value Histogram 1 56 ******************************************************** 2 67 ******************************************************************* >>> [/CODE] Looks like you have quite good start, you only need to consider the correct scaling by finding the maximum count value before printing. | |
Re: [CODE]decimal.getcontext().prec = 9 now = "230.939809280" then = "230.939808600" print "%.9f" % (decimal.Decimal(now) - decimal.Decimal(then)) # -> 0.000000680 [/CODE] | |
Re: You mean [url]http://effbot.org/tkinterbook/radiobutton.htm[/url] ? | |
Re: Here is what could be considered 'behind the book correct answer' cheat to is_prime function from my utility module: [CODE]def is_prime(n): sqrt_n = int(n**0.5 + 0.5) if n == 2 or n == 3: return True elif n < 2 or n % 2 == 0 or n % 3 … | |
Re: Sounds like you should compare the strings for matches in same place or Longest Common Subsequence anywhere instead of just printing them. | |
Re: As you are eager to learn more, this should be next in your schedule seeing your variable names: [url]http://en.wikipedia.org/wiki/Naming_convention_%28programming%29[/url] And surely you read this already? It is the basic guidelines standard for Python: [url]http://www.python.org/dev/peps/pep-0008/[/url] | |
Re: facts are easily found by looking through suitable newbies data correct position in statistics page as I have reacently posted to Community feedback forum. To restate from todays data: 9181 have posted in thread of others which have been marked solved. 54521 have posted more than two times. | |
Re: You could use ordered data type like namedtuple instead of unordered dictionary. | |
Re: I think black Jack is dealt normally from shoe with many decks shuffled together. Then the cards do not finish so often. I think fresh deck should be automatically shuffled in Deck's __init__. Number of cards should be possible to check by len(myhand) but better would be to have deal … | |
Re: The new function is not doing exactly same as old one as it failed to decrypt file crypted with old function. Usage change also, I changed the input being from file given as first parameter and return to be the (sde)crypted content and changed the example use accordingly to show … | |
Re: [CODE]import os os.chdir('/some/path') print(os.listdir(os.curdir)) [/CODE] Hope this is OK, i type this from my mobile and I have not possibility to run it now. | |
Re: I do not understand: [CODE]What is .pbp and how to open .pbp file PBP is the proprietary file extension generated by Sony PlayStation Portable (PSP). It is widely used to update the firmware, install game demo, homebrew games and applications. Commonly, file must copy to /PSP/GAME/UPDATE/EBOOT.PBP on a memory stick. … | |
Re: You should mark this thread solved, even you solved it yourself. | |
Re: I know that text editor is kind of heavy weight champion in editors, but maybe you would like to give [URL="http://www.contexteditor.org/"]ConTEXTeditor[/URL] a try. I have been happy using it some time now and setting up it's function keys to run various versions of Python was breeze. | |
Re: OP do not necessary need more than input (raw_input in Python 2) Also there should be one Vegaseats snippet how to use Tkinter without window to get key event. You could also adapt the Tkinter menu I have posted before, it is not finally so much more difficult than writing … | |
Re: You have forgotten your code, don't forget the code-tags. | |
Re: Looks there is [URL="http://ciberjacobo.com/python-ipod"]something[/URL], but it is Python 2.4 level. Should maybe consider to recompile more recent version as they have reported, that the job was not very difficult diffs from standard version are small: [url]http://ciberjacobo.com/en/diffs.html[/url] | |
Re: Check the documentation for try..except statement and the int function. line 5 of lrh9's code is meant to be [CODE] if not i:[/CODE] | |
Re: You could find this my old function useful: [URL="http://www.daniweb.com/forums/post1245223.html#post1245223"]Longest common subsequence[/URL] | |
Re: Is this helpfull? [CODE]import random test_data = [random.randint(28,31) for count in range(12)] day_data = [[random.randint(1,5) for count in range(days)] for days in test_data ] print('Data generated') for m, month in enumerate(day_data): print(m+1, month) n = 5 for m, month in enumerate(day_data): print('Last %i days measurements for month %i are:\n%s' % … | |
Re: Use 'quotes as outer quotes or double the " inside quotes. | |
Re: Test first for length, then read characters, fail if no vowel found or if there is any other vowel after first vowel found. As alternative you can make correct length word lowercase and strip all consonants, if only one wovel is left accept the original word. | |
Re: Default lineterminator is '\n\r' [CODE]import csv def main(): filename = 'test.txt' csv_fp = csv.writer(open(filename,"w"), delimiter=',', lineterminator='\n') csv_fp.writerows([['1', '2', '3'],[4,5,6]]) if __name__ == '__main__': main() [/CODE] | |
Re: The official way is data[-2:] | |
Re: Please do not override the builtin type as variable name. | |
Re: I have this moment solved with Python 131 problems starting New Years time as I earlier had posted help on some problems in Python forum for others and thought to do those myself. For the 98, I have following functions in my solution in Python (first cross post for your … | |
Re: You could [B]seek[/B] to n KB from end of file, read n KB, if string found stop, otherwise seek n KB - search string length [B]more behind[/B], read n KB, .... until succeed or beginning is reached and string is not in file. | |
Re: I have difficulty understanding why you do not leave values in the object. From variable name I would expect to be list of measurement objects. | |
Not my code but I think free to share. This is intended as beginning point of learning classes or learning data structures. Read the document [url]http://mcsp.wartburg.edu/zelle/python/python-first.html[/url] As first exercise, this does not work instead of the while loop in test part: [CODE] for i in numbers: print i [/CODE] [QUOTE] … | |
See the ranking of this newbie poster and compare it to statistics of the day for the site. Gives some thoughts about what kind of members the forum has. How about OpenID login without registration. | |
Re: I am not so sure about interprocess communication alternatives, but I do not think OSes take much penalty for repeatedly checking when one file was last written to. | |
Re: [QUOTE=arkoenig;1499743]If you're going to generate a list of primes, rather than testing whether a single integer is prime, then why not use the list itself for the divisors?[/QUOTE] Ok here the more advanced alternatives: [CODE]from __future__ import print_function import time from math import sqrt, ceil try: import numpy as np … | |
Re: Slight change from the code I already posted to you: [CODE]from __future__ import print_function # created in python 3.2 by Dan Holding and Tony Veijalainen on the "14/03/2011" import sys, os if len(sys.argv) != 2: print('''Usage: %s inputfilename Where inputFilename is the name of the file to be processed, I … | |
Re: Something like this with regular Python: [CODE]stu_file = """ S100007|S100007|Kimf|Shovctter|K.Shogdftter@UCS.AC.UK|Y|Enabled|Y| S100038|S100038|Lxois|Macvnsfield|L.Manfdfsfield@UCS.AC.UK|Y|Enabled S100040|S100040|Revxbecca|Harcvxcris|R.Hargrfgis@UCS.AC.UK|Y|Enabled|Y S100076|S100076|Hocvlly|Wilkxcvins|H.Wifgkins@UCS.AC.UK|Y|Enabled|Y""" for line in stu_file.splitlines(): print line[:10].lower()+line[10:] [/CODE] | |
Re: Error happens in your myutils code where zlib does not like your file format. There is also the obfuscate code [B]myutils.password_obfuscate[/B], which you did not post. You have much to correct in your style. Use for example assert, not if, to check your assumptions. | |
Re: You can simplify out parts which are not essential to demonstrate and you should post code which is runnable to see what problem you have, especially when you are not giving any error messages and exact problems. At least I do not see how the indentation of the second piece … | |
Re: These two loops do nothing so they simplify to just. [CODE]pass[/CODE] |
The End.