SEARCH YOUR SOLUTION HERE  

PYTHON PROGRAMMING HELP PLSSS !!URGENT



Please do not double post. Especially with more than one email
address. If someone can help you. I am sure they will.

Danyelle

Posted On: Monday 5th of November 2012 02:35:40 AM Total Views:  280
View Complete with Replies




Related Messages:

bash-style pipes in python?   (91 Views)
I'm constantly flipping back and forth between bash and python. Sometimes, I'll start a program in one, and end up recoding in the other, or including a bunch of python inside my bash scripts, or snippets of bash in my python. But what if python had more of the power of bash-style pipes I might not need to flip back and forth so much. I could code almost entirely in python. The kind of thing I do over and over in bash looks like: #!/usr/bin/env bash # exit on errors, like python. Exit on undefind variables, like python. set -eu # give the true/false value of the last false command in a pipeline # not the true/false value of the lat command in the pipeline - like # nothing I've seen set -o pipefail # save output in "output", but only echo it to the screen if the command fails if ! output=$(foo | bar 2>&1) then echo "$0: foo | bar failed" 1>&2 echo "$output" 1>&2 exit 1 fi Sometimes I use $PIPESTATUS too, but not that much. I'm aware that python has a variety of pipe handling support in its standard library. But is there a similarly-simple way already, in python, of hooking the stdout of process foo to the stdin of process bar, saving the stdout and errors from both in a variable, and still having convenient access to process exit values Would it be possible to overload | (pipe) in python to have the same behavior as in bash I could deal with slightly more cumbersome syntax, like: (stdout, stderrs, exit_status) = proc('foo') | proc('bar') ....if the basic semantics were there. How about it Has someone already done this
python extra   (101 Views)
Just a little python humor: http://www.amazon.com/Vitamin-Shoppe...917462&sr=1-14
In search of python idiom for accessing arbitrary fields at run time   (127 Views)
I'm trying to find the preferred python idiom for access arbitrary fields of objects at run time. For example, say I have an object the business code will do *something* with three arbitrary fields at a given time, but I don't know what the three fields are at run time. In perl, I'd do something like this: sub three_fields{ my $self = shift; my @fields = @_; foreach my $field (@fields) { my $value = $self->$field; # this is the one I'm interested in [...] } } In python, I'm doing something like this: def three_fields(self, field1, field2, field3): for field in (field1, field2, field3): value = eval('self.' + field) # this is the one I'm interested in [...] This seems to do what I expect it to do. I'm wondering if that's the preferred or standard way to do this in python. I wasn't sure how to tease the answer to this question out of Google.
Web Programming thru python   (85 Views)
HI, Please help how to execute a py file with xitami. I installed xitami , downloaded lrwp file. accessing the first web application program import urllib # Get a file-like object for the Python Web site's home page. f = urllib.urlopen("http://www.python.org") # Read from the object, storing the page's contents in 's'. s = f.read() f.close() through browser like "http://localhost/first.py it is dispaying the source code of the first.py. Please help me how to execute the file.
Re: In search of python idiom for accessing arbitrary fields at runtime   (135 Views)
On Sun, 08 Jul 2007 18:21:41 -0000, mshiltonj wrote: >I'm trying to find the preferred python idiom for access arbitrary >fields of objects at run time. > It's not an idiom, it's a built-in function: getattr. Jean-Paul
hang in multithreaded program / python and gdb.   (110 Views)
Hi I want to debug a locking situation in my program. http://wiki.python.org/moin/DebuggingWithGdb Where do I get binaries for - debug python 2.5 binary/rpm for FC7 Also, the description of the hang is as follows. 2 therads waiting in sem_wait@GLIBC_2.0 ... from PyThread_acquire_lock() 1 thread in _poll from _socketmodule.so. Any ideas what might be going on. (Isnt PyThread_acquire_lock() trying to get the global interpreter lock )
connecting to serial port + python   (231 Views)
, I am trying to connect my Nokia 6610 using usb cable, I have installed usb-serial driver of it. I hv tested it with Hyperterminal and it works fine. but when I wrote a python script I am not able to receive the responce from the device. import os import re import time import sys from threading import Thread import serial class connect_serial(Thread): def __init__(self,socks): Thread.__init__(self) self.sock = socks self.count = 0 def run(self): self.count = 0 try: while 1: self.count +=1 if (self.count>=5): break lines = self.sock.read(100) if lines: print lines print 'read success-----------------------------------------------' else: print 'nothing to read',str(self.getName()) except Exception,e: print self.getName() print time.ctime() print try: conn1 = serial.Serial(4) conn1.baudrate = '9600' conn1.parity = serial.PARITY_EVEN conn1.timeout=1 except Exception,e: print 'port is Buzy' sys.exit(-1) print '------------------------------' print 'getSupportedBaudrates',conn1.getSupportedBaudrates() print 'getSupportedByteSizes',conn1.getSupportedByteSizes() print 'getSupportedParities',conn1.getSupportedParities() print 'getSupportedStopbits',conn1.getSupportedStopbits() print '------------------------------' print 'getBaudrates',conn1.getBaudrate() print 'getByteSizes',conn1.getByteSize() print 'getParities',conn1.getParity() print 'getStopbits',conn1.getStopbits() print '------------------------------' print 'port is in use',conn1.portstr list1 = [] command = ['AT','ATI','ATl1','AT+GMMM'] for cmd in command: conn1.write(str(cmd)) th = connect_serial(conn1) list1.append(th) th.start() for th1 in list1: print 'started joining',th1.getName(), 'counter :',th1.count th1.join() print time.ctime()
Using struct timeval in python   (83 Views)
I am using a library (pcapy) that returns a timeval object T= (seconds,microseconds) where microseconds is always < 1e6. Is there a Python class that can handle timeval structs Specifically, I wish to subtract two T (defined above) objects, taking into account the large values of T[0] and T[1] (esp T[0]) At one point, I would have to step in, since T[0] rolls back to zero (after some time). Any pointers
Re: 2 python questions!   (104 Views)
resist_think@hushmail.com wrote: > Hi python community! > First question has to do with threading support. There is the > following simple case: > I have a dictionnary that gets it's values -which are url's-from a > function. Sort of > > dictionnary['1'] = "http://www.google.com" > dictionnary['2'] = "http://www.python.com" > .... > > I need to fill in the dictionnary with some url's. If I do it on > the simplest way, it would be like: > > for i in range(20): > dictionnary["%s" % i] = get_urls(args) > > and wait a long long time till it finishes. Can I do it easily with > threads, without having to add too much code Ideal case would be > if all threads start simultaneously > Look at thread.start_new_thread here: http://docs.python.org/lib/module-thread.html You can call a function in a separate thread, and you do not need to write a new class. (I do not like start_new_thread and I would define classes for this, but you are free to use this feature.) > Now the second question has to do with images retrieval and > manipulation. Which libraries do you propose to work with to > retrieve and resize images from the web > I would use PIL because it is popular, easy to use, available on most platforms and has few dependencies. Check out http://www.pythonware.com/products/pil/ Best, Laszlo
Re: need help with converting c function to python function   (151 Views)
In article , nephish says... > i have a c function from some modbus documentation that i need to > translate into python. > > it looks like this: > > > unsigned short CRC16(puchMsg, usDataLen) > unsigned char *puchMsg ; > unsigned short usDataLen ; > { > unsigned char uchCRCHi = 0xFF ; > unsigned char uchCRCLo = 0xFF ; > unsigned uIndex ; > while (usDataLen--) > { > uIndex = uchCRCHi ^ *puchMsgg++ ; > uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ; > uchCRCLo = auchCRCLo[uIndex] ; > } > return (uchCRCHi } > > some of it i can make out, but i can't seem to figgure out > this part ' auchCRCHi[uIndex}; > it looks like a typo, because there is a closing } that does not match > the opening [. > > > here is what i have so far, but is not giving me the right values > > def crc16(data): > crc_hi = 0xff > crc_lo = 0xff > for x in data: > crc_index = crc_hi ^ x > crc_hi = crc_lo ^ (crc_hi | crc_index) > crc_lo = crc_lo | crc_index > return (crc_hi > whaddya think Use lateral thinking. CRC usually means some standard data checking algorithm. If you google for crc16 you will find various python implementations. Off hand I would first try this one because he seems to have been thinking about it: http://mail.python.org/pipermail/pyt...er/342097.html But I don't really know what it is you are looking for, cyclic redundancy check http://en.wikipedia.org/wiki/Cyclic_redundancy_check A.
Re: [python 3.0] reload() gone?   (104 Views)
"Bernard Lebel" wrote in message news:61d0e2b40708311110l5a13819fh4e6b2aafe928b44d@mail.gmail.com... |I read in the Python 3.0 documentation that reload() was removed, | without further explanations. | | http://docs.python.org/dev/3.0/whats...ghlight=reload The .a1 release docs are a bit skimpy in places. Reload() often does not do what people want or expect. | So what are we supposed to do to reload modules He once said he was working on a replacement that he was first testing on himself. I guess it did not make .a1. tjr
python + gcov   (97 Views)
Hi I want to profile (and ****yse coverage) some c++ code imported as a python module I've compiled python (2.4.2) with gcc 3.4.3 and flags=-Wall -fprofile- arcs -ftest-coverage in order to use gcov. However, the python binary does not generate any coverage file (such than *.gcno, gcda) during execution. any tips or may be another method to profile c++ wrapped modules within python
Embedding the python interpreter   (92 Views)
, Do you know an easy way to embed the python interpreter in a python program (so a non-technical user, which has no idea how to install the python interpreter would be able to run the script as an executable)
Is it reasonably easy easy to something like this with python?   (102 Views)
Gerardo Herzig a crit : > walterbyrd wrote: > >> This is made with a php5 framework called qcodo. >> >> http://examples.qcodo.com/examples/d...ne_editing.php >> >> With qcodo it's easy to make grids that are sortable and inline >> editable. Qcodo grids work from the database - not an xml table or >> array. Qcodo handles complex data relations, and fairly large >> datadabes. >> >> I like python better than php, but I don't know of any python tools to >> create these sorts of grids. >> >> >> > The one who make that table sorteable is AJAX. Not php. The php part is > kind of trivial (so it would be `trivial' in python too). It just reads > some data and format it in an html table. FWIW, Pylons have all sorts of javascript/ajax helpers (using prototype.js).
socket on cygwin python   (101 Views)
I've installed cygwin with latest python 2.5.1, but it seems that the socket lib file do NOT support IPv6(cygwin\lib\python2.5\lib-dynload \_socket.dll), what can I do if I want to use IPv6
python setup.py: how to override a setup.cfg value ?   (103 Views)
I'm building python-ldap and need to change values of library and include paths that are in the setup.cfg file. This is an automated build (using "buildit") so I'd prefer not to have edit the .cfg by hand, with sed, or even with buildit's Substitute(). I'd like to be able to do something like I'd do with "make", specify a value on the command line like: make -Dprefix=/usr/local or in this case python setup.py -Dlibs="ldap lber" build [Does NOT work] I cannot see how to do this from the --help or from googling. The closest I've gotten is to do: python setup.py setopt --command=_ldap --option=libs --set-value="ldap lber" but that overwrites the python.cfg, a bit rude it seems to me. Am I missing something is there a way to override a .cfg value on the command line while running a setup.py command like "build" or "install"
Vista 64 + Python2.5 + wxpython 28 issue   (267 Views)
Guys, I have installed python 2.5 (AMD64) on Vista (64), also installed wx 2.8 but I'm getting this error: """" Traceback (most recent call last): File "mymodule.py", line 39, in import wx File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 4 5, in from wx._core import * File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, i n import _core_ ImportError: DLL load failed with error code 193 """ I have set python.exe to run under admin but that do not fix the problem. Any ideas
Hot subject: a good python editor and/or IDE?   (204 Views)
Hi folks, I am currently using Eclipse+PyDev when developping Python projects but I lack a fast, simple editor for tiny bit of scripts. So here is my question: what is, for you, the current best ( but still kind of light! ) Python editor/IDE A tiny precision, I am on Ubuntu so I am looking for a linux compatible editor. Cheers, Sbastien , On Sun, 19 Aug 2007 13:08:35 +0000, Samuel wrote: > $ sudo apt-get install vim I just realized, this should be $ sudo apt-get install vim-python or $ sudo apt-get install vim-full -Samuel
Re: Hot subject: a good python editor and/or IDE?   (95 Views)
At 02:47 AM 8/19/2007, Sbastien wrote: >Hi folks, > >I am currently using Eclipse+PyDev when developping Python projects but >I lack a fast, simple editor for tiny bit of scripts. So here is my >question: what is, for you, the current best ( but still kind of light! >) Python editor/IDE A tiny precision, I am on Ubuntu so I am looking >for a linux compatible editor. I thought Ulipad WAS linux-compatible. Isn't it Dick Moores XP, Python 2.5, editor is Ulipad ====================================== Bagdad Weather
wxpython log redirect   (116 Views)
, Why this wx example don't return \nHELLO WORLD and other text in same window: import wx import logging import sys def nekaj(): print "\nHELLO WORLD" class WxLog(logging.Handler): def __init__(self, ctrl): logging.Handler.__init__(self) self.ctrl = ctrl def emit(self, record): self.ctrl.AppendText(self.format(record)+"\n") class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title="logging test") sizer = wx.BoxSizer(wx.VERTICAL) log = wx.TextCtrl(self, style=wx.TE_MULTILINE) rootLogger = logging.getLogger('') rootLogger.setLevel(logging.DEBUG) hdlr = WxLog(log) hdlr.setFormatter(logging.Formatter('%(levelname)s | %(name)s | %(message)s [@ %(asctime)s in %(filename)s:%(lineno)d]')) rootLogger.addHandler(hdlr) rootLogger.debug(str(sys.stdout)) nekaj() # goes to the function nekaj if __name__ =="__main__": app = wx.App(0) frame = MainFrame() frame.Show() app.MainLoop()