3,386 Posted Topics

Member Avatar for EMT

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]

Member Avatar for TrustyTony
0
600
Member Avatar for danholding

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

Member Avatar for vegaseat
0
1K
Member Avatar for jacksparrow01

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 …

Member Avatar for jacksparrow01
0
172
Member Avatar for e-papa

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.

Member Avatar for e-papa
1
880
Member Avatar for e-papa

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 …

Member Avatar for e-papa
0
4K
Member Avatar for ThePythonNoob

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 …

Member Avatar for richieking
0
123
Member Avatar for Jerix

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

Member Avatar for TrustyTony
0
505
Member Avatar for parijat24

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 …

Member Avatar for TrustyTony
0
196
Member Avatar for e-papa

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

Member Avatar for e-papa
0
19K
Member Avatar for e-papa

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 …

Member Avatar for e-papa
0
729
Member Avatar for e-papa

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.

Member Avatar for e-papa
0
929
Member Avatar for e-papa

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]

Member Avatar for e-papa
0
177
Member Avatar for joeywheels

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

Member Avatar for TrustyTony
0
1K
Member Avatar for Simplified

[CODE]decimal.getcontext().prec = 9 now = "230.939809280" then = "230.939808600" print "%.9f" % (decimal.Decimal(now) - decimal.Decimal(then)) # -> 0.000000680 [/CODE]

Member Avatar for Simplified
0
216
Member Avatar for xleon
Member Avatar for xleon
0
4K
Member Avatar for e-papa

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 …

Member Avatar for e-papa
0
221
Member Avatar for dustbunny000

Sounds like you should compare the strings for matches in same place or Longest Common Subsequence anywhere instead of just printing them.

Member Avatar for jice
0
232
Member Avatar for e-papa

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]

Member Avatar for TrustyTony
0
6K
Member Avatar for happygeek

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.

Member Avatar for TrustyTony
0
477
Member Avatar for banannamoofin

You could use ordered data type like namedtuple instead of unordered dictionary.

Member Avatar for TrustyTony
0
213
Member Avatar for bwbyron

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 …

Member Avatar for woooee
0
320
Member Avatar for vegaseat

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 …

Member Avatar for TrustyTony
3
7K
Member Avatar for e-papa

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

Member Avatar for e-papa
0
180
Member Avatar for lucksoar

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

Member Avatar for TrustyTony
0
286
Member Avatar for spe_eddy
Member Avatar for Echo_2011

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.

Member Avatar for e-papa
0
1K
Member Avatar for Atistus

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 …

Member Avatar for Atistus
0
176
Member Avatar for shawntheking
Member Avatar for lucksoar

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]

Member Avatar for lucksoar
0
255
Member Avatar for ThePythonNoob

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]

Member Avatar for bumsfeld
0
172
Member Avatar for doomas10

You could find this my old function useful: [URL="http://www.daniweb.com/forums/post1245223.html#post1245223"]Longest common subsequence[/URL]

Member Avatar for TrustyTony
0
229
Member Avatar for spe_eddy

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

Member Avatar for spe_eddy
0
145
Member Avatar for blacknred
Member Avatar for scyonto

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.

Member Avatar for TrustyTony
0
115
Member Avatar for leeggodfrey
Member Avatar for meensatwork

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]

Member Avatar for meensatwork
0
131
Member Avatar for G_S
Member Avatar for linuxoidoz
Member Avatar for frogboy77

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 …

Member Avatar for frogboy77
0
159
Member Avatar for constntine

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.

Member Avatar for snippsat
0
541
Member Avatar for spe_eddy

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.

Member Avatar for TrustyTony
0
3K
Member Avatar for TrustyTony

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

Member Avatar for TrustyTony
0
857
Member Avatar for TrustyTony

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.

Member Avatar for Dani
0
227
Member Avatar for rustybar

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.

Member Avatar for TrustyTony
0
1K
Member Avatar for bumsfeld

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

Member Avatar for TrustyTony
0
2K
Member Avatar for danholding

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 …

Member Avatar for danholding
0
146
Member Avatar for danholding

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]

Member Avatar for TrustyTony
0
427
Member Avatar for Swift2

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.

Member Avatar for Swift2
0
206
Member Avatar for tubesnube

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 …

Member Avatar for tubesnube
0
2K
Member Avatar for bpatt22
Member Avatar for Gribouillis
0
151

The End.