Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2009, 05:37 AM
pmcdonogh pmcdonogh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 1 pmcdonogh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 35 sec
Reputation Power: 0
Spilt string into its arguments

Hi All,

I am creating objects using eval.

For instance:

class MyClass():
def __init__(self,stringField,integerField,sequenceField):
self.stringField = stringField
self.integerField = integerField
self.sequenceField = sequenceField

theString = 'MyClass("foo",32,["foo","bar"])'

theMyClass = eval(stripPackage(theEventString))

This works fine.

I am in the situation where i would like to modify some of the parameters. Is there a way to spit the parameter string i.e. ("foo",32,["foo","bar"]) into an array or list that contains the parameters.

So that the string ("foo",32,["foo","bar"]) would be split into an array of three strings the first being "foo" second being 32 and third being ["foo","bar"].

I would appreciate any help on this as I am completelly stuck.

Reply With Quote
  #2  
Old July 1st, 2009, 08:05 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 488 sfb User rank is Sergeant (500 - 2000 Reputation Level)sfb User rank is Sergeant (500 - 2000 Reputation Level)sfb User rank is Sergeant (500 - 2000 Reputation Level)sfb User rank is Sergeant (500 - 2000 Reputation Level)sfb User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 35 m 47 sec
Reputation Power: 20
Sounds like a badly designed system to me. The two key indicators are:

1) Using eval() full stop.

2) Getting to a stage where you need to manually parse a string containing Python code into running Python so you can modify it before converting it back to a string so you can feed it into the function that parses strings containing Python code into running Python.

Whatever you're doing (it's not clear), take a couple of steps back and rethink, I say.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Spilt string into its arguments


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
Stay green...Green IT