473,666 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Noobie Question: Using strings and paths in mkdir (os.mkdir("/test/"a))

Hello!

I can't seem to get paths and variables working together:

import os
a = 'books'
os.chdir( '/test')
os.mkdir("/test/"a)

the last line does not seem to work. os.mkdir(a) makes the directory
books, but i want this directory as a subdirectory of test.

I also tried: os.mkdir("/test/",a), and trying to make b = 'test' and
then os.mkdir(a b).

Does someone have any ideas or a link they can give me, I looked under
strings in the python tutorial and library manual but I guess not in
the right spot.

Thanks for your help!

Shaun
Jul 19 '05 #1
2 1749
# sm******@gmail. com / 2005-04-22 00:13:05 -0700:
Hello!

I can't seem to get paths and variables working together:

import os
a = 'books'
os.chdir( '/test')
os.mkdir("/test/"a)

the last line does not seem to work. os.mkdir(a) makes the directory
books, but i want this directory as a subdirectory of test.

I also tried: os.mkdir("/test/",a), and trying to make b = 'test' and
then os.mkdir(a b).

Does someone have any ideas or a link they can give me, I looked under
strings in the python tutorial and library manual but I guess not in
the right spot.


http://docs.python.org/ref/string-catenation.html

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
Jul 19 '05 #2
On 4/22/05, Roman Neuhauser <ne************ *************** ***@sigpipe.cz> wrote:
import os
a = 'books'
os.chdir( '/test')
os.mkdir("/test/"a)

the last line does not seem to work. os.mkdir(a) makes the directory
books, but i want this directory as a subdirectory of test.

http://docs.python.org/ref/string-catenation.html


For this job, os.path.join() might be better. See
<http://docs.python.org/lib/module-os.path.html>.

--
Cheers,
Simon B,
si***@brunningo nline.net,
http://www.brunningonline.net/simon/blog/
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1939
by: Aristotelis E. Charalampakis | last post by:
Hi all, this is a newbie question :-) I was wondering if there was a way to use the switch statement in a manner that each case statement includes more that a simple value. i.e.: switch ( myFloat ) { case >0: // ??? how do i write this ???
5
11398
by: Tarjei Romtveit | last post by:
I'm still a newbie into C++ programming, so I got a quite foolish string related question. Using: Dev-cpp 4.9.9.2 (I think Dev-Cpp uses a gcc compiler of some sort) If i declare a char string like this: char szString = "Hello";
4
2424
by: Benne Smith | last post by:
In our company, i have three servers; 1) a development server (mine only - here i make daily changes and test my stuff) 2) a test server (for the users to test milestone builds - changes weekly) 3) production server (for when a new build is fully tested, and stable) The problem is that the connectionstring in the web.config, should be replaced with something else, for each of the enviroments.
2
1753
by: jimi_xyz | last post by:
Hi, I current have a from with 12 textboxes, and want to index all of them, i keep getting this error.. 'System.Windows.Forms.Control.ControlCollection' does not contain a definition for 'IndexOfKey' I figure its because the the function IndexOfKey is not defined.. here is the code..
0
316
by: Daniel | last post by:
Does system.xml have any way to transofrm data with an xswl style sheet using strings like MSXML2 does? how to convert this to use System.XML so i do not depend on MSXML2 interop? static public string XslTransform(string style, string strdata) { MSXML2.IXMLDOMDocument pDoc = new MSXML2.DOMDocumentClass(); pDoc.async = false; pDoc.loadXML(strdata);
3
5295
by: maharg | last post by:
Hi, I have a small application that displays an html file locally from the hard drive. Using Navigate2, I would like to launch the html from the same directory using a relative path. Right now I have:
4
2909
by: sanou | last post by:
Hi No doubt this question, or a similar version of it, has been asked before. But, I was looking around the forums and i couldn't find anything. I'm using VC++ to create a simple calculator that sums the values from 2 textboxes. I wanted to implement a simple data validation that would spit out various error messages if the user typed in incorrect data. I managed to vomit out the following code. Yes I know it's beastly,...
1
1223
by: Bit Byte | last post by:
I have several years programming experience (C/C++) and have only recently started looking at developing web apps - after playing with PHP for a while, I decided there weren't enough tools etc to get me up and running quickly enough, so I turned to look at ASP.Net ASP.Net looks like it has the development tools that I expect of any serious proposition, but I am confused between the apparent availability of two options: 1. Web...
5
1730
by: SM | last post by:
Hello I have simple question using simpleXML and PHP. i have an xml file that looks like this: <?xml version="1.0" encoding="UTF-8"?> <discography version="0.01"> <CD> <title>Moonlight</title> <year>1978</year>
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.