Sponsored Content
Top Forums Shell Programming and Scripting Help with Python Code Whitespace Post 302324688 by jhampt on Thursday 11th of June 2009 11:15:49 AM
Old 06-11-2009
Help with Python Code Whitespace

Hello All,

I have some python code that pulls together titles and displays them on web pages.

Here is the section of code I am struggling with:

#string to grab title

titlePattern =r'''\s*(\([^\)]+\))?(?P<title>.*)'''

#returns the title part of the subject line

def getTitle (self,data):

return re.search (

PartParser.titlepattern,

self.getSubject (data),

re.X

).group ("title)


This code will print out a title with whitespace in the midde od the title

ie: This is a (whitespace here, spaces or tabs) great day.

I am trying to use join and split to make the tile read

ie: This is a great day.

I believe I can remove the whitespace with

newtitlePattern = ' '.join(titlePattern(1).split())

and

PartParser.newtitlePattern

but I an not sure where to put this in the code.

Please help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Code conversion from JSP to PYTHON

Guys I need to convert a code from JSP (Java Tags are also there inside JSP) to PYTHON. I have OK kind of knowledge in PYTHON, but dont have a muck knowledge in JAVA/JSP. Any idea how to approach? Thanks in advance to all C Saha (1 Reply)
Discussion started by: csaha
1 Replies

2. Shell Programming and Scripting

python code...convert to ksh or sh

Helloo... I am not much familiar with python..I found this small script in python I even do not have python on my computer...can anyone help me out to convert this into ksh or sh.. PLEASE any help I will appreciate.. here is python code.. #!/usr/bin/env python import random # Get a... (3 Replies)
Discussion started by: amon
3 Replies

3. Shell Programming and Scripting

Python - how to get rid of whitespace

Hello, I am trying to figure out how to get rid of whitespace that is in certain areas (Title) of HTML pages that are created be a python script. IE: This is the title. (tabs are creating these spaces) This is another title. (tabs are creating these spaces)... (5 Replies)
Discussion started by: jhampt
5 Replies

4. Shell Programming and Scripting

How to match (whitespace digits whitespace) sequence?

Hi Following is an example line. echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:" I want it's output to be 200 However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies

5. Programming

Compiling and running Python code

Hey there, First post here in the Unix forums, but I have used them a lot for research over the last year. Anyways, to why I'm here now: I'm working on a project and I'll be using the AIS Parser SDK by Brian C. Lane (can't post the link, but google that and the first 8 links will be relevant) ... (4 Replies)
Discussion started by: pmd006
4 Replies

6. Shell Programming and Scripting

conversion of code in perl and python

How to convert below bash code in perl and python. for BLOCK in /sys/block/emcpow* do echo "100000" > "$BLOCK"/queue/nr_requests echo "noop" > "$BLOCK"/queue/scheduler done (2 Replies)
Discussion started by: learnbash
2 Replies

7. Programming

Curl alternative for python code

Need to run this api command via curl, the python code works without any problems , but we want the same to be run as curl command import requests params = {'username': 'testuser'} params = 'c3NhbmthMDJjsd' params = 'test' params = 'guide' params = '192.168.0.37' params =... (2 Replies)
Discussion started by: iron_michael86
2 Replies

8. Shell Programming and Scripting

Simple Python Code Question

I have the following code: #!/usr/bin/env python mylist = def printWithoutNewlines(): for objects in mylist: #print(objects) objects = objects.replace('hello', "hi") print objects When executed, it gives the following output: ## ./loop.py hi... (3 Replies)
Discussion started by: SkySmart
3 Replies

9. Programming

What is wrong with below python inheritance code?

I am using python 3.4. Below is the exception I am getting- Traceback (most recent call last): File "./oop.py", line 20, in <module> y = DerivedClass("Manu") File "./oop.py", line 15, in __init__ super().__init__(self,value) TypeError: __init__() takes 2 positional arguments but... (2 Replies)
Discussion started by: Tanu
2 Replies

10. Programming

Two problems with my python code

Hello everyone , I need your help to end my python code. I've this code in python : from ipywidgets import interact, Dropdown from ipywidgets import * from ipywidgets.embed import embed_minimal_html import pandas as pd import os import sys #################### Dropdown servers... (1 Reply)
Discussion started by: Tim2424
1 Replies
pbmtopsg3(29 June 2001)                                                                                                    pbmtopsg3(29 June 2001)

NAME
pbmtopsg3 - convert PBM images to Postscript with G3 fax compression SYNOPSIS
pbmtopsg3 [--title=title] [--dpi=dpi] [filespec] DESCRIPTION
Converts the PBM images in the input PBM file to pages in a Postscript file encoded with G3 fax compression. If you don't specify filespec, the input is from Standard Input. Remember that you can create a multi-image PBM file simply by concatenating single-image PBM files, so if each page is in a different file, you might do: cat faxpage* | pbmtopsg3 >fax.ps OPTIONS
-title The Postscript title value. Default is no title. -dpi The resolution of the Postscript output. Default is 72 dpi. SEE ALSO
pnmtops(1), pstopnm(1), gs(1), pstopnm(1), pbmtolps(1), pbmtoepsi(1), pbmtog3(1), g3topbm(1), pbm(5) pbmtopsg3(29 June 2001)
All times are GMT -4. The time now is 09:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy