469,622 Members | 2,112 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,622 developers. It's quick & easy.

split question

This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 21 '06 #1
2 1396
Never mind I found the answer to that. os.path.basename(filename)



This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 22 '06 #2
bartonc
6,596 Expert 4TB
Thanks for keeping us up-to-date. This helps us a lot.
Nov 22 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by alexk | last post: by
2 posts views Thread by SL_McManus | last post: by
3 posts views Thread by rxl124 | last post: by
6 posts views Thread by Senthil | last post: by
3 posts views Thread by John Salerno | last post: by
5 posts views Thread by KC | last post: by
4 posts views Thread by Michele Petrazzo | last post: by
7 posts views Thread by Matthias Winterland | last post: by
1 post views Thread by John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.