# Python syntax to use File.separator

**URL:** https://discourse.processing.org/t/python-syntax-to-use-file-separator/19378
**Category:** Processing.py
**Created:** [April 4, 2020, 3:49am UTC](https://discourse.processing.org/t/python-syntax-to-use-file-separator/19378 "2020-04-04T03:49:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cupofcalculus](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@cupofcalculus](https://discourse.processing.org/u/cupofcalculus)
#### Post date: [April 4, 2020, 3:49am UTC](https://discourse.processing.org/t/python-syntax-to-use-file-separator/19378/1 "2020-04-04T03:49:24Z")

</div>

My instructor uses the Java syntax in Processing, and I’m trying to convert it to Python. The relevant part of his code is:

```auto
//Global variables
String fname4 = "gumballs.jpg";
String loadName = fname4;
int ncolors = 8;

//Inside the setup function
String fileName = loadName;
int nc = ncolors;
String paletteName = "palettes" + File.separator + fileName.substring(0, fileName.length()-4) + 
                "_" + str(nc) + ".bmp";
readPalette(paletteName, colorTable);

```

Python throws an error saying:

```auto
NameError: global name 'File' is not defined

```

Is there something wrong with the code, or is there a Python alteration needed?

---

<div class="post-metadata">

### Author: ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)
#### Post date: [April 4, 2020, 4:05am UTC](https://discourse.processing.org/t/python-syntax-to-use-file-separator/19378/2 "2020-04-04T04:05:36Z")

</div>

`File.separator` is a java feature and it doesn’t exist in Python. Here’s one link to file separator in Python [https://kite.com/python/examples/1093/os-get-the-path-separator-for-the-system](https://kite.com/python/examples/1093/os-get-the-path-separator-for-the-system).

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [April 4, 2020, 4:12am UTC](https://discourse.processing.org/t/python-syntax-to-use-file-separator/19378/3 "2020-04-04T04:12:40Z")

</div>

[Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html](http://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html)  
`from java.io import File`
