Search Results

Search found 8942 results on 358 pages for 'print r'.

Page 188/358 | < Previous Page | 184 185 186 187 188 189 190 191 192 193 194 195  | Next Page >

  • Python/Biomolecular Physics- Trying to code a simple stochastic simulation of a system exhibiting co

    - by user359597
    *edited 6/17/10 I'm trying to understand how to improve my code (make it more pythonic). Also, I'm interested in writing more intuitive 'conditionals' that would describe scenarios that are commonplace in biochemistry. The conditional criteria in the below program is explained in Answer #2, but I am not satisfied with it- it is correct, but isn't obvious and isn't easy to implement for more complicated conditional scenarios. Ideas welcome. Comments/criticisms welcome. First posting experience @ stackoverflow- please comment on etiquette if needed. The code generates a list of values that are the solution to the following exercise: "In a programming language of your choice, implement Gillespie’s First Reaction Algorithm to study the temporal behaviour of the reaction A---B in which the transition from A to B can only take place if another compound, C, is present, and where C dynamically interconverts with D, as modelled in the Petri-net below. Assume that there are 100 molecules of A, 1 of C, and no B or D present at the start of the reaction. Set kAB to 0.1 s-1 and both kCD and kDC to 1.0 s-1. Simulate the behaviour of the system over 100 s." def sim(): # Set the rate constants for all transitions kAB = 0.1 kCD = 1.0 kDC = 1.0 # Set up the initial state A = 100 B = 0 C = 1 D = 0 # Set the start and end times t = 0.0 tEnd = 100.0 print "Time\t", "Transition\t", "A\t", "B\t", "C\t", "D" # Compute the first interval transition, interval = transitionData(A, B, C, D, kAB, kCD, kDC) # Loop until the end time is exceded or no transition can fire any more while t <= tEnd and transition >= 0: print t, '\t', transition, '\t', A, '\t', B, '\t', C, '\t', D t += interval if transition == 0: A -= 1 B += 1 if transition == 1: C -= 1 D += 1 if transition == 2: C += 1 D -= 1 transition, interval = transitionData(A, B, C, D, kAB, kCD, kDC) def transitionData(A, B, C, D, kAB, kCD, kDC): """ Returns nTransition, the number of the firing transition (0: A->B, 1: C->D, 2: D->C), and interval, the interval between the time of the previous transition and that of the current one. """ RAB = kAB * A * C RCD = kCD * C RDC = kDC * D dt = [-1.0, -1.0, -1.0] if RAB > 0.0: dt[0] = -math.log(1.0 - random.random())/RAB if RCD > 0.0: dt[1] = -math.log(1.0 - random.random())/RCD if RDC > 0.0: dt[2] = -math.log(1.0 - random.random())/RDC interval = 1e36 transition = -1 for n in range(len(dt)): if dt[n] > 0.0 and dt[n] < interval: interval = dt[n] transition = n return transition, interval if __name__ == '__main__': sim()

    Read the article

  • Need ad-hoc reporting component

    - by Nelson
    We need some simple ad-hoc reporting solution for our ASP.NET web-site. Just an ability to build a query with user friendly interface, then show the result of this query in some table and maybe export it to Excel or print. The solution must be quite easy for end users (our site visitors) who know nothing about databases, SQL and other tech stuff.

    Read the article

  • Exception Handling in google app engine

    - by Rahul99
    i am raising exception using if UserId == '' and Password == '': raise Exception.MyException , "wrong userId or password" but i want print the error message on same page class MyException(Exception): def __init__(self,msg): Exception.__init__(self,msg)

    Read the article

  • Getting $_POST variable from table

    - by Sakamoto Kazuma
    I'm trying to build a sort of resource allocation form. I'd like to be able to print a table from a database, and then allow users to click on each cell that they would like to reserve. Also, being able to drag and select multiple cells. Then send all of this via $_POST to another php script. Problem is, I have no idea where to start. Any suggestions?

    Read the article

  • python class decorator question?

    - by nsharish
    decorator 1: def dec(f): def wrap(obj, *args, **kwargs): f(obj, *args,**kwargs) return wrap decorator 2: class dec: def __init__(self, f): self.f = f def __call__(self, obj, *args, **kwargs): self.f(obj, *args, **kwargs) A sample class, class Test: @dec def disp(self, *args, **kwargs): print(*args,**kwargs) The follwing code works with decorator 1 but not with decorator 2. a = Test() a.disp("Message") I dont understand why decorator 2 is not working here. Can someone help me with this?

    Read the article

  • How do I distinguish files and folders on an FTP server

    - by soulmerge
    I want to list all files on an FTP server using PHP. According to RFC 959 the FTP command LIST is allowed to print arbitrary human-readable information on files/folders, which seems to make it impossible to determine the file type correctly. But how do other FTP clients manage to distinguish files and folders? Is there an unwritten standard or such?

    Read the article

  • php count rss entries since a specific date/time

    - by Steven
    can anyone tell me why this code don't work: $q = $_GET['q']; // Load and parse the XML document $rss = simplexml_load_file("http://search.twitter.com/search.atom?lang=en&q=$q&rpp=100&page=1"); $Count1 = 0; while(strtotime($rss->entry->published)>1270833600){ foreach ($rss->entry as $item) { $Count1++; } } print "Total Record: ".$Count1;

    Read the article

  • Example for a simple LaTeX glossary

    - by Sven Klouem
    I'm trying to include a simple glossary to my LaTeX document, I already searched for something like that on google, but never got it running. I would like to use glossary or glossaries. how to write it in the text? how to print it? what to execute on which position?

    Read the article

  • Unknown syntax error.

    - by matt1024
    Why do I get a syntax error running this code? If I remove the highlighted section (return cards[i]) I get the error highlighting the function call instead. Please help :) def dealcards(): for i in range(len(cards)): cards[i] = '' for j in range(8): cards[i] = cards[i].append(random.randint(0,9) return cards[i] print (dealcards())

    Read the article

  • Unexpected tag T_ECHO in inline if

    - by Lombo
    I have something like this in one of my views <li <?php $isCurrent ? echo 'class="current"' : ''?> > <a href="SOME_LINK" class="SOME_CLASS">SOME_TEXT</a> </li> This causes a syntax error, unexpected T_ECHO. Changing echo for print solves the issue, but I would like to understand why I cannot use echo.

    Read the article

  • Getting the previous line in Jython

    - by kdev
    I want to print the line immediately before the searched string. How can I do that? Lets say my two lines are AADRG SDFJGKDFSDF and I am searching for SDF. I have found SDFJGKDFSDF, but how can I obtain the previous line AADRG? Does file.readline()-1 work?

    Read the article

  • Google Apps shared contacts API get a contact for python

    - by Mike
    I'm having some issues trying to pull a shared contact using the gdata api for python that Google provides. Here is what I have to get the contacts.. but they are not all listed there feed = gd_client.GetContactsFeed() for i, entry in enumerate(feed.entry): print entry.title I can't figure out how to pull out a single contact so I can edit the contact information.. thanks!

    Read the article

  • Python decorator question

    - by nsharish
    decorator 1: def dec(f): def wrap(obj, *args, **kwargs): f(obj, *args,**kwargs) return wrap decorator 2: class dec: def __init__(self, f): self.f = f def __call__(self, obj, *args, **kwargs): self.f(obj, *args, **kwargs) A sample class, class Test: @dec def disp(self, *args, **kwargs): print(*args,**kwargs) The follwing code works with decorator 1 but not with decorator 2. a = Test() a.disp("Message") I dont understand why decorator 2 is not working here. Can someone help me with this?

    Read the article

  • Find last match with python regular expression

    - by SDD
    I wanto to match the last occurence of a simple pattern in a string, e.g. list = re.findall(r"\w+ AAAA \w+", "foo bar AAAA foo2 AAAA bar2) print "last match: ", list[len(list)-1] however, if the string is very long, a huge list of matches is generated. Is there a more direct way to match the second occurence of "AAAA" or should I use this workaround?

    Read the article

  • Counting HTML images with Python

    - by user2537246
    I need some feedback on how to count HTML images with Python 3.01 after extracting them, maybe my regular expression are used properly. Here is my code: import re, os import urllib.request def get_image(url): url = 'http://www.google.com' total = 0 try: f = urllib.request.urlopen(url) for line in f.readline(): line = re.compile('<img.*?src="(.*?)">') if total > 0: x = line.count(total) total += x print('Images total:', total) except: pass

    Read the article

  • linux piping ( convert -> pdf2ps -> lp)

    - by Bor
    Ok, so I can print a pdf doing: pdf2ps file.pdf - | lp -s But now I want to use convert to merge several pdf files, I can do this with: convert file1.pdf file2.pdf merged.pdf which merges file1.pdf and file2.pdf into merged.pdf, target can be replaced with '-'. Question How could I pipe convert into pdf2ps and then into lp though?

    Read the article

  • problems with scanf

    - by lego69
    hello, I've got some problems with this snippet of the code while(scanf("%d",&numOfPlayers)!=1){ printf("Please enter the right number of players"); } my purpose is to take the number from the user but if number is not int, I must ask him one more time, when I check this snippet and print 'r' for example I receive eternal loop, what may be the problem, how can I improve it? thanks in advance

    Read the article

  • Many returned records cause stackoverflow with Hibernate

    - by mimi law
    If there are many return records from DB. It will get stackoverflow problem. User is a class, which has a one to many relationship (to 3 other classes). When I print out the SQL, i found that the system runs the same query many time to get the data from DB. Does anyone know what the problem is? result.addAll(getCurrentSession().createCriteria(User.class) .add(Restrictions.ilike("name", "tom", MatchMode.ANYWHERE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list());

    Read the article

  • differences between "d.clear()" and "d={}"

    - by Tshepang
    On my machine, the execution speed between "d.clear()" and "d={}" is over 100ns so am curious why one would use one over the other. import timeit def timing(): d = dict() if __name__=='__main__': t = timeit.Timer('timing()', 'from __main__ import timing') print t.repeat()

    Read the article

  • Need a fast programming language that can drive two printers

    - by Pete
    I have a rather unusual application that isn't working the way I need, and I hope someone here will have some suggestions or at least a direction to investigate. We have a museum exhibit that has a computer at the entrance driving two small receipt printers. There are two buttons on a console, wired to the left and right buttons of a disemboweled mouse. The two printers and associated buttons are for girls and boys, each button does a random selection from a database of names and prints a small ticket on the appropriate printer with a graphic image, a few words about the exhibit and the randomly chosen name. Conceptually all is well, but it hangs quite often. I got the project at the last minute, because the original designer got bogged down and couldn't deliver, so the exhibit's author asked me the day before opening, whether I could write something that would work. I did it in Word, since I am an experienced VBA programmer. Several other avenues I attempted first all lead to dead ends - one couldn't do graphics, another couldn't handle two printers, yet another couldn't change fonts and so on. The problem is that it simply isn't fast enough - Word can only drive one printer at a time and changing the active printer takes a long time. Not by office standards, where a second or two of delay before a printer starts working on your document is not an issue, but here I need more or less instant response. If kids press a button and nothing happens, they press it over and over until something does happen, resulting in maybe half a dozen commands being sent before the printer starts reacting. Sometimes it jams the program completely, since boys and girls will be pressing the two buttons simultaneously and Word locks up, and even when it doesn't jam, the printers then spit out a stream of tickets, making a mess. The kids start squabbling over which ticket is whose, pulling them out of the printers, snarling the paper tape, jamming the printer and generally making a mess of the whole affair, often necessitating the exhibit caretakers having to restart the computer and clear torn bits of paper out the printers. What I need is some sort of fast programming language that can drive two printers *-simultaneously-*, not the MSOffice claptrap of having to switch the active printer, that can react to both left and right mouse button click events, can print a small graphic image and can print in different font sizes and styles and. I don't need many, but it's not all in one typeface. Can anyone suggest what I might use for this? I don't even know if it's possible at all under Windows, whether the "single active printer" garbage is an Office artifact, or a Windows restriction. My little Commodore-64 twenty-five years ago had two printers attached to it and drove both simultaneously with no difficulties - it doesn't seem to me it should be such an impossible requirement today.

    Read the article

  • How to get informative compile error messages when using flexmojos-maven-plugin?

    - by Tony
    I'am using flexmojos-maven-plugin to build my Flex module. So on the compile phase I'm getting org.apache.maven.plugin.MojoExecutionException: Error compiling! with no information on where (on what source file) the error happens and what is nature of the compile error. I'll appreciate if anyone can instruct me on how to make flexmojos-maven-plugin print more information about compile errors.

    Read the article

  • Numpy Matrix keeps giving me an Error,

    - by uberjumper
    Okay this is werid, i keep getting the error, randomly. ValueError: matrix must be 2-dimensional So i tracked it down, and cornered it to basically something like this: a_list = [[(1,100) for _ in range(32)] for _ in range(32)] numpy.matrix(a_list) Whats wrong with this? If i print a_list it is clearly a 2d matrix of tuples, however numpy does not believe so.

    Read the article

< Previous Page | 184 185 186 187 188 189 190 191 192 193 194 195  | Next Page >