473,767 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.mkdir simple help

Hi there,

I'm totally new to Python and was wondering why I was getting an error
for this. I'm just trying to create a folder based on user input:

import os

def setupProject(pr oject):
os.mkdir(projec t)
os.chdir(projec t)

test = input("Please enter project name: ")
setupProject(te st)

If I enter "roger" as my input I get : NameError: name 'roger' is not
defined

I know it's incredibly simple but help would be much appreciated!
Thanks in advance!

Feb 19 '06 #1
4 8723
On Sat, 18 Feb 2006 23:51:42 -0800, m.wanstall wrote:
test = input("Please enter project name: ")
setupProject(te st)

If I enter "roger" as my input I get : NameError: name 'roger' is not
defined

I know it's incredibly simple but help would be much appreciated!
Thanks in advance!


"input" takes the user-entered string and evaluates it as a Python
expression. You want raw_input().
--
Steven.

Feb 19 '06 #2
That's got it, thanks Steven!

Feb 19 '06 #3
I'm new to python too, but I've read that sys.stdin.readl ine() is
preferred. Is that right?

Feb 20 '06 #4
My pygtk gui can not be started from a gnome panel,
because, apparently, the panel doesn't know about my
modified PYTHONPATH. So how can I instruct the panel ?
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
=============== =============== =============== =============== ============
Feb 20 '06 #5

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

Similar topics

2
2431
by: Salmo Bytes | last post by:
I have a script that wants to mirror a directory structure, reading from location1 and writing (mkdir) at location2. This code works fine on a my own desktop test box. But fails at 'mkdir' when run on virtualhost box with safe_mode enabled and virtual (chrooted?) filesystems. My script makes the first top-level directory just
2
1755
by: Shaun | last post by:
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
7
3215
by: DataSmash | last post by:
Hello, I think I've tried everything now and can't figure out how to do it. I want to read in a text list from the current directory, and for each line in the list, make a system directory for that name. My text file would look something like this: 1144 1145 1146 1147
8
6060
by: Sue | last post by:
AccessXP in Access2000 Mode: In my code I use the MkDir method to create a folder and then I want to use the transfertext method to create a delimited text file in that folder. MkDir runs and then when transfertext runs I get a message that a file can not be created in the folder because the folder is Read Only. When I check the folder's attributes with Windows Explorer, sure enough the folder is Read Only. How can I use the MkDir...
5
9274
by: eoindeb | last post by:
I am trying to create a directory on Solaris using the mkdir() function. This works fine when I pass a string literal ("/etc/hosts") to mkdir, but if I try passing a directory pointer to mkdir, it returns a -1 error. The directory error works fine with fopen - does anyone know what I am doing wrong?? Here's a snippet of the code: int Check_Directory() //check for existence of directory - if not there, create the file { int status, ret...
3
8139
by: gazelle04 | last post by:
I wanted to create a subfolder in a directory and I used the MkDir statement but it gives me an error like "Path/File access error" Here are the codes: MkDir "\\BC123456\Attachments\" & Me.UniversityID.Value BC123456 = shared computer Attachments = shared folder Me.UniversityID = is a text box on the form with a number format
30
7707
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the target directory (where the backup copies will be kept, on another drive). I can successfully test whether the target directory exists or not using findfirst(), but if it doesn't, I wanted to create it using mkdir(), but it doesn't like the path...
8
24525
by: vj | last post by:
How do I do the following unix command: mkdir -m770 test with the os.mkdir command. Using os.mkdir(mode=0770) ends with the incorrect permissions. Thanks, VJ
3
3028
by: Cris | last post by:
OK, I do this call on a linux system: if(!file_exists("../pages/".$_POST."/")) { $dirname = "/home/u2/sss/sss/html/pages/".$_POST.""; mkdir($dirname, $mode); } and get this:
0
9571
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
9404
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
10168
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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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...
0
8835
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
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...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.