removing text string


I need to remove text string from the list of the numbers mentioned below: 080829-7_A 070529-5_c 080824-7_O 070405_6_p The output will be : 080829-7 070529-5 080824-7 070405-6 Any idea is highly appreciated....
Posted On: Sunday 11th of November 2012 08:27:32 PM Total Views:  135
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




RE: removing text string

You just want to drop the last two characters Slice it. >>> s = "080829-7_A"[:-2] >>> print s 080829-7 - Adam > -----Original Message----- > From: python-list-bounces+adam=volition-inc.com@python.org > [mailtoython-list-bounces+adam=volition-inc.com@python.org] On Behalf > Of Ahmed, Shakir > Sent: Wednesday, September 10, 2008 10:22 AM > To: python-list@python.org > Subject: removing text string > > I need to remove text string from the list of the numbers mentioned > below: > > 080829-7_A > 070529-5_c > 080824-7_O > 070405_6_p > > The output will be : 080829-7 > 070529-5 > 080824-7 > 070405-6 > > Any idea is highly appreciated. > > > > -- > http://mail.python.org/mailman/listinfo/python-list
VIEWS ON THIS POST

134

Posted on:

Sunday 4th November 2012
View Replies!

Re: Import removing first module component

In article , koblas wrote: > Have the following line: > import notewave.runner.LMTP > > Yeilding the following error: > ImportError: No module named runner.LMTP > > For the life of me I don't understand why the first component > "notewave" is being stripped off, when the import is happening. Does notewave contain a _module_ named runner.LMTP Probably not, since the error message says there's no such module. >
VIEWS ON THIS POST

107

Posted on:

Sunday 4th November 2012
View Replies!

removing extension

i was trying to convert all images in a folder to another type and save the new images in a separate folder.for that i wrote a class and coded some part class ConvertImgs: def __init__(self,infldr,outfldr): if os.path.isdir(infldr): self.infldr=infldr self.outfldr=outfldr else: print "no such folder,exits program" exit(1) if not os.path.isdir(self.outfldr): os.mkdir(self.outfldr) print "made:",self.outfldr for x in os.listdir(infldr): self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in os.listdir(infldr)] .... the self.origlist returns a list of filenames in infolder.I would like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ \imageone.jpg' sothat i can add a diff extension to all those strings in the list and save in diff format(ie change 'C:\\myimages\\imageone' to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't know how to remove those extension from the namestring ..can someone help W
VIEWS ON THIS POST

121

Posted on:

Sunday 4th November 2012
View Replies!

removing all instances of a certain value from a list

I have a float array ( eg [-1.3, 1.22, 9.2, None, 2.3] ) but there are many missing vlaues which are represented as None. I would like to remove all such instances in one go. There is a remove function but it removes only the first instance, is there a delete/remove all function
VIEWS ON THIS POST

128

Posted on:

Sunday 4th November 2012
View Replies!

Re: Possible suggestion for removing the GIL

Prateek wrote: [...] > Mainly it revolves around dedicating one core for executing > synchronized code and doing context switches instead of acquiring/ > releasing locks. > > http://www.brainwavelive.com/blog/in...eter-Lock.html Context switches are generally more expensive than acquiring and release locks. Most systems' run-queues are protected by locks. The context switches at issue all involve the dedicated core, so I do not see any parallelism advantage. -- --Bryan
VIEWS ON THIS POST

131

Posted on:

Monday 5th November 2012
View Replies!

Re: Python is removing my quotes!

* Gary Herron (Tue, 21 Aug 2007 09:09:13 -0700) > Robert Dailey wrote: > > Note: I'm using Python on Windows > > > > I have an application that allows a user to submit a password as a > > command line parameter. The password of choice may contain any > > characters the user wishes, including quotes. If I do the following: > > > > python password.py "9999"MyPassword > > > > The resulting output when I print this inside the script is: > > > > 9999MyPassword > > > > Notice how the quotations have been stripped. Is it DOS doing this, or > > Python Is there a way I can fix it > > Not Python. It never even sees those quotes. Whatever system you are > using for entering the text is stripping them. Is it the command prompt > (cmd.exe) If so then you can escape the quote by preceding it with a > backslash. (This is true of the DOS prompt [...] No, under Cmd it's "^".
VIEWS ON THIS POST

169

Posted on:

Monday 5th November 2012
View Replies!

Re: Possible suggestion for removing the GIL

Prateek wrote: > > > Recently there was some talk on removing the GIL and even the BDFL has > written a blog post on it. > I was trying to come up with a scalable and backwards compatible > approach for how to do it. > > I've put my thoughts up in a blog post - and I'd really like to hear > what the community thinks of it. > Mainly it revolves around dedicating one core for executing > synchronized code and doing context switches instead of acquiring/ > releasing locks. Where is the gain Having just one core doesn't give you true parallelism - which is the main reason behind the cries for a GIL-less Python. Diez
VIEWS ON THIS POST

221

Posted on:

Monday 5th November 2012
View Replies!

Re: Python is removing my quotes!

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Robert Dailey schrieb: > Thank you for your response. The back slashes work! It's a bit annoying; but > I have Microsoft to thank for that. It's not Microsoft, you would experience the same problems under any Unix I know of. At least the bash treats quotes as special characters, so does afaik the sh and a couple of other shells in the Unixverse. You will also need to escape blanks and depending on the shell a number of other special characters (like for example the pipe). Greetings Nils -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGyye3zvGJy8WEGTcRAuWiAJ9SVUmNtQDkeGO1zBIXLeL548kXswCeMAEA zYMRE8LSV/9kYiAQkCz1PAU= =oDke -----END PGP SIGNATURE-----
VIEWS ON THIS POST

126

Posted on:

Monday 5th November 2012
View Replies!

Re: Efficiently removing duplicate rows from a 2-dimensional Numericarray

"Alex Mont" wrote in message news:76EEE12626B7A84EBACE67EC513AE53D060F8CE9@WIN-MSG-20.wingroup.windeploy.ntdev.microsoft.com... I have a 2-dimensional Numeric array with the shape (2,N) and I want to remove all duplicate rows from the array. For example if I start out with: [[1,2], [1,3], [1,2], [2,3]] I want to end up with [[1,2], [1,3], [2,3]]. ================================================= If you can define a 1-1 map of rows to ints (or even float or strings), you can put intsnumbers into a set and then convert (unique) items back to rows. For example above, the obvious 10*r[0] + r[1] would do. So would chr(r[0]) + chr(r[1]). More generally, you need the min and max of the second numbers and not have them be too far apart/ tjr
VIEWS ON THIS POST

129

Posted on:

Monday 5th November 2012
View Replies!

lxml removing tag, keeping text order

Using lxml to clean up auto-generated xml to validate against a dtd; I need to remove an element tag but keep the text in order. For example s0 = ''' first text ladida emphasized text middle text last text ''' I want to get rid of the tag but keep everything else as it is; that is, I need this result: first text ladida emphasized text middle text last text I'm beginning to think this an impossible task, so I'm asking here to see if there is some method that will work. What I've done so far is this: (outer encloses the parent, outside is the parent, inside is the child to remove) from lxml import etree import copy def rm_tag(elem, outer, outside, inside): newdiv = etree.Element(outside) newdiv.text = '' for e0 in elem.getiterator(outside): for i,e1 in enumerate(e0.getiterator()): if i == 0: if e1.text: newdiv.text += e1.text elif (e1.tag != inside): newdiv.append(copy.deepcopy(e1)) elif (e1.text): newdiv.text += e1.text for t in elem.getiterator(): if t.tag == outer: t.clear() t.append(newdiv) break return etree.ElementTree(elem) print etree.tostring(rm_tag(el,'option','optional','emphasis'),pretty_print=True) But the text is messed up using this method. I see why it's wrong, but not how to make it right. It returns: first text emphasized text ladida last text Maybe I should send the outside element (via tostring) to a regexp for removing the child and return that string Regexp Getting desperate, hey. Any pointers much appreciated, --Tim Arnold
VIEWS ON THIS POST

166

Posted on:

Wednesday 7th November 2012
View Replies!

Re: removing items from a dictionary ?

Stef Mientki wrote in news:46A8EFF5.4060600@mailbox.kun.nl: > hello, > > I want to remove some items from a dictionary, > so I would expect this should work: > > Nets = {} > ... fill the dictionary Nets > > for net in Nets: > if net.upper() in Eagle_Power_Nets : > del Nets [ net ] > > > But it gives me > Message File Name Line Position > Traceback > D:\data_to_test\JALsPy\Eagle_import.py 380 > RuntimeError: dictionary changed size during iteration > > > [snip...] > > > thanks, > Stef Mientki I think that you need to find a different iteration condition. Using for n in dict will iterate using an iterator which doesn't support "parallel" deletions. bests, ../alex -- ..w( the_mindstorm )p.
VIEWS ON THIS POST

296

Posted on:

Wednesday 7th November 2012
View Replies!

Re: Class context execution problems

En Thu, 06 Mar 2008 11:04:26 -0200, Marcelo de Moraes Serpa escribi: > I'm using a class in a conext other than the subpackage in which it is > located and I'm getting template lookup errors. > > This ...
VIEWS ON THIS POST

60

Posted on:

Saturday 10th November 2012
View Replies!

Hyphenation: PyHyphen 0.4.1 and textwrap2-0.1.1 released

This latest version of PyHyphen is only important for Python 2.4 addicts who encountered a missing type when compiling. Further, a few signed/unsigned mismatch warnings coming from MSVC should be fixed. As I have only Python 2.5, I'd be interested ...
VIEWS ON THIS POST

101

Posted on:

Saturday 10th November 2012
View Replies!

C function in a Python context

To write quick C things that Python won't do up to speed. So it's got a redundancy. import ext extA= ext.Ext() extA[ 'enumfactors' ]= r""" int enumfactors( int a, const char* sep ) { int ret= 0, i; for( i= ...
VIEWS ON THIS POST

45

Posted on:

Saturday 10th November 2012
View Replies!

PyGTK, Glade, and ComboBoxEntry.append_text()

all, I'm a relative newbie to Python (switched over from Scheme fairly recently) but I've been using PyGTK and Glade to create an interface, which is a combo I'm very impressed with. There is, however, one thing I've been ...
VIEWS ON THIS POST

56

Posted on:

Saturday 10th November 2012
View Replies!

Request for loading zipped modules in some context

When trying to import a module from a filesystem directory there are several possibilities. Most obviously one can use an import statement but if this is not sufficient one has also API functions. However these API functions don't seem to ...
VIEWS ON THIS POST

126

Posted on:

Saturday 10th November 2012
View Replies!

Bind mouse over event for panel (or Static text) wxPython

How to I couldn't find anything except EVT_ENTER_WINDOW that didn't work....
VIEWS ON THIS POST

61

Posted on:

Saturday 10th November 2012
View Replies!

Compressing a text file using count of continous characters

I need to count the number of continous character occurances(more than 1) in a file, and replace it with a compressed version, like below XYZAAAAAAAADEFAAcdAA --> XYZ8ADEF2Acd2A
VIEWS ON THIS POST

106

Posted on:

Saturday 10th November 2012
View Replies!

A context manager for temporary memoization.

I posted this to my blog at http://michaelspeer.blogspot.com/200...temporary.html . I decided to forward it onto the list for comments. I thought someone might find it interesting. *** This is very much a fragile hack at the moment. It's an interesting ...
VIEWS ON THIS POST

46

Posted on:

Saturday 10th November 2012
View Replies!

question about the textwrap module

Hi everybody, Recently, I have tried to improve the look of the printed text in command line. For this, I was compelled to remove redundant spaces in strings, because in my scripts, often the strings are spreading on several lines. ...
VIEWS ON THIS POST

58

Posted on:

Saturday 10th November 2012
View Replies!