According to old movies, there were two types of European long-distance train.
One was the sexy, luxurious sleeper such as the Orient Express, carrying exiled duchesses and dapper gents in tuxedos to elegant cities like Paris.
The other was a shabby dimly lit train packed with foreign agents and shady smugglers, hoping to slip unnoticed past the Iron Curtain.
You might think that age of exoticism and intrigue on the rails is gone; replaced by shiny high-speed trains with bland open carriages, zipping across unmonitored borders.
But you'd be wrong. There's still plenty of the old-school vibe available if you head far enough east, and I'm about to do just that – by catching the nightly sleeper train from Krakow, Poland to Lviv in western Ukraine.
For a very long time this was a simple domestic journey; at first within the Austro-Hungarian Empire, then after World War I within Poland. But in 1946 Lviv was shuffled into Ukraine, then part of the Soviet Union.
Now, with Poland being on the edge of the EU's Schengen Zone of passport-free travel, its frontier with Ukraine remains a "hard border" with peak-hatted border guards and rigorous checks.
It's a cool evening as I wait on the platform at Krakow's main station for the nightly Lwow Express (Lwow being the Polish name for the Ukrainian city). "Express" is a flexible word on Poland's railways, but I'm leaving at 10.21pm, and should arrive about 7am, after a lengthy pause at the border.
There's a sit-up option, but far more appealing is the idea of a berth in a sleeper car, trundling through the night to a new land. So I've booked via a third-party service, Polrail, as it's impossible to buy these tickets directly online.
The Lviv train alternates every second night between Polish and Ukrainian carriages. Tonight I've drawn the local version, and my sleeper car's Polish attendant takes my ticket and ushers me into my temporary home on wheels.
Berth 31 is in a practical compartment of about four square metres. It can accommodate up to three passengers in bunk beds, but as it's affordable I've decided to splurge and book out the entire compartment as a "Single".
It may not be the largest hotel room I've ever paid for, and it's clearly been in service for many years, but it's much more space than you'd receive on a long-distance flight.
My bunk is made up and ready for sleep, and on the opposite wall are coat hooks and an alcove for shoes. To one side is a square table, which swings up to reveal a sink. In the cupboard above I find a towel, two bottles of water, an orange juice and a small plastic-wrapped chocolate muffin.
The latter is something of a luxury, for I've been warned this train doesn't have a dining car. Not that it matters much at this time of night.
I couldn't reach any other carriage anyway, as ours seems sealed off from the others; perhaps a way of ensuring extra security for passengers' belongings.
Having dispatched the muffin, I sit on the bunk and notice a heating unit which I immediately turn right down. It's a warm evening and – wonder of wonders – the window can be opened.
Then we're off, sliding out of the station for the initial four-hour run to Przemysl on the Polish side of the border, so I put my head down for a sleep. I have a feeling I won't be getting much rest when we reach the frontier.
I'm right. In the middle of the night there's a lot of shunting, clanking and banging as the train's wheels are adjusted to the wider Ukrainian rail gauge, inherited from the Soviet Union. This used to involve lifting each carriage in a hoist, but now it's achieved via a less dramatic adjustment in which wheels are slid to their correct settings.
I have visits from various officials over the next hour or two. First Polish customs officials ask politely if I have anything to declare, then Polish border guards stamp me out of the EU; and after we progress across the border, Ukrainian officers check my visa (required for Australians) and stamp me in.
This step-by-step process in the wee small hours makes me prey to nameless fears. What if there's something wrong with my visa? What about language barriers? What if someone wants a bribe?
None of these problems eventuate. But I don't get much sleep, which somewhat negates the benefit of travelling at night.
Still, I drift off for a nap, then suddenly it's 7am and we're pulling into a grand though poorly labelled station I can only conclude is Lviv.
It's a magnificent terminal, with a huge curved roof with skylights above platforms with wrought-iron railings. I take a photo of the dusty sky-blue engine we must have picked up at the border, then head through an underpass to discover the city.
It turns out to be wonderful. As an important provincial capital, Austro-Hungarian Lemberg (Lviv's name in German) developed a beautiful city centre with a harmonious blend of neoclassical, baroque and renaissance buildings. Though showing the scuffs of the Soviet period, it's still a gorgeous collection and rightly listed as a World Heritage site.
And it's not just architecture the Austrians left behind. The Viennese-style coffee house of grandiose decor and lavish cakes is alive and well in this corner of Ukraine. My new "local" is soon established as Svit Kavy, an small cafe on a cobblestone lane between the Latin Cathedral and the tiny but lavishly decorated Boim Chapel.
My other pleasant discovery is that Ukraine is cheap. Really, really cheap. A tram ticket costs 10 cents, a meal $5, a baked snack 40 cents. The food is good quality too.
After three days of this fine architecture and inexpensive coffee, I'm heading onwards by rail to Kiev. This time I'll travel aboard a sleek modern Hyundai high-speed train which bridges the 560 kilometres between the cities in just five hours (older trains routinely take twice as long).
The only problem is the timing. This fast train runs the Lviv-Kiev route just twice a day, leaving at either 6.30am or 5.30pm. I've chosen the latter, though it'll get me into the capital well after nightfall.
With time to kill before departure, I lash out 50 cents on entry to Lviv station's extravagantly named Extra Comfort Lounge.
The extra comfort, however, is in the eye of the beholder. Its seats are hard and wooden, and the promised Wi-Fi isn't working. However, it's less crowded here than in the public waiting rooms, and there are power points at which to recharge phones.
Boarding my Ukrainian Railways train, I'm pleased to find a smooth contemporary interior. My first class fare ($24) provides a seat that's wide and comfortable, with lots of leg room and a large tray table. There's free Wi-Fi too, if slightly flaky, and an "in-train" magazine.
In due course two attendants come by with a refreshment trolley, and I buy a sandwich and a drink for dinner.
As we head towards the capital in the slowly fading light, I gaze out the window at undulating green fields punctuated by villages and the odd stand of forest. The occasional roadside Orthodox shrine also catches the eye.
Arriving on time at 10.30pm, I can see at once that Lviv and Kiev are like chalk and cheese. Where Lviv's slightly worn charm made it seem like a fairy-tale city come adrift from Central Europe, the capital is clearly constructed of sterner and grander stuff.
Kyiv-Pasazhyrsky station, the main passenger terminal, features enormous soaring interiors, with huge chandeliers and moulded plaster decorations hanging above its long escalators and vast concourse.
The station forecourt is busy with taxis, buses and pedestrians. As my hotel is only a kilometre away, however, I hoist my backpack onto my shoulders and step out into the Kiev night.
Emirates and its partners connect to Ukraine via Dubai. See www.emirates.com
Nightly sleeper trains travel from Poland to Lviv and Kiev; a Krakow-Lviv sleeper berth ranges from $75-$140. See polrail.com
Tickets for rail journeys within Ukraine can be purchased at uz.gov.ua
Tim Richards paid for his train fares and was hosted by Accor Hotels.
FIVE ATTRACTIONS OF KIEV
Independence Square, or just "Maydan'', is the focal point of the city centre and a magnet for everyone from tourists to street performers. It's surrounded by striking architecture and monuments.
Otherwise known as the Golden Gate, this reconstruction of a medieval city gate looms impressively on a hillock. To one side is a statue of 11th-century ruler Prince Yaroslav the Wise.
ST SOPHIA'S CATHEDRAL
This place of worship has survived much over the past thousand years, including being turned into a museum by the Soviets. Now its golden domes are gleaming, and visitors are welcome within its ornate interior.
Andrew's Descent is an attractive cobblestone street winding up a hill lined by pretty facades, and replete with restaurants, cafes and art galleries.
Kiev has seen bad times as well as good, and one of the worst was the 1986 Chernobyl nuclear disaster just 100 kilometres north of the city. This museum details the heroic efforts by emergency workers to contain the meltdown. See chornobylmuseum.kiev.ua